SDMMC:
authorxbw <xbw@rock-chips.com>
Fri, 25 Jan 2013 07:25:24 +0000 (15:25 +0800)
committerxbw <xbw@rock-chips.com>
Fri, 25 Jan 2013 07:25:24 +0000 (15:25 +0800)
unified engineering code version of SDMMC in your board-xxx.c

arch/arm/mach-rk30/board-rk3168-LR097.c
arch/arm/mach-rk30/board-rk3168-ds1006h-sdmmc-config.c [new file with mode: 0644]
arch/arm/mach-rk30/board-rk3168-ds1006h.c
arch/arm/mach-rk30/board-rk3168-tb.c
arch/arm/mach-rk3188/board-rk3188-ds1006h-sdmmc-config.c [new file with mode: 0644]

index 83f6b1b278f1178e28905bd17334d445a8762b64..6c91ed7a73ee11a9fcdf6045c482f66099e1187b 100755 (executable)
@@ -904,10 +904,10 @@ static int rk29_sdmmc0_cfg_gpio(void)
 #ifdef CONFIG_SDMMC_RK29_OLD
        iomux_set(MMC0_CMD);
        iomux_set(MMC0_CLKOUT);
-       iomux_set(MMC0_DATA0);
-       iomux_set(MMC0_DATA1);
-       iomux_set(MMC0_DATA2);
-       iomux_set(MMC0_DATA3);
+       iomux_set(MMC0_D0);
+       iomux_set(MMC0_D1);
+       iomux_set(MMC0_D2);
+       iomux_set(MMC0_D3);
 
        iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
 
diff --git a/arch/arm/mach-rk30/board-rk3168-ds1006h-sdmmc-config.c b/arch/arm/mach-rk30/board-rk3168-ds1006h-sdmmc-config.c
new file mode 100644 (file)
index 0000000..861772f
--- /dev/null
@@ -0,0 +1,120 @@
+/*****************************************************************************************
+ * arch/arm/mach-rkxx/baord-xxx-sdmmc-config.c
+ *
+ * Copyright (C) 2013 ROCKCHIP, Inc.
+ *
+ * Description: 
+ *     define the gpio for SD-MMC-SDIO-Wifi functions  according to your own projects.
+ *
+ * Author: Michael Xie
+ *         15 Jan,2013
+ * E-mail: xbw@rock-chips.com
+ *
+ ******************************************************************************************/
+
+/*
+** If you select the macro of CONFIG_SDMMC0_RK29_WRITE_PROTECT, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#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
+
+/*
+** If you select the macro of CONFIG_SDMMC1_RK29_WRITE_PROTECT, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#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
+    
+/*
+** If you select the macro of CONFIG_RK29_SDIO_IRQ_FROM_GPIO, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#define RK29SDK_WIFI_SDIO_CARD_INT         RK30_PIN3_PD2
+
+
+/*
+* define sdcard PowerEn-pin
+*/
+#define RK29SDK_SD_CARD_PWR_EN                  RK30_PIN3_PA1
+#define RK29SDK_SD_CARD_PWR_EN_LEVEL            GPIO_LOW 
+
+/*
+* define the card-detect-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 wifi module's power and reset gpio, and gpio sensitive level.
+* Please set the value according to your own project.
+*
+* Well, you just own engineering module to set the value in the corresponding module branch.
+* Otherwise, you do not define this macro, eliminate it.
+*
+*/          
+#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//GPIO_HIGH        
+    
+#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_RESET_N               RK30_PIN2_PA7
+    #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE    GPIO_HIGH 
+
+#elif defined(CONFIG_MT5931_MT6622) || defined(CONFIG_MT5931)
+
+       #ifdef  CONFIG_MACH_RK3168_LR097 
+       #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
+
+       #else
+       #define RK30SDK_WIFI_GPIO_POWER_N               RK30_PIN0_PA5
+       #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
+
+#elif defined(CONFIG_MT6620)
+    #define COMBO_MODULE_MT6620_CDT    1  // to control antsel2,antsel3 and gps_lan foot when using AcSip or Cdtech chip. 
+                                             //- 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        
+    //reset, DAIRST,SYSRST_B
+    #define RK30SDK_WIFI_GPIO_RESET_N                   RK30_PIN3_PD1
+    #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE        GPIO_HIGH 
+    //VDDIO
+    //#define RK30SDK_WIFI_GPIO_VCCIO_WL                  RK30_PIN0_PD2 //You do not get control of the foot, and you do not need to define the macro 
+    //#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 
+    //BGF_INT_B
+    #define RK30SDK_WIFI_GPIO_BGF_INT_B                 RK30_PIN6_PA7
+    #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE    GPIO_HIGH 
+    //GPS_SYNC
+    #define RK30SDK_WIFI_GPIO_GPS_SYNC                  RK30_PIN3_PD0
+    #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE     GPIO_HIGH 
+
+    #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.
+    //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..
+    //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..
+    #endif // #if COMBO_MODULE_MT6620_CDT--#endif
+#endif 
+
+   
index 364ef90192b0be31bed4f60222f0edeb87e3d4eb..f2531997dcb8b3e1dd43b503e5b6b959698e545a 100644 (file)
@@ -567,7 +567,9 @@ static struct platform_device device_ion = {
  * 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"
+#include "board-rk3168-ds1006h-sdmmc-config.c"
+#include "../plat-rk/rk-sdmmc-ops.c"
+#include "../plat-rk/rk-sdmmc-wifi.c"
 #endif //endif ---#ifdef CONFIG_SDMMC_RK29
 
 #ifdef CONFIG_SDMMC0_RK29
@@ -580,7 +582,8 @@ static int rk29_sdmmc0_cfg_gpio(void)
        iomux_set(MMC0_D1);
        iomux_set(MMC0_D2);
        iomux_set(MMC0_D3);
-       iomux_set(MMC0_DETN);
+
+       iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
 
        gpio_request(RK30_PIN3_PA7, "sdmmc-power");
        gpio_direction_output(RK30_PIN3_PA7, GPIO_LOW);
@@ -589,9 +592,17 @@ static int rk29_sdmmc0_cfg_gpio(void)
        rk29_sdmmc_set_iomux(0, 0xFFFF);
 
     #if defined(CONFIG_SDMMC0_RK29_SDCARD_DET_FROM_GPIO)
+        #if SDMMC_USE_NEW_IOMUX_API
+        iomux_set_gpio_mode(iomux_gpio_to_mode(RK29SDK_SD_CARD_DETECT_N));
+        #else
         rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FGPIO);
