mmc: host: rk3288-pinctrl: fix sdmmc & sdio0 controller pad iomux setting
authorlintao <lintao@rock-chips.com>
Wed, 26 Mar 2014 05:19:17 +0000 (13:19 +0800)
committerlintao <lintao@rock-chips.com>
Wed, 26 Mar 2014 05:19:17 +0000 (13:19 +0800)
           rk_sdmmc: setting default pinctrl in controller probe but eMMC.

arch/arm/boot/dts/rk3288-pinctrl.dtsi
arch/arm/boot/dts/rk3288.dtsi
drivers/mmc/host/rk_sdmmc.c
include/linux/mmc/rk_mmc.h

index b121ff87c029e8417b11571a311354874d2d97e8..220b53ce34c598be15c2bf3eced54de9ff89558f 100755 (executable)
                                rockchip,drive = <VALUE_DRV_DEFAULT>;
                                //rockchip,tristate = <VALUE_TRI_DEFAULT>;
                        };
+                       
+                       sdmmc0_gpio: sdmmc0_gpio{
+                               rockchip,pins = 
+                                       <GPIO6_C4>,  //CMD
+                                       <GPIO6_C5>,  //CLK
+                                       <GPIO6_C6>,  //DET
+                                       <GPIO6_C0>,  //D0
+                                       <GPIO6_C1>,  //D1
+                                       <GPIO6_C2>,  //D2
+                                       <GPIO6_C3>;  //D3
+                               rockchip,pull = <VALUE_PULL_UP>;
+                               //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                               rockchip,drive = <VALUE_DRV_DEFAULT>;
+                               //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+                       };
+
                };
 
