socfpga: Enable SD/MMC support
Subsystems (7)
v5 cover socfpga: Enable SD/MMC support
From: Dinh Nguyen <[email protected]>
Hi,
This is v5 of the patch series to enable SD/MMC on the SOCFPGA platform.
V5 differences from V4:
* This patch series is now dependent on patch series:
[mmc: dw_mmc: Make the use of the hold reg generic]
* Instead of re-using the platform specific "rockchip,rk2928-dw-mshc" binding, just use the generic "snps,dw-mshc" binding.
* No longer need to CC DTS Bindings maintainers as there aren't any new bindings.
Thanks,
Dinh Nguyen (4):
arm: dts: Add support for SD/MMC on SOCFPGA
clk: socfpga: Add a hook for SD/MMC driver to control CIU clock
settings
mmc: dw_mmc-socfpga: Remove the SOCFPGA specific platform for dw_mmc
ARM: socfpga_defconfig: enable SD/MMC support
arch/arm/boot/dts/socfpga.dtsi | 11 +++ arch/arm/boot/dts/socfpga_arria5.dtsi | 12 +++ arch/arm/boot/dts/socfpga_cyclone5.dtsi | 12 +++ arch/arm/boot/dts/socfpga_vt.dts | 12 +++ arch/arm/configs/socfpga_defconfig | 2 + drivers/clk/socfpga/clk.c | 25 ++++++ drivers/mmc/host/Kconfig | 8 -- drivers/mmc/host/dw_mmc-socfpga.c | 138 ------------------------------- 8 files changed, 74 insertions(+), 146 deletions(-) delete mode 100644 drivers/mmc/host/dw_mmc-socfpga.c
Signature · 1 line
1.7.9.5
PATCH v5 1/4 arm: dts: Add support for SD/MMC on SOCFPGA
From: Dinh Nguyen <[email protected]>
Use the standard "snps,dw-mshc" binding that will support SD/MMC on Altera's SOCFPGA platform.
---
v5: Use the standard "snps,dw-mshc" binding
v4: Re-use "rockchip,rk2928-dw-mshc" binding
v3: none
v2: none
--- arch/arm/boot/dts/socfpga.dtsi | 11 +++++++++++ arch/arm/boot/dts/socfpga_arria5.dtsi | 12 ++++++++++++ arch/arm/boot/dts/socfpga_cyclone5.dtsi | 12 ++++++++++++ arch/arm/boot/dts/socfpga_vt.dts | 12 ++++++++++++ 4 files changed, 47 insertions(+)
arch/arm/boot/dts/socfpga.dtsi +11 -0
@@ -469,6 +469,17 @@ cache-level = <2>; }; + mmc: dwmmc0 at ff704000 { + compatible = "snps,dw-mshc"; + reg = <0xff704000 0x1000>; + interrupts = <0 139 4>; + fifo-depth = <0x400>; + #address-cells = <1>; + #size-cells = <0>; + clocks = <&l4_mp_clk>, <&sdmmc_clk>; + clock-names = "biu", "ciu"; + }; + /* Local timer */ timer at fffec600 { compatible = "arm,cortex-a9-twd-timer";
arch/arm/boot/dts/socfpga_arria5.dtsi +12 -0
@@ -27,6 +27,18 @@ }; }; + dwmmc0 at ff704000 { + num-slots = <1>; + supports-highspeed; + broken-cd; + samsung,dw-mshc-sdr-timing = <0 3>; + + slot at 0 { + reg = <0>; + bus-width = <4>; + }; + }; + serial0 at ffc02000 { clock-frequency = <100000000>; };
arch/arm/boot/dts/socfpga_cyclone5.dtsi +12 -0
@@ -28,6 +28,18 @@ }; }; + dwmmc0 at ff704000 { + num-slots = <1>; + supports-highspeed; + broken-cd; + samsung,dw-mshc-sdr-timing = <0 3>; + + slot at 0 { + reg = <0>; + bus-width = <4>; + }; + }; + ethernet at ff702000 { phy-mode = "rgmii"; phy-addr = <0xffffffff>; /* probe for phy addr */
arch/arm/boot/dts/socfpga_vt.dts +12 -0
@@ -41,6 +41,18 @@ }; }; + dwmmc0 at ff704000 { + num-slots = <1>; + supports-highspeed; + broken-cd; + samsung,dw-mshc-sdr-timing = <0 3>; + + slot at 0 { + reg = <0>; + bus-width = <4>; + }; + }; + ethernet at ff700000 { phy-mode = "gmii"; status = "okay";
Signature · 1 line
1.7.9.5
PATCH v5 2/4 clk: socfpga: Add a hook for SD/MMC driver to control CIU clock settings
In reply to dinguyen at altera.comFrom: Dinh Nguyen <[email protected]>
Populate the .prepare function in the clk-ops for the "sdmmc_clk" that represents the "ciu" clock for the SD/MMC driver. The prepare function will handle setting the correct clock-phase for the CIU clock of the SD/MMC IP.
---
v5: Use the "snps,dw-mshc" binding
v4: none
v3: none
v2: none
--- drivers/clk/socfpga/clk.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/clk/socfpga/clk.c +25 -0
@@ -55,7 +55,13 @@#define div_mask (width) ((1 << (width)) - 1)#define streq (a, b) (strcmp((a), (b)) == 0) +#define SYSMGR_SDMMCGRP_CTRL_OFFSET 0x108 +/* SDMMC Group for System Manager defines */ +#define SYSMGR_SDMMC_CTRL_SET (smplsel, drvsel) \ + ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0)) +extern void __iomem *clk_mgr_base_addr; +extern void __iomem *sys_manager_base_addr;struct socfpga_clk {struct clk_gate hw;
@@ -68,6 +74,22 @@ struct socfpga_clk { };#define to_socfpga_clk (p) container_of(p, struct socfpga_clk, hw.hw) +static int sdmmc_ciuclk_prepare (struct clk_hw *hwclk) +{ +struct device_node *np; +u32 timing[2 ]; +u32 hs_timing; + + np =of_find_compatible_node (NULL ,NULL ,"snps,dw-mshc" ); +if (of_property_read_u32_array (np,"samsung,dw-mshc-sdr-timing" , timing,2 )) { +pr_err ("SDMMC: cannot find samsung,dw-mshc-sdr-timing!\n" ); +return -ENODATA ; + } + hs_timing =SYSMGR_SDMMC_CTRL_SET (timing[0 ], timing[1 ]); +writel (hs_timing, sys_manager_base_addr +SYSMGR_SDMMCGRP_CTRL_OFFSET ); +return 0 ; +} +static unsigned long clk_pll_recalc_rate (struct clk_hw *hwclk,unsigned long parent_rate) {
@@ -274,6 +296,9 @@ static void __init socfpga_gate_clk_init(struct device_node *node, socfpga_clk->hw.reg = clk_mgr_base_addr + clk_gate[0 ]; socfpga_clk->hw.bit_idx = clk_gate[1 ]; +if (streq (clk_name,"sdmmc_clk" )) + gateclk_ops.prepare = sdmmc_ciuclk_prepare; + gateclk_ops.enable = clk_gate_ops.enable; gateclk_ops.disable = clk_gate_ops.disable; }
Signature · 1 line
1.7.9.5
PATCH v5 2/4 clk: socfpga: Add a hook for SD/MMC driver to control CIU clock settings
Quoted 7 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
Populate the .prepare function in the clk-ops for the "
sdmmc_clk" that represents the "ciu" clock for the SD/MMC driver. The prepare function will handle setting the correct clock-phase for the CIU clock of the SD/MMC IP.Signed-off-by Dinh Nguyen <[email protected]>
Please see my comments for this patch for v4, it still looks wrong to me. The other three patches are good though.
Arnd
PATCH v5 2/4 clk: socfpga: Add a hook for SD/MMC driver to control CIU clock settings
Quoted 11 lines · Arnd Bergmann
Quoted 7 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
Populate the .prepare function in the clk-ops for the "
sdmmc_clk" that represents the "ciu" clock for the SD/MMC driver. The prepare function will handle setting the correct clock-phase for the CIU clock of the SD/MMC IP.Signed-off-by Dinh Nguyen <[email protected]>Please see my comments for this patch for v4, it still looks wrong to me. The other three patches are good though.
I apologize for missing your V4 comments. It somehow never ended in my Altera mbox but is there at gmail. I will address them.
Dinh
Quoted 3 lines
Arnd
PATCH v5 3/4 mmc: dw_mmc-socfpga: Remove the SOCFPGA specific platform for dw_mmc
In reply to dinguyen at altera.comFrom: Dinh Nguyen <[email protected]>
It turns now that the only really platform specific code that is needed for SOCFPGA is using the SDMMC_CMD_USE_HOLD_REG in the prepare_command function. Now that the code to check for the usage of the SDMMC_CMD_USE_HOLD_REG bit is done by checking the speed mode of the slot, we can remove platform specific code for SOCFPGA.
---
v5: none
v4: Update commit message with updated code to check the hold reg bi
v3: none
v2: none
--- drivers/mmc/host/Kconfig | 8 --- drivers/mmc/host/dw_mmc-socfpga.c | 138 ------------------------------------- 2 files changed, 146 deletions(-) delete mode 100644 drivers/mmc/host/dw_mmc-socfpga.c
drivers/mmc/host/Kconfig +0 -8
@@ -567,14 +567,6 @@ config MMC_DW_EXYNOS Synopsys DesignWare Memory Card Interface driver. Select this option for platforms based on Exynos4 and Exynos5 SoC's. -config MMC_DW_SOCFPGA - tristate "SOCFPGA specific extensions for Synopsys DW Memory Card Interface" - depends on MMC_DW && MFD_SYSCON - select MMC_DW_PLTFM - help - This selects support for Altera SoCFPGA specific extensions to the - Synopsys DesignWare Memory Card Interface driver. - config MMC_DW_PCI tristate "Synopsys Designware MCI support on PCI bus" depends on MMC_DW && PCI
drivers/mmc/host/dw_mmc-socfpga.c deleted +0 -138
138 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v5 4/4 ARM: socfpga_defconfig: enable SD/MMC support
In reply to dinguyen at altera.comFrom: Dinh Nguyen <[email protected]>
Enables the dw_mmc driver for SOCFPGA.
---
v5: none
v4: Added patch
v3: none
v3: none
--- arch/arm/configs/socfpga_defconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/configs/socfpga_defconfig +2 -0
@@ -82,3 +82,5 @@ CONFIG_DEBUG_INFO=y CONFIG_ENABLE_DEFAULT_TRACERS=y CONFIG_DEBUG_USER=y CONFIG_XZ_DEC=y +CONFIG_MMC=y +CONFIG_MMC_DW=y
Signature · 1 line
1.7.9.5