+        #endif
     #else
-           rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
+        #if SDMMC_USE_NEW_IOMUX_API       
+        iomux_set(MMC0_DETN);
+        #else
+        rk30_mux_api_set(RK29SDK_SD_CARD_DETECT_PIN_NAME, RK29SDK_SD_CARD_DETECT_IOMUX_FMUX);
+        #endif
     #endif     
 
 #if defined(CONFIG_SDMMC0_RK29_WRITE_PROTECT)
@@ -675,12 +686,12 @@ struct rk29_sdmmc_platform_data default_sdmmc0_data = {
 static int rk29_sdmmc1_cfg_gpio(void)
 {
 #if defined(CONFIG_SDMMC_RK29_OLD)
-       iomux_set(MMC0_CMD);
-       iomux_set(MMC0_CLKOUT);
-       iomux_set(MMC0_D0);
-       iomux_set(MMC0_D1);
-       iomux_set(MMC0_D2);
-       iomux_set(MMC0_D3);
+       iomux_set(MMC1_CMD);
+       iomux_set(MMC1_CLKOUT);
+       iomux_set(MMC1_D0);
+       iomux_set(MMC1_D1);
+       iomux_set(MMC1_D2);
+       iomux_set(MMC1_D3);
 #else
 
 #if defined(CONFIG_SDMMC1_RK29_WRITE_PROTECT)
index a67c0e00feeb34cdc4e01eac7abc427fb5834c41..7b9bb93e043da43d4ed00f6080015397d85c86b6 100755 (executable)
@@ -799,10 +799,10 @@ static int rk29_sdmmc0_cfg_gpio(void)
 #ifdef CONFIG_SDMMC_RK29_OLD
        iomux_set(MMC0_CMD);
        iomux_set(MMC0_CLKOUT);
-       iomux_set(MMC0_DATA0);
-       iomux_set(MMC0_DATA1);
-       iomux_set(MMC0_DATA2);
-       iomux_set(MMC0_DATA3);
+       iomux_set(MMC0_D0);
+       iomux_set(MMC0_D1);
+       iomux_set(MMC0_D2);
+       iomux_set(MMC0_D3);
 
        iomux_set_gpio_mode(iomux_mode_to_gpio(MMC0_DETN));
 
diff --git a/arch/arm/mach-rk3188/board-rk3188-ds1006h-sdmmc-config.c b/arch/arm/mach-rk3188/board-rk3188-ds1006h-sdmmc-config.c
new file mode 100644 (file)
index 0000000..861772f
--- /dev/null
@@ -0,0 +1,120 @@
+/*****************************************************************************************
+ * arch/arm/mach-rkxx/baord-xxx-sdmmc-config.c
+ *
+ * Copyright (C) 2013 ROCKCHIP, Inc.
+ *
+ * Description: 
+ *     define the gpio for SD-MMC-SDIO-Wifi functions  according to your own projects.
+ *
+ * Author: Michael Xie
+ *         15 Jan,2013
+ * E-mail: xbw@rock-chips.com
+ *
+ ******************************************************************************************/
+
+/*
+** If you select the macro of CONFIG_SDMMC0_RK29_WRITE_PROTECT, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#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
+
+/*
+** If you select the macro of CONFIG_SDMMC1_RK29_WRITE_PROTECT, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#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
+    
+/*
+** If you select the macro of CONFIG_RK29_SDIO_IRQ_FROM_GPIO, You must define the following values.
+** Otherwise, there is no need to define the following values¡£
+*/
+//#define RK29SDK_WIFI_SDIO_CARD_INT         RK30_PIN3_PD2
+
+
+/*
+* define sdcard PowerEn-pin
+*/
+#define RK29SDK_SD_CARD_PWR_EN                  RK30_PIN3_PA1
+#define RK29SDK_SD_CARD_PWR_EN_LEVEL            GPIO_LOW 
+
+/*
+* define the card-detect-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 wifi module's power and reset gpio, and gpio sensitive level.
+* Please set the value according to your own project.
+*
+* Well, you just own engineering module to set the value in the corresponding module branch.
+* Otherwise, you do not define this macro, eliminate it.
+*
+*/          
+#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//GPIO_HIGH        
+    
+#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_RESET_N               RK30_PIN2_PA7
+    #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE    GPIO_HIGH 
+
+#elif defined(CONFIG_MT5931_MT6622) || defined(CONFIG_MT5931)
+
+       #ifdef  CONFIG_MACH_RK3168_LR097 
+       #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
+
+       #else
+       #define RK30SDK_WIFI_GPIO_POWER_N               RK30_PIN0_PA5
+       #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
+
+#elif defined(CONFIG_MT6620)
+    #define COMBO_MODULE_MT6620_CDT    1  // to control antsel2,antsel3 and gps_lan foot when using AcSip or Cdtech chip. 
+                                             //- 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        
+    //reset, DAIRST,SYSRST_B
+    #define RK30SDK_WIFI_GPIO_RESET_N                   RK30_PIN3_PD1
+    #define RK30SDK_WIFI_GPIO_RESET_ENABLE_VALUE        GPIO_HIGH 
+    //VDDIO
+    //#define RK30SDK_WIFI_GPIO_VCCIO_WL                  RK30_PIN0_PD2 //You do not get control of the foot, and you do not need to define the macro 
+    //#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 
+    //BGF_INT_B
+    #define RK30SDK_WIFI_GPIO_BGF_INT_B                 RK30_PIN6_PA7
+    #define RK30SDK_WIFI_GPIO_BGF_INT_B_ENABLE_VALUE    GPIO_HIGH 
+    //GPS_SYNC
+    #define RK30SDK_WIFI_GPIO_GPS_SYNC                  RK30_PIN3_PD0
+    #define RK30SDK_WIFI_GPIO_GPS_SYNC_ENABLE_VALUE     GPIO_HIGH 
+
+    #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.
+    //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..
+    //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..
+    #endif // #if COMBO_MODULE_MT6620_CDT--#endif
+#endif 
+
+