mmc: add hclk_mmc_peri for 3368
authorlintao <lintao@rock-chips.com>
Tue, 3 Mar 2015 06:26:03 +0000 (14:26 +0800)
committerlintao <lintao@rock-chips.com>
Tue, 3 Mar 2015 06:26:15 +0000 (14:26 +0800)
Signed-off-by: lintao <lintao@rock-chips.com>
arch/arm64/boot/dts/rk3368.dtsi
drivers/mmc/host/rk_sdmmc.c
include/linux/mmc/rk_mmc.h

index dba07a2d5f0d63ce23b87e3084c5c3a8923cc927..7d7de7e1518eea936ca233a650a8e6cb78bbc502 100755 (executable)
                interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
                #address-cells = <1>;
                #size-cells = <0>;
-               clocks = <&clk_emmc>, <&clk_gates21 2>;
-               clock-names = "clk_mmc", "hclk_mmc";
+               clocks = <&clk_emmc>, <&clk_gates21 2>, <&clk_gates20 10>;
+               clock-names = "clk_mmc", "hclk_mmc", "hpclk_mmc";
                rockchip,grf = <&grf>;
                num-slots = <1>;
                fifo-depth = <0x100>;
                pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_dectn &sdmmc_bus4>;
                pinctrl-1 = <&sdmmc_gpio>;
                cd-gpios = <&gpio2 GPIO_B3 GPIO_ACTIVE_HIGH>;/*CD GPIO*/
-               clocks = <&clk_sdmmc0>, <&clk_gates21 0>;
-               clock-names = "clk_mmc", "hclk_mmc";
+               clocks = <&clk_sdmmc0>, <&clk_gates21 0>, <&clk_gates20 10>;
+               clock-names = "clk_mmc", "hclk_mmc", "hpclk_mmc";
                rockchip,grf = <&grf>;
                num-slots = <1>;
                fifo-depth = <0x100>;
                pinctrl-names = "default","idle";
                pinctrl-0 = <&sdio0_clk &sdio0_cmd &sdio0_wrprt &sdio0_pwren &sdio0_bkpwr &sdio0_int &sdio0_bus4>;
                pinctrl-1 = <&sdio0_gpio>;
-               clocks = <&clk_sdio0>, <&clk_gates21 1>;
-               clock-names = "clk_mmc", "hclk_mmc";
+               clocks = <&clk_sdio0>, <&clk_gates21 1>, <&clk_gates20 10>;
+               clock-names = "clk_mmc", "hclk_mmc", "hpclk_mmc";
                rockchip,grf = <&grf>;
                num-slots = <1>;
                fifo-depth = <0x100>;
index 1d9e5a3f507124740539e61e639be6ce9eb6a8d2..09d0e323f57e0dfa824d3dc5c2ceff3141a5684d 100755 (executable)
@@ -1522,15 +1522,21 @@ static int dw_mci_set_sdio_status(struct mmc_host *mmc, int val)
         spin_unlock_bh(&host->lock);
 
         if(test_bit(DW_MMC_CARD_PRESENT, &slot->flags)){
-                if(__clk_is_enabled(host->hclk_mmc) == false)
+                if (!IS_ERR(host->hpclk_mmc) &&
+                        __clk_is_enabled(host->hpclk_mmc) == false)
+                        clk_prepare_enable(host->hpclk_mmc);
+               if (__clk_is_enabled(host->hclk_mmc) == false)
                         clk_prepare_enable(host->hclk_mmc);
-                if(__clk_is_enabled(host->clk_mmc) == false)
+                if (__clk_is_enabled(host->clk_mmc) == false)
                         clk_prepare_enable(host->clk_mmc);
         }else{
-                if(__clk_is_enabled(host->clk_mmc) == true)
+                if (__clk_is_enabled(host->clk_mmc) == true)
                         clk_disable_unprepare(slot->host->clk_mmc);
-                if(__clk_is_enabled(host->hclk_mmc) == true)
+                if (__clk_is_enabled(host->hclk_mmc) == true)
                         clk_disable_unprepare(slot->host->hclk_mmc);
+               if (!IS_ERR(host->hpclk_mmc) &&
+                       __clk_is_enabled(host->hpclk_mmc) == true)
+                       clk_disable_unprepare(slot->host->hpclk_mmc);
         }
 
         mmc_detect_change(slot->mmc, 20);
@@ -3868,6 +3874,15 @@ int dw_mci_probe(struct dw_mci *host)
        else
                host->data_offset = DATA_240A_OFFSET;
 
+       //hpclk enable
+       host->hpclk_mmc= devm_clk_get(host->dev, "hpclk_mmc");
+       if (IS_ERR(host->hpclk_mmc)) {
+               dev_err(host->dev, "failed to get hpclk_mmc\n");
+               ret = PTR_ERR(host->hpclk_mmc);
+               goto err_hpclk_mmc;
+       }
+       clk_prepare_enable(host->hpclk_mmc);
+
         //hclk enable
         host->hclk_mmc= devm_clk_get(host->dev, "hclk_mmc");
         if (IS_ERR(host->hclk_mmc)) {
@@ -4063,12 +4078,14 @@ err_dmaunmap:
        }
 
 err_clk_mmc:
-    if (!IS_ERR(host->clk_mmc))
+       if (!IS_ERR(host->clk_mmc))
                clk_disable_unprepare(host->clk_mmc);
 err_hclk_mmc:
-    if (!IS_ERR(host->hclk_mmc))
+       if (!IS_ERR(host->hclk_mmc))
                clk_disable_unprepare(host->hclk_mmc);
-               
+err_hpclk_mmc:
+       if (!IS_ERR(host->hpclk_mmc))
+               clk_disable_unprepare(host->hpclk_mmc);
        return ret;
 }
 EXPORT_SYMBOL(dw_mci_probe);
@@ -4096,21 +4113,23 @@ void dw_mci_remove(struct dw_mci *host)
         if (host->mmc->restrict_caps & RESTRICT_CARD_TYPE_SD)
                 unregister_pm_notifier(&host->mmc->pm_notify);
 
-        if(host->use_dma && host->dma_ops->exit)
+        if (host->use_dma && host->dma_ops->exit)
                 host->dma_ops->exit(host);
 
         if (gpio_is_valid(slot->cd_gpio))
                 dw_mci_of_free_cd_gpio_irq(host->dev, slot->cd_gpio, host->mmc);
 
-        if(host->vmmc){
+        if (host->vmmc){
                 regulator_disable(host->vmmc);
                 regulator_put(host->vmmc);
         }
-       if(!IS_ERR(host->clk_mmc))
+       if (!IS_ERR(host->clk_mmc))
                 clk_disable_unprepare(host->clk_mmc);
 
-        if(!IS_ERR(host->hclk_mmc))
+        if (!IS_ERR(host->hclk_mmc))
                 clk_disable_unprepare(host->hclk_mmc);
+       if (!IS_ERR(host->hpclk_mmc))
+               clk_disable_unprepare(host->hpclk_mmc);
 }
 EXPORT_SYMBOL(dw_mci_remove);
 
index 6f02751efca9fc6c56d610865b6964db37a197f7..e6a081d2906b264ab99b631ad8423094c83b3987 100755 (executable)
@@ -180,6 +180,7 @@ struct dw_mci {
        struct dw_mci_board     *pdata;
        const struct dw_mci_drv_data    *drv_data;
        void                    *priv;
+       struct clk      *hpclk_mmc;
        struct clk      *hclk_mmc;
        struct clk      *clk_mmc;
        struct dw_mci_slot      *slot[MAX_MCI_SLOTS];