mmc: Add support to Marvell Xenon SD Host Controller
Subsystems (5)
v3 cover mmc: Add support to Marvell Xenon SD Host Controller
Hello,
This the third version of the series adding support for the SDHCI Xenon controller. It can be currently found on the Armada 37xx and the Armada 7K/8K but will be also used in more Marvell SoC (and not only the mvebu ones actually).
I think that now most (if not all) the remarks had been taking into account since the second version. According to Ziji Hu, here are the following changes:
" Changes in V3:
Adjust and improve Xenon DT bindings. Move some caps setting from driver into DT. Use mmc-card sub-node to represent eMMC type.
Remove PHY Sampling Fixed Delay Line scan in lower speed mode. Improve Xenon probe and ->init_card() functions.
Export sdhci_enable_sdio_irq() and implement own SDIO IRQ control. Split PHY patch into two smaller patches.
Temporarily remove AXI clock before its implementation is improved."
Besides this changes I also
- Removed the sdhci-xenon-phy.h and moved its content in the shc-xenon-phy.c file.
- Fixed the tuning-count usage
- Managed the error case for clk_prepare_enable
For the record the change from v1 was:
" Changes in V2:
rebase on v4.9-rc2.
Re-write Xenon bindings. Ajust Xenon DT property naming. Add a new DT property to indicate eMMC card type, instead of using variable card_candidate.
Clear quirks SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12 in Xenon platform data Add support to HS400 retuning."
Thanks,
Gregory
Gregory CLEMENT (3):
arm64: dts: marvell: add eMMC support for Armada 37xx
arm64: dts: marvell: add sdhci support for Armada 7K/8K
arm64: configs: enable SDHCI driver for Xenon
Hu Ziji (9):
mmc: sdhci: Export sdhci_set_ios() from sdhci.c
mmc: sdhci: Export sdhci_start_signal_voltage_switch() in sdhci.c
mmc: sdhci: Export sdhci_execute_tuning() in sdhci.c
mmc: sdhci: Export sdhci_enable_sdio_irq() from sdhci.c
MAINTAINERS: add entry for Marvell Xenon MMC Host Controller drivers
dt: bindings: Add bindings for Marvell Xenon SD Host Controller
mmc: sdhci-xenon: Add Marvell Xenon SDHC core functionality
mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC.
mmc: sdhci-xenon: Add SOC PHY PAD voltage control
Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt | 197 ++- MAINTAINERS | 7 +- arch/arm64/boot/dts/marvell/armada-3720-db.dts | 17 +- arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 11 +- arch/arm64/boot/dts/marvell/armada-7040-db.dts | 7 +- arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 9 +- arch/arm64/configs/defconfig | 1 +- drivers/mmc/host/Kconfig | 9 +- drivers/mmc/host/Makefile | 3 +- drivers/mmc/host/sdhci-xenon-phy.c | 908 +++++++- drivers/mmc/host/sdhci-xenon.c | 616 +++++- drivers/mmc/host/sdhci-xenon.h | 111 +- drivers/mmc/host/sdhci.c | 14 +- drivers/mmc/host/sdhci.h | 5 +- 14 files changed, 1910 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt create mode 100644 drivers/mmc/host/sdhci-xenon-phy.c create mode 100644 drivers/mmc/host/sdhci-xenon.c create mode 100644 drivers/mmc/host/sdhci-xenon.h
base-commit: 9fe68cad6e74967b88d0c6aeca7d9cd6b6e91942
Signature · 1 line
git-series 0.9.1
PATCH v3 1/12 mmc: sdhci: Export sdhci_set_ios() from sdhci.c
From: Hu Ziji <[email protected]>
Export sdhci_set_ios() in sdhci.c.
Thus vendor sdhci driver can implement its own set_ios() routine.
--- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -1563,7 +1563,7 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing) }EXPORT_SYMBOL_GPL (sdhci_set_uhs_signaling); -static void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios) +void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc);unsigned long flags;
@@ -1723,6 +1723,7 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)mmiowb ();spin_unlock_irqrestore (&host->lock, flags); } +EXPORT_SYMBOL_GPL (sdhci_set_ios);static int sdhci_get_cd (struct mmc_host *mmc) {
drivers/mmc/host/sdhci.h +1 -0
@@ -688,6 +688,7 @@ void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,void sdhci_set_bus_width (struct sdhci_host *host,int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing); +void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios);#ifdef CONFIG_PM extern int sdhci_suspend_host (struct sdhci_host *host);
Signature · 1 line
git-series 0.9.1
PATCH v3 2/12 mmc: sdhci: Export sdhci_start_signal_voltage_switch() in sdhci.c
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Export sdhci_start_signal_voltage_switch() from sdhci.c. Thus vendor sdhci driver can implement its own signal voltage switch routine.
--- drivers/mmc/host/sdhci.c | 5 +++-- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +3 -2
@@ -1832,8 +1832,8 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)spin_unlock_irqrestore (&host->lock, flags); } -static int sdhci_start_signal_voltage_switch (struct mmc_host *mmc, -struct mmc_ios *ios) +int sdhci_start_signal_voltage_switch (struct mmc_host *mmc, +struct mmc_ios *ios) {struct sdhci_host *host =mmc_priv (mmc);u16 ctrl;
@@ -1925,6 +1925,7 @@ static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; } } +EXPORT_SYMBOL_GPL (sdhci_start_signal_voltage_switch);static int sdhci_card_busy (struct mmc_host *mmc) {
drivers/mmc/host/sdhci.h +2 -0
@@ -689,6 +689,8 @@ void sdhci_set_bus_width(struct sdhci_host *host, int width);void sdhci_reset (struct sdhci_host *host,u8 mask);void sdhci_set_uhs_signaling (struct sdhci_host *host,unsigned timing);void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios); +int sdhci_start_signal_voltage_switch (struct mmc_host *mmc, +struct mmc_ios *ios);#ifdef CONFIG_PM extern int sdhci_suspend_host (struct sdhci_host *host);
Signature · 1 line
git-series 0.9.1
PATCH v3 3/12 mmc: sdhci: Export sdhci_execute_tuning() in sdhci.c
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Export sdhci_execute_tuning() from sdhci.c.
Thus vendor sdhci driver can execute its own tuning process.
--- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -1950,7 +1950,7 @@ static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)return 0 ; } -static int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode) +int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode) {struct sdhci_host *host =mmc_priv (mmc);u16 ctrl;
@@ -2139,6 +2139,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)spin_unlock_irqrestore (&host->lock, flags);return err; } +EXPORT_SYMBOL_GPL (sdhci_execute_tuning); static int sdhci_select_drive_strength(struct mmc_card *card, unsigned int max_dtr, int host_drv,
drivers/mmc/host/sdhci.h +1 -0
@@ -691,6 +691,7 @@ void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);void sdhci_set_ios (struct mmc_host *mmc,struct mmc_ios *ios);int sdhci_start_signal_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios); +int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode);#ifdef CONFIG_PM extern int sdhci_suspend_host (struct sdhci_host *host);
Signature · 1 line
git-series 0.9.1
PATCH v3 4/12 mmc: sdhci: Export sdhci_enable_sdio_irq() from sdhci.c
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Export sdhci_enable_sdio_irq() from sdhci.c. Thus vendor SDHC driver can implement its specific SDIO irq contorl.
--- drivers/mmc/host/sdhci.c | 3 ++- drivers/mmc/host/sdhci.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -1817,7 +1817,7 @@ static void sdhci_enable_sdio_irq_nolock(struct sdhci_host *host, int enable) } } -static void sdhci_enable_sdio_irq (struct mmc_host *mmc,int enable) +void sdhci_enable_sdio_irq (struct mmc_host *mmc,int enable) {struct sdhci_host *host =mmc_priv (mmc);unsigned long flags;
@@ -1831,6 +1831,7 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)sdhci_enable_sdio_irq_nolock (host, enable);spin_unlock_irqrestore (&host->lock, flags); } +EXPORT_SYMBOL_GPL (sdhci_enable_sdio_irq);int sdhci_start_signal_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios)
drivers/mmc/host/sdhci.h +1 -0
@@ -692,6 +692,7 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);int sdhci_start_signal_voltage_switch (struct mmc_host *mmc,struct mmc_ios *ios);int sdhci_execute_tuning (struct mmc_host *mmc,u32 opcode); +void sdhci_enable_sdio_irq (struct mmc_host *mmc,int enable);#ifdef CONFIG_PM extern int sdhci_suspend_host (struct sdhci_host *host);
Signature · 1 line
git-series 0.9.1
PATCH v3 5/12 MAINTAINERS: add entry for Marvell Xenon MMC Host Controller drivers
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Add maintainer entry for Marvell Xenon eMMC/SD/SDIO Host Controller drivers.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -7604,6 +7604,11 @@ M: Nicolas Pitre <[email protected]> S: Odd Fixes F: drivers/mmc/host/mvsdio.* +MARVELL XENON MMC/SD/SDIO HOST CONTROLLER DRIVER +M: Ziji Hu <[email protected]> +L: linux-mmc at vger.kernel.org +S: Supported + MATROX FRAMEBUFFER DRIVER L: linux-fbdev at vger.kernel.org S: Orphan
Signature · 1 line
git-series 0.9.1
PATCH v3 6/12 dt: bindings: Add bindings for Marvell Xenon SD Host Controller
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Marvell Xenon SDHC can support eMMC/SD/SDIO.
Add Xenon-specific properties.
Also add properties for Xenon PHY setting.
--- Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt | 197 +++++++- MAINTAINERS | 1 +- 2 files changed, 198 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt
Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt new file +197 -0
@@ -0,0 +1,197 @@ +Marvell Xenon SDHCI Controller device tree bindings +This file documents differences between the core mmc properties +described by mmc.txt and the properties used by the Xenon implementation. + +Multiple SDHCs might be put into a single Xenon IP, to save size and cost. +Each SDHC is independent and owns independent resources, such as register sets, +clock and PHY. +Each SDHC should have an independent device tree node. + +Required Properties: +- compatible: should be one of the following + - "marvell,armada-3700-sdhci": For controllers on Armada-3700 SOC. + Must provide a second register area and marvell,pad-type. + - "marvell,armada-7000-sdhci": For controllers on Armada 7K/8K SOC. + +- clocks: + Array of clocks required for SDHC. + Require at least input clock for Xenon IP core. + +- clock-names: + Array of names corresponding to clocks property. + The input clock for Xenon IP core should be named as "core". + +- reg: + * For "marvell,armada-3700-sdhci", two register areas. + The first one for Xenon IP register. The second one for the Armada 3700 SOC + PHY PAD Voltage Control register. + Please follow the examples with compatible "marvell,armada-3700-sdhci" + in below. + Please also check property marvell,pad-type in below. + + * For other compatible strings, one register area for Xenon IP. + +Optional Properties: +- mmc-card: + mmc-card child node must be provided when current SDHC is for eMMC. + Xenon SDHC often can support both SD and eMMC. This child node indicates that + current SDHC is for eMMC card. Thus Xenon eMMC specific configuration and + operations can be enabled prior to eMMC init sequence. + Please refer to Documentation/devicetree/bindings/mmc/mmc-card.txt. + This child node should not be set if current Xenon SDHC is for SD/SDIO. + +- bus-width: + When 8-bit data bus width is in use for eMMC, this property should be + explicitly provided and set as 8. + It is optional when data bus width is 4-bit or 1-bit. + +- mmc-ddr-1_8v: + Select this property when eMMC HS DDR is supported on SDHC side. + +- mmc-hs400-1_8v: + Select this property when eMMC HS400 is supported on SDHC side. + +- no-1-8-v: + Select this property when 1.8V signaling voltage supply is unavailable. + When this property is enabled, both mmc-ddr-1_8v and mmc-hs400-1_8v should be + cleared. + +- marvell,xenon-sdhc-id: + Indicate the corresponding bit index of current SDHC in + SDHC System Operation Control Register Bit[7:0]. + Set/clear the corresponding bit to enable/disable current SDHC. + If Xenon IP contains only one SDHC, this property is optional. + +- marvell,xenon-phy-type: + Xenon support mutilple types of PHYs. + To select eMMC 5.1 PHY, set: + marvell,xenon-phy-type = "emmc 5.1 phy" + eMMC 5.1 PHY is the default choice if this property is not provided. + To select eMMC 5.0 PHY, set: + marvell,xenon-phy-type = "emmc 5.0 phy" + + All those types of PHYs can support eMMC, SD and SDIO. + Please note that this property only presents the type of PHY. + It doesn't stand for the entire SDHC type or property. + For example, "emmc 5.1 phy" doesn't mean that this Xenon SDHC only supports + eMMC 5.1. + +- marvell,xenon-phy-znr: + Set PHY ZNR value. + Only available for eMMC PHY 5.1 and eMMC PHY 5.0. + Valid range = [0:0x1F]. + ZNR is set as 0xF by default if this property is not provided. + +- marvell,xenon-phy-zpr: + Set PHY ZPR value. + Only available for eMMC PHY 5.1 and eMMC PHY 5.0. + Valid range = [0:0x1F]. + ZPR is set as 0xF by default if this property is not provided. + +- marvell,xenon-phy-nr-success-tun: + Set the number of required consecutive successful sampling points used to + identify a valid sampling window, in tuning process. + Valid range = [1:7]. + Set as 0x4 by default if this property is not provided. + +- marvell,xenon-phy-tun-step-divider: + Set the divider for calculating TUN_STEP. + Set as 64 by default if this property is not provided. + +- marvell,xenon-phy-slow-mode: + If this property is selected, transfers will bypass PHY. + Only available when bus frequency lower than 55MHz in SDR mde. + Disabled by default. Please only try this property if timing issues always + occur with PHY enabled in eMMC HS SDR, SD SDR12, SD SDR25, SD SDR50 mode. + +- marvell,xenon-tun-count: + Xenon SDHC SOC usually doesn't provide re-tuning counter in + Capabilities Register 3 Bit[11:8]. + This property provides the re-tuning counter. + If this property is not set, default re-tuning counter will + be set as 0x9 in driver. + +- marvell,pad-type: + Type of Armada 3700 SOC PHY PAD Voltage Controller register. + Only valid when "marvell,armada-3700-sdhci" is selected. + Two types: "sd" and "fixed-1-8v". + If "sd" is slected, SOC PHY PAD is set as 3.3V at the beginning and is + switched to 1.8V when SD in UHS-I. + If "fixed-1-8v" is slected, SOC PHY PAD is fixed 1.8V, such as for eMMC. + Please follow the examples with compatible "marvell,armada-3700-sdhci" + in below. + +Example: +- For eMMC: + + sdhci at aa0000 { + compatible = "marvell,armada-7000-sdhci"; + reg = <0xaa0000 0x1000>; + interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH> + clocks = <&emmc_clk>; + clock-names = "core"; + bus-width = <8>; + mmc-ddr-1_8v; + mmc-hs400-1_8v; + marvell,xenon-sdhc-id = <0>; + marvell,xenon-phy-type = "emmc 5.1 phy"; + marvell,xenon-tun-count = <11>; + + #address-cells = <1>; + #size-cells = <0>; + mmccard: mmccard at 0 { + compatible = "mmc-card"; + reg = <0>; + }; + }; + +- For SD/SDIO: + + sdhci at ab0000 { + compatible = "marvell,armada-7000-sdhci"; + reg = <0xab0000 0x1000>; + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH> + vqmmc-supply = <&sd_regulator>; + clocks = <&sdclk>; + clock-names = "core"; + bus-width = <4>; + marvell,xenon-tun-count = <9>; + }; + +- For eMMC with compatible "marvell,armada-3700-sdhci": + + sdhci at aa0000 { + compatible = "marvell,armada-3700-sdhci"; + reg = <0xaa0000 0x1000>, + <phy_addr 0x4>; + interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH> + clocks = <&emmcclk>; + clock-names = "core"; + bus-width = <8>; + mmc-ddr-1_8v; + mmc-hs400-1_8v; + + marvell,pad-type = "fixed-1-8v"; + + #address-cells = <1>; + #size-cells = <0>; + mmccard: mmccard at 0 { + compatible = "mmc-card"; + reg = <0>; + }; + }; + +- For SD/SDIO with compatible "marvell,armada-3700-sdhci": + + sdhci at ab0000 { + compatible = "marvell,armada-3700-sdhci"; + reg = <0xab0000 0x1000>, + <phy_addr 0x4>; + interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH> + vqmmc-supply = <&sd_regulator>; + clocks = <&sdclk>; + clock-names = "core"; + bus-width = <4>; + + marvell,pad-type = "sd"; + };
MAINTAINERS +1 -0
@@ -7608,6 +7608,7 @@ MARVELL XENON MMC/SD/SDIO HOST CONTROLLER DRIVER M: Ziji Hu <[email protected]> L: linux-mmc at vger.kernel.org S: Supported +F: Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt MATROX FRAMEBUFFER DRIVER L: linux-fbdev at vger.kernel.org
Signature · 1 line
git-series 0.9.1
PATCH v3 7/12 mmc: sdhci-xenon: Add Marvell Xenon SDHC core functionality
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Add Xenon eMMC/SD/SDIO host controller core functionality. Add Xenon specific intialization process.
Add Xenon specific mmc_host_ops APIs.
Add Xenon specific register definitions.
Add CONFIG_MMC_SDHCI_XENON support in drivers/mmc/host/Kconfig.
Marvell Xenon SDHC conforms to SD Physical Layer Specification Version 3.01 and is designed according to the guidelines provided in the SD Host Controller Standard Specification Version 3.00.
--- MAINTAINERS | 1 +- drivers/mmc/host/Kconfig | 9 +- drivers/mmc/host/Makefile | 3 +- drivers/mmc/host/sdhci-xenon.c | 613 ++++++++++++++++++++++++++++++++++- drivers/mmc/host/sdhci-xenon.h | 70 ++++- 5 files changed, 696 insertions(+) create mode 100644 drivers/mmc/host/sdhci-xenon.c create mode 100644 drivers/mmc/host/sdhci-xenon.h
MAINTAINERS +1 -0
@@ -7608,6 +7608,7 @@ MARVELL XENON MMC/SD/SDIO HOST CONTROLLER DRIVER M: Ziji Hu <[email protected]> L: linux-mmc at vger.kernel.org S: Supported +F: drivers/mmc/host/sdhci-xenon* F: Documentation/devicetree/bindings/mmc/marvell,xenon-sdhci.txt MATROX FRAMEBUFFER DRIVER
drivers/mmc/host/Kconfig +9 -0
@@ -798,3 +798,12 @@ config MMC_SDHCI_BRCMSTB Broadcom STB SoCs. If unsure, say Y. + +config MMC_SDHCI_XENON + tristate "Marvell Xenon eMMC/SD/SDIO SDHCI driver" + depends on MMC_SDHCI && MMC_SDHCI_PLTFM + help + This selects Marvell Xenon eMMC/SD/SDIO SDHCI. + If you have a machine with integrated Marvell Xenon SDHC IP, + say Y or M here. + If unsure, say N.
drivers/mmc/host/Makefile +3 -0
@@ -80,3 +80,6 @@ obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o ifeq ($(CONFIG_CB710_DEBUG),y) CFLAGS-cb710-mmc += -DDEBUG endif + +obj-$(CONFIG_MMC_SDHCI_XENON) += sdhci-xenon-driver.o +sdhci-xenon-driver-y += sdhci-xenon.o
drivers/mmc/host/sdhci-xenon.c new file +613 -0
613 lines not on this page · raw message
drivers/mmc/host/sdhci-xenon.h new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
git-series 0.9.1
PATCH v3 8/12 mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC.
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Marvell Xenon eMMC/SD/SDIO Host Controller contains PHY. Multiple types of PHYs are supported.
Add support to multiple types of PHYs init and configuration. Add register definitions of PHYs.
Xenon PHY cannot fit in kernel common PHY framework. Xenon SDHC PHY register is a part of Xenon SDHC register set. Besides, MMC initialization has to call several PHY functions to complete timing setting.
Those PHY setting functions have to access SDHC registers and know current MMC setting, such as bus width, clock frequency and speed mode.
As a result, implement Xenon PHY in MMC host directory.
--- drivers/mmc/host/Makefile | 2 +- drivers/mmc/host/sdhci-xenon-phy.c | 799 ++++++++++++++++++++++++++++++- drivers/mmc/host/sdhci-xenon.c | 3 +- drivers/mmc/host/sdhci-xenon.h | 39 +- 4 files changed, 841 insertions(+), 2 deletions(-) create mode 100644 drivers/mmc/host/sdhci-xenon-phy.c
drivers/mmc/host/Makefile +1 -1
@@ -82,4 +82,4 @@ ifeq ($(CONFIG_CB710_DEBUG),y) endif obj-$(CONFIG_MMC_SDHCI_XENON) += sdhci-xenon-driver.o -sdhci-xenon-driver-y += sdhci-xenon.o +sdhci-xenon-driver-y += sdhci-xenon.o sdhci-xenon-phy.o
drivers/mmc/host/sdhci-xenon-phy.c new file +799 -0
799 lines not on this page · raw message
drivers/mmc/host/sdhci-xenon.c +2 -1
@@ -244,6 +244,7 @@ static void xenon_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)spin_unlock_irqrestore (&host->lock, flags);sdhci_set_ios (mmc, ios); +xenon_phy_adj (host, ios);if (host->clock >SDHCI_DEFAULT_SDCLK_FREQ ) {spin_lock_irqsave (&host->lock, flags);
@@ -482,7 +483,7 @@ static int xenon_probe_dt(struct platform_device *pdev) } priv->tuning_count = tuning_count; -return err; +return xenon_phy_parse_dt (np, host); }static int xenon_sdhc_probe (struct sdhci_host *host)
drivers/mmc/host/sdhci-xenon.h +39 -0
@@ -23,8 +23,19 @@#define SDHCI_SLOT_ENABLE_SHIFT 0#define SDHCI_SYS_EXT_OP_CTRL 0x010C +#define SDHCI_MASK_CMD_CONFLICT_ERROR BIT(8) + +#define SDHCI_SLOT_OP_STATUS_CTRL 0x0128 + +#define SDHCI_TUN_CONSECUTIVE_TIMES_SHIFT 16 +#define SDHCI_TUN_CONSECUTIVE_TIMES_MASK 0x7 +#define SDHCI_TUN_CONSECUTIVE_TIMES 0x4 +#define SDHCI_TUNING_STEP_SHIFT 12 +#define SDHCI_TUNING_STEP_MASK 0xF +#define SDHCI_TUNING_STEP_DIVIDER BIT(6)#define SDHCI_SLOT_EMMC_CTRL 0x0130 +#define SDHCI_ENABLE_DATA_STROBE BIT(24)#define SDHCI_EMMC_VCCQ_MASK 0x3#define SDHCI_EMMC_VCCQ_1_8V 0x1#define SDHCI_EMMC_VCCQ_3_3V 0x3
@@ -33,11 +44,17 @@/* retuning compatible */ #define SDHCI_RETUNING_COMPATIBLE 0x1 +#define SDHCI_SLOT_EXT_PRESENT_STATE 0x014C +#define SDHCI_DLL_LOCK_STATE 0x1 + +#define SDHCI_SLOT_DLL_CUR_DLY_VAL 0x0150 +/* Tuning Parameter */ #define SDHCI_TMR_RETUN_NO_PRESENT 0xF#define SDHCI_DEF_TUNING_COUNT 0x9#define SDHCI_DEFAULT_SDCLK_FREQ (400000) +#define SDHCI_LOWEST_SDCLK_FREQ (100000)/* Xenon specific Mode Select value */ #define SDHCI_XENON_CTRL_HS200 0x5
@@ -65,6 +82,28 @@ struct sdhci_xenon_priv {* initialization completes. */ unsigned int init_card_type; + +/* +* The bus_width, timing, and clock fields in below +* record the current ios setting of Xenon SDHC. +* Driver will adjust PHY setting if any change to +* ios affects PHY timing. +*/ +unsigned char bus_width; +unsigned char timing; +unsigned int clock; + +int phy_type; +/* +* Contains board-specific PHY parameters +* passed from device tree. +*/ +void *phy_params; + struct xenon_emmc_phy_regs *emmc_phy_regs; }; + +int xenon_phy_adj (struct sdhci_host *host,struct mmc_ios *ios); +int xenon_phy_parse_dt (struct device_node *np, +struct sdhci_host *host);#endif
Signature · 1 line
git-series 0.9.1
kbuild test robot
build bot[PATCH v3 08/12] mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC.
url: https://github.com/0day-ci/linux/commits/Gregory-CLEMENT/mmc-Add-support-to-Marvell-Xenon-SD-Host-Controller/20161210-002602 base:
Hi Hu,
[auto build test WARNING on ]
coccinelle warnings: (new ones prefixed by >>)
>> drivers/mmc/host/sdhci-xenon-phy.c:469:9-10: WARNING: return of 0/1 in function 'emmc_phy_slow_mode' with return type bool
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build bot[PATCH] mmc: sdhci-xenon: fix boolreturn.cocci warnings
In reply to Gregory CLEMENTdrivers/mmc/host/sdhci-xenon-phy.c:469:9-10: WARNING: return of 0/1 in function 'emmc_phy_slow_mode' with return type bool
drivers/mmc/host/sdhci-xenon-phy.c:469:9-10: WARNING: return of 0/1 in function 'emmc_phy_slow_mode' with return type bool
Return statements in functions returning bool should use true/false instead of 1/0.
Generated by: scripts/coccinelle/misc/boolreturn.cocci
---
sdhci-xenon-phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-xenon-phy.c +2 -2
@@ -466,11 +466,11 @@ static bool emmc_phy_slow_mode(struct sd/* Skip temp stages from HS200 to HS400 */ if (temp_stage_hs200_to_hs400 (host, priv)) -return 0 ; +return false;/* Skip temp stages from HS400 t0 HS200 */ if (temp_stage_hs400_to_h200 (host, priv)) -return 0 ; +return false; reg =sdhci_readl (host, phy_regs->timing_adj);/* Enable Slow Mode for SDIO in slower SDR mode */
PATCH v3 9/12 mmc: sdhci-xenon: Add SOC PHY PAD voltage control
In reply to Gregory CLEMENTFrom: Hu Ziji <[email protected]>
Some SOCs have PHY PAD outside Xenon IP.
PHY PAD voltage should match signalling voltage in use.
Add generic SOC PHY PAD voltage control interface. Implement Aramda-3700 SOC PHY PAD voltage control.
--- drivers/mmc/host/sdhci-xenon-phy.c | 111 +++++++++++++++++++++++++++++- drivers/mmc/host/sdhci-xenon.c | 2 +- drivers/mmc/host/sdhci-xenon.h | 2 +- 3 files changed, 114 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-xenon-phy.c +110 -1
@@ -148,6 +148,22 @@ enum phy_type_enum {NR_PHY_TYPES }; +struct soc_pad_ctrl_table { +const char *soc; +void (*set_soc_pad)(struct sdhci_host *host, +unsigned char signal_voltage); +}; + +struct soc_pad_ctrl { +/* Register address of SOC PHY PAD ctrl */ +void __iomem *reg; +/* SOC PHY PAD ctrl type */ +enum soc_pad_ctrl_type pad_type; +/* SOC specific operation to set SOC PHY PAD */ +void (*set_soc_pad)(struct sdhci_host *host, +unsigned char signal_voltage); +}; +static struct xenon_emmc_phy_regs xenon_emmc_5_0_phy_regs = { .timing_adj =SDHCI_EMMC_5_0_PHY_TIMING_ADJUST , .func_ctrl =SDHCI_EMMC_5_0_PHY_FUNC_CONTROL ,
@@ -181,6 +197,8 @@ struct emmc_phy_params {u8 nr_tun_times;/* Divider for calculating Tuning Step */ u8 tun_step_divider; + +struct soc_pad_ctrl pad_ctrl; };static int alloc_emmc_phy (struct sdhci_xenon_priv *priv)
@@ -257,6 +275,45 @@ static int emmc_phy_init(struct sdhci_host *host)return 0 ; } +#define ARMADA_3700_SOC_PAD_1_8V 0x1 +#define ARMADA_3700_SOC_PAD_3_3V 0x0 + +static void armada_3700_soc_pad_voltage_set (struct sdhci_host *host, +unsigned char signal_voltage) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); +struct emmc_phy_params *params = priv->phy_params; + +if (params->pad_ctrl.pad_type ==SOC_PAD_FIXED_1_8V ) { +writel (ARMADA_3700_SOC_PAD_1_8V , params->pad_ctrl.reg); + }else if (params->pad_ctrl.pad_type ==SOC_PAD_SD ) { +if (signal_voltage ==MMC_SIGNAL_VOLTAGE_180 ) +writel (ARMADA_3700_SOC_PAD_1_8V , params->pad_ctrl.reg); +else if (signal_voltage ==MMC_SIGNAL_VOLTAGE_330 ) +writel (ARMADA_3700_SOC_PAD_3_3V , params->pad_ctrl.reg); + } +} + +/* +* Set SOC PHY voltage PAD control register, +* according to the operation voltage on PAD. +* The detailed operation depends on SOC implementaion. +*/ +static void emmc_phy_set_soc_pad (struct sdhci_host *host, +unsigned char signal_voltage) +{ +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct sdhci_xenon_priv *priv =sdhci_pltfm_priv (pltfm_host); +struct emmc_phy_params *params = priv->phy_params; + +if (!params->pad_ctrl.reg) +return ; + +if (params->pad_ctrl.set_soc_pad) + params->pad_ctrl.set_soc_pad (host, signal_voltage); +} +/* * Enable eMMC PHY HW DLL * DLL should be enabled and stable before HS200/SDR104 tuning,
@@ -630,6 +687,51 @@ static void emmc_phy_set(struct sdhci_host *host,dev_dbg (mmc_dev (host->mmc),"eMMC PHY setting completes\n" ); } +static int get_dt_pad_ctrl_data (struct sdhci_host *host, +struct device_node *np, +struct emmc_phy_params *params) +{ +int ret =0 ; +const char *name; +struct resource iomem; + +if (of_device_is_compatible (np,"marvell,armada-3700-sdhci" )) + params->pad_ctrl.set_soc_pad = armada_3700_soc_pad_voltage_set; +else +return 0 ; + +if (of_address_to_resource (np,1 , &iomem)) { +dev_err (mmc_dev (host->mmc),"Unable to find SOC PAD ctrl register address for %s\n" , + np->name); +return -EINVAL ; + } + + params->pad_ctrl.reg =devm_ioremap_resource (mmc_dev (host->mmc), + &iomem); +if (IS_ERR (params->pad_ctrl.reg)) { +dev_err (mmc_dev (host->mmc),"Unable to get SOC PHY PAD ctrl regiser for %s\n" , + np->name); +return PTR_ERR (params->pad_ctrl.reg); + } + + ret =of_property_read_string (np,"marvell,pad-type" , &name); +if (ret) { +dev_err (mmc_dev (host->mmc),"Unable to determine SOC PHY PAD ctrl type\n" ); +return ret; + } +if (!strcmp (name,"sd" )) { + params->pad_ctrl.pad_type =SOC_PAD_SD ; + }else if (!strcmp (name,"fixed-1-8v" )) { + params->pad_ctrl.pad_type =SOC_PAD_FIXED_1_8V ; + }else { +dev_err (mmc_dev (host->mmc),"Unsupported SOC PHY PAD ctrl type %s\n" , + name); +return -EINVAL ; + } + +return ret; +} +static int emmc_phy_parse_param_dt (struct sdhci_host *host,struct device_node *np,struct emmc_phy_params *params)
@@ -663,7 +765,14 @@ static int emmc_phy_parse_param_dt(struct sdhci_host *host,else params->tun_step_divider =SDHCI_TUNING_STEP_DIVIDER ; -return 0 ; +return get_dt_pad_ctrl_data (host, np, params); +} + +/* Set SOC PHY Voltage PAD */ +void xenon_soc_pad_ctrl (struct sdhci_host *host, +unsigned char signal_voltage) +{ +emmc_phy_set_soc_pad (host, signal_voltage); }/*
drivers/mmc/host/sdhci-xenon.c +2 -0
@@ -322,6 +322,8 @@ static int xenon_start_signal_voltage_switch(struct mmc_host *mmc,*/ enable_xenon_internal_clk (host); +xenon_soc_pad_ctrl (host, ios->signal_voltage); +if (priv->init_card_type ==MMC_TYPE_MMC )return xenon_emmc_signal_voltage_switch (mmc, ios);
drivers/mmc/host/sdhci-xenon.h +2 -0
@@ -106,4 +106,6 @@ struct sdhci_xenon_priv {int xenon_phy_adj (struct sdhci_host *host,struct mmc_ios *ios);int xenon_phy_parse_dt (struct device_node *np,struct sdhci_host *host); +void xenon_soc_pad_ctrl (struct sdhci_host *host, +unsigned char signal_voltage);#endif
Signature · 1 line
git-series 0.9.1
PATCH v3 10/12 arm64: dts: marvell: add eMMC support for Armada 37xx
In reply to Gregory CLEMENTAdd the eMMC support for Armada 37xx SoC and enable it in the Armada 3720 DB board.
--- arch/arm64/boot/dts/marvell/armada-3720-db.dts | 17 +++++++++++++++++ arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 11 +++++++++++ 2 files changed, 28 insertions(+)
arch/arm64/boot/dts/marvell/armada-3720-db.dts +17 -0
@@ -72,6 +72,23 @@ status = "okay"; }; +&sdhci0 { + non-removable; + bus-width = <8>; + mmc-ddr-1_8v; + mmc-hs400-1_8v; + marvell,xenon-emmc; + marvell,pad-type = "fixed-1-8v"; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + mmccard: mmccard at 0 { + compatible = "mmc-card"; + reg = <0>; + }; +}; + /* CON31 */ &usb3 { status = "okay";
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +11 -0
@@ -161,6 +161,17 @@ }; }; + sdhci0: sdhci at d8000 { + compatible = "marvell,armada-3700-sdhci", + "marvell,sdhci-xenon"; + reg = <0xd8000 0x300 + 0x17808 0x4>; + interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&nb_perih_clk 0>; + clock-names = "core"; + status = "disabled"; + }; + sata: sata at e0000 { compatible = "marvell,armada-3700-ahci"; reg = <0xe0000 0x2000>;
Signature · 1 line
git-series 0.9.1
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
In reply to Gregory CLEMENTAlso enable it on the Armada 7040 DB board
--- arch/arm64/boot/dts/marvell/armada-7040-db.dts | 7 +++++++ arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 9 +++++++++ 2 files changed, 16 insertions(+)
arch/arm64/boot/dts/marvell/armada-7040-db.dts +7 -0
@@ -146,3 +146,10 @@ &cpm_usb3_1 { status = "okay"; }; + +&sdhci0 { + status = "okay"; + bus-width = <4>; + no-1-8-v; + non-removable; +};
arch/arm64/boot/dts/marvell/armada-ap806.dtsi +9 -0
@@ -229,6 +229,15 @@ }; + sdhci0: sdhci at 6e0000 { + compatible = "marvell,armada-7000-sdhci"; + reg = <0x6e0000 0x300>; + interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; + clock-names = "core"; + clocks = <&cpm_syscon0 1 4>; + status = "disabled"; + }; + ap_syscon: system-controller at 6f4000 { compatible = "marvell,ap806-system-controller", "syscon";
Signature · 1 line
git-series 0.9.1
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
Quoted 3 lines · Gregory CLEMENT
Also enable it on the Armada 7040 DB board
Signed-off-by Gregory CLEMENT <[email protected]>
Hi,
Can this also be added to the cp110 on the 7k/8k SoCs as well, or does it rely on other unmerged support?
Thanks.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
Hi Russell King,
Quoted 9 lines · Russell King - ARM Linux
Quoted 3 lines · Gregory CLEMENT
Also enable it on the Armada 7040 DB board
Signed-off-by Gregory CLEMENT <[email protected]>Hi,
Can this also be added to the cp110 on the 7k/8k SoCs as well, or does it rely on other unmerged support?
I did not add this one because until now I had not the hardware setup available to test it.
But at least I can add the ressources in the device tree and now I can test it partially.
Gregory
Quoted 7 lines
Thanks.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Signature · 4 lines
Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
Quoted 11 lines · Gregory CLEMENT
Hi Russell King,
Quoted 7 lines · Russell King - ARM Linux
Quoted 3 lines · Gregory CLEMENT
Also enable it on the Armada 7040 DB board
Signed-off-by Gregory CLEMENT <[email protected]>Hi,
Quoted 8 lines
Quoted 2 lines
Can this also be added to the cp110 on the 7k/8k SoCs as well, or does it rely on other unmerged support?
I did not add this one because until now I had not the hardware setup available to test it.
But at least I can add the ressources in the device tree and now I can test it partially.
There's another option: add the DT resources in a separate patch, send it out for someone else to test. When it comes back with a tested-by, then it can be included along with the rest of the patch set.
I'd send something, but I don't know what the GIC interrupt number would be without using the CP110's ICU (which isn't supported in mainline yet.) I've already tested your previous patch set (along with ICU support + needed DT bits) on the SR Macchiatobin board... it seems to work fine.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
Hello,
Quoted 3 lines · Russell King - ARM Linux
I'd send something, but I don't know what the GIC interrupt number would be without using the CP110's ICU (which isn't supported in mainline yet.)
For now, mainline relies on a static mapping of CP interrupts to GIC interrupts, via an ICU configuration done in ATF. It's pretty straightforward to figure out the CP interrupts to GIC interrupt mapping if you have access to the ATF source code. If you don't, I can provide the necessary details.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v3 11/12 arm64: dts: marvell: add sdhci support for Armada 7K/8K
In reply to Russell King - ARM LinuxHi Gregory,
2016-12-12 20:16 GMT+01:00 Russell King - ARM Linux <[email protected]>:
Quoted 18 lines · Gregory CLEMENT
Quoted 17 lines
Hi Russell King,
Quoted 9 lines · Russell King - ARM Linux
Quoted 3 lines · Gregory CLEMENT
Also enable it on the Armada 7040 DB board
Signed-off-by Gregory CLEMENT <[email protected]>Hi,
Can this also be added to the cp110 on the 7k/8k SoCs as well, or does it rely on other unmerged support?
I did not add this one because until now I had not the hardware setup available to test it.
Quoted 6 lines
Quoted 2 lines
But at least I can add the ressources in the device tree and now I can test it partially.
There's another option: add the DT resources in a separate patch, send it out for someone else to test. When it comes back with a tested-by, then it can be included along with the rest of the patch set.
I work on A7040-DB with SD slot from AP and CP eMMC. If you have the board, you can use eMMC module from A3720-DB and plug it to CON11. Some small soldering may be required. Anyway, you can also just let me test it:)
Best regards,
Marcin
PATCH v3 12/12 arm64: configs: enable SDHCI driver for Xenon
In reply to Gregory CLEMENTThis patch enables the driver for the SDHCI controller found on the Marvell Armada 3700 and 7K/8K ARM64 SoCs.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -353,6 +353,7 @@ CONFIG_MMC_DW=y CONFIG_MMC_DW_EXYNOS=y CONFIG_MMC_DW_K3=y CONFIG_MMC_SUNXI=y +CONFIG_MMC_SDHCI_XENON=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y CONFIG_LEDS_GPIO=y
Signature · 1 line
git-series 0.9.1