Index: firmware/target/arm/as3525/backlight-e200v2-fuze.c =================================================================== --- firmware/target/arm/as3525/backlight-e200v2-fuze.c (Revision 21234) +++ firmware/target/arm/as3525/backlight-e200v2-fuze.c (Arbeitskopie) @@ -26,6 +26,8 @@ #include "ascodec-target.h" #include "as3514.h" +int buttonlight_is_on = 0; + void _backlight_set_brightness(int brightness) { ascodec_write(AS3514_DCDC15, brightness); @@ -53,12 +55,20 @@ void _buttonlight_on(void) { + /* Needed for buttonlight and MicroSD to work at the same time */ + /* Turn ROD control on, as the OF does */ GPIOD_DIR |= (1<<7); + SD_MCI_POWER |= (1<<7); GPIOD_PIN(7) = (1<<7); + buttonlight_is_on = 1; } void _buttonlight_off(void) { + /* Needed for buttonlight and MicroSD to work at the same time */ + /* Turn ROD control off, as the OF does */ + SD_MCI_POWER &= ~(1<<7); GPIOD_PIN(7) = 0; GPIOD_DIR &= ~(1<<7); + buttonlight_is_on = 0; } Index: firmware/target/arm/as3525/ata_sd_as3525.c =================================================================== --- firmware/target/arm/as3525/ata_sd_as3525.c (Revision 21234) +++ firmware/target/arm/as3525/ata_sd_as3525.c (Arbeitskopie) @@ -38,6 +38,9 @@ #include "pl081.h" /* DMA controller */ #include "dma-target.h" /* DMA request lines */ #include "clock-target.h" +#ifdef HAVE_BUTTON_LIGHT +#include "backlight-target.h" +#endif #include "stdbool.h" #include "ata_idle_notify.h" #include "sd.h" @@ -809,6 +812,11 @@ void sd_enable(bool on) { + /* buttonlight AMSes need a bit of special handling for the buttonlight here, + * due to the dual mapping of GPIOD and XPD */ +#ifdef HAVE_BUTTON_LIGHT + extern int buttonlight_is_on; +#endif if (sd_enabled == on) return; /* nothing to do */ if(on) @@ -816,11 +824,14 @@ CGU_PERI |= CGU_NAF_CLOCK_ENABLE; #ifdef HAVE_MULTIVOLUME CGU_PERI |= CGU_MCI_CLOCK_ENABLE; - /* Needed for buttonlight and MicroSD to work at the same time */ - /* Turn ROD control on, as the OF does */ - SD_MCI_POWER |= (1<<7); +#ifdef HAVE_BUTTON_LIGHT CCU_IO |= (1<<2); + if (buttonlight_is_on) + GPIOD_DIR &= ~(1<<7); + else + _buttonlight_off(); #endif +#endif CGU_IDE |= (1<<7) /* AHB interface enable */ | (1<<6) /* interface enable */; sd_enabled = true; @@ -829,12 +840,13 @@ { CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; #ifdef HAVE_MULTIVOLUME - CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE; - /* Needed for buttonlight and MicroSD to work at the same time */ - /* Turn ROD control off, as the OF does */ - SD_MCI_POWER &= ~(1<<7); +#ifdef HAVE_BUTTON_LIGHT CCU_IO &= ~(1<<2); + if (buttonlight_is_on) + _buttonlight_on(); #endif + CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE; +#endif CGU_IDE &= ~((1<<7)|(1<<6)); sd_enabled = false; }