+               gpio4_sdio0 {
+                               
+                               sdio0_clk: sdio0_clk {
+                rockchip,pins = <SDIO0_CLKOUT>;
+                rockchip,pull = <VALUE_PULL_DISABLE>;
+                //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                rockchip,drive = <VALUE_DRV_DEFAULT>;
+                //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+
+               sdio0_cmd: sdio0_cmd {
+                       rockchip,pins = <SDIO0_CMD>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                       
+               sdio0_dectn: sdio0-dectn{
+                       rockchip,pins = <SDIO0_DETECTN>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                                               
+                               sdio0_wrprt: sdio0_wrprt{
+                       rockchip,pins = <SDIO0_WRPRT>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                               
+                               sdio0_pwr: sdio0-pwren{
+                       rockchip,pins = <SDIO0_PWREN>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                               
+                               sdio0_bkpwr: sdio0-bkpwr{
+                       rockchip,pins = <SDIO0_BKPWR>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                               
+                               sdio0_intn: sdio0-intn{
+                       rockchip,pins = <SDIO0_INTN>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+                               
+       
+               sdio0_bus1: sdio0-bus-width1 {
+                       rockchip,pins = <SDIO0_DATA0>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+
+               sdio0_bus4: sdio0-bus-width4 {
+                       rockchip,pins = <SDIO0_DATA0>,
+                        <SDIO0_DATA1>,
+                        <SDIO0_DATA2>,
+                        <SDIO0_DATA3>;
+                       rockchip,pull = <VALUE_PULL_UP>;
+                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+               };
+            
+               sdio0_gpio: sdio0-all-gpio{
+                                       rockchip,pins = 
+                                               <GPIO4_D1>,   //CLK
+                                               <GPIO4_D0>,   //CMD
+                                               <GPIO4_D2>,   //DET
+                                               <GPIO4_D3>,   //wrprt
+                                               <GPIO4_D4>,   //PWREN
+                                               <GPIO4_D5>,   //BKPWR
+                                               <GPIO4_D6>,   //DO
+                                               <GPIO4_C4>,   //D1    
+                                               <GPIO4_C5>,   //D2
+                                               <GPIO4_C6>,   //D3
+                                               <GPIO4_C7>;   //INTN
+                                       rockchip,pull = <VALUE_PULL_UP>;
+                                       //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                                       rockchip,drive = <VALUE_DRV_DEFAULT>;
+                                       //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+                               };
+               };              
+
                gpio2_gps {
                        gps_mag:gps-mag {
                                rockchip,pins = <GPS_MAG>;
index 227f643a8e6caca15c1e7aac0cc991e8f67acd32..a44d231bccdf7348d1b6f2d08a132cf2d3efb3bf 100755 (executable)
        };
 
        sdmmc: rksdmmc@ff0c0000 {
-               compatible = "rockchip,rk_mmc";
+         compatible = "rockchip,rk_mmc";
                reg = <0xff0c0000 0x4000>;
                interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>; /*irq=64*/
-               #address-cells = <1>;
-               #size-cells = <0>;
+         #address-cells = <1>;
+         #size-cells = <0>;
                
-               //pinctrl-names = "default","suspend";
-               //pinctrl-0 = <&sd0_clk &sd0_cmd &sd0_cd &sd0_wp &sd0_pwr &sd0_bus1 &sd0_bus4>;
-               //pinctrl-1 = <&sd0_cd_gpio>; //for int gpio?
+               pinctrl-names = "default","idle";
+         pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_dectn &sdmmc0_bus4>;
+         pinctrl-1 = <&sdmmc0_gpio>; 
 
                clocks = <&clk_sdmmc>, <&clk_gates8 3>;
                clock-names = "clk_mmc", "hclk_mmc";
-               num-slots = <1>;    
-               fifo-depth = <0x100>;
-               bus-width = <4>;
+       num-slots = <1>;    
+         fifo-depth = <0x100>;
+         bus-width = <4>;
            
        };
 
        sdio: rksdmmc@ff0d0000 {
                compatible = "rockchip,rk_mmc";
-               reg = <0xff0d0000 0x4000>;
-               interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               //pinctrl-names = "default","suspend";
-               //pinctrl-0 = <&sd1_clk &sd1_cmd &sd1_cd &sd1_wp &sd1_bus1 &sd1_bus4>;
-
+         reg = <0xff0d0000 0x4000>;
+         interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+         #address-cells = <1>;
+         #size-cells = <0>;
+         pinctrl-names = "default","idle";
+         pinctrl-0 = <&sdio0_clk &sdio0_cmd &sdio0_dectn  &sdio0_wrprt &sdio0_pwr &sdio0_bkpwr
+                                        &sdio0_intn &sdio0_bus4>;
+         pinctrl-1 = <&sdio0_gpio>;
+               
                clocks = <&clk_sdio0>, <&clk_gates8 4>;      
                clock-names = "clk_mmc", "hclk_mmc";
-               num-slots = <1>;
+    num-slots = <1>;
 
-               fifo-depth = <0x100>;
-               bus-width = <4>;
+         fifo-depth = <0x100>;
+         bus-width = <4>;
        };
 
         sdio1: rksdmmc@ff0e0000 {
index 44790e43760df492a510d30bde975f0ae0eba437..793c8ba8d5e25a031679b74525727930657fddaf 100755 (executable)
@@ -727,7 +727,8 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
        if (host->prev_blksz != data->blksz)
                dw_mci_adjust_fifoth(host, data);
 
-    temp = mci_readl(host, CTRL);
+    /* Reset DMA FIFO*/
+       temp = mci_readl(host, CTRL);
        temp |= (SDMMC_CTRL_DMA_RESET | SDMMC_CTRL_FIFO_RESET);
        mci_writel(host, CTRL, temp);
 
@@ -756,6 +757,11 @@ static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data)
        host->sg = NULL;
        host->data = data;
 
+       /* Reset FIFO*/
+       temp = mci_readl(host, CTRL);
+       temp |= (SDMMC_CTRL_DMA_RESET | SDMMC_CTRL_FIFO_RESET);
+       mci_writel(host, CTRL, temp);
+
        if (data->flags & MMC_DATA_READ) {
                host->dir_status = DW_MCI_RECV_STATUS;
                dw_mci_ctrl_rd_thld(host, data);
@@ -2649,6 +2655,19 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
        if (ret)
                goto err_setup_bus;
 
+    /* Pinctrl set default iomux state to fucntion port.
+     * Fixme: DON'T TOUCH EMMC SETTING!
+     */
+    if(!(host->mmc->restrict_caps & RESTRICT_CARD_TYPE_EMMC))
+    {
+        host->pinctrl = devm_pinctrl_get(host->dev);
+        host->pins_default = pinctrl_lookup_state(host->pinctrl,PINCTRL_STATE_DEFAULT);
+        if(!host->pins_default)
+            pinctrl_select_state(host->pinctrl, host->pins_default);
+        else
+            printk("%s: Warning : No default pinctrl matched!\n",mmc_hostname(host->mmc));
+    }
+    
 #if defined(CONFIG_DEBUG_FS)
        dw_mci_init_debugfs(slot);
 #endif
index a2984f83bab9cef8852671e0c0d1345900f1467d..c21f8ba6c803a195bb9ef6a1bf6cdb9a73b11766 100755 (executable)
@@ -195,6 +195,10 @@ struct dw_mci {
        struct regulator        *vmmc;  /* Power regulator */
        unsigned long           irq_flags; /* IRQ flags */
        int                     irq;
+       struct pinctrl *pinctrl; /*Pinctrl state*/
+       struct pinctrl_state    *pins_default;
+       struct pinctrl_state    *pins_idle;
+       struct pinctrl_state    *pins_sleep;
 };
 
 /* DMA ops for Internal/External DMAC interface */