diff options
author | Tomasz Moń <desowin@gmail.com> | 2011-12-15 15:33:53 +0000 |
---|---|---|
committer | Tomasz Moń <desowin@gmail.com> | 2011-12-15 15:33:53 +0000 |
commit | ddd594b03ea7209f1b17b1ce918e585c48bd1df8 (patch) | |
tree | ba3d050533f0ca319465ecfc46428f77597269b5 /firmware | |
parent | 89aec97f3d03ed66637574bfddea36040f94f0aa (diff) |
Sansa Connect: Use sleep() instead udelay() in AVR spi_txrx.
This should prevent buffer underruns that can occur during heavy use of buttons or scrollwheel.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31267 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
6 files changed, 18 insertions, 8 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c index dedd017cf7..2ed69b6c9b 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c @@ -228,7 +228,9 @@ static void spi_txrx(unsigned char *buf_tx, unsigned char *buf_rx, int n) for (i = 0; i<n; i++) { IO_SERIAL1_TX_DATA = buf_tx[i]; - udelay(100); + + /* a short wait for AVR to process data */ + sleep(HZ/1000); do { @@ -248,7 +250,7 @@ static void spi_txrx(unsigned char *buf_tx, unsigned char *buf_rx, int n) mutex_unlock(&avr_mtx); } -static void avr_hid_sync(void) +void avr_hid_sync(void) { int i; unsigned char prg[4] = {CMD_SYNC, CMD_VER, CMD_FILL, CMD_CLOSE}; @@ -279,8 +281,6 @@ void avr_hid_init(void) IO_SERIAL1_MODE = 0x6DB; mutex_init(&avr_mtx); - - avr_hid_sync(); } /* defined in powermgmt-sansaconnect.c */ diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.h b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.h index 64b44675f7..06fd2b2d72 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.h +++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.h @@ -24,6 +24,7 @@ #include "config.h" +void avr_hid_sync(void); void avr_hid_init(void); void avr_hid_enable_charger(void); diff --git a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c index fcfc82e876..e53a15e94f 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c @@ -133,6 +133,7 @@ void lcd_init_device(void) /* Copy Rockbox frame buffer to the second framebuffer */ lcd_update(); + avr_hid_sync(); avr_hid_lcm_power_on(); /* set framebuffer address - OF sets RAM start address to 0x1000000 */ diff --git a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c index f73df98641..ecdf3b1a75 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c @@ -60,6 +60,9 @@ void power_init(void) /* Set LCM (LDO1) to 2.85V, Set CODEC and USB (LDO2) to 1.8V */ tps65021_write_reg(0x08, 0x36); + + /* Enable internal charger */ + avr_hid_enable_charger(); } void power_off(void) diff --git a/firmware/target/arm/tms320dm320/sdmmc-dm320.c b/firmware/target/arm/tms320dm320/sdmmc-dm320.c index 7df2925e20..6c744755f2 100644 --- a/firmware/target/arm/tms320dm320/sdmmc-dm320.c +++ b/firmware/target/arm/tms320dm320/sdmmc-dm320.c @@ -891,9 +891,9 @@ int sd_init(void) bitclr16(&IO_CLK_MOD2, CLK_MOD2_MMC); bitset16(&IO_CLK_INV, CLK_INV_MMC); - /* mmc module clock: 75 Mhz (AHB) / 2 = ~37.5 Mhz */ - /* OF uses 1, but for some reason it freezes on us */ - IO_CLK_DIV3 = (IO_CLK_DIV3 & 0xFF00) | 0x02; + /* mmc module clock: 75 Mhz (AHB) / 2 = ~37.5 Mhz + * (Frequencies above are taken from Sansa Connect's OF source code) */ + IO_CLK_DIV3 = (IO_CLK_DIV3 & 0xFF00) | 0x01; bitset16(&IO_CLK_MOD2, CLK_MOD2_MMC); diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c index 37d06f4343..abdca21627 100644 --- a/firmware/target/arm/tms320dm320/system-dm320.c +++ b/firmware/target/arm/tms320dm320/system-dm320.c @@ -310,6 +310,11 @@ void system_init(void) else #endif { +#ifdef SANSA_CONNECT + /* Setting AHB divisor to 0 causes MMC/SD interface to lock */ + clock_arm_slow = (1 << 8) | 3; + clock_arm_fast = (1 << 8) | 1; +#else /* Set the slow and fast clock speeds used for boosting * Slow Setup: * ARM div = 4 ( 87.5 MHz ) @@ -320,6 +325,7 @@ void system_init(void) */ clock_arm_slow = (0 << 8) | 3; clock_arm_fast = (1 << 8) | 1; +#endif } /* M48XI disabled, USB buffer powerdown */ @@ -368,7 +374,6 @@ void system_init(void) i2c_init(); avr_hid_init(); - avr_hid_enable_charger(); #endif } |