summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-05-07 22:29:35 +0000
committerJens Arnold <amiconn@rockbox.org>2005-05-07 22:29:35 +0000
commitc42a1a05bbd623e434d34d72aa320188a723675d (patch)
tree401d969500f5dfd9fdd7135a6a2cc17ccd21c008
parentf34ce792ec48984721016137cb254ed2dc06411c (diff)
downloadrockbox-c42a1a05bbd623e434d34d72aa320188a723675d.tar.gz
rockbox-c42a1a05bbd623e434d34d72aa320188a723675d.zip
Moved unrelated stuff from i2c the driver to appropriate places. Minor optimisation in i2c driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6419 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/i2c.c24
-rw-r--r--firmware/drivers/mas.c6
-rw-r--r--firmware/drivers/power.c6
3 files changed, 19 insertions, 17 deletions
diff --git a/firmware/drivers/i2c.c b/firmware/drivers/i2c.c
index ed12145da9..71cb9cf8b0 100644
--- a/firmware/drivers/i2c.c
+++ b/firmware/drivers/i2c.c
@@ -50,7 +50,7 @@
#define SDA_HI or_b(0x80, &PBDRL)
#define SDA_INPUT and_b(~0x80, &PBIORL)
#define SDA_OUTPUT or_b(0x80, &PBIORL)
-#define SDA (PBDR & 0x80)
+#define SDA (PBDRL & 0x80)
#if CONFIG_I2C == I2C_ONDIO
/* Ondio pinout, SCL moved to PB6 */
@@ -58,14 +58,14 @@
#define SCL_OUTPUT or_b(0x40, &PBIORL)
#define SCL_LO and_b(~0x40, &PBDRL)
#define SCL_HI or_b(0x40, &PBDRL)
-#define SCL (PBDR & 0x0040)
+#define SCL (PBDRL & 0x40)
#else
/* "classic" pinout, SCL is PB13 */
#define SCL_INPUT and_b(~0x20, &PBIORH)
#define SCL_OUTPUT or_b(0x20, &PBIORH)
#define SCL_LO and_b(~0x20, &PBDRH)
#define SCL_HI or_b(0x20, &PBDRH)
-#define SCL (PBDR & 0x2000)
+#define SCL (PBDRH & 0x20)
#endif
#endif /* ! I2C_GMINI */
@@ -109,22 +109,14 @@ void i2c_init(void)
#if CONFIG_I2C == I2C_GMINI
SCL_INPUT;
SDA_INPUT;
-#else
-#if CONFIG_I2C == I2C_ONDIO
- /* make PB5, PB6 & PB7 general I/O */
- PBCR2 &= ~0xfc00; /* includes PB5, see FIXME below */
+#elif CONFIG_I2C == I2C_ONDIO
+ /* make PB6 & PB7 general I/O */
+ PBCR2 &= ~0xf000;
#else /* not Gmini, not Ondio */
- /* make PB5, PB7 & PB13 general I/O */
+ /* make PB7 & PB13 general I/O */
PBCR1 &= ~0x0c00; /* PB13 */
- PBCR2 &= ~0xcc00; /* PB5 and PB7, see FIXME below */
+ PBCR2 &= ~0xc000; /* PB7 */
#endif
-
- /* PB5 is "MAS enable" (no I2C signal!). make it output and high */
- /* FIXME: this is true only for Players, and should go into mas.c */
- /* for Recorders, it shuts off the charger, for FM/V2 it holds power */
- or_b(0x20, &PBIORL);
- or_b(0x20, &PBDRL);
-#endif /* end of non-Gmini */
SCL_OUTPUT;
SDA_OUTPUT;
diff --git a/firmware/drivers/mas.c b/firmware/drivers/mas.c
index 891ceff18d..7c8b55c422 100644
--- a/firmware/drivers/mas.c
+++ b/firmware/drivers/mas.c
@@ -271,11 +271,15 @@ void mas_reset(void)
or_b(0x01, &PAIORH);
#if CONFIG_HWCODEC == MAS3507D
+ /* PB5 is "MAS enable". make it GPIO output and high */
+ PBCR2 &= ~0x0c00;
+ or_b(0x20, &PBIORL);
+ or_b(0x20, &PBDRL);
+
and_b(~0x01, &PADRH);
sleep(HZ/100);
or_b(0x01, &PADRH);
sleep(HZ/5);
-
#elif (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
if(old_recorder)
{
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index de62c7aa96..2d6c1c815c 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -74,7 +74,13 @@ void power_init(void)
spdif_power_enable(false);
#endif
#else
+#ifdef HAVE_POWEROFF_ON_PB5
+ PBCR2 &= ~0x0c00; /* GPIO for PB5 */
+ or_b(0x20, &PBIORL);
+ or_b(0x20, &PBDRL); /* hold power */
+#endif
#ifdef HAVE_CHARGE_CTRL
+ PBCR2 &= ~0x0c00; /* GPIO for PB5 */
or_b(0x20, &PBIORL); /* Set charging control bit to output */
charger_enable(false); /* Default to charger OFF */
#endif