From dac9df953e1beb7a64f2635290973918e6fd759c Mon Sep 17 00:00:00 2001 From: xbw Date: Tue, 27 Nov 2012 18:36:19 +0800 Subject: [PATCH] Unified version of the file board-xxx-sdmmc.c --- arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c | 1523 ++++++++++++++++++--- arch/arm/mach-rk30/board-rk30-sdk.c | 104 +- arch/arm/plat-rk/include/plat/board.h | 15 +- drivers/mmc/host/rk29_sdmmc.c | 180 +-- 4 files changed, 1446 insertions(+), 376 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c b/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c index 9a070a7914e0..47f653fbcd64 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c +++ b/arch/arm/mach-rk30/board-rk30-sdk-sdmmc.c @@ -11,9 +11,911 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * + * * + * History: + * ver1.0 add combo-wifi operateions. such as commit e049351a09c78db8a08aa5c49ce8eba0a3d6824e, at 2012-09-16 + * ver2.0 Unify all the file versions of board_xxxx_sdmmc.c, at 2012-11-05 + * + * Content: + * Part 1: define the gpio for SD-MMC-SDIO-Wifi functions according to your own projects. + *********************************************************************************** + * Please set the value according to your own project. + *********************************************************************************** + * + * Part 2: define the gpio for the SDMMC controller. Based on the chip datasheet. + *********************************************************************************** + * Please do not change, each platform has a fixed set. !!!!!!!!!!!!!!!!!! + * The system personnel will set the value depending on the specific arch datasheet, + * such as RK29XX, RK30XX. + * If you have any doubt, please consult BangWang Xie. + *********************************************************************************** + * + *.Part 3: The various operations of the SDMMC-SDIO module + *********************************************************************************** + * Please do not change, each platform has a fixed set. !!!!!!!!!!!!!!!!!! + * define the varaious operations for SDMMC module + * Generally only the author of SDMMC module will modify this section. + * If you have any doubt, please consult BangWang Xie. + *********************************************************************************** + * + *.Part 4: The various operations of the Wifi-BT module + *********************************************************************************** + * Please do not change, each module has a fixed set. !!!!!!!!!!!!!!!!!! + * define the varaious operations for Wifi module + * Generally only the author of Wifi module will modify this section. + * If you have any doubt, please consult BangWang Xie, Weiguo Hu, and Weilong Gao. + *********************************************************************************** + * */ -#ifdef CONFIG_SDMMC_RK29 +//1.Part 1: define the gpio for SD-MMC-SDIO-Wifi functions according to your own projects. + +/************************************************************************* +* define the gpio for sd-sdio-wifi module +*************************************************************************/ +#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) +#define SDMMC0_WRITE_PROTECT_PIN RK30_PIN3_PB2 //According to your own project to set the value of write-protect-pin. +#define SDMMC0_WRITE_PROTECT_ENABLE_VALUE GPIO_HIGH +#endif + +#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) +#define SDMMC1_WRITE_PROTECT_PIN RK30_PIN3_PB3 //According to your own project to set the value of write-protect-pin. +#define SDMMC1_WRITE_PROTECT_ENABLE_VALUE GPIO_HIGH +#endif + +#if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO) +#define RK29SDK_WIFI_SDIO_CARD_INT RK30_PIN3_PD2 +#endif + +//define the card-detect-pin. +#if defined(CONFIG_ARCH_RK29) +//refer to file /arch/arm/mach-rk29/include/mach/Iomux.h +//define reset-pin +#define RK29SDK_SD_CARD_DETECT_N RK29_PIN2_PA2 //According to your own project to set the value of card-detect-pin. +#define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. +#define RK29SDK_SD_CARD_DETECT_PIN_NAME GPIO2A2_SDMMC0DETECTN_NAME +#define RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO GPIO2L_GPIO2A2 +#define RK29SDK_SD_CARD_DETECT_IOMUX_FMUX GPIO2L_SDMMC0_DETECT_N + +#elif defined(CONFIG_ARCH_RK3066B) +//refer to file /arch/arm/mach-rk30/include/mach/iomux-rk3066b.h +//define reset-pin +#define RK29SDK_SD_CARD_DETECT_N RK30_PIN3_PB0 //According to your own project to set the value of card-detect-pin. +#define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. +#define RK29SDK_SD_CARD_DETECT_PIN_NAME GPIO3B0_SDMMC0DETECTN_NAME +#define RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO GPIO3B_GPIO3B0 +#define RK29SDK_SD_CARD_DETECT_IOMUX_FMUX GPIO3B_SDMMC0_DETECT_N + +#elif defined(CONFIG_ARCH_RK30) +//refer to file /arch/arm/mach-rk30/include/mach/Iomux.h +//define reset-pin +#define RK29SDK_SD_CARD_DETECT_N RK30_PIN3_PB6 //According to your own project to set the value of card-detect-pin. +#define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. +#define RK29SDK_SD_CARD_DETECT_PIN_NAME GPIO3B6_SDMMC0DETECTN_NAME +#define RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO GPIO3B_GPIO3B6 +#define RK29SDK_SD_CARD_DETECT_IOMUX_FMUX GPIO3B_SDMMC0_DETECT_N + +#elif defined(CONFIG_ARCH_RK2928) +//refer to file ./arch/arm/mach-rk2928/include/mach/iomux.h +//define reset-pin + #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) + //use gpio-interupt to dectec card in RK2926. Please pay attention to modify the default setting. + #define RK29SDK_SD_CARD_DETECT_N RK2928_PIN2_PA7 //According to your own project to set the value of card-detect-pin. + #define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. + #define RK29SDK_SD_CARD_DETECT_PIN_NAME GPIO2A7_NAND_DPS_EMMC_CLKOUT_NAME + #define RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO GPIO2A_GPIO2A7 + #define RK29SDK_SD_CARD_DETECT_IOMUX_FMUX GPIO2A_EMMC_CLKOUT + #else + #define RK29SDK_SD_CARD_DETECT_N RK2928_PIN1_PC1 //According to your own project to set the value of card-detect-pin. + #define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. + #define RK29SDK_SD_CARD_DETECT_PIN_NAME GPIO1C1_MMC0_DETN_NAME + #define RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO GPIO1C_GPIO1C1 + #define RK29SDK_SD_CARD_DETECT_IOMUX_FMUX GPIO1C_MMC0_DETN + #endif +#endif + + +// +// Define wifi module's power and reset gpio, and gpio sensitive level. +// Please set the value according to your own project. +// +#if defined(CONFIG_ARCH_RK30) // refer to file /arch/arm/mach-rk30/include/mach/Iomux.h + #define WIFI_HOST_WAKE RK30_PIN3_PD2 + + #if defined(CONFIG_RK903) || defined(CONFIG_RK901) || defined(CONFIG_RTL8192CU) || defined(CONFIG_RTL8188EU) + //power + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + //reset + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + + #elif defined(CONFIG_BCM4329) || defined(CONFIG_BCM4319) + //power + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + //reset + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + + #elif defined(CONFIG_MT6620) + #if !defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) + #define USE_SDMMC_CONTROLLER_FOR_WIFI 1 + + #if defined(CONFIG_MACH_RK30_PHONE_PAD) // define the gpio for MT6620 in RK30_PHONE_PAD project. + #define COMBO_MODULE_MT6620_CDT 0 //- 1--use Cdtech chip; 0--unuse CDT chip + //power, PMU_EN + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PC7 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3C7_SDMMC1WRITEPRT_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3C_GPIO3C7 + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX GPIO3C_SDMMC1_WRITE_PRT + //reset, DAIRST,SYSRST_B + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX GPIO3D_SDMMC1_BACKEND_PWR + //VDDIO + //#define RK30SDK_WIFI_GPIO_VCCIO_WL RK30_PIN6_PB4 + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE GPIO_HIGH + //WIFI_INT_B + #define RK30SDK_WIFI_GPIO_WIFI_INT_B RK30_PIN4_PD2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME GPIO4D2_SMCDATA10_TRACEDATA10_NAME + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO GPIO4D_GPIO4D2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX GPIO4D_SMC_DATA10 + //BGF_INT_B + #define RK30SDK_WIFI_GPIO_BGF_INT_B RK30_PIN6_PA7 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE GPIO_HIGH + //#define RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME GPIO3C6_SDMMC1DETECTN_NAME + //#define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO GPIO3C_GPIO3C6 + //#define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX GPIO3C_SDMMC1_DETECT_N + //GPS_SYNC + #define RK30SDK_WIFI_GPIO_GPS_SYNC RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO GPIO3D_GPIO3D0 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX GPIO3D_SDMMC1_PWR_EN + + #elif defined(CONFIG_MACH_RK3066_M8000R) // define the gpio for MT6620 in CONFIG_MACH_RK3066_M8000R project. + #define COMBO_MODULE_MT6620_CDT 1 //- 1--use Cdtech chip; 0--unuse CDT chip + //power, PMU_EN + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PC7 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3C7_SDMMC1WRITEPRT_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3C_GPIO3C7 + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX GPIO3C_SDMMC1_WRITE_PRT + //reset, DAIRST,SYSRST_B + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX GPIO3D_SDMMC1_BACKEND_PWR + //VDDIO + #define RK30SDK_WIFI_GPIO_VCCIO_WL RK30_PIN0_PD2 + #define RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME GPIO0D2_I2S22CHLRCKRX_SMCOEN_NAME + #define RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FGPIO GPIO0D_GPIO0D2 + #define RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FMUX GPIO0D_I2S2_2CH_LRCK_RX + //WIFI_INT_B + #define RK30SDK_WIFI_GPIO_WIFI_INT_B RK30_PIN3_PD2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME GPIO3D2_SDMMC1INTN_NAME + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO GPIO3D_GPIO3D2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX GPIO3D_SDMMC1_INT_N + //BGF_INT_B + #define RK30SDK_WIFI_GPIO_BGF_INT_B RK30_PIN6_PA7 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE GPIO_HIGH + //#define RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME GPIO3C6_SDMMC1DETECTN_NAME + //#define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO GPIO3C_GPIO3C6 + // #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX GPIO3C_SDMMC1_DETECT_N + //GPS_SYNC + #define RK30SDK_WIFI_GPIO_GPS_SYNC RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO GPIO3D_GPIO3D0 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX GPIO3D_SDMMC1_PWR_EN + + #if COMBO_MODULE_MT6620_CDT + //ANTSEL2 + //#define RK30SDK_WIFI_GPIO_ANTSEL2 RK30_PIN4_PD4 + //#define RK30SDK_WIFI_GPIO_ANTSEL2_ENABLE_VALUE GPIO_LOW //use 6620 in CDT chip, LOW--work; High--no work. + //#define RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME GPIO4D4_SMCDATA12_TRACEDATA12_NAME + //#define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FGPIO GPIO4D_GPIO4D4 + //#define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FMUX GPIO4D_TRACE_DATA12 + //ANTSEL3 + //#define RK30SDK_WIFI_GPIO_ANTSEL3 RK30_PIN4_PD3 + //#define RK30SDK_WIFI_GPIO_ANTSEL3_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + //#define RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME GPIO4D3_SMCDATA11_TRACEDATA11_NAME + //#define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FGPIO GPIO4D_GPIO4D3 + //#define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FMUX GPIO4D_TRACE_DATA11 + //GPS_LAN + //#define RK30SDK_WIFI_GPIO_GPS_LAN RK30_PIN4_PD6 + //#define RK30SDK_WIFI_GPIO_GPS_LAN_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + //#define RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME GPIO4D6_SMCDATA14_TRACEDATA14_NAME + //#define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FGPIO GPIO4D_GPIO4D6 + //#define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FMUX GPIO4D_TRACE_DATA14 + #endif // #if COMBO_MODULE_MT6620_CDT--#endif + + #elif defined(CONFIG_MACH_SKYWORTH_T10_SDK) // define the gpio for MT6620 in KYWORTH_T10 project. + #define COMBO_MODULE_MT6620_CDT 0 //- 1--use Cdtech chip; 0--unuse CDT chip + //power, PMU_EN + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX GPIO3D_SDMMC1_PWR_EN + //reset, DAIRST,SYSRST_B + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX GPIO3D_SDMMC1_BACKEND_PWR + //VDDIO + //#define RK30SDK_WIFI_GPIO_VCCIO_WL RK30_PIN6_PB4 + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE GPIO_HIGH + //WIFI_INT_B + #define RK30SDK_WIFI_GPIO_WIFI_INT_B RK30_PIN3_PD2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME GPIO3D2_SDMMC1INTN_NAME + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO GPIO3D_GPIO3D2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX GPIO3D_SDMMC1_INT_N + //BGF_INT_B + #define RK30SDK_WIFI_GPIO_BGF_INT_B RK30_PIN3_PC6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME GPIO3C6_SDMMC1DETECTN_NAME + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO GPIO3C_GPIO3C6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX GPIO3C_SDMMC1_DETECT_N + //GPS_SYNC + #define RK30SDK_WIFI_GPIO_GPS_SYNC RK30_PIN3_PC7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME GPIO3C7_SDMMC1WRITEPRT_NAME + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO GPIO3C_GPIO3C7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX GPIO3C_SDMMC1_WRITE_PRT + + #else //For exmpale, to define the gpio for MT6620 in RK30SDK project. + #define COMBO_MODULE_MT6620_CDT 1 //- 1--use Cdtech chip; 0--unuse CDT chip + //power + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX GPIO3D_SDMMC1_PWR_EN + //reset + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX GPIO3D_SDMMC1_BACKEND_PWR + //VDDIO + //#define RK30SDK_WIFI_GPIO_VCCIO_WL RK30_PIN0_PD2 + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE GPIO_HIGH + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME GPIO0D2_I2S22CHLRCKRX_SMCOEN_NAME + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FGPIO GPIO0D_GPIO0D2 + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FMUX GPIO0D_I2S2_2CH_LRCK_RX + //WIFI_INT_B + #define RK30SDK_WIFI_GPIO_WIFI_INT_B RK30_PIN3_PD2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME GPIO3D2_SDMMC1INTN_NAME + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO GPIO3D_GPIO3D2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX GPIO3D_SDMMC1_INT_N + //BGF_INT_B + #define RK30SDK_WIFI_GPIO_BGF_INT_B RK30_PIN3_PC6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME GPIO3C6_SDMMC1DETECTN_NAME + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO GPIO3C_GPIO3C6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX GPIO3C_SDMMC1_DETECT_N + //GPS_SYNC + #define RK30SDK_WIFI_GPIO_GPS_SYNC RK30_PIN3_PC7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME GPIO3C7_SDMMC1WRITEPRT_NAME + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO GPIO3C_GPIO3C7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX GPIO3C_SDMMC1_WRITE_PRT + + #if COMBO_MODULE_MT6620_CDT + //ANTSEL2 + #define RK30SDK_WIFI_GPIO_ANTSEL2 RK30_PIN4_PD4 + #define RK30SDK_WIFI_GPIO_ANTSEL2_ENABLE_VALUE GPIO_LOW //use 6620 in CDT chip, LOW--work; High--no work. + #define RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME GPIO4D4_SMCDATA12_TRACEDATA12_NAME + #define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FGPIO GPIO4D_GPIO4D4 + #define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FMUX GPIO4D_TRACE_DATA12 + //ANTSEL3 + #define RK30SDK_WIFI_GPIO_ANTSEL3 RK30_PIN4_PD3 + #define RK30SDK_WIFI_GPIO_ANTSEL3_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + #define RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME GPIO4D3_SMCDATA11_TRACEDATA11_NAME + #define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FGPIO GPIO4D_GPIO4D3 + #define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FMUX GPIO4D_TRACE_DATA11 + //GPS_LAN + #define RK30SDK_WIFI_GPIO_GPS_LAN RK30_PIN4_PD6 + #define RK30SDK_WIFI_GPIO_GPS_LAN_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + #define RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME GPIO4D6_SMCDATA14_TRACEDATA14_NAME + #define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FGPIO GPIO4D_GPIO4D6 + //#define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FMUX GPIO4D_TRACE_DATA14 + #endif // #if COMBO_MODULE_MT6620_CDT--#endif + #endif + #endif// #endif --#if !defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) + #endif +#elif defined(CONFIG_ARCH_RK3066B)//refer to file /arch/arm/mach-rk30/include/mach/iomux-rk3066b.h + #define WIFI_HOST_WAKE RK30_PIN3_PD2 + + #if defined(CONFIG_RTL8192CU) || defined(CONFIG_RTL8188EU) + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + + #elif defined(CONFIG_BCM4329) || defined(CONFIG_BCM4319) || defined(CONFIG_RK903) || defined(CONFIG_RK901) + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN2_PA7 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO2A7_LCDC1DATA7_SMCADDR11_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO2A_GPIO2A7 + #endif +#elif defined(CONFIG_ARCH_RK2928) //refer to file ./arch/arm/mach-rk2928/include/mach/iomux.h + #define WIFI_HOST_WAKE RK2928_PIN3_PC0 + + #if defined(CONFIG_RK903) || defined(CONFIG_RK901) || defined(CONFIG_BCM4329) || defined(CONFIG_BCM4319) + #define RK30SDK_WIFI_GPIO_POWER_N RK2928_PIN0_PD6 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO0D6_MMC1_PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO0D_GPIO0D6 + + #define RK30SDK_WIFI_GPIO_RESET_N RK2928_PIN3_PC2 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3C2_SDMMC1DATA1_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3C_GPIO3C2 + + #elif defined(CONFIG_RDA5990) + #define RK30SDK_WIFI_GPIO_POWER_N RK2928_PIN0_PD6 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO0D6_MMC1_PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO0D_GPIO0D6 + + #define RK30SDK_WIFI_GPIO_RESET_N RK2928_PIN3_PC2 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3C2_SDMMC1DATA1_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3C_GPIO3C2 + + + #elif defined(CONFIG_RTL8192CU) || defined(CONFIG_RTL8188EU) + #define RK30SDK_WIFI_GPIO_POWER_N RK2928_PIN0_PD6 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_LOW + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO0D6_MMC1_PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO0D_GPIO0D6 + + #endif +#endif + + +//1. Part 2: to define the gpio for the SDMMC controller. Based on the chip datasheet. +/************************************************************************* +* define the gpio for SDMMC module on various platforms +* Generally only system personnel will modify this part +*************************************************************************/ +#if defined(CONFIG_ARCH_RK29) +//refer to file /arch/arm/mach-rk29/include/mach/Iomux.h +//define PowerEn-pin +#define RK29SDK_SD_CARD_PWR_EN RK29_PIN5_PD5 +#define RK29SDK_SD_CARD_PWR_EN_LEVEL GPIO_LOW +#define RK29SDK_SD_CARD_PWR_EN_PIN_NAME GPIO5D5_SDMMC0PWREN_NAME +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO GPIO5H_GPIO5D5 +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX GPIO5H_SDMMC0_PWR_EN + +#elif defined(CONFIG_ARCH_RK3066B) +//refer to file /arch/arm/mach-rk30/include/mach/iomux-rk3066b.h +//define PowerEn-pin +#define RK29SDK_SD_CARD_PWR_EN RK30_PIN3_PA1 +#define RK29SDK_SD_CARD_PWR_EN_LEVEL GPIO_LOW +#define RK29SDK_SD_CARD_PWR_EN_PIN_NAME GPIO3A1_SDMMC0PWREN_NAME +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO GPIO3A_GPIO3A1 +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX GPIO3A_SDMMC0PWREN + +#elif defined(CONFIG_ARCH_RK30) +//refer to file /arch/arm/mach-rk30/include/mach/Iomux.h +//define PowerEn-pin +#define RK29SDK_SD_CARD_PWR_EN RK30_PIN3_PA7 +#define RK29SDK_SD_CARD_PWR_EN_LEVEL GPIO_LOW +#define RK29SDK_SD_CARD_PWR_EN_PIN_NAME GPIO3A7_SDMMC0PWREN_NAME +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO GPIO3A_GPIO3A7 +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX GPIO3A_SDMMC0_PWR_EN + +#elif defined(CONFIG_ARCH_RK2928) +//refer to file ./arch/arm/mach-rk2928/include/mach/iomux.h +//define PowerEn-pin +#define RK29SDK_SD_CARD_PWR_EN RK2928_PIN1_PB6 +#define RK29SDK_SD_CARD_PWR_EN_LEVEL GPIO_LOW +#define RK29SDK_SD_CARD_PWR_EN_PIN_NAME GPIO1B6_MMC0_PWREN_NAME +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO GPIO1B_GPIO1B6 +#define RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX GPIO1B_MMC0_PWREN + +#endif + +#if defined(CONFIG_ARCH_RK30) +/* +* define the gpio for sdmmc0 +*/ +struct rksdmmc_gpio_board rksdmmc0_gpio_init = { + + .clk_gpio = { + .io = RK30_PIN3_PB0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B0_SDMMC0CLKOUT_NAME, + .fgpio = GPIO3B_GPIO3B0, + .fmux = GPIO3B_SDMMC0_CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK30_PIN3_PB1, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B1_SDMMC0CMD_NAME, + .fgpio = GPIO3B_GPIO3B1, + .fmux = GPIO3B_SDMMC0_CMD, + }, + }, + + .data0_gpio = { + .io = RK30_PIN3_PB2, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B2_SDMMC0DATA0_NAME, + .fgpio = GPIO3B_GPIO3B2, + .fmux = GPIO3B_SDMMC0_DATA0, + }, + }, + + .data1_gpio = { + .io = RK30_PIN3_PB3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B3_SDMMC0DATA1_NAME, + .fgpio = GPIO3B_GPIO3B3, + .fmux = GPIO3B_SDMMC0_DATA1, + }, + }, + + .data2_gpio = { + .io = RK30_PIN3_PB4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B4_SDMMC0DATA2_NAME, + .fgpio = GPIO3B_GPIO3B4, + .fmux = GPIO3B_SDMMC0_DATA2, + }, + }, + + .data3_gpio = { + .io = RK30_PIN3_PB5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3B5_SDMMC0DATA3_NAME, + .fgpio = GPIO3B_GPIO3B5, + .fmux = GPIO3B_SDMMC0_DATA3, + }, + }, + + .power_en_gpio = { + .io = RK29SDK_SD_CARD_PWR_EN, + .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX, + }, + }, + + .detect_irq = { + .io = RK29SDK_SD_CARD_DETECT_N, + .enable = RK29SDK_SD_CARD_INSERT_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_DETECT_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX, + }, + }, +}; + + +/* +* define the gpio for sdmmc1 +*/ +static struct rksdmmc_gpio_board rksdmmc1_gpio_init = { + + .clk_gpio = { + .io = RK30_PIN3_PC5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C5_SDMMC1CLKOUT_NAME, + .fgpio = GPIO3C_GPIO3C5, + .fmux = GPIO3B_SDMMC0_CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK30_PIN3_PC0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C0_SMMC1CMD_NAME, + .fgpio = GPIO3C_GPIO3C0, + .fmux = GPIO3B_SDMMC0_CMD, + }, + }, + + .data0_gpio = { + .io = RK30_PIN3_PC1, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C1_SDMMC1DATA0_NAME, + .fgpio = GPIO3C_GPIO3C1, + .fmux = GPIO3B_SDMMC0_DATA0, + }, + }, + + .data1_gpio = { + .io = RK30_PIN3_PC2, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C2_SDMMC1DATA1_NAME, + .fgpio = GPIO3C_GPIO3C2, + .fmux = GPIO3B_SDMMC0_DATA1, + }, + }, + + .data2_gpio = { + .io = RK30_PIN3_PC3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C3_SDMMC1DATA2_NAME, + .fgpio = GPIO3C_GPIO3C3, + .fmux = GPIO3B_SDMMC0_DATA2, + }, + }, + + .data3_gpio = { + .io = RK30_PIN3_PC4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C4_SDMMC1DATA3_NAME, + .fgpio = GPIO3C_GPIO3C4, + .fmux = GPIO3B_SDMMC0_DATA3, + }, + }, +}; + // ---end -#if defined(CONFIG_ARCH_RK30) + +#elif defined(CONFIG_ARCH_RK3066B) + +/* +* define the gpio for sdmmc0 +*/ +static struct rksdmmc_gpio_board rksdmmc0_gpio_init = { + + .clk_gpio = { + .io = RK30_PIN3_PB0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A2_SDMMC0CLKOUT_NAME, + .fgpio = GPIO3A_GPIO3A2, + .fmux = GPIO3A_SDMMC0CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK30_PIN3_PB1, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A3_SDMMC0CMD_NAME, + .fgpio = GPIO3A_GPIO3A3, + .fmux = GPIO3A_SDMMC0CMD, + }, + }, + + .data0_gpio = { + .io = RK30_PIN3_PB2, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A4_SDMMC0DATA0_NAME, + .fgpio = GPIO3A_GPIO3A4, + .fmux = GPIO3A_SDMMC0DATA0, + }, + }, + + .data1_gpio = { + .io = RK30_PIN3_PB3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A5_SDMMC0DATA1_NAME, + .fgpio = GPIO3A_GPIO3A5, + .fmux = GPIO3A_SDMMC0DATA1, + }, + }, + + .data2_gpio = { + .io = RK30_PIN3_PB4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A6_SDMMC0DATA2_NAME, + .fgpio = GPIO3A_GPIO3A6, + .fmux = GPIO3A_SDMMC0DATA2, + }, + }, + + .data3_gpio = { + .io = RK30_PIN3_PB5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3A7_SDMMC0DATA3_NAME, + .fgpio = GPIO3A_GPIO3A7, + .fmux = GPIO3A_SDMMC0DATA3, + }, + }, + + .power_en_gpio = { + .io = RK29SDK_SD_CARD_PWR_EN, + .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX, + }, + }, + + .detect_irq = { + .io = RK29SDK_SD_CARD_DETECT_N, + .enable = RK29SDK_SD_CARD_INSERT_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_DETECT_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX, + }, + }, +}; + + +/* +* define the gpio for sdmmc1 +*/ +static struct rksdmmc_gpio_board rksdmmc1_gpio_init = { + + .clk_gpio = { + .io = RK30_PIN3_PC5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C5_SDMMC1CLKOUT_RMIICLKOUT_RMIICLKIN_NAME, + .fgpio = GPIO3C_GPIO3C5, + .fmux = GPIO3C_SDMMC1CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK30_PIN3_PC0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C0_SDMMC1CMD_RMIITXEN_NAME, + .fgpio = GPIO3C_GPIO3C0, + .fmux = GPIO3C_SDMMC1CMD, + }, + }, + + .data0_gpio = { + .io = RK30_PIN3_PC1, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C1_SDMMC1DATA0_RMIITXD1_NAME, + .fgpio = GPIO3C_GPIO3C1, + .fmux = GPIO3C_SDMMC1DATA0, + }, + }, + + .data1_gpio = { + .io = RK30_PIN3_PC2, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C2_SDMMC1DATA1_RMIITXD0_NAME, + .fgpio = GPIO3C_GPIO3C2, + .fmux = GPIO3C_SDMMC1DATA1, + }, + }, + + .data2_gpio = { + .io = RK30_PIN3_PC3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C3_SDMMC1DATA2_RMIIRXD0_NAME, + .fgpio = GPIO3C_GPIO3C3, + .fmux = GPIO3C_SDMMC1DATA2, + }, + }, + + .data3_gpio = { + .io = RK30_PIN3_PC4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO3C4_SDMMC1DATA3_RMIIRXD1_NAME, + .fgpio = GPIO3C_GPIO3C4, + .fmux = GPIO3C_SDMMC1DATA3, + }, + }, +}; +// ---end -#if defined(CONFIG_ARCH_RK3066B) + +#elif defined(CONFIG_ARCH_RK2928) +/* +* define the gpio for sdmmc0 +*/ +static struct rksdmmc_gpio_board rksdmmc0_gpio_init = { + + .clk_gpio = { + .io = RK2928_PIN1_PC0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1C0_MMC0_CLKOUT_NAME, + .fgpio = GPIO1C_GPIO1C0, + .fmux = GPIO1C_MMC0_CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK2928_PIN1_PC7, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1B7_MMC0_CMD_NAME, + .fgpio = GPIO1B_GPIO1B7, + .fmux = GPIO1B_MMC0_CMD, + }, + }, + + .data0_gpio = { + .io = RK2928_PIN1_PC2, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1C2_MMC0_D0_NAME, + .fgpio = GPIO1C_GPIO1C2, + .fmux = GPIO1C_MMC0_D0, + }, + }, + + .data1_gpio = { + .io = RK2928_PIN1_PC3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1C3_MMC0_D1_NAME, + .fgpio = GPIO1C_GPIO1C3, + .fmux = GPIO1C_MMC0_D1, + }, + }, + + .data2_gpio = { + .io = RK2928_PIN1_PC4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1C4_MMC0_D2_NAME, + .fgpio = GPIO1C_GPIO1C4, + .fmux = GPIO1C_MMC0_D2, + }, + }, + + .data3_gpio = { + .io = RK2928_PIN1_PC5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO1C5_MMC0_D3_NAME, + .fgpio = GPIO1C_GPIO1C5, + .fmux = GPIO1C_MMC0_D3, + }, + }, + + .power_en_gpio = { + .io = RK29SDK_SD_CARD_PWR_EN, + .enable = RK29SDK_SD_CARD_PWR_EN_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_PWR_EN_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_PWR_EN_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_PWR_EN_IOMUX_FMUX, + }, + }, + + .detect_irq = { + .io = RK29SDK_SD_CARD_DETECT_N, + .enable = RK29SDK_SD_CARD_INSERT_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_DETECT_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX, + }, + }, + +}; + + +/* +* define the gpio for sdmmc1 +*/ +static struct rksdmmc_gpio_board rksdmmc1_gpio_init = { + + .clk_gpio = { + .io = RK2928_PIN0_PB1, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B1_MMC1_CLKOUT_NAME, + .fgpio = GPIO0B_GPIO0B1, + .fmux = GPIO0B_MMC1_CLKOUT, + }, + }, + + .cmd_gpio = { + .io = RK2928_PIN0_PB0, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B0_MMC1_CMD_NAME, + .fgpio = GPIO0B_GPIO0B0, + .fmux = GPIO0B_MMC1_CMD, + }, + }, + + .data0_gpio = { + .io = RK2928_PIN0_PB3, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B3_MMC1_D0_NAME, + .fgpio = GPIO0B_GPIO0B3, + .fmux = GPIO0B_MMC1_D0, + }, + }, + + .data1_gpio = { + .io = RK2928_PIN0_PB4, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B4_MMC1_D1_NAME, + .fgpio = GPIO0B_GPIO0B4, + .fmux = GPIO0B_MMC1_D1, + }, + }, + + .data2_gpio = { + .io = RK2928_PIN0_PB5, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B5_MMC1_D2_NAME, + .fgpio = GPIO0B_GPIO0B5, + .fmux = GPIO0B_MMC1_D2, + }, + }, + + .data3_gpio = { + .io = RK2928_PIN0_PB6, + .enable = GPIO_HIGH, + .iomux = { + .name = GPIO0B6_MMC1_D3_NAME, + .fgpio = GPIO0B_GPIO0B6, + .fmux = GPIO0B_MMC1_D3, + }, + }, + + +}; +// ---end -#if defined(CONFIG_ARCH_RK2928) +#endif + + + +//1.Part 3: The various operations of the SDMMC-SDIO module +/************************************************************************* +* define the varaious operations for SDMMC module +* Generally only the author of SDMMC module will modify this section. +*************************************************************************/ #if !defined(CONFIG_SDMMC_RK29_OLD) static void rk29_sdmmc_gpio_open(int device_id, int on) @@ -25,40 +927,40 @@ static void rk29_sdmmc_gpio_open(int device_id, int on) #ifdef CONFIG_SDMMC0_RK29 if(on) { - gpio_direction_output(GPIO3B_GPIO3B0,GPIO_HIGH);//set mmc0-clk to high - gpio_direction_output(GPIO3B_GPIO3B1,GPIO_HIGH);// set mmc0-cmd to high. - gpio_direction_output(GPIO3B_GPIO3B2,GPIO_HIGH);//set mmc0-data0 to high. - gpio_direction_output(GPIO3B_GPIO3B3,GPIO_HIGH);//set mmc0-data1 to high. - gpio_direction_output(GPIO3B_GPIO3B4,GPIO_HIGH);//set mmc0-data2 to high. - gpio_direction_output(GPIO3B_GPIO3B5,GPIO_HIGH);//set mmc0-data3 to high. + gpio_direction_output(rksdmmc0_gpio_init.clk_gpio.io, GPIO_HIGH);//set mmc0-clk to high + gpio_direction_output(rksdmmc0_gpio_init.cmd_gpio.io, GPIO_HIGH);// set mmc0-cmd to high. + gpio_direction_output(rksdmmc0_gpio_init.data0_gpio.io,GPIO_HIGH);//set mmc0-data0 to high. + gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc0-data1 to high. + gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc0-data2 to high. + gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc0-data3 to high. mdelay(30); } else { - rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_GPIO3B0); - gpio_request(RK30_PIN3_PB0, "mmc0-clk"); - gpio_direction_output(RK30_PIN3_PB0,GPIO_LOW);//set mmc0-clk to low. + rk30_mux_api_set(rksdmmc0_gpio_init.clk_gpio.iomux.name, rksdmmc0_gpio_init.clk_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.clk_gpio.io, "mmc0-clk"); + gpio_direction_output(rksdmmc0_gpio_init.clk_gpio.io,GPIO_LOW);//set mmc0-clk to low. - rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_GPIO3B1); - gpio_request(RK30_PIN3_PB1, "mmc0-cmd"); - gpio_direction_output(RK30_PIN3_PB1,GPIO_LOW);//set mmc0-cmd to low. + rk30_mux_api_set(rksdmmc0_gpio_init.cmd_gpio.iomux.name, rksdmmc0_gpio_init.cmd_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.cmd_gpio.io, "mmc0-cmd"); + gpio_direction_output(rksdmmc0_gpio_init.cmd_gpio.io,GPIO_LOW);//set mmc0-cmd to low. - rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_GPIO3B2); - gpio_request(RK30_PIN3_PB2, "mmc0-data0"); - gpio_direction_output(RK30_PIN3_PB2,GPIO_LOW);//set mmc0-data0 to low. + rk30_mux_api_set(rksdmmc0_gpio_init.data0_gpio.iomux.name, rksdmmc0_gpio_init.data0_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data0_gpio.io, "mmc0-data0"); + gpio_direction_output(rksdmmc0_gpio_init.data0_gpio.io,GPIO_LOW);//set mmc0-data0 to low. - rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_GPIO3B3); - gpio_request(RK30_PIN3_PB3, "mmc0-data1"); - gpio_direction_output(RK30_PIN3_PB3,GPIO_LOW);//set mmc0-data1 to low. + rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data1_gpio.io, "mmc0-data1"); + gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_LOW);//set mmc0-data1 to low. - rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_GPIO3B4); - gpio_request(RK30_PIN3_PB4, "mmc0-data2"); - gpio_direction_output(RK30_PIN3_PB4,GPIO_LOW);//set mmc0-data2 to low. + rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data2_gpio.io, "mmc0-data2"); + gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_LOW);//set mmc0-data2 to low. - rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_GPIO3B5); - gpio_request(RK30_PIN3_PB5, "mmc0-data3"); - gpio_direction_output(RK30_PIN3_PB5,GPIO_LOW);//set mmc0-data3 to low. + rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data3_gpio.io, "mmc0-data3"); + gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_LOW);//set mmc0-data3 to low. mdelay(30); } @@ -71,39 +973,40 @@ static void rk29_sdmmc_gpio_open(int device_id, int on) #ifdef CONFIG_SDMMC1_RK29 if(on) { - gpio_direction_output(RK30_PIN3_PC5,GPIO_HIGH);//set mmc1-clk to high - gpio_direction_output(RK30_PIN3_PC0,GPIO_HIGH);//set mmc1-cmd to high. - gpio_direction_output(RK30_PIN3_PC1,GPIO_HIGH);//set mmc1-data0 to high. - gpio_direction_output(RK30_PIN3_PC2,GPIO_HIGH);//set mmc1-data1 to high. - gpio_direction_output(RK30_PIN3_PC3,GPIO_HIGH);//set mmc1-data2 to high. - gpio_direction_output(RK30_PIN3_PC5,GPIO_HIGH);//set mmc1-data3 to high. + gpio_direction_output(rksdmmc1_gpio_init.clk_gpio.io,GPIO_HIGH);//set mmc1-clk to high + gpio_direction_output(rksdmmc1_gpio_init.cmd_gpio.io,GPIO_HIGH);//set mmc1-cmd to high. + gpio_direction_output(rksdmmc1_gpio_init.data0_gpio.io,GPIO_HIGH);//set mmc1-data0 to high. + gpio_direction_output(rksdmmc1_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc1-data1 to high. + gpio_direction_output(rksdmmc1_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc1-data2 to high. + gpio_direction_output(rksdmmc1_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc1-data3 to high. mdelay(100); } else { - rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_GPIO3C5); - gpio_request(RK30_PIN3_PC5, "mmc1-clk"); - gpio_direction_output(RK30_PIN3_PC5,GPIO_LOW);//set mmc1-clk to low. - - rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_GPIO3C0); - gpio_request(RK30_PIN3_PC0, "mmc1-cmd"); - gpio_direction_output(RK30_PIN3_PC0,GPIO_LOW);//set mmc1-cmd to low. - - rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_GPIO3C1); - gpio_request(RK30_PIN3_PC1, "mmc1-data0"); - gpio_direction_output(RK30_PIN3_PC1,GPIO_LOW);//set mmc1-data0 to low. + rk30_mux_api_set(rksdmmc1_gpio_init.clk_gpio.iomux.name, rksdmmc1_gpio_init.clk_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.clk_gpio.io, "mmc1-clk"); + gpio_direction_output(rksdmmc1_gpio_init.clk_gpio.io,GPIO_LOW);//set mmc1-clk to low. + + rk30_mux_api_set(rksdmmc1_gpio_init.cmd_gpio.iomux.name, rksdmmc1_gpio_init.cmd_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.cmd_gpio.io, "mmc1-cmd"); + gpio_direction_output(rksdmmc1_gpio_init.cmd_gpio.io,GPIO_LOW);//set mmc1-cmd to low. + + rk30_mux_api_set(rksdmmc1_gpio_init.data0_gpio.iomux.name, rksdmmc1_gpio_init.data0_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data0_gpio.io, "mmc1-data0"); + gpio_direction_output(rksdmmc1_gpio_init.data0_gpio.io,GPIO_LOW);//set mmc1-data0 to low. + #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) - rk29_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_GPIO3C2); - gpio_request(RK30_PIN3_PC2, "mmc1-data1"); - gpio_direction_output(RK30_PIN3_PC2,GPIO_LOW);//set mmc1-data1 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data1_gpio.iomux.name, rksdmmc1_gpio_init.data1_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data1_gpio.io, "mmc1-data1"); + gpio_direction_output(rksdmmc1_gpio_init.data1_gpio.io,GPIO_LOW);//set mmc1-data1 to low. - rk29_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_GPIO3C3); - gpio_request(RK30_PIN3_PC3, "mmc1-data2"); - gpio_direction_output(RK30_PIN3_PC3,GPIO_LOW);//set mmc1-data2 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data2_gpio.iomux.name, rksdmmc1_gpio_init.data2_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data2_gpio.io, "mmc1-data2"); + gpio_direction_output(rksdmmc1_gpio_init.data2_gpio.io,GPIO_LOW);//set mmc1-data2 to low. - rk29_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_GPIO3C4); - gpio_request(RK30_PIN3_PC4, "mmc1-data3"); - gpio_direction_output(RK30_PIN3_PC4,GPIO_LOW);//set mmc1-data3 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data3_gpio.iomux.name, rksdmmc1_gpio_init.data3_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data3_gpio.io, "mmc1-data3"); + gpio_direction_output(rksdmmc1_gpio_init.data3_gpio.io,GPIO_LOW);//set mmc1-data3 to low. #endif mdelay(100); } @@ -126,9 +1029,9 @@ static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width) case 1://SDMMC_CTYPE_4BIT: { - rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_SDMMC0_DATA1); - rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_SDMMC0_DATA2); - rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_SDMMC0_DATA3); + rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fmux); } break; @@ -136,14 +1039,14 @@ static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width) break; case 0xFFFF: //gpio_reset { - rk30_mux_api_set(GPIO3A7_SDMMC0PWREN_NAME, GPIO3A_GPIO3A7); - gpio_request(RK30_PIN3_PA7,"sdmmc-power"); - gpio_direction_output(RK30_PIN3_PA7,GPIO_HIGH); //power-off + rk30_mux_api_set(rksdmmc0_gpio_init.power_en_gpio.iomux.name, rksdmmc0_gpio_init.power_en_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.power_en_gpio.io,"sdmmc-power"); + gpio_direction_output(rksdmmc0_gpio_init.power_en_gpio.io, !(rksdmmc0_gpio_init.power_en_gpio.enable)); //power-off #if 0 //replace the power control into rk29_sdmmc_set_ios(); modifyed by xbw at 2012-08-12 rk29_sdmmc_gpio_open(0, 0); - gpio_direction_output(RK30_PIN3_PA7,GPIO_LOW); //power-on + gpio_direction_output(rksdmmc0_gpio_init.power_en_gpio.io, rksdmmc0_gpio_init.power_en_gpio.enable); //power-on rk29_sdmmc_gpio_open(0, 1); #endif @@ -152,21 +1055,21 @@ static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width) default: //case 0://SDMMC_CTYPE_1BIT: { - rk30_mux_api_set(GPIO3B1_SDMMC0CMD_NAME, GPIO3B_SDMMC0_CMD); - rk30_mux_api_set(GPIO3B0_SDMMC0CLKOUT_NAME, GPIO3B_SDMMC0_CLKOUT); - rk30_mux_api_set(GPIO3B2_SDMMC0DATA0_NAME, GPIO3B_SDMMC0_DATA0); + rk30_mux_api_set(rksdmmc0_gpio_init.cmd_gpio.iomux.name, rksdmmc0_gpio_init.cmd_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc0_gpio_init.clk_gpio.iomux.name, rksdmmc0_gpio_init.clk_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc0_gpio_init.data0_gpio.iomux.name, rksdmmc0_gpio_init.data0_gpio.iomux.fmux); - rk30_mux_api_set(GPIO3B3_SDMMC0DATA1_NAME, GPIO3B_GPIO3B3); - gpio_request(RK30_PIN3_PB3, "mmc0-data1"); - gpio_direction_output(RK30_PIN3_PB3,GPIO_HIGH);//set mmc0-data1 to high. + rk30_mux_api_set(rksdmmc0_gpio_init.data1_gpio.iomux.name, rksdmmc0_gpio_init.data1_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data1_gpio.io, "mmc0-data1"); + gpio_direction_output(rksdmmc0_gpio_init.data1_gpio.io,GPIO_HIGH);//set mmc0-data1 to high. - rk30_mux_api_set(GPIO3B4_SDMMC0DATA2_NAME, GPIO3B_GPIO3B4); - gpio_request(RK30_PIN3_PB4, "mmc0-data2"); - gpio_direction_output(RK30_PIN3_PB4,GPIO_HIGH);//set mmc0-data2 to high. + rk30_mux_api_set(rksdmmc0_gpio_init.data2_gpio.iomux.name, rksdmmc0_gpio_init.data2_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data2_gpio.io, "mmc0-data2"); + gpio_direction_output(rksdmmc0_gpio_init.data2_gpio.io,GPIO_HIGH);//set mmc0-data2 to high. - rk30_mux_api_set(GPIO3B5_SDMMC0DATA3_NAME, GPIO3B_GPIO3B5); - gpio_request(RK30_PIN3_PB5, "mmc0-data3"); - gpio_direction_output(RK30_PIN3_PB5,GPIO_HIGH);//set mmc0-data3 to high. + rk30_mux_api_set(rksdmmc0_gpio_init.data3_gpio.iomux.name, rksdmmc0_gpio_init.data3_gpio.iomux.fgpio); + gpio_request(rksdmmc0_gpio_init.data3_gpio.io, "mmc0-data3"); + gpio_direction_output(rksdmmc0_gpio_init.data3_gpio.io,GPIO_HIGH);//set mmc0-data3 to high. } break; } @@ -174,12 +1077,12 @@ static void rk29_sdmmc_set_iomux_mmc0(unsigned int bus_width) static void rk29_sdmmc_set_iomux_mmc1(unsigned int bus_width) { - rk30_mux_api_set(GPIO3C0_SMMC1CMD_NAME, GPIO3C_SMMC1_CMD); - rk30_mux_api_set(GPIO3C5_SDMMC1CLKOUT_NAME, GPIO3C_SDMMC1_CLKOUT); - rk30_mux_api_set(GPIO3C1_SDMMC1DATA0_NAME, GPIO3C_SDMMC1_DATA0); - rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1); - rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2); - rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3); + rk30_mux_api_set(rksdmmc1_gpio_init.cmd_gpio.iomux.name, rksdmmc1_gpio_init.cmd_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc1_gpio_init.clk_gpio.iomux.name, rksdmmc1_gpio_init.clk_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc1_gpio_init.data0_gpio.iomux.name, rksdmmc1_gpio_init.data0_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc1_gpio_init.data1_gpio.iomux.name, rksdmmc1_gpio_init.data1_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc1_gpio_init.data2_gpio.iomux.name, rksdmmc1_gpio_init.data2_gpio.iomux.fmux); + rk30_mux_api_set(rksdmmc1_gpio_init.data3_gpio.iomux.name, rksdmmc1_gpio_init.data3_gpio.iomux.fmux); } static void rk29_sdmmc_set_iomux_mmc2(unsigned int bus_width) @@ -211,6 +1114,14 @@ static void rk29_sdmmc_set_iomux(int device_id, unsigned int bus_width) #endif + + +//1.Part 4: The various operations of the Wifi-BT module +/************************************************************************* +* define the varaious operations for Wifi module +* Generally only the author of Wifi module will modify this section. +*************************************************************************/ + static int rk29sdk_wifi_status(struct device *dev); static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id); @@ -223,35 +1134,227 @@ static void *wifi_mmc0_status_cb_devid; int rk29sdk_wifi_power_state = 0; int rk29sdk_bt_power_state = 0; -#endif + + #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) + ///////////////////////////////////////////////////////////////////////////////////// + // set the gpio to develop wifi EVB if you select the macro of CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD + #define USE_SDMMC_CONTROLLER_FOR_WIFI 0 + #define COMBO_MODULE_MT6620_CDT 0 //- 1--use Cdtech chip; 0--unuse CDT chip + //power + #define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 + #define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_POWER_PIN_NAME GPIO3D0_SDMMC1PWREN_NAME + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO GPIO3D_GPIO3D0 + #define RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX GPIO3D_SDMMC1_PWR_EN + //reset + #define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 + #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_RESET_PIN_NAME GPIO3D1_SDMMC1BACKENDPWR_NAME + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO GPIO3D_GPIO3D1 + #define RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX GPIO3D_SDMMC1_BACKEND_PWR + //VDDIO + //#define RK30SDK_WIFI_GPIO_VCCIO_WL RK30_PIN2_PC5 + //#define RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE GPIO_HIGH + //WIFI_INT_B + #define RK30SDK_WIFI_GPIO_WIFI_INT_B RK30_PIN3_PD2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME GPIO3D2_SDMMC1INTN_NAME + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO GPIO3D_GPIO3D2 + #define RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX GPIO3D_SDMMC1_INT_N + //BGF_INT_B + #define RK30SDK_WIFI_GPIO_BGF_INT_B RK30_PIN3_PC6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME GPIO3C6_SDMMC1DETECTN_NAME + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO GPIO3C_GPIO3C6 + #define RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX GPIO3C_SDMMC1_DETECT_N + //GPS_SYNC + #define RK30SDK_WIFI_GPIO_GPS_SYNC RK30_PIN3_PC7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE GPIO_HIGH + #define RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME GPIO3C7_SDMMC1WRITEPRT_NAME + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO GPIO3C_GPIO3C7 + #define RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX GPIO3C_SDMMC1_WRITE_PRT + + #if COMBO_MODULE_MT6620_CDT + //ANTSEL2 + #define RK30SDK_WIFI_GPIO_ANTSEL2 RK30_PIN4_PD4 + #define RK30SDK_WIFI_GPIO_ANTSEL2_ENABLE_VALUE GPIO_LOW //use 6620 in CDT chip, LOW--work; High--no work. + #define RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME GPIO4D4_SMCDATA12_TRACEDATA12_NAME + #define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FGPIO GPIO4D_GPIO4D4 + #define RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FMUX GPIO4D_TRACE_DATA12 + //ANTSEL3 + #define RK30SDK_WIFI_GPIO_ANTSEL3 RK30_PIN4_PD3 + #define RK30SDK_WIFI_GPIO_ANTSEL3_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + #define RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME GPIO4D3_SMCDATA11_TRACEDATA11_NAME + #define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FGPIO GPIO4D_GPIO4D3 + #define RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FMUX GPIO4D_TRACE_DATA11 + //GPS_LAN + #define RK30SDK_WIFI_GPIO_GPS_LAN RK30_PIN4_PD6 + #define RK30SDK_WIFI_GPIO_GPS_LAN_ENABLE_VALUE GPIO_HIGH //use 6620 in CDT chip, High--work; Low--no work.. + #define RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME GPIO4D6_SMCDATA14_TRACEDATA14_NAME + #define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FGPIO GPIO4D_GPIO4D6 + #define RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FMUX GPIO4D_TRACE_DATA14 + #endif // #if COMBO_MODULE_MT6620_CDT--#endif + + #endif // #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD)---#endif +#endif // #if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) ---#endif static int rk29sdk_wifi_cd = 0; /* wifi virtual 'card detect' status */ static void (*wifi_status_cb)(int card_present, void *dev_id); static void *wifi_status_cb_devid; -#ifdef CONFIG_WIFI_CONTROL_FUNC +#if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO) +#define RK29SDK_WIFI_SDIO_CARD_INT RK30SDK_WIFI_GPIO_WIFI_INT_B +#endif -// -// Define wifi module's power and reset gpio, and gpio sensitive level -// +struct rksdmmc_gpio_wifi_moudle rk_platform_wifi_gpio = { + .power_n = { + .io = RK30SDK_WIFI_GPIO_POWER_N, + .enable = RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_POWER_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_POWER_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_POWER_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_POWER_IOMUX_FMUX, + #endif + }, + #endif + }, + + #ifdef RK30SDK_WIFI_GPIO_RESET_N + .reset_n = { + .io = RK30SDK_WIFI_GPIO_RESET_N, + .enable = RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_RESET_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_RESET_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_RESET_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_RESET_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif + + #ifdef RK30SDK_WIFI_GPIO_WIFI_INT_B + .wifi_int_b = { + .io = RK30SDK_WIFI_GPIO_WIFI_INT_B, + .enable = RK30SDK_WIFI_GPIO_WIFI_INT_B_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_WIFI_INT_B_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif + + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL + .vddio = { + .io = RK30SDK_WIFI_GPIO_VCCIO_WL, + .enable = RK30SDK_WIFI_GPIO_VCCIO_WL_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_VCCIO_WL_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif + + #ifdef RK30SDK_WIFI_GPIO_BGF_INT_B + .bgf_int_b = { + .io = RK30SDK_WIFI_GPIO_BGF_INT_B, + .enable = RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_BGF_INT_B_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif + + #ifdef RK30SDK_WIFI_GPIO_GPS_SYNC + .gps_sync = { + .io = RK30SDK_WIFI_GPIO_GPS_SYNC, + .enable = RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_GPS_SYNC_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_GPS_SYNC_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif + +#if COMBO_MODULE_MT6620_CDT + #ifdef RK30SDK_WIFI_GPIO_ANTSEL2 + .ANTSEL2 = { + .io = RK30SDK_WIFI_GPIO_ANTSEL2, + .enable = RK30SDK_WIFI_GPIO_ANTSEL2_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_ANTSEL2_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif -#if defined(CONFIG_RK903) || defined(CONFIG_RK901) -#define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 -#define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH -#endif + #ifdef RK30SDK_WIFI_GPIO_ANTSEL3 + .ANTSEL3 = { + .io = RK30SDK_WIFI_GPIO_ANTSEL3, + .enable = RK30SDK_WIFI_GPIO_ANTSEL3_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_ANTSEL3_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif -#if defined(CONFIG_RTL8192CU) || defined(CONFIG_RTL8188EU) -#define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 -#define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_LOW -#endif + #ifdef RK30SDK_WIFI_GPIO_GPS_LAN + .GPS_LAN = { + .io = RK30SDK_WIFI_GPIO_GPS_LAN, + .enable = RK30SDK_WIFI_GPIO_GPS_LAN_ENABLE_VALUE, + #ifdef RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME + .iomux = { + .name = RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME, + .fgpio = RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FGPIO, + #ifdef RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FMUX + .fmux = RK30SDK_WIFI_GPIO_GPS_LAN_IOMUX_FMUX, + #endif + }, + #endif + }, + #endif +#endif // #if COMBO_MODULE_MT6620_CDT--#endif +}; -#if defined(CONFIG_BCM4329) || defined(CONFIG_BCM4319) -#define RK30SDK_WIFI_GPIO_POWER_N RK30_PIN3_PD0 -#define RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE GPIO_HIGH -#define RK30SDK_WIFI_GPIO_RESET_N RK30_PIN3_PD1 -#define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE GPIO_HIGH -#endif + +#ifdef CONFIG_WIFI_CONTROL_FUNC #define PREALLOC_WLAN_SEC_NUM 4 #define PREALLOC_WLAN_BUF_NUM 160 #define PREALLOC_WLAN_SECTION_HEADER 24 @@ -344,41 +1447,41 @@ static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void static int __init rk29sdk_wifi_bt_gpio_control_init(void) { - rk29sdk_init_wifi_mem(); + rk29sdk_init_wifi_mem(); + rk29_mux_api_set(rk_platform_wifi_gpio.power_n.iomux.name, rk_platform_wifi_gpio.power_n.iomux.fgpio); - rk29_mux_api_set(GPIO3D0_SDMMC1PWREN_NAME, GPIO3D_GPIO3D0); - - if (gpio_request(RK30SDK_WIFI_GPIO_POWER_N, "wifi_power")) { + if (gpio_request(rk_platform_wifi_gpio.power_n.io, "wifi_power")) { pr_info("%s: request wifi power gpio failed\n", __func__); return -1; } #ifdef RK30SDK_WIFI_GPIO_RESET_N - if (gpio_request(RK30SDK_WIFI_GPIO_RESET_N, "wifi reset")) { + if (gpio_request(rk_platform_wifi_gpio.reset_n.io, "wifi reset")) { pr_info("%s: request wifi reset gpio failed\n", __func__); - gpio_free(RK30SDK_WIFI_GPIO_POWER_N); + gpio_free(rk_platform_wifi_gpio.reset_n.io); return -1; } #endif - gpio_direction_output(RK30SDK_WIFI_GPIO_POWER_N, !RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE); -#ifdef RK30SDK_WIFI_GPIO_RESET_N - gpio_direction_output(RK30SDK_WIFI_GPIO_RESET_N, !RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE); + gpio_direction_output(rk_platform_wifi_gpio.power_n.io, !(rk_platform_wifi_gpio.power_n.enable) ); + +#ifdef RK30SDK_WIFI_GPIO_RESET_N + gpio_direction_output(rk_platform_wifi_gpio.reset_n.io, !(rk_platform_wifi_gpio.reset_n.enable) ); #endif #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) - rk29_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_GPIO3C2); - gpio_request(RK30_PIN3_PC2, "mmc1-data1"); - gpio_direction_output(RK30_PIN3_PC2,GPIO_LOW);//set mmc1-data1 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data1_gpio.iomux.name, rksdmmc1_gpio_init.data1_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data1_gpio.io, "mmc1-data1"); + gpio_direction_output(rksdmmc1_gpio_init.data1_gpio.io,GPIO_LOW);//set mmc1-data1 to low. - rk29_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_GPIO3C3); - gpio_request(RK30_PIN3_PC3, "mmc1-data2"); - gpio_direction_output(RK30_PIN3_PC3,GPIO_LOW);//set mmc1-data2 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data2_gpio.iomux.name, rksdmmc1_gpio_init.data2_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data2_gpio.io, "mmc1-data2"); + gpio_direction_output(rksdmmc1_gpio_init.data2_gpio.io,GPIO_LOW);//set mmc1-data2 to low. - rk29_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_GPIO3C4); - gpio_request(RK30_PIN3_PC4, "mmc1-data3"); - gpio_direction_output(RK30_PIN3_PC4,GPIO_LOW);//set mmc1-data3 to low. + rk29_mux_api_set(rksdmmc1_gpio_init.data3_gpio.iomux.name, rksdmmc1_gpio_init.data3_gpio.iomux.fgpio); + gpio_request(rksdmmc1_gpio_init.data3_gpio.io, "mmc1-data3"); + gpio_direction_output(rksdmmc1_gpio_init.data3_gpio.io,GPIO_LOW);//set mmc1-data3 to low. rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13 #endif @@ -387,24 +1490,46 @@ static int __init rk29sdk_wifi_bt_gpio_control_init(void) return 0; } +#if (defined(CONFIG_RTL8192CU) || defined(CONFIG_RTL8188EU) )&& defined(CONFIG_ARCH_RK2928) +static int usbwifi_power_status = 1; +int rk29sdk_wifi_power(int on) +{ + pr_info("%s: %d\n", __func__, on); + if (on){ + if(usbwifi_power_status == 1) { + rkusb_wifi_power(0); + mdelay(50); + } + rkusb_wifi_power(1); + usbwifi_power_status = 1; + pr_info("wifi turn on power\n"); + }else{ + rkusb_wifi_power(0); + usbwifi_power_status = 0; + pr_info("wifi shut off power\n"); + } + return 0; +} +#else int rk29sdk_wifi_power(int on) { pr_info("%s: %d\n", __func__, on); if (on){ - gpio_set_value(RK30SDK_WIFI_GPIO_POWER_N, RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE); + gpio_set_value(rk_platform_wifi_gpio.power_n.io, rk_platform_wifi_gpio.power_n.enable); + mdelay(50); #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) rk29_sdmmc_gpio_open(1, 1); //added by xbw at 2011-10-13 #endif -#ifdef RK30SDK_WIFI_GPIO_RESET_N - gpio_set_value(RK30SDK_WIFI_GPIO_RESET_N, RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE); -#endif + #ifdef RK30SDK_WIFI_GPIO_RESET_N + gpio_set_value(rk_platform_wifi_gpio.reset_n.io, rk_platform_wifi_gpio.reset_n.enable); + #endif mdelay(100); pr_info("wifi turn on power\n"); }else{ // if (!rk29sdk_bt_power_state){ - gpio_set_value(RK30SDK_WIFI_GPIO_POWER_N, !RK30SDK_WIFI_GPIO_POWER_ENABLE_VALUE); + gpio_set_value(rk_platform_wifi_gpio.power_n.io, !(rk_platform_wifi_gpio.power_n.enable)); #if defined(CONFIG_SDMMC1_RK29) && !defined(CONFIG_SDMMC_RK29_OLD) rk29_sdmmc_gpio_open(1, 0); //added by xbw at 2011-10-13 @@ -417,13 +1542,14 @@ int rk29sdk_wifi_power(int on) // pr_info("wifi shouldn't shut off power, bt is using it!\n"); // } #ifdef RK30SDK_WIFI_GPIO_RESET_N - gpio_set_value(RK30SDK_WIFI_GPIO_RESET_N, !RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE); + gpio_set_value(rk_platform_wifi_gpio.reset_n.io, !(rk_platform_wifi_gpio.reset_n.enable)); #endif } // rk29sdk_wifi_power_state = on; return 0; } +#endif EXPORT_SYMBOL(rk29sdk_wifi_power); static int rk29sdk_wifi_reset_state; @@ -448,7 +1574,6 @@ int rk29sdk_wifi_set_carddetect(int val) } EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); -#define WIFI_HOST_WAKE RK30_PIN3_PD2 static struct resource resources[] = { { @@ -457,85 +1582,98 @@ static struct resource resources[] = { .name = "bcmdhd_wlan_irq", }, }; - + //#if defined(CONFIG_WIFI_CONTROL_FUNC)----#elif /////////////////////////////////////////////////////////////////////////////////// #elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) -#if defined(CONFIG_MACH_RK30_PHONE_PAD) - #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) - #define USE_SDMMC_CONTROLLER_FOR_WIFI 0 - #define RK29SDK_WIFI_COMBO_GPIO_POWER_N RK30_PIN4_PD2 - #define RK29SDK_WIFI_COMBO_GPIO_RESET_N RK30_PIN4_PD1 - #define RK29SDK_WIFI_COMBO_GPIO_VDDIO RK30_PIN1_PA6 - #define RK29SDK_WIFI_COMBO_GPIO_BGF_INT_B RK30_PIN1_PA7 - #define RK29SDK_WIFI_COMBO_GPS_SYNC RK30_PIN3_PC7 - - #else - #define USE_SDMMC_CONTROLLER_FOR_WIFI 1 - #define RK29SDK_WIFI_COMBO_GPIO_POWER_N RK30_PIN3_PC7 - #define RK29SDK_WIFI_COMBO_GPIO_RESET_N RK30_PIN3_PD1 - #define RK29SDK_WIFI_COMBO_GPIO_WIFI_INT_B RK30_PIN3_PD2 - - //#define RK29SDK_WIFI_COMBO_GPIO_VDDIO RK30_PIN6_PB4 - #define RK29SDK_WIFI_COMBO_GPIO_BGF_INT_B RK30_PIN6_PA7 - #define RK29SDK_WIFI_COMBO_GPS_SYNC RK30_PIN3_PD0 - #endif -#else - - #if defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) - #define USE_SDMMC_CONTROLLER_FOR_WIFI 0 - #define RK29SDK_WIFI_COMBO_GPIO_POWER_N RK30_PIN4_PD2 - #define RK29SDK_WIFI_COMBO_GPIO_RESET_N RK30_PIN4_PD1 - #define RK29SDK_WIFI_COMBO_GPIO_VDDIO RK30_PIN1_PA6 - #define RK29SDK_WIFI_COMBO_GPIO_BGF_INT_B RK30_PIN1_PA7 - #define RK29SDK_WIFI_COMBO_GPS_SYNC RK30_PIN3_PC7 - - #else - #define USE_SDMMC_CONTROLLER_FOR_WIFI 1 - #define RK29SDK_WIFI_COMBO_GPIO_POWER_N RK30_PIN3_PD0 - #define RK29SDK_WIFI_COMBO_GPIO_RESET_N RK30_PIN3_PD1 - #define RK29SDK_WIFI_COMBO_GPIO_WIFI_INT_B RK30_PIN3_PD2 - - #define RK29SDK_WIFI_COMBO_GPIO_VDDIO RK30_PIN6_PB4 - #define RK29SDK_WIFI_COMBO_GPIO_BGF_INT_B RK30_PIN3_PC6 - #define RK29SDK_WIFI_COMBO_GPS_SYNC RK30_PIN3_PC7 - #endif -#endif #define debug_combo_system 0 int rk29sdk_wifi_combo_get_BGFgpio(void) { - return RK29SDK_WIFI_COMBO_GPIO_BGF_INT_B; + return rk_platform_wifi_gpio.bgf_int_b.io; } EXPORT_SYMBOL(rk29sdk_wifi_combo_get_BGFgpio); int rk29sdk_wifi_combo_get_GPS_SYNC_gpio(void) { - return RK29SDK_WIFI_COMBO_GPS_SYNC; + return rk_platform_wifi_gpio.gps_sync.io; } EXPORT_SYMBOL(rk29sdk_wifi_combo_get_GPS_SYNC_gpio); static int rk29sdk_wifi_combo_module_gpio_init(void) -{ - if (gpio_request(RK29SDK_WIFI_COMBO_GPIO_RESET_N, "combo-RST")) - { - pr_info("%s:request combo-RST failed\n", __func__); - return -1; - } - gpio_direction_output(RK29SDK_WIFI_COMBO_GPIO_RESET_N, GPIO_LOW); +{ + //VDDIO + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.vddio.iomux.name, rk_platform_wifi_gpio.vddio.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.vddio.io, "combo-VDDIO"); + gpio_direction_output(rk_platform_wifi_gpio.vddio.io, !(rk_platform_wifi_gpio.power_n.enable)); + #endif + + //BGF_INT_B + #ifdef RK30SDK_WIFI_GPIO_BGF_INT_B_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.bgf_int_b.iomux.name, rk_platform_wifi_gpio.bgf_int_b.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.bgf_int_b.io, "combo-BGFINT"); + gpio_pull_updown(rk_platform_wifi_gpio.bgf_int_b.io, GPIOPullUp); + gpio_direction_input(rk_platform_wifi_gpio.bgf_int_b.io); + + //WIFI_INT_B + #ifdef RK30SDK_WIFI_GPIO_WIFI_INT_B_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.bgf_int_b.iomux.name, rk_platform_wifi_gpio.bgf_int_b.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.wifi_int_b.io, "combo-WIFIINT"); + gpio_pull_updown(rk_platform_wifi_gpio.wifi_int_b.io, GPIOPullUp); + gpio_direction_input(rk_platform_wifi_gpio.wifi_int_b.io); + + //reset + #ifdef RK30SDK_WIFI_GPIO_RESET_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.reset_n.iomux.name, rk_platform_wifi_gpio.reset_n.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.reset_n.io, "combo-RST"); + gpio_direction_output(rk_platform_wifi_gpio.reset_n.io, !(rk_platform_wifi_gpio.reset_n.enable)); + + //power + #ifdef RK30SDK_WIFI_GPIO_POWER_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.power_n.iomux.name, rk_platform_wifi_gpio.power_n.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.power_n.io, "combo-PMUEN"); + gpio_direction_output(rk_platform_wifi_gpio.power_n.io, !(rk_platform_wifi_gpio.power_n.enable)); + + #if COMBO_MODULE_MT6620_CDT + //ANTSEL2 + #ifdef RK30SDK_WIFI_GPIO_ANTSEL2 + #ifdef RK30SDK_WIFI_GPIO_ANTSEL2_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.ANTSEL2.iomux.name, rk_platform_wifi_gpio.ANTSEL2.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.ANTSEL2.io, "combo-ANTSEL2"); + gpio_direction_output(rk_platform_wifi_gpio.reset_n.io, rk_platform_wifi_gpio.ANTSEL2.enable); + #endif + + //ANTSEL3 + #ifdef RK30SDK_WIFI_GPIO_ANTSEL3 + #ifdef RK30SDK_WIFI_GPIO_ANTSEL3_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.ANTSEL3.iomux.name, rk_platform_wifi_gpio.ANTSEL3.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.ANTSEL3.io, "combo-ANTSEL3"); + gpio_direction_output(rk_platform_wifi_gpio.ANTSEL3.io, rk_platform_wifi_gpio.ANTSEL3.enable); + #endif + + //GPS_LAN + #ifdef RK30SDK_WIFI_GPIO_GPS_LAN + #ifdef RK30SDK_WIFI_GPIO_GPS_LAN_PIN_NAME + rk30_mux_api_set(rk_platform_wifi_gpio.GPS_LAN.iomux.name, rk_platform_wifi_gpio.GPS_LAN.iomux.fgpio); + #endif + gpio_request(rk_platform_wifi_gpio.GPS_LAN.io, "combo-GPSLAN"); + gpio_direction_output(rk_platform_wifi_gpio.GPS_LAN.io, rk_platform_wifi_gpio.GPS_LAN.enable); + #endif + + #endif//#if COMBO_MODULE_MT6620_CDT ---#endif - if (gpio_request(RK29SDK_WIFI_COMBO_GPIO_POWER_N, "combo-PMUEN")) - { - pr_info("%s:request combo-PMUEN failed\n", __func__); - return -1; - } - - //gpio_pull_updown(RK29SDK_WIFI_COMBO_GPIO_POWER_N,0); - //gpio_direction_input(RK29SDK_WIFI_COMBO_GPIO_POWER_N); - gpio_direction_output(RK29SDK_WIFI_COMBO_GPIO_POWER_N, GPIO_LOW); return 0; } @@ -544,17 +1682,24 @@ int rk29sdk_wifi_combo_module_power(int on) { if(on) { - //gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_VDDIO, GPIO_HIGH); - //mdelay(10); - gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_POWER_N, GPIO_HIGH); + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL + gpio_set_value(rk_platform_wifi_gpio.vddio.io, rk_platform_wifi_gpio.vddio.enable); + mdelay(10); + #endif + + gpio_set_value(rk_platform_wifi_gpio.power_n.io, rk_platform_wifi_gpio.power_n.enable); mdelay(10); pr_info("combo-module turn on power\n"); } else { - gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_POWER_N, GPIO_LOW); + gpio_set_value(rk_platform_wifi_gpio.power_n.io, !(rk_platform_wifi_gpio.power_n.enable) ); mdelay(10); - //gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_VDDIO, GPIO_LOW); + + #ifdef RK30SDK_WIFI_GPIO_VCCIO_WL + gpio_set_value(rk_platform_wifi_gpio.vddio.io, !(rk_platform_wifi_gpio.vddio.enable)); + #endif + pr_info("combo-module turn off power\n"); } return 0; @@ -567,12 +1712,12 @@ int rk29sdk_wifi_combo_module_reset(int on) { if(on) { - gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_RESET_N, GPIO_HIGH); + gpio_set_value(rk_platform_wifi_gpio.reset_n.io, rk_platform_wifi_gpio.reset_n.enable); pr_info("combo-module reset out 1\n"); } else { - gpio_set_value(RK29SDK_WIFI_COMBO_GPIO_RESET_N, GPIO_LOW); + gpio_set_value(rk_platform_wifi_gpio.reset_n.io, !(rk_platform_wifi_gpio.reset_n.enable) ); pr_info("combo-module reset out 0\n"); } @@ -609,7 +1754,6 @@ static int rk29sdk_wifi_status_register(void (*callback)(int card_present, void wifi_status_cb_devid = dev_id; return 0; } -extern unsigned int sdio_irq_global; int rk29sdk_wifi_power(int on) { @@ -687,7 +1831,8 @@ int rk29sdk_wifi_set_carddetect(int val) EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect); -#endif /// #endif ---#elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) +/////////////////////////////////////////////////////////////////////////////////// +#endif //#if defined(CONFIG_WIFI_CONTROL_FUNC)---#elif defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) --#endif @@ -743,5 +1888,3 @@ static struct platform_device rk29sdk_wifi_device = { #endif -#endif // endif --#ifdef CONFIG_SDMMC_RK29 - diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index c30488edddfd..b0eceb8b103b 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -868,26 +868,12 @@ static struct platform_device device_ion = { #endif /************************************************************************************************** - * SDMMC devices, include the module of SD,MMC,and sdio.noted by xbw at 2012-03-05 + * SDMMC devices, include the module of SD,MMC,and SDIO.noted by xbw at 2012-03-05 **************************************************************************************************/ #ifdef CONFIG_SDMMC_RK29 #include "board-rk30-sdk-sdmmc.c" - -#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) -#define SDMMC0_WRITE_PROTECT_PIN RK30_PIN3_PB2 //According to your own project to set the value of write-protect-pin. -#endif - -#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) -#define SDMMC1_WRITE_PROTECT_PIN RK30_PIN3_PB3 //According to your own project to set the value of write-protect-pin. #endif -#define RK29SDK_WIFI_SDIO_CARD_DETECT_N RK30_PIN6_PB2 -#define RK29SDK_WIFI_SDIO_CARD_INT RK30_PIN3_PD2 - -#define RK29SDK_SD_CARD_DETECT_N RK30_PIN3_PB6 //According to your own project to set the value of card-detect-pin. -#define RK29SDK_SD_CARD_INSERT_LEVEL GPIO_LOW // set the voltage of insert-card. Please pay attention to the default setting. -#endif //endif ---#ifdef CONFIG_SDMMC_RK29 - #ifdef CONFIG_SDMMC0_RK29 static int rk29_sdmmc0_cfg_gpio(void) { @@ -906,18 +892,18 @@ static int rk29_sdmmc0_cfg_gpio(void) gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW); #else - rk29_sdmmc_set_iomux(0, 0xFFFF); + rk29_sdmmc_set_iomux(0, 0xFFFF); -#if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6); -#else - rk30_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N); -#endif + #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) + rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO); + #else + rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX); + #endif -#if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) - gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp"); - gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN); -#endif + #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) + gpio_request(SDMMC0_WRITE_PROTECT_PIN, "sdmmc-wp"); + gpio_direction_input(SDMMC0_WRITE_PROTECT_PIN); + #endif #endif @@ -945,23 +931,32 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = { .use_dma = 0, #endif -#if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) +#if defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) && defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) .status = rk29sdk_wifi_mmc0_status, .register_status_notify = rk29sdk_wifi_mmc0_status_register, #endif -#if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - .detect_irq = RK29SDK_SD_CARD_DETECT_N, - .insert_card_level = RK29SDK_SD_CARD_INSERT_LEVEL, -#else - .detect_irq = RK30_PIN3_PB6, // INVALID_GPIO -#endif + + .power_en = RK29SDK_SD_CARD_PWR_EN, + .power_en_level = RK29SDK_SD_CARD_PWR_EN_LEVEL, + .enable_sd_wakeup = 0, #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) .write_prt = SDMMC0_WRITE_PROTECT_PIN, + .write_prt_enalbe_level = SDMMC0_WRITE_PROTECT_ENABLE_VALUE; #else .write_prt = INVALID_GPIO, #endif + + .det_pin_info = { + .io = RK29SDK_SD_CARD_DETECT_N, //INVALID_GPIO, + .enable = RK29SDK_SD_CARD_INSERT_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_DETECT_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO, + .fmux = RK29SDK_SD_CARD_DETECT_IOMUX_FMUX, + }, + }, }; #endif // CONFIG_SDMMC0_RK29 @@ -976,8 +971,6 @@ static int rk29_sdmmc1_cfg_gpio(void) rk30_mux_api_set(GPIO3C2_SDMMC1DATA1_NAME, GPIO3C_SDMMC1_DATA1); rk30_mux_api_set(GPIO3C3_SDMMC1DATA2_NAME, GPIO3C_SDMMC1_DATA2); rk30_mux_api_set(GPIO3C4_SDMMC1DATA3_NAME, GPIO3C_SDMMC1_DATA3); - //rk30_mux_api_set(GPIO3C6_SDMMC1DETECTN_NAME, GPIO3C_SDMMC1_DETECT_N); - #else #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) @@ -1017,32 +1010,37 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = { .use_dma = 0, #endif -#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD) #if defined(CONFIG_WIFI_CONTROL_FUNC) || defined(CONFIG_WIFI_COMBO_MODULE_CONTROL_FUNC) - .status = rk29sdk_wifi_status, - .register_status_notify = rk29sdk_wifi_status_register, -#endif -#if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - .detect_irq = INVALID_GPIO,//RK29SDK_WIFI_SDIO_CARD_DETECT_N, -#else - //.detect_irq = RK29SDK_WIFI_SDIO_CARD_DETECT_N, + .status = rk29sdk_wifi_status, + .register_status_notify = rk29sdk_wifi_status_register, #endif -#if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) - .write_prt = SDMMC1_WRITE_PROTECT_PIN, -#else - .write_prt = INVALID_GPIO, -#endif + #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) + .write_prt = SDMMC1_WRITE_PROTECT_PIN, + .write_prt_enalbe_level = SDMMC1_WRITE_PROTECT_ENABLE_VALUE; + #else + .write_prt = INVALID_GPIO, + #endif -#if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO) - .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT, -#endif + #if defined(CONFIG_RK29_SDIO_IRQ_FROM_GPIO) + .sdio_INT_gpio = RK29SDK_WIFI_SDIO_CARD_INT, + #endif + .det_pin_info = { +#if !defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD) + .io = RK29SDK_SD_CARD_DETECT_N, #else - .detect_irq = INVALID_GPIO, - .enable_sd_wakeup = 0, + .io = INVALID_GPIO, #endif - + .enable = RK29SDK_SD_CARD_INSERT_LEVEL, + .iomux = { + .name = RK29SDK_SD_CARD_DETECT_PIN_NAME, + .fgpio = RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO, + .fmux = GPIO3B_SDMMC0_DETECT_N, + }, + }, + + .enable_sd_wakeup = 0, }; #endif //endif--#ifdef CONFIG_SDMMC1_RK29 diff --git a/arch/arm/plat-rk/include/plat/board.h b/arch/arm/plat-rk/include/plat/board.h index 97055875bb15..2f74c56bec6b 100755 --- a/arch/arm/plat-rk/include/plat/board.h +++ b/arch/arm/plat-rk/include/plat/board.h @@ -136,12 +136,15 @@ struct rksdmmc_gpio_board { struct rksdmmc_gpio_wifi_moudle { - struct rksdmmc_gpio power_n; - struct rksdmmc_gpio reset_n; - struct rksdmmc_gpio vddio; + struct rksdmmc_gpio power_n; //PMU_EN + struct rksdmmc_gpio reset_n; //SYSRET_B, DAIRST + struct rksdmmc_gpio vddio; //power source struct rksdmmc_gpio bgf_int_b; struct rksdmmc_gpio wifi_int_b; struct rksdmmc_gpio gps_sync; + struct rksdmmc_gpio ANTSEL2; //pin5--ANTSEL2 + struct rksdmmc_gpio ANTSEL3; //pin6--ANTSEL3 + struct rksdmmc_gpio GPS_LAN; //pin33--GPS_LAN }; @@ -157,9 +160,13 @@ struct rk29_sdmmc_platform_data { int (*register_status_notify)(void (*callback)(int card_present, void *dev_id), void *dev_id); int detect_irq; int insert_card_level; + int power_en; + int power_en_level; int enable_sd_wakeup; int write_prt; - unsigned int sdio_INT_gpio; //add gpio INT for sdio interrupt.Modifed by xbw at 2012-08-09 + int write_prt_enalbe_level; + unsigned int sdio_INT_gpio; + struct rksdmmc_gpio det_pin_info; }; struct gsensor_platform_data { diff --git a/drivers/mmc/host/rk29_sdmmc.c b/drivers/mmc/host/rk29_sdmmc.c index deb9e53aa321..71ed31c80f00 100755 --- a/drivers/mmc/host/rk29_sdmmc.c +++ b/drivers/mmc/host/rk29_sdmmc.c @@ -70,20 +70,6 @@ int debug_level = 5; #define SDMMC_USE_INT_UNBUSY 0///1 #endif -#if defined(CONFIG_ARCH_RK29) - #define RK29_SDMMC0DETECTN_GPIO RK29_PIN2_PA2 - #define RK29_SDMMC0PWREN_GPIO RK29_PIN5_PD5 -#elif defined(CONFIG_ARCH_RK3066B) - #define RK29_SDMMC0DETECTN_GPIO RK30_PIN3_PB0 - #define RK29_SDMMC0PWREN_GPIO RK30_PIN3_PA1 -#elif defined(CONFIG_ARCH_RK30) - #define RK29_SDMMC0DETECTN_GPIO RK30_PIN3_PB6 - #define RK29_SDMMC0PWREN_GPIO RK30_PIN3_PA7 -#elif defined(CONFIG_ARCH_RK2928) - #define RK29_SDMMC0DETECTN_GPIO RK2928_PIN1_PC1 - #define RK29_SDMMC0PWREN_GPIO RK2928_PIN1_PB6 -#endif - #define RK29_SDMMC_ERROR_FLAGS (SDMMC_INT_FRUN | SDMMC_INT_HLE ) #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) @@ -109,7 +95,7 @@ int debug_level = 5; #define RK29_SDMMC_WAIT_DTO_INTERNVAL 4500 //The time interval from the CMD_DONE_INT to DTO_INT #define RK29_SDMMC_REMOVAL_DELAY 2000 //The time interval from the CD_INT to detect_timer react. -#define RK29_SDMMC_VERSION "Ver.4.09 The last modify date is 2012-10-12" +#define RK29_SDMMC_VERSION "Ver.5.00 The last modify date is 2012-11-05" #if !defined(CONFIG_USE_SDMMC0_FOR_WIFI_DEVELOP_BOARD) #define RK29_CTRL_SDMMC_ID 0 //mainly used by SDMMC @@ -196,11 +182,9 @@ struct rk29_sdmmc { struct mmc_request *mrq; struct mmc_request *new_mrq; struct mmc_command *cmd; - struct mmc_data *data; - + struct mmc_data *data; struct scatterlist *sg; - dma_addr_t dma_addr;; unsigned int use_dma:1; char dma_name[8]; @@ -245,6 +229,7 @@ struct rk29_sdmmc { struct timer_list request_timer; //the timer for INT_CMD_DONE struct timer_list DTO_timer; //the timer for INT_DTO struct mmc_command stopcmd; + struct rksdmmc_gpio det_pin; /* flag for current bus settings */ u32 bus_mode; @@ -254,8 +239,8 @@ struct rk29_sdmmc { unsigned int retryfunc; int gpio_irq; - int gpio_det; - int insert_level; + int gpio_power_en; + int gpio_power_en_level; struct delayed_work work; #ifdef CONFIG_RK29_SDIO_IRQ_FROM_GPIO @@ -265,6 +250,7 @@ struct rk29_sdmmc { #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) int write_protect; + int protect_level; #endif bool irq_state; @@ -1577,17 +1563,17 @@ static int rk29_sdmmc_get_cd(struct mmc_host *mmc) case 0: { #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - if(host->gpio_det == INVALID_GPIO) + if(host->det_pin.io == INVALID_GPIO) return 1; - cdetect = gpio_get_value(host->gpio_det); - if(host->insert_level) + cdetect = gpio_get_value(host->det_pin.io); + if(host->det_pin.enable) cdetect = cdetect?1:0; else cdetect = cdetect?0:1; #else - if(host->gpio_det == INVALID_GPIO) + if(host->det_pin.io == INVALID_GPIO) return 1; cdetect = rk29_sdmmc_read(host->regs, SDMMC_CDETECT); @@ -1603,7 +1589,7 @@ static int rk29_sdmmc_get_cd(struct mmc_host *mmc) #if defined(CONFIG_USE_SDMMC1_FOR_WIFI_DEVELOP_BOARD) cdetect = 1; #else - if(host->gpio_det == INVALID_GPIO) + if(host->det_pin.io == INVALID_GPIO) return 1; cdetect = test_bit(RK29_SDMMC_CARD_PRESENT, &host->flags)?1:0; @@ -1634,10 +1620,7 @@ int rk29_sdmmc_reset_controller(struct rk29_sdmmc *host) int timeOut = 0; rk29_sdmmc_write(host->regs, SDMMC_PWREN, POWER_ENABLE); - - /* reset SDMMC IP */ - //SDPAM_SDCClkEnable(host, TRUE); - + //Clean the fifo. for(timeOut=0; timeOutnew_mrq = mrq; spin_unlock_irqrestore(&host->lock, iflags); rk29_sdmmc_start_request(mmc); - - #else - if (host->state == STATE_IDLE) - { - spin_unlock_irqrestore(&host->lock, iflags); - - host->new_mrq = mrq; - rk29_sdmmc_start_request(mmc); - } - else - { - #ifdef RK29_SDMMC_LIST_QUEUE - - printk(KERN_INFO "%s..%d...Danger! Danger! New request was added to queue. [%s]\n", \ - __FUNCTION__, __LINE__,host->dma_name); - list_add_tail(&host->queue_node, &host->queue); - - #else - - printk(KERN_WARNING "%s..%d..state Error! ,old_state=%d, OldCMD=%d ,NewCMD%2d,arg=0x%x [%s]\n", \ - __FUNCTION__, __LINE__, host->state, host->cmd->opcode,mrq->cmd->opcode,mrq->cmd->arg, host->dma_name); - - mrq->cmd->error = -ENOMEDIUM; - - spin_unlock_irqrestore(&host->lock, iflags); - mmc_request_done(mmc, mrq); - - return; - - #endif - } - #endif - } @@ -2448,9 +2397,8 @@ static void rk29_sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) xbwprintk(7, "%s..%d..POWER_UP, call reset_controller, initialized_flags=%d [%s]\n",\ __FUNCTION__, __LINE__, host->mmc->re_initialized_flags,host->dma_name); - //power-on; (#define RK29_SDMMC0PWREN_GPIO RK30_PIN3_PA7 in RK3066 platform) - gpio_direction_output(RK29_SDMMC0PWREN_GPIO,GPIO_LOW); - //printk("##########vcc_sd power on##########\n"); + //power-on; + gpio_direction_output(host->gpio_power_en, host->gpio_power_en_level); mdelay(5); @@ -2475,9 +2423,7 @@ static void rk29_sdmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } //power-off - gpio_direction_output(RK29_SDMMC0PWREN_GPIO,GPIO_HIGH); - //printk("##########vcc_sd power off##########\n"); - + gpio_direction_output(host->gpio_power_en, !(host->gpio_power_en_level)); } break; @@ -2541,10 +2487,10 @@ static int rk29_sdmmc_get_ro(struct mmc_host *mmc) if(INVALID_GPIO == host->write_protect) ret = 0;//no write-protect else - ret = gpio_get_value(host->write_protect)?1:0; + ret = (host->protect_level == gpio_get_value(host->write_protect)?1:0; - xbwprintk(7,"%s..%d.. write_prt_pin=%d, get_ro=%d. [%s]\n",\ - __FUNCTION__, __LINE__,host->write_protect, ret, host->dma_name); + xbwprintk(7,"%s..%d.. write_prt_pin=%d, get_ro=%d. [%s]\n",\ + __FUNCTION__, __LINE__,host->write_protect, ret, host->dma_name); #else u32 wrtprt = rk29_sdmmc_read(host->regs, SDMMC_WRTPRT); @@ -2572,10 +2518,7 @@ static int rk29_sdmmc_get_ro(struct mmc_host *mmc) static irqreturn_t rk29_sdmmc_sdio_irq_cb(int irq, void *dev_id) { struct rk29_sdmmc *host = dev_id; - //printk("%d..%s: sdio_gpio_int callback. ====[%s]==\n", __LINE__, __FUNCTION__, host->dma_name); - - //rk28_send_wakeup_key(); //wake up backlight - + if(host && host->mmc) mmc_signal_sdio_irq(host->mmc); @@ -3500,14 +3443,7 @@ static void rk29_sdmmc_detect_change_work(struct work_struct *work) struct rk29_sdmmc *host = container_of(work, struct rk29_sdmmc, work.work); rk28_send_wakeup_key(); - rk29_sdmmc_detect_change(host); -#if 0 - free_irq(host->gpio_irq, host); - ret = request_irq(host->gpio_irq,det_keys_isr, - rk29_sdmmc_get_cd(host->mmc)?IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING, - "sd_detect", - host); -#endif + rk29_sdmmc_detect_change(host); } #endif @@ -3529,7 +3465,7 @@ static irqreturn_t det_keys_isr(int irq, void *dev_id) __FUNCTION__, present_old, present, host->dma_name); #if 1 - value = gpio_get_value(host->gpio_det) ?IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; + value = gpio_get_value(host->det_pin.io) ?IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; irq_set_irq_type(host->gpio_irq, value); #endif @@ -3555,7 +3491,7 @@ static irqreturn_t det_keys_isr(int irq, void *dev_id) } #else dev_info(&host->pdev->dev, "sd det_gpio changed(%s), send wakeup key!\n", - gpio_get_value(RK29_SDMMC0DETECTN_GPIO)?"removed":"insert"); + gpio_get_value(host->det_pin.io)?"removed":"insert"); rk29_sdmmc_detect_change((unsigned long)dev_id); #endif return IRQ_HANDLED; @@ -3613,11 +3549,16 @@ static int rk29_sdmmc_probe(struct platform_device *pdev) host->new_mrq = NULL; host->irq_state = true; host->timeout_times = 0; - -#if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - host->gpio_det = pdata->detect_irq; - host->insert_level = pdata->insert_card_level; -#endif + + //detect pin info + host->det_pin.io = pdata->det_pin_info.io; + host->det_pin.enable = pdata->det_pin_info.enable; + host->det_pin.iomux.name = pdata->det_pin_info.iomux.name; + host->det_pin.iomux.fgpio = pdata->det_pin_info.iomux.fgpio; + host->det_pin.iomux.fmux = pdata->det_pin_info.iomux.fmux; + //power pin info + host->gpio_power_en = pdata->power_en; + host->gpio_power_en_level = pdata->power_en_level; host->set_iomux = pdata->set_iomux; @@ -3792,7 +3733,8 @@ static int rk29_sdmmc_probe(struct platform_device *pdev) } #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT) || defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT) - host->write_protect = pdata->write_prt; + host->write_protect = pdata->write_prt; + host->protect_level = pdata->write_prt_enalbe_level; #endif #if defined(CONFIG_ARCH_RK29) @@ -3813,19 +3755,19 @@ static int rk29_sdmmc_probe(struct platform_device *pdev) } #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - if((RK29_CTRL_SDMMC_ID == host->pdev->id) && (INVALID_GPIO != host->gpio_det)) + if((RK29_CTRL_SDMMC_ID == host->pdev->id) && (INVALID_GPIO != host->det_pin.io)) { INIT_DELAYED_WORK(&host->work, rk29_sdmmc_detect_change_work); - ret = gpio_request(host->gpio_det, "sd_detect"); + ret = gpio_request(host->det_pin.io, "sd_detect"); if(ret < 0) { dev_err(&pdev->dev, "gpio_request error\n"); goto err_dmaunmap; } - gpio_direction_input(host->gpio_det); + gpio_direction_input(host->det_pin.io); - level_value = gpio_get_value(host->gpio_det); + level_value = gpio_get_value(host->det_pin.io); - host->gpio_irq = gpio_to_irq(host->gpio_det); + host->gpio_irq = gpio_to_irq(host->det_pin.io); ret = request_irq(host->gpio_irq, det_keys_isr, level_value?IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING, "sd_detect", @@ -3834,6 +3776,8 @@ static int rk29_sdmmc_probe(struct platform_device *pdev) dev_err(&pdev->dev, "gpio request_irq error\n"); goto err_dmaunmap; } + + enable_irq_wake(host->gpio_irq); } #endif @@ -3998,52 +3942,30 @@ static int rk29_sdmmc_sdcard_suspend(struct rk29_sdmmc *host) { int ret = 0; #if !defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - -#if defined(CONFIG_ARCH_RK29) - rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_GPIO2A2); -#elif defined(CONFIG_ARCH_RK3066B) - rk29_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B0); -#elif defined(CONFIG_ARCH_RK30) - rk29_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_GPIO3B6); -#elif defined(CONFIG_ARCH_RK2928) - rk29_mux_api_set(GPIO1C1_MMC0_DETN_NAME, GPIO1C_GPIO1C1); -#endif + rk29_mux_api_set(host->det_pin.iomux.name, host->det_pin.iomux.fgpio); + gpio_request(host->det_pin.io, "sd_detect"); + gpio_direction_input(host->det_pin.io); - gpio_request(RK29_SDMMC0DETECTN_GPIO, "sd_detect"); - gpio_direction_input(RK29_SDMMC0DETECTN_GPIO); - - host->gpio_irq = gpio_to_irq(RK29_SDMMC0DETECTN_GPIO); + host->gpio_irq = gpio_to_irq(host->det_pin.io); ret = request_irq(host->gpio_irq, det_keys_isr, - (gpio_get_value(RK29_SDMMC0DETECTN_GPIO))?IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING, + (gpio_get_value(host->det_pin.io))?IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING, "sd_detect", host); enable_irq_wake(host->gpio_irq); -#endif ////----end of #if !defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - +#endif return ret; } static void rk29_sdmmc_sdcard_resume(struct rk29_sdmmc *host) { #if !defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) - disable_irq_wake(host->gpio_irq); free_irq(host->gpio_irq,host); - gpio_free(RK29_SDMMC0DETECTN_GPIO); - -#if defined(CONFIG_ARCH_RK29) - rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N); -#elif defined(CONFIG_ARCH_RK3066B) - rk29_mux_api_set(GPIO3B0_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0DETECTN); -#elif defined(CONFIG_ARCH_RK30) - rk29_mux_api_set(GPIO3B6_SDMMC0DETECTN_NAME, GPIO3B_SDMMC0_DETECT_N); -#elif defined(CONFIG_ARCH_RK2928) - rk29_mux_api_set(GPIO1C1_MMC0_DETN_NAME, GPIO1C_MMC0_DETN); -#endif - -#endif ////----end of #if !defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO) + gpio_free(host->det_pin.io); + rk29_mux_api_set(host->det_pin.iomux.name, host->det_pin.iomux.fmux); +#endif } static int rk29_sdmmc_suspend(struct platform_device *pdev, pm_message_t state) -- 2.34.1