socfpga: Enable SD/MMC support
Subsystems (7)
v6 cover socfpga: Enable SD/MMC support
From: Dinh Nguyen <[email protected]>
Hi,
This is v6 of the patch series to enable SD/MMC on the SOCFPGA platform.
V6 differences from V5:
* Adds a new patch to the series.
[mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework] This patch enables the setting for the SDR and DDR setting through the common clock framework. This patch can be independently applied on its own. I lumped it into this series to show how the SOCFPGA can make use of it.
* Add a new clock type "altr,socfpga-sdmmc-sdr-clk" to the SOCFPGA clock driver. This clock type implements the clk_set_rate function which can set the SD/MMC's clock phase settings. Can now use the syscon driver in the set_rate function.
* Will have to CC DTS Maintainers as I am adding a new binding to the clock driver.
Thanks,
Dinh Nguyen (5):
mmc: dw_mmc: Add support to set the SDR and DDR timing through clock
framework
clk: socfpga: Add a clock type for the SD/MMC driver
dts: socfpga: Add support for SD/MMC on the SOCFPGA platform
mmc: dw_mmc-socfpga: Remove the SOCFPGA specific platform for dw_mmc
ARM: socfpga_defconfig: enable SD/MMC support
.../devicetree/bindings/clock/altr_socfpga.txt | 11 +- arch/arm/boot/dts/socfpga.dtsi | 19 ++- 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 | 86 ++++++++++++ drivers/mmc/host/Kconfig | 8 -- drivers/mmc/host/dw_mmc-socfpga.c | 138 -------------------- drivers/mmc/host/dw_mmc.c | 23 ++++ include/linux/mmc/dw_mmc.h | 6 + 11 files changed, 180 insertions(+), 149 deletions(-) delete mode 100644 drivers/mmc/host/dw_mmc-socfpga.c
Signature · 1 line
1.7.9.5
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
From: Dinh Nguyen <[email protected]>
All implementations of the Synopsys DW SD/MMC IP have settings to control the phase shift of the CIU clk. These phase shift settings are necessary for the SD/MMC to correctly clock the card. All variants of the dw_mmc will need these settings, but how they are implemented can vastly vary.
This patch enables the setting for the SDR and/or DDR settings through the common clock framework.
Depends on the patch "mmc: dw_mmc: Enable the hold reg for certain speed modes", that is already reading the "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" bindings, this patch saves those values into a u32 bitmask that can be passed to the clock framework to use.
---
v6: Add this patch
v5: none
v4: none
v3: none
v2: none
--- drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++++ include/linux/mmc/dw_mmc.h | 6 ++++++ 2 files changed, 29 insertions(+)
drivers/mmc/host/dw_mmc.c +23 -0
@@ -2431,6 +2431,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)if ((sdr_timing[1 ] ==0 ) || (ddr_timing[1 ] ==0 )) pdata->cclk_in_drv =0 ; + pdata->sdr_timing = (sdr_timing[1 ] | (sdr_timing[0 ] <<4 )); + pdata->ddr_timing = (ddr_timing[1 ] | (ddr_timing[0 ] <<4 ));return pdata; }
@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail +* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk)) +dev_dbg (host->dev,"ddr_mmc clock not available\n" ); +else +clk_set_rate (host->ddr_clk, host->pdata->ddr_timing); + } + ret =clk_prepare_enable (host->ciu_clk);if (ret) {dev_err (host->dev,"failed to enable ciu clock\n" );
include/linux/mmc/dw_mmc.h +6 -0
@@ -83,6 +83,8 @@ struct mmc_data;* @priv: Implementation defined private data. * @biu_clk: Pointer to bus interface unit clock instance. * @ciu_clk: Pointer to card interface unit clock instance. +* @sdr_clk: Pointer to the SDR clock instance. +* @ddr_clk: Pointer to the DDR clock instance. * @slot: Slots sharing this MMC controller. * @fifo_depth: depth of FIFO. * @data_shift: log2 of FIFO item size.
@@ -170,6 +172,8 @@ struct dw_mci {void *priv;struct clk *biu_clk;struct clk *ciu_clk; +struct clk *sdr_clk; +struct clk *ddr_clk;struct dw_mci_slot *slot[MAX_MCI_SLOTS ];/* FIFO push and pull */
@@ -241,6 +245,8 @@ struct dw_mci_board {u32 caps2;/* More capabilities */ u32 pm_caps;/* PM capabilities */ u32 cclk_in_drv;/*cclk_in_drv phase shift */ +u32 sdr_timing;/* Single data rate timing setting. */ +u32 ddr_timing;/* Double data rate timing setting. */ /* * Override fifo depth. If 0, autodetect it from the FIFOTH register, * but note that this may not be reliable after a bootloader has used
Signature · 1 line
1.7.9.5
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
Dear Dinh
Quoted 55 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
All implementations of the Synopsys DW SD/MMC IP have settings to control the phase shift of the CIU clk. These phase shift settings are necessary for the SD/MMC to correctly clock the card. All variants of the
dw_mmcwill need these settings, but how they are implemented can vastly vary.This patch enables the setting for the SDR and/or DDR settings through the common clock framework.
Depends on the patch "mmc:
dw_mmc: Enable the hold reg for certain speed modes", that is already reading the "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" bindings, this patch saves those values into a u32 bitmask that can be passed to the clock framework to use.Signed-off-by Dinh Nguyen <[email protected]>---
v6: Add this patch
v5: none
v4: none
v3: none
v2: none--- drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++++ include/linux/mmc/dw_mmc.h | 6 ++++++ 2 files changed, 29 insertions(+)drivers/mmc/host/dw_mmc.c +13
-0@@ -2431,6 +2431,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)if ((sdr_timing[1 ] ==0 ) || (ddr_timing[1 ] ==0 )) pdata->cclk_in_drv =0 ; + pdata->sdr_timing = (sdr_timing[1 ] | (sdr_timing[0 ] <<4 )); + pdata->ddr_timing = (ddr_timing[1 ] | (ddr_timing[0 ] <<4 ));return pdata; }@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail +* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing);
drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2503
Quoted 10 lines
drivers/mmc/host/dw_mmc.c +10
-0+ } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk)) +dev_dbg (host->dev,"ddr_mmc clock not available\n" ); +else +clk_set_rate (host->ddr_clk, host->pdata->ddr_timing); + } +
Just curious, does pdata->sdr_timing and pdata->ddr_timing are fixed, fixed as each controller, or different with different board.
In case they are fixed, or fixed in each controller, and only required to be set in probe only once, maybe they can be hide in clk_mmc_ops.prepare And the clock can be used as ciu_clock, or parent of ciu_clock, which is called in dw_mmc.c, maybe these code can be ignored.
Quoted 26 lines
drivers/mmc/host/dw_mmc.c +0
-0ret =clk_prepare_enable (host->ciu_clk);if (ret) {dev_err (host->dev,"failed to enable ciu clock\n" );include/linux/mmc/dw_mmc.h +4
-0@@ -83,6 +83,8 @@ struct mmc_data;* @priv: Implementation defined private data. * @biu_clk: Pointer to bus interface unit clock instance. * @ciu_clk: Pointer to card interface unit clock instance. +* @sdr_clk: Pointer to the SDR clock instance. +* @ddr_clk: Pointer to the DDR clock instance. * @slot: Slots sharing this MMC controller. * @fifo_depth: depth of FIFO. * @data_shift: log2 of FIFO item size. @@ -170,6 +172,8 @@ struct dw_mci {void *priv;struct clk *biu_clk;struct clk *ciu_clk; +struct clk *sdr_clk; +struct clk *ddr_clk;struct dw_mci_slot *slot[MAX_MCI_SLOTS ];/* FIFO push and pull */
include/linux/mmc/dw_mmc.h struct dw_mci_board { · line 249
Quoted 5 lines
include/linux/mmc/dw_mmc.h +2
-0@@ -241,6 +245,8 @@ struct dw_mci_board {u32 caps2;/* More capabilities */ u32 pm_caps;/* PM capabilities */ u32 cclk_in_drv;/*cclk_in_drv phase shift */ +u32 sdr_timing;/* Single data rate timing setting. */ +u32 ddr_timing;/* Double data rate timing setting. */
Are they fixed or not?
Thanks
Zhangfei
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
Hi Zhangfei,
Quoted 70 lines · zhangfei
Dear Dinh
Quoted 67 lines · On 12/13/2013 04:30 AM, [email protected] wrote:
From: Dinh Nguyen <[email protected]>
All implementations of the Synopsys DW SD/MMC IP have settings to control
the phase shift of the CIU clk. These phase shift settings are necessary for
the SD/MMC to correctly clock the card. All variants of thedw_mmcwill need
these settings, but how they are implemented can vastly vary.This patch enables the setting for the SDR and/or DDR settings through the
common clock framework.Depends on the patch "mmc:
dw_mmc: Enable the hold reg for certain speed modes",
that is already reading the "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" bindings, this patch saves those values into a
u32 bitmask that can be passed to the clock framework to use.Signed-off-by Dinh Nguyen <[email protected]>---
v6: Add this patch
v5: none
v4: none
v3: none
v2: none--- drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++++ include/linux/mmc/dw_mmc.h | 6 ++++++ 2 files changed, 29 insertions(+)drivers/mmc/host/dw_mmc.c +18
-0@@ -2431,6 +2431,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)if ((sdr_timing[1 ] ==0 ) || (ddr_timing[1 ] ==0 )) pdata->cclk_in_drv =0 ; + pdata->sdr_timing = (sdr_timing[1 ] | (sdr_timing[0 ] <<4 )); + pdata->ddr_timing = (ddr_timing[1 ] | (ddr_timing[0 ] <<4 ));return pdata; }@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail +* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk))
Quoted 8 lines
drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2503
Quoted 5 lines
drivers/mmc/host/dw_mmc.c +5
-0+dev_dbg (host->dev,"ddr_mmc clock not available\n" ); + else + clk_set_rate(host->ddr_clk, host->pdata->ddr_timing); + } +Just curious, does
pdata->sdr_timingandpdata->ddr_timingare fixed, fixed as each controller, or different with different board.
Yes, they are fixed for each controller per SoC.
Quoted 6 lines
In case they are fixed, or fixed in each controller, and only required to be set in probe only once, maybe they can be hide in clk_mmc_ops.prepare
And the clock can be used asciu_clock, or parent ofciu_clock, which is called indw_mmc.c, maybe these code can be ignored.
Please see v5 of this patch: https://patchwork.kernel.org/patch/3311121/
The issue with V5 was that there is no way for the dw_mmc driver to pass the clock phase settings
in the clk_mmc_ops.prepare function.
Quoted 26 lines
Quoted 26 lines
drivers/mmc/host/dw_mmc.c +0
-0ret =clk_prepare_enable (host->ciu_clk);if (ret) {dev_err (host->dev,"failed to enable ciu clock\n" );include/linux/mmc/dw_mmc.h +4
-0@@ -83,6 +83,8 @@ struct mmc_data;* @priv: Implementation defined private data. * @biu_clk: Pointer to bus interface unit clock instance. * @ciu_clk: Pointer to card interface unit clock instance. +* @sdr_clk: Pointer to the SDR clock instance. +* @ddr_clk: Pointer to the DDR clock instance. * @slot: Slots sharing this MMC controller. * @fifo_depth: depth of FIFO. * @data_shift: log2 of FIFO item size. @@ -170,6 +172,8 @@ struct dw_mci {void *priv;struct clk *biu_clk;struct clk *ciu_clk; +struct clk *sdr_clk; +struct clk *ddr_clk;struct dw_mci_slot *slot[MAX_MCI_SLOTS ];
Quoted 9 lines
include/linux/mmc/dw_mmc.h struct dw_mci_board { · line 249
Quoted 7 lines
include/linux/mmc/dw_mmc.h +2
-0/* FIFO push and pull */ @@ -241,6 +245,8 @@ struct dw_mci_board {u32 caps2;/* More capabilities */ u32 pm_caps;/* PM capabilities */ u32 cclk_in_drv;/*cclk_in_drv phase shift */ +u32 sdr_timing;/* Single data rate timing setting. */ +u32 ddr_timing;/* Double data rate timing setting. */ Are they fixed or not?
They are fixed values that is represented in the DTS bindings.
Dinh
Quoted 3 lines
Thanks
Zhangfei
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
Quoted 37 lines · Dinh Nguyen
Hi Zhangfei,
Quoted 20 lines
Quoted 20 lines
drivers/mmc/host/dw_mmc.c +16
-0@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail +* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk))Quoted 8 lines
drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2503
Quoted 5 lines
drivers/mmc/host/dw_mmc.c +5
-0+dev_dbg (host->dev,"ddr_mmc clock not available\n" ); + else + clk_set_rate(host->ddr_clk, host->pdata->ddr_timing); + } +Just curious, does
pdata->sdr_timingandpdata->ddr_timingare fixed, fixed as each controller, or different with different board.Yes, they are fixed for each controller per SoC.
Quoted 6 lines
In case they are fixed, or fixed in each controller, and only required to be set in probe only once, maybe they can be hide in clk_mmc_ops.prepare
And the clock can be used asciu_clock, or parent ofciu_clock, which is called indw_mmc.c, maybe these code can be ignored.
Quoted 4 lines
Please see v5 of this patch: https://patchwork.kernel.org/patch/3311121/
The issue with V5 was that there is no way for thedw_mmcdriver to pass the clock phase settings
in the clk_mmc_ops.prepare function.
Personally, I think v5 is simpler :)
Could these fixed para be used as internal para when register. Likesocfpga_gate_clk_init
rc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2);
compatible = "altr,socfpga-gate-clk";
clocks = <&mainclk>;
div-reg = <0x64 0 2>;
clk-gate = <0x60 1>;Could we also define mmc-ciu-clock with para clk-init.
Thanks
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
Quoted 41 lines · zhangfei
Quoted 38 lines · Dinh Nguyen
Hi Zhangfei,
Quoted 21 lines
Quoted 21 lines
drivers/mmc/host/dw_mmc.c +3
-0@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail
drivers/mmc/host/dw_mmc.c +13
-0+* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk))Quoted 8 lines
drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2503
Quoted 5 lines
drivers/mmc/host/dw_mmc.c +5
-0+dev_dbg (host->dev,"ddr_mmc clock not available\n" ); + else + clk_set_rate(host->ddr_clk, host->pdata->ddr_timing); + } +Just curious, does
pdata->sdr_timingandpdata->ddr_timingare fixed, fixed as each controller, or different with different board.Yes, they are fixed for each controller per SoC.
Quoted 6 lines
In case they are fixed, or fixed in each controller, and only required to be set in probe only once, maybe they can be hide in clk_mmc_ops.prepare
And the clock can be used asciu_clock, or parent ofciu_clock, which is called indw_mmc.c, maybe these code can be ignored.
Quoted 6 lines
Quoted 4 lines
Please see v5 of this patch: https://patchwork.kernel.org/patch/3311121/
The issue with V5 was that there is no way for thedw_mmcdriver to pass the clock phase settings
in the clk_mmc_ops.prepare function.Personally, I think v5 is simpler :)
I agree...
Quoted 10 lines
Could these fixed para be used as internal para when register. Like
socfpga_gate_clk_initrc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); compatible = "altr,socfpga-gate-clk"; clocks = <&mainclk>; div-reg = <0x64 0 2>; clk-gate = <0x60 1>;Could we also define mmc-ciu-clock with para clk-init.
Hmm..this was one of Arnd's suggestion. Will this also work for you? If so then I think I can
proceed down this path, as I think this should be the most direct and simplest.
Thanks,
Dinh
Quoted 2 lines
Thanks
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
Quoted 54 lines · Dinh Nguyen
Quoted 37 lines
Quoted 37 lines
Quoted 22 lines
Quoted 22 lines
drivers/mmc/host/dw_mmc.c +3
-0@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail
drivers/mmc/host/dw_mmc.c +13
-0+* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk))Quoted 8 lines
drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2503
Quoted 5 lines
drivers/mmc/host/dw_mmc.c +5
-0+dev_dbg (host->dev,"ddr_mmc clock not available\n" ); + else + clk_set_rate(host->ddr_clk, host->pdata->ddr_timing); + } +Just curious, does
pdata->sdr_timingandpdata->ddr_timingare fixed, fixed as each controller, or different with different board.Yes, they are fixed for each controller per SoC.
Quoted 6 lines
In case they are fixed, or fixed in each controller, and only required to be set in probe only once, maybe they can be hide in clk_mmc_ops.prepare
And the clock can be used asciu_clock, or parent ofciu_clock, which is called indw_mmc.c, maybe these code can be ignored.Quoted 6 lines
Quoted 4 lines
Please see v5 of this patch: https://patchwork.kernel.org/patch/3311121/
The issue with V5 was that there is no way for thedw_mmcdriver to pass the clock phase settings
in the clk_mmc_ops.prepare function.Personally, I think v5 is simpler :)
I agree...
Quoted 10 lines
Could these fixed para be used as internal para when register. Like
socfpga_gate_clk_initrc = of_property_read_u32_array(node, "clk-gate", clk_gate, 2); compatible = "altr,socfpga-gate-clk"; clocks = <&mainclk>; div-reg = <0x64 0 2>; clk-gate = <0x60 1>;Could we also define mmc-ciu-clock with para clk-init.
Quoted 5 lines
Hmm..this was one of Arnd's suggestion. Will this also work for you? If so then I think I can
proceed down this path, as I think this should be the most direct and simplest.
Yes, go ahead.sdr_timing & ddr_timing only takes effect on socfpga-mmc. It is good to put in clk driver specifically for socfpga, instead of putting in common dw_mmc.c
Thanks
PATCH v6 1/5 mmc: dw_mmc: Add support to set the SDR and DDR timing through clock framework
In reply to dinguyen at altera.comQuoted 7 lines · Dinh Nguyen
From: Dinh Nguyen <[email protected]>
All implementations of the Synopsys DW SD/MMC IP have settings to control the phase shift of the CIU clk. These phase shift settings are necessary for the SD/MMC to correctly clock the card. All variants of the
dw_mmcwill need these settings, but how they are implemented can vastly vary.
Quoted 7 lines
This patch enables the setting for the SDR and/or DDR settings through the common clock framework.
Depends on the patch "mmc:
dw_mmc: Enable the hold reg for certain speed modes", that is already reading the "samsung,dw-mshc-sdr-timing" and "samsung,dw-mshc-ddr-timing" bindings, this patch saves those values into a u32 bitmask that can be passed to the clock framework to use.
I didn't understand this patch.
As you mentioned, clock implementation can be different each SOC. And what is the difference with existing ciu clock?
Quoted 18 lines
Signed-off-by Dinh Nguyen <[email protected]>---
v6: Add this patch
v5: none
v4: none
v3: none
v2: none--- drivers/mmc/host/dw_mmc.c | 23 +++++++++++++++++++++++ include/linux/mmc/dw_mmc.h | 6 ++++++ 2 files changed, 29 insertions(+)drivers/mmc/host/dw_mmc.c +0
-0
drivers/mmc/host/dw_mmc.c static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) · line 2435
Quoted 5 lines
drivers/mmc/host/dw_mmc.c +2
-0@@ -2431,6 +2431,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)if ((sdr_timing[1 ] ==0 ) || (ddr_timing[1 ] ==0 )) pdata->cclk_in_drv =0 ; + pdata->sdr_timing = (sdr_timing[1 ] | (sdr_timing[0 ] <<4 )); + pdata->ddr_timing = (ddr_timing[1 ] | (ddr_timing[0 ] <<4 ));
Can you explain what it is for?
Thanks,
Seungwon
Quoted 70 lines
drivers/mmc/host/dw_mmc.c +21
-0return pdata; }@@ -2478,6 +2480,27 @@ int dw_mci_probe(struct dw_mci *host)dev_dbg (host->dev,"ciu clock not available\n" ); host->bus_hz = host->pdata->bus_hz; }else { +/* If the CIU clk is available, we check for SDR and DDR +* timing phase shift settings. But not all platforms +* may have populated these settings, the driver will not fail +* if these settings are not specified. +*/ +if (host->pdata->sdr_timing) { + host->sdr_clk =devm_clk_get (host->dev,"sdr_mmc_clk" ); +if (IS_ERR (host->sdr_clk)) +dev_dbg (host->dev,"sdr_mmc clock not available\n" ); +else +clk_set_rate (host->sdr_clk, host->pdata->sdr_timing); + } + +if (host->pdata->ddr_timing) { + host->ddr_clk =devm_clk_get (host->dev,"ddr_mmc_clk" ); +if (IS_ERR (host->ddr_clk)) +dev_dbg (host->dev,"ddr_mmc clock not available\n" ); +else +clk_set_rate (host->ddr_clk, host->pdata->ddr_timing); + } + ret =clk_prepare_enable (host->ciu_clk);if (ret) {dev_err (host->dev,"failed to enable ciu clock\n" );include/linux/mmc/dw_mmc.h +6
-1@@ -83,6 +83,8 @@ struct mmc_data;* @priv: Implementation defined private data. * @biu_clk: Pointer to bus interface unit clock instance. * @ciu_clk: Pointer to card interface unit clock instance. +* @sdr_clk: Pointer to the SDR clock instance. +* @ddr_clk: Pointer to the DDR clock instance. * @slot: Slots sharing this MMC controller. * @fifo_depth: depth of FIFO. * @data_shift: log2 of FIFO item size. @@ -170,6 +172,8 @@ struct dw_mci {void *priv;struct clk *biu_clk;struct clk *ciu_clk; +struct clk *sdr_clk; +struct clk *ddr_clk;struct dw_mci_slot *slot[MAX_MCI_SLOTS ];/* FIFO push and pull */ @@ -241,6 +245,8 @@ struct dw_mci_board {u32 caps2;/* More capabilities */ u32 pm_caps;/* PM capabilities */ u32 cclk_in_drv;/*cclk_in_drv phase shift */ +u32 sdr_timing;/* Single data rate timing setting. */ +u32 ddr_timing;/* Double data rate timing setting. */ /* * Override fifo depth. If 0, autodetect it from the FIFOTH register, * but note that this may not be reliable after a bootloader has used -- 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
In reply to dinguyen at altera.comFrom: Dinh Nguyen <[email protected]>
Add a "altr,socfpga-sdmmc-sdr-clk" clock type in the SOCFPGA clock driver. This clock type is not really a "clock" for say, but a mechanism to set the phase shift of the clock that is used to feed the SD/MMC CIU's clock. This clock does not have parent so it is designated as a CLK_IS_ROOT.
This clock implements the set_clk_rate method that is meant to receive the SDR settings that is designated by the "samsung,dw-mshc-sdr-timing" binding. The SD/MMC driver passes this clock phase information into the clock driver to use.
This enables the SD/MMC driver to touch registers that are located outside of the SD/MMC IP, which helps make the core SD/MMC driver generic.
---
v6: Add a new clock type "altr,socfpga-sdmmc-sdr-clk" that will be used to set the phase shift settings.
v5: Use the "snps,dw-mshc" binding
v4: Use the sdmmc_clk prepare function to set the phase shift settings
v3: Not use the syscon driver because as of 3.13-rc1, the syscon driver is loaded after the clock driver.
v2: Use the syscon driver
--- drivers/clk/socfpga/clk.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
drivers/clk/socfpga/clk.c +86 -0
@@ -21,8 +21,10 @@#include <linux/clkdev.h> #include <linux/clk-provider.h> #include <linux/io.h> +#include <linux/mfd/syscon.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/regmap.h> /* Clock Manager offsets */ #define CLKMGR_CTRL 0x0
@@ -69,6 +71,84 @@ struct socfpga_clk { };#define to_socfpga_clk (p) container_of(p, struct socfpga_clk, hw.hw) +/* SDMMC Group for System Manager defines */ +#define SYSMGR_SDMMC_CTRL_SET (smplsel, drvsel) \ + ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0)) +struct sdmmc_sdr_clk { +struct clk_hw hw; +u32 reg; +}; +#define to_sdmmc_sdr_clk (p) container_of(p, struct sdmmc_sdr_clk, hw) + +static int sdr_clk_set_rate (struct clk_hw *hwclk,unsigned long rate, +unsigned long parent_rate) +{ +struct sdmmc_sdr_clk *sdmmc_sdr_clk =to_sdmmc_sdr_clk (hwclk); +struct regmap *sys_mgr_base_addr; +u32 hs_timing; + + sys_mgr_base_addr =syscon_regmap_lookup_by_compatible ("altr,sys-mgr" ); +if (IS_ERR (sys_mgr_base_addr)) { +pr_err ("%s: failed to find altr,sys-mgr regmap!\n" , __func__); +return -EINVAL ; + } + hs_timing =SYSMGR_SDMMC_CTRL_SET (((rate >4 ) &0xf ), (rate &0xf )); +regmap_write (sys_mgr_base_addr, sdmmc_sdr_clk->reg, hs_timing); +return 0 ; +} + +static unsigned long sdr_clk_recalc_rate (struct clk_hw *hwclk, +unsigned long parent_rate) +{ +return parent_rate; +} + +static long sdr_clk_round_rate (struct clk_hw *hwclk,unsigned long rate, +unsigned long *parent_rate) +{ +return rate; +} + +static const struct clk_ops sdmmc_sdr_clk_ops = { + .recalc_rate = sdr_clk_recalc_rate, + .round_rate = sdr_clk_round_rate, + .set_rate = sdr_clk_set_rate, +}; + +static __init struct clk *socfpga_sdmmc_sdr_clk_init (struct device_node *node, +const struct clk_ops *ops) +{ +u32 reg; +struct clk *clk; +struct sdmmc_sdr_clk *sdmmc_sdr_clk; +const char *clk_name = node->name; +struct clk_init_data init; +int rc; + + rc =of_property_read_u32 (node,"reg" , ®); + + sdmmc_sdr_clk =kzalloc (sizeof (*sdmmc_sdr_clk),GFP_KERNEL ); +if (WARN_ON (!sdmmc_sdr_clk)) +return NULL ; + + sdmmc_sdr_clk->reg = reg; +of_property_read_string (node,"clock-output-names" , &clk_name); + + init.name = clk_name; + init.ops = ops; + init.flags =CLK_IS_ROOT ; + init.num_parents =0 ; + sdmmc_sdr_clk->hw.init = &init; + + clk =clk_register (NULL , &sdmmc_sdr_clk->hw); +if (WARN_ON (IS_ERR (clk))) { +kfree (sdmmc_sdr_clk); +return NULL ; + } + rc =of_clk_add_provider (node, of_clk_src_simple_get, clk); +return clk; +} +static unsigned long clk_pll_recalc_rate (struct clk_hw *hwclk,unsigned long parent_rate) {
@@ -332,10 +412,16 @@ static void __init socfpga_gate_init(struct device_node *node)socfpga_gate_clk_init (node, &gateclk_ops); } +static void __init socfpga_sdmmc_init (struct device_node *node) +{ +socfpga_sdmmc_sdr_clk_init (node, &sdmmc_sdr_clk_ops); +} +static struct of_device_id socfpga_child_clocks[] = { { .compatible ="altr,socfpga-pll-clock" , socfpga_pll_init, }, { .compatible ="altr,socfpga-perip-clk" , socfpga_periph_init, }, { .compatible ="altr,socfpga-gate-clk" , socfpga_gate_init, }, + { .compatible ="altr,socfpga-sdmmc-sdr-clk" , socfpga_sdmmc_init, }, {}, };
Signature · 1 line
1.7.9.5
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Quoted 7 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
Add a "altr,socfpga-sdmmc-sdr-clk" clock type in the SOCFPGA clock driver. This clock type is not really a "clock" for say, but a mechanism to set the phase shift of the clock that is used to feed the SD/MMC CIU's clock. This clock does not have parent so it is designated as a
CLK_IS_ROOT.
Quoted 8 lines
This clock implements the
set_clk_ratemethod that is meant to receive the SDR settings that is designated by the "samsung,dw-mshc-sdr-timing" binding. The SD/MMC driver passes this clock phase information into the clock driver to use.This enables the SD/MMC driver to touch registers that are located outside of the SD/MMC IP, which helps make the core SD/MMC driver generic.
Signed-off-by Dinh Nguyen <[email protected]>
Ok, this looks like it will work, but we haven't concluded if this is the best way to do it. I'm looking for guidance from Mike here.
The alternatives I can see for this particular problem are:
1. fake a clock and use the 'clk_set_rate' callback to set the phase rather than the clock frequency (as you do in this patch).
2. extend the common clock API to provide a 'clk_set_phase' interface that you can call on the CIU clock to set this, so you don't have to fake anything. This seems to be the nicest interface if we have the same problem in more drivers.
3. make the phase setting private to whichever clock is used for CIU (as one of your previous patches did, which I did not like).
4. make the phase an additional argument to the clock specifier, so you would have <&mmcclock 12345 5678> rather than just <&mmcclock> in the mmc host device node to specify the two possible phases.
I would also like to get buy-in from Zhangfei Gao, since he is working on the same thing. Please coordinate with him to make sure whatever one of you comes up with works for the other one too. At the moment, patches are flying so fast without much discussion inbetween that I'd prefer Chris to hold off from merging either one until you have both revieved and Acked each other's patches.
Arnd
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Dear Arnd
Quoted 34 lines · Arnd Bergmann
Quoted 7 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
Add a "altr,socfpga-sdmmc-sdr-clk" clock type in the SOCFPGA clock driver. This clock type is not really a "clock" for say, but a mechanism to set the phase shift of the clock that is used to feed the SD/MMC CIU's clock. This clock does not have parent so it is designated as a
CLK_IS_ROOT.Quoted 8 lines
This clock implements the
set_clk_ratemethod that is meant to receive the SDR settings that is designated by the "samsung,dw-mshc-sdr-timing" binding. The SD/MMC driver passes this clock phase information into the clock driver to use.This enables the SD/MMC driver to touch registers that are located outside of the SD/MMC IP, which helps make the core SD/MMC driver generic.
Signed-off-by Dinh Nguyen <[email protected]>Ok, this looks like it will work, but we haven't concluded if this is the best way to do it. I'm looking for guidance from Mike here.
The alternatives I can see for this particular problem are:
1. fake a clock and use the '
clk_set_rate' callback to set the phase rather than the clock frequency (as you do in this patch).
2. extend the common clock API to provide a 'clk_set_phase' interface that you can call on the CIU clock to set this, so you don't have to fake anything. This seems to be the nicest interface if we have the same problem in more drivers.
3. make the phase setting private to whichever clock is used for CIU (as one of your previous patches did, which I did not like).
4. make the phase an additional argument to the clock specifier, so you would have <&mmcclock 12345 5678> rather than just <&mmcclock> in the mmc host device node to specify the two possible phases.
Quoted 7 lines
I would also like to get buy-in from Zhangfei Gao, since he is working on the same thing. Please coordinate with him to make sure whatever one of you comes up with works for the other one too. At the moment, patches are flying so fast without much discussion inbetween that I'd prefer Chris to hold off from merging either one until you have both revieved and Acked each other's patches.
This is our case
In this version ip, supported now.
Only several mode (LEGACY, HS) are supported in the code, where fixed div and sample is need to be set, so we can hide them in clock. And each controller have different value & register, so different controller use different clock.
These clock can be ciu_clock, whose parent are original clock input.
In next version ip, which still not in hand.
HS200 and other mode have to be supported, tuning process have to be included, good example is drivers/mmc/host/dw_mmc-exynos.c
.execute_tuning = dw_mci_exynos_execute_tuning,
It have to choose the best point during the tuning process. Some other mode may still need tuning, which is special in our case.
Zhangfei
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Quoting zhangfei (2013-12-14 18:18:45)
Quoted 31 lines
Dear Arnd
Quoted 28 lines · Arnd Bergmann
Quoted 7 lines · dinguyen at altera.com
From: Dinh Nguyen <[email protected]>
Add a "altr,socfpga-sdmmc-sdr-clk" clock type in the SOCFPGA clock driver. This clock type is not really a "clock" for say, but a mechanism to set the phase shift of the clock that is used to feed the SD/MMC CIU's clock. This clock does not have parent so it is designated as a
CLK_IS_ROOT.Quoted 8 lines
This clock implements the
set_clk_ratemethod that is meant to receive the SDR settings that is designated by the "samsung,dw-mshc-sdr-timing" binding. The SD/MMC driver passes this clock phase information into the clock driver to use.This enables the SD/MMC driver to touch registers that are located outside of the SD/MMC IP, which helps make the core SD/MMC driver generic.
Signed-off-by Dinh Nguyen <[email protected]>Ok, this looks like it will work, but we haven't concluded if this is the best way to do it. I'm looking for guidance from Mike here.
The alternatives I can see for this particular problem are:
1. fake a clock and use the '
clk_set_rate' callback to set the phase rather than the clock frequency (as you do in this patch).
2. extend the common clock API to provide a 'clk_set_phase' interface that you can call on the CIU clock to set this, so you don't have to fake anything. This seems to be the nicest interface if we have the same problem in more drivers.
clk_set_phase has been proposed before and now may be the time to add it. There are two things that need to be addressed:
1) what are the values for the phase? This needs to work for others that must set clk phase, so we need to consider all those requirements before making a new function declaration in clk.h
2) is setting a clock's phase something done dynamically? Put another way, does the same clock has it's phase set multiple times while the system is running? For static configuration that only happens during initialization we do not need a new API. The clock driver can handle it privately. For dynamic operations though we likely need a new API.
I've Cc'd Peter since I think Tegra has clock phase requirements as well that we discussed some time back.
Regards,
Mike
Quoted 35 lines
Quoted 6 lines
3. make the phase setting private to whichever clock is used for CIU (as one of your previous patches did, which I did not like).
4. make the phase an additional argument to the clock specifier, so you would have <&mmcclock 12345 5678> rather than just <&mmcclock> in the mmc host device node to specify the two possible phases.Quoted 7 lines
I would also like to get buy-in from Zhangfei Gao, since he is working on the same thing. Please coordinate with him to make sure whatever one of you comes up with works for the other one too. At the moment, patches are flying so fast without much discussion inbetween that I'd prefer Chris to hold off from merging either one until you have both revieved and Acked each other's patches.
This is our case
In this version ip, supported now.
Only several mode (LEGACY, HS) are supported in the code, where fixed div and sample is need to be set, so we can hide them in clock. And each controller have different value & register, so different controller use different clock.
These clock can beciu_clock, whose parent are original clock input.In next version ip, which still not in hand.
HS200 and other mode have to be supported, tuning process have to be included, good example isdrivers/mmc/host/dw_mmc-exynos.c
.execute_tuning =dw_mci_exynos_execute_tuning,
It have to choose the best point during the tuning process. Some other mode may still need tuning, which is special in our case.Zhangfei
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Hi Mike et al,
El 15/12/13 01:51, Mike Turquette escribi?:
Quoted 7 lines
clk_set_phasehas been proposed before and now may be the time to add it. There are two things that need to be addressed:1) what are the values for the phase? This needs to work for others that must set clk phase, so we need to consider all those requirements before making a new function declaration in
clk.h
Quoted 5 lines
2) is setting a clock's phase something done dynamically? Put another way, does the same clock has it's phase set multiple times while the system is running? For static configuration that only happens during initialization we do not need a new API. The clock driver can handle it privately. For dynamic operations though we likely need a new API.
We on sunxi also need this for our (not yet merged) MMC driver; we currently have it implemented as an exported
void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)
that takes the MMC clock (and only the MMC clock) and does the setup (it's basically configuring two values, "sample" and "output", into the clock register). I really don't know what does this do/why is it required/when is it used; I'm cc'ing Hans and David who can hopefully explain that part.
I also saw a similar requirement from the gmac people (on cc too), who needed to set the phy type (or something like that) on one of the clock registers; so I'm thinking maybe a generic "tune something" approach that lets users configure some clock-dependent, arbitrary aspect of the clock is the way forward. Otherwise, we're going to end up bloating the clock framework with a lot of callback pointers that are going to be used in one or two clocks out of potentially hundreds on the whole system.
Cheers,
Emilio
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Hi,
Quoted 16 lines · Emilio L?pez
Hi Mike et al,
El 15/12/13 01:51, Mike Turquette escribi?:
Quoted 7 lines
clk_set_phasehas been proposed before and now may be the time to add it. There are two things that need to be addressed:1) what are the values for the phase? This needs to work for others that must set clk phase, so we need to consider all those requirements before making a new function declaration in
clk.hQuoted 5 lines
2) is setting a clock's phase something done dynamically? Put another way, does the same clock has it's phase set multiple times while the system is running? For static configuration that only happens during initialization we do not need a new API. The clock driver can handle it privately. For dynamic operations though we likely need a new API.
Quoted 5 lines
We on sunxi also need this for our (not yet merged) MMC driver; we currently have it implemented as an exported
void
clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)that takes the MMC clock (and only the MMC clock) and does the setup (it's basically configuring two values, "sample" and "output", into the clock register). I really don't know what does this do/why is it required/when is it used; I'm cc'ing Hans and David who can hopefully explain that part.
I'm afraid I cannot explain that part, the MMC controller in the sunxi SoCs is undocumented, so what we're doing there comes straight from the android kernel code. I do understand most of the bits of the sunxi-mci driver, but this bit is black magic to me.
Regards,
Hans
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
In reply to Emilio LópezHi
Quoted 5 lines
that takes the MMC clock (and only the MMC clock) and does the setup (it's basically configuring two values, "sample" and "output", into the clock register). I really don't know what does this do/why is it required/when is it used; I'm cc'ing Hans and David who can hopefully explain that part.
Since the read/write operations have to happen asynchronously and in a manner so that the data provided by the SD-Card can be fetched on time, a specific clock phase shift is required as you can see in the linked picture[1]. That's what the function is doing: It accesses the special registers of the MMC clock device and configures this phase offset.
Quoted 7 lines
I also saw a similar requirement from the gmac people (on cc too), who needed to set the phy type (or something like that) on one of the clock registers; so I'm thinking maybe a generic "tune something" approach that lets users configure some clock-dependent, arbitrary aspect of the clock is the way forward. Otherwise, we're going to end up bloating the clock framework with a lot of callback pointers that are going to be used in one or two clocks out of potentially hundreds on the whole system.
It totally makes sense, since GMAC will be doing asynchrous operations as well.
-David
[1] http://www.chipestimate.com/techtalk/images/11022010_fig2_3.JPG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131216/b7515f05/attachment.sig>
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
Quoting David Lanzend?rfer (2013-12-16 13:54:21)
Quoted 11 lines
Hi
Quoted 5 lines
that takes the MMC clock (and only the MMC clock) and does the setup (it's basically configuring two values, "sample" and "output", into the clock register). I really don't know what does this do/why is it required/when is it used; I'm cc'ing Hans and David who can hopefully explain that part.
Since the read/write operations have to happen asynchronously and in a manner so that the data provided by the SD-Card can be fetched on time, a specific clock phase shift is required as you can see in the linked picture[1]. That's what the function is doing: It accesses the special registers of the MMC clock device and configures this phase offset.
Yeah, clock phase is a fairly common thing to tune but there are two things to consider when crafting a new api like clk_set_phase(...):
1) are we adjusting the phase of the clock signal or the phase of something else related to the clock rate? This is just something to think about. Sometimes it would be better to have video_signal_set_phase() instead of clk_set_phase().
2) what is the input parameter to clk_set_phase? I guess the two best options are degrees (zero to 359), or a fraction of the clock period (1/4, 1/2, etc).
Any thoughts?
Regards,
Mike
Quoted 14 lines
Quoted 8 lines
I also saw a similar requirement from the gmac people (on cc too), who needed to set the phy type (or something like that) on one of the clock registers; so I'm thinking maybe a generic "tune something" approach that lets users configure some clock-dependent, arbitrary aspect of the clock is the way forward. Otherwise, we're going to end up bloating the clock framework with a lot of callback pointers that are going to be used in one or two clocks out of potentially hundreds on the whole system.
It totally makes sense, since GMAC will be doing asynchrous operations as well.
-David
[1] http://www.chipestimate.com/techtalk/images/11022010_fig2_3.JPG
PATCH v6 2/5 clk: socfpga: Add a clock type for the SD/MMC driver
In reply to Emilio LópezHi,
Quoted 2 lines · Emilio L?pez
I also saw a similar requirement from the gmac people (on cc too), who needed to set the phy type (or something like that) on one of the clock
The GMAC clock register controls the tx clock source (a mux) and the interface type, which is most likely a gate to control the direction of the tx clock.
So I modeled it as a composite clock source for now. I'm open to other options.
Quoted 5 lines
registers; so I'm thinking maybe a generic "tune something" approach that lets users configure some clock-dependent, arbitrary aspect of the clock is the way forward. Otherwise, we're going to end up bloating the clock framework with a lot of callback pointers that are going to be used in one or two clocks out of potentially hundreds on the whole system.
ChenYu
PATCH v6 3/5 dts: socfpga: Add support for SD/MMC on the SOCFPGA platform
In reply to dinguyen at altera.comFrom: Dinh Nguyen <[email protected]>
Adds a new binding, "altr,socfpga-sdmmc-sdr-clk". This is a new clock binding that the SD/MMC driver can use the common clock framework to set the appropriate clock phase shift settings for the CIU clock.
Also add the "syscon" binding to the "altr,sys-mgr" node. The clock driver can use the syscon driver to toggle the register for the SD/MMC clock phase shift settings.
---
v6: Add documentation for "altr,socfpga-sdmmc-sdr-clk". Add "syscon" to the sysmgr binding.
v5: Use the "snps,dw-mshc" binding
v4: Re-use "rockchip,rk2928-dw-mshc" binding
v3: none
v2: none
--- .../devicetree/bindings/clock/altr_socfpga.txt | 11 +++++++++-- arch/arm/boot/dts/socfpga.dtsi | 19 ++++++++++++++++++- arch/arm/boot/dts/socfpga_arria5.dtsi | 12 ++++++++++++ arch/arm/boot/dts/socfpga_cyclone5.dtsi | 12 ++++++++++++ arch/arm/boot/dts/socfpga_vt.dts | 12 ++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/clock/altr_socfpga.txt +9 -2
@@ -11,10 +11,17 @@ Required properties: PLL clock. "altr,socfpga-gate-clk" - Clocks that directly feed peripherals and can get gated. + "altr,socfpga-sdmmc-sdr-clk" - Clock that controls the SD/MMC SDR phase + shift settings for the SD/MMC -- reg : shall be the control register offset from CLOCK_MANAGER's base for the clock. +- reg : shall be one of the following: + * For the "altr,socfpga-sdmmc-sdr-clk" clock, reg will the register + offset that controls the SD/MMC SDR phase shift settings. + * For all of the other clocks, control register offset from + CLOCK_MANAGER's base for the clock. - clocks : shall be the input parent clock phandle for the clock. This is - either an oscillator or a pll output. + either an oscillator or a pll output. This is an optional field for + the "altr,socfpga-sdmmc-sdr-clk" clock. - #clock-cells : from common clock binding, shall be set to 0. Optional properties:
arch/arm/boot/dts/socfpga.dtsi +18 -1
@@ -436,6 +436,12 @@ clocks = <&f2s_periph_ref_clk>, <&main_qspi_clk>, <&per_qspi_clk>; clk-gate = <0xa0 11>; }; + + sdr_mmc_clk: sdr_mmc_clk { + #clock-cells = <0>; + compatible = "altr,socfpga-sdmmc-sdr-clk"; + reg = <0x108>; + }; }; };
@@ -469,6 +475,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>, <&sdr_mmc_clk>; + clock-names = "biu", "ciu", "sdr_mmc_clk"; + }; + /* Local timer */ timer at fffec600 { compatible = "arm,cortex-a9-twd-timer";
@@ -523,7 +540,7 @@ }; sysmgr at ffd08000 { - compatible = "altr,sys-mgr"; + compatible = "altr,sys-mgr", "syscon"; reg = <0xffd08000 0x4000>; }; };
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 v6 4/5 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. Since the Rockchip already has this functionality, re-use the code that is already in dw_mmc-pltfm.c.
---
v6: none
v5: none
v4: Remove dw_mmc-socfpga platform specific code
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 v6 5/5 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.
---
v6: none
v5: Add dw_mmc driver into socfpga_defconfig
v4: none
v3: none
v2: 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