From: lintao Date: Tue, 3 Mar 2015 06:26:03 +0000 (+0800) Subject: mmc: add hclk_mmc_peri for 3368 X-Git-Tag: firefly_0821_release~4158^2~422 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2e12006ac475dc1857ff3d12de0c1d0fdbdb567d;p=firefly-linux-kernel-4.4.55.git mmc: add hclk_mmc_peri for 3368 Signed-off-by: lintao --- diff --git a/arch/arm64/boot/dts/rk3368.dtsi b/arch/arm64/boot/dts/rk3368.dtsi index dba07a2d5f0d..7d7de7e1518e 100755 --- a/arch/arm64/boot/dts/rk3368.dtsi +++ b/arch/arm64/boot/dts/rk3368.dtsi @@ -339,8 +339,8 @@ interrupts = ; #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>; @@ -357,8 +357,8 @@ 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>; @@ -374,8 +374,8 @@ 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>; diff --git a/drivers/mmc/host/rk_sdmmc.c b/drivers/mmc/host/rk_sdmmc.c index 1d9e5a3f5071..09d0e323f57e 100755 --- a/drivers/mmc/host/rk_sdmmc.c +++ b/drivers/mmc/host/rk_sdmmc.c @@ -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); diff --git a/include/linux/mmc/rk_mmc.h b/include/linux/mmc/rk_mmc.h index 6f02751efca9..e6a081d2906b 100755 --- a/include/linux/mmc/rk_mmc.h +++ b/include/linux/mmc/rk_mmc.h @@ -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];