mmc: sdhci-msm: Add support for MSM chipsets
Subsystems (4)
v7 cover mmc: sdhci-msm: Add support for MSM chipsets
This patchset adds basic support of the Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Tested with SD card on APQ8074 Dragonboard.
Patchset applies to mmc-next, as it depends on:
4525181 mmc: sdhci: add hooks for platform specific tuning
Changes from v6:
- Fixed wrong pointer in sdhci_msm_pwr_irq().
- Added platform_execute_tuning() callback as the MSM SDHC does not support tuning as in SDHC 3.0 spec and will need custom implementation in order to support SDR104, HS200 and HS400.
- Removed the always-on devicetree property - if the regulator is configured as always-on, it will not be disabled anyway.
- Removed devm_pinctrl_get_select_default() - the default pins are already set from the device core.
- Removed wrapper function sdhci_msm_set_vdd_io_vol() and enum vdd_io_level and now calling regulator_set_voltage() directly.
- Converted #defines to use BIT() macro.
- Added IS_ERR(vreg->reg) check at the beginning of sdhci_msm_vreg functions.
- Do not print errors when regulators init return -EPROBE_DEFER as the deffered init is not an actual error.
- Handle each power irq status bit separately in sdhci_msm_pwr_irq().
- Ensure that any pending power irq is acknowledged before enabling it, otherwise the irq handler will be fired prematurely.
- Minor changes.
Changes from v5:
- Driver is split into multiple patches
- Do not initialize variables that are assigned later in code
- Remove some useless comments
- Use shorter variable names
- Change pr_err() to dev_err()
- Optimized sdhci_msm_setup_vreg()
- Some code alignment fixes
- Improved DT values sanity check
- Added dev_dbg print for sdhci controller version in probe()
- Added usleep_range() after SW reset - it can take some time
- Added SDHCI_QUIRK_SINGLE_POWER_WRITE - power handled by PMIC
- Renamed DT property vdd-io to vddio
Changes from v4:
- Simplified sdhci_msm_vreg_disable() and sdhci_msm_set_vdd_io_vol()
- Use devm_ioremap_resource() instead of devm_ioremap()
- Converted IS_ERR_OR_NULL to IS_ERR
- Disable regulators in sdhci_msm_remove()
- Check for DT node at the beginning in sdhci_msm_probe()
- Removed more redundant code
- Changes in some error messages
- Minor fixes
Changes from v3:
- Allocate memory for all required structs at once
- Added termination entry in sdhci_msm_dt_match[]
- Fixed a missing sdhci_pltfm_free() in probe()
- Removed redundant of_match_ptr
- Removed the unneeded function sdhci_msm_vreg_reset()
Changes from v2:
- Added DT bindings for clocks
- Moved voltage regulators data to platform data
- Removed unneeded includes
- Removed obsolete and wrapper functions
- Removed error checking where unnecessary
- Removed redundant _clk suffix from clock names
- Just return instead of goto where possible
- Minor fixes
Changes from v1:
- GPIO references are replaced by pinctrl
- DT parsing is done mostly by mmc_of_parse()
- Use of_match_device() for DT matching
- A few minor changes
Georgi Djakov (2):
mmc: sdhci-msm: Initial SDHCI MSM driver documentation
mmc: sdhci-msm: Initial support for MSM chipsets
.../devicetree/bindings/mmc/sdhci-msm.txt | 93 +++ drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-msm.c | 655 ++++++++++++++++++++ 4 files changed, 762 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-msm.txt create mode 100644 drivers/mmc/host/sdhci-msm.c
Signature · 1 line
1.7.9.5
PATCH v7 1/2 mmc: sdhci-msm: Initial SDHCI MSM driver documentation
This patch adds documentation for Qualcomm SDHCI MSM driver. It contains the differences between the core properties in mmc.txt and the properties used by the sdhci-msm driver.
--- .../devicetree/bindings/mmc/sdhci-msm.txt | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-msm.txt
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +92 -0
@@ -0,0 +1,92 @@ +* Qualcomm SDHCI controller (sdhci-msm) + +This file documents differences between the core properties in mmc.txt +and the properties used by the sdhci-msm driver. + +Required properties: +- compatible: should contain "qcom,sdhci-msm" +- reg: should contain SDHC, SD Core register map +- reg-names: indicates various resources passed to driver (via reg proptery) by name + "reg-names" examples are "hc_mem" and "core_mem" +- interrupts: should contain SDHC interrupts +- interrupt-names: indicates interrupts passed to driver (via interrupts property) by name + "interrupt-names" examples are "hc_irq" and "pwr_irq" +- vdd-supply: phandle to the regulator for the vdd (flash core voltage) supply. +- vddio-supply: phandle to the regulator for the vdd-io (i/o voltage) supply. +- pinctrl-names: Should contain only one value - "default". +- pinctrl-0: Should specify pin control groups used for this controller. +- clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names +- clock-names: Should contain the following: + "iface" - Main peripheral bus clock (PCLK/HCLK - AHB Bus clock) (required) + "core" - SDC MMC clock (MCLK) (required) + "bus" - SDCC bus voter clock (optional) + +Optional properties: +- qcom,bus-speed-mode: specifies the supported bus speed modes by host + The supported bus speed modes are: + "HS200_1p8v" - indicates that host can support HS200 at 1.8v + "HS200_1p2v" - indicates that host can support HS200 at 1.2v + "DDR_1p8v" - indicates that host can support DDR mode at 1.8v + "DDR_1p2v" - indicates that host can support DDR mode at 1.2v + +- qcom,{vdd,vdd-io}-lpm-sup - specifies whether the supply can be kept in low power mode. +- qcom,{vdd,vdd-io}-voltage-level - specifies voltage levels for the supply. + Should be specified in pairs (min, max), units uV. +- qcom,{vdd,vdd-io}-current-level - specifies load levels for the supply in lpm + or high power mode (hpm). Should be specified in pairs (lpm, hpm), units uA. + +Example: + + aliases { + sdhc1 = &sdhc_1; + sdhc2 = &sdhc_2; + }; + + sdhc_1: qcom,sdhc@f9824900 { + compatible = "qcom,sdhci-msm"; + reg = <0xf9824900 0x11c>, <0xf9824000 0x800>; + reg-names = "hc_mem", "core_mem"; + interrupts = <0 123 0>, <0 138 0>; + interrupt-names = "hc_irq", "pwr_irq"; + bus-width = <8>; + non-removable; + + vdd-supply = <&pm8941_l20>; + qcom,vdd-io-lpm-sup; + qcom,vdd-voltage-level = <2950000 2950000>; + qcom,vdd-current-level = <800 500000>; + + vdd-io-supply = <&pm8941_s3>; + qcom,vdd-io-voltage-level = <1800000 1800000>; + qcom,vdd-io-current-level = <250 154000>; + qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v"; + + pinctrl-names = "default" + pinctrl-0 = <&sdc1_clk &sdc1_cmd &sdc1_data>; + + clocks = <&gcc GCC_SDCC1_APPS_CLK>, <&gcc GCC_SDCC1_AHB_CLK>; + clock-names = "iface", "core"; + }; + + sdhc_2: sdhci@f98a4900 { + compatible = "qcom,sdhci-msm"; + reg = <0xf98a4900 0x11c>, <0xf98a4000 0x800>; + reg-names = "hc_mem", "core_mem"; + interrupts = <0 125 0>, <0 221 0>; + interrupt-names = "hc_irq", "pwr_irq"; + bus-width = <4>; + + vdd-supply = <&pm8941_l21>; + qcom,vdd-voltage-level = <2950000 2950000>; + qcom,vdd-current-level = <9000 800000>; + + vdd-io-supply = <&pm8941_l13>; + qcom,vdd-io-voltage-level = <1800000 2950000>; + qcom,vdd-io-current-level = <6 22000>; + + pinctrl-names = "default"; + pinctrl-0 = <&sdc2_clk &sdc2_cmd &sdc2_data>; + + clocks = <&gcc GCC_SDCC2_APPS_CLK>, <&gcc GCC_SDCC2_AHB_CLK>; + clock-names = "core", "iface"; + };
Signature · 1 line
1.7.9.5
PATCH v7 2/2 mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Georgi DjakovThis platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
--- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-msm.c | 651 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 665 insertions(+) create mode 100644 drivers/mmc/host/sdhci-msm.c
drivers/mmc/host/Kconfig +13 -0
@@ -322,6 +322,19 @@ config MMC_ATMELMCI If unsure, say N. +config MMC_SDHCI_MSM + tristate "Qualcomm SDHCI Controller Support" + depends on ARCH_MSM + depends on MMC_SDHCI_PLTFM + help + This selects the Secure Digital Host Controller Interface (SDHCI) + support present in MSM SOCs from Qualcomm. The controller + supports SD/MMC/SDIO devices. + + If you have a controller with this interface, say Y or M here. + + If unsure, say N. + config MMC_MSM tristate "Qualcomm SDCC Controller Support" depends on MMC && ARCH_MSM
drivers/mmc/host/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o obj-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o obj-$(CONFIG_MMC_SDHCI_BCM_KONA) += sdhci-bcm-kona.o obj-$(CONFIG_MMC_SDHCI_BCM2835) += sdhci-bcm2835.o +obj-$(CONFIG_MMC_SDHCI_MSM) += sdhci-msm.o ifeq ($(CONFIG_CB710_DEBUG),y) CFLAGS-cb710-mmc += -DDEBUG
drivers/mmc/host/sdhci-msm.c new file +651 -0
651 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Hi Georgi,
Quoted 4 lines · Georgi Djakov
This patchset adds basic support of the Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Tested with SD card on APQ8074 Dragonboard.
Thanks, Tested with mass-storage gadget :-). Forks fine.
Regards.
Quoted 13 lines
Georgi Djakov (2):
mmc: sdhci-msm: Initial SDHCI MSM driver documentation
mmc: sdhci-msm: Initial support for MSM chipsets.../devicetree/bindings/mmc/sdhci-msm.txt | 93 +++ drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-msm.c | 655 ++++++++++++++++++++ 4 files changed, 762 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-msm.txt create mode 100644 drivers/mmc/host/sdhci-msm.c
Re: [PATCH v7 1/2] mmc: sdhci-msm: Initial SDHCI MSM driver documentation
In reply to Georgi DjakovHi,
Apologies for the late reply.
Quoted 3 lines · Georgi Djakov
This patch adds documentation for Qualcomm SDHCI MSM driver. It contains the differences between the core properties in mmc.txt and the properties used by the sdhci-msm driver.
Nit, but this is documentation of the binding, not the driver.
Quoted 13 lines
Signed-off-by Georgi Djakov <[email protected]>--- .../devicetree/bindings/mmc/sdhci-msm.txt | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-msm.txtDocumentation/devicetree/bindings/mmc/sdhci-msm.txt new file +0
-0
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +8
-0@@ -0,0 +1,92 @@ +* Qualcomm SDHCI controller (sdhci-msm) + +This file documents differences between the core properties in mmc.txt +and the properties used by the sdhci-msm driver. + +Required properties: +- compatible: should contain "qcom,sdhci-msm" +- reg: should contain SDHC, SD Core register map
As this seems to depend on reg-names, it would be nice to write this in terms of reg-names (as with clocks and clock-names).
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 10
Quoted 2 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +2
-0+- reg-names: indicates various resources passed to driver (via reg proptery) by name + "reg-names" examples are "hc_mem" and "core_mem"
Either there are a fixed set of names you expect (and therefore these aren't examples but rather a definition), or this property is useless. Please either define the set of names or remove this property.
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 13
Quoted 3 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0+- interrupts: should contain SDHC interrupts +- interrupt-names: indicates interrupts passed to driver (via interrupts property) by name + "interrupt-names" examples are "hc_irq" and "pwr_irq"
Likewise for both points.
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 22
Quoted 9 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +9
-0+- vdd-supply: phandle to the regulator for the vdd (flash core voltage) supply. +- vddio-supply: phandle to the regulator for the vdd-io (i/o voltage) supply. +- pinctrl-names: Should contain only one value - "default". +- pinctrl-0: Should specify pin control groups used for this controller. +- clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names +- clock-names: Should contain the following: + "iface" - Main peripheral bus clock (PCLK/HCLK - AHB Bus clock) (required) + "core" - SDC MMC clock (MCLK) (required) + "bus" - SDCC bus voter clock (optional)
This looks good :)
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +8
-0+ +Optional properties: +- qcom,bus-speed-mode: specifies the supported bus speed modes by host + The supported bus speed modes are: + "HS200_1p8v" - indicates that host can support HS200 at 1.8v + "HS200_1p2v" - indicates that host can support HS200 at 1.2v + "DDR_1p8v" - indicates that host can support DDR mode at 1.8v + "DDR_1p2v" - indicates that host can support DDR mode at 1.2v
Is this a list of strings, or does the unit only support one of these?
This could be a set of boolean properties instead, is this likely to expand in future?
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 32
Quoted 2 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +2
-0+ +- qcom,{vdd,vdd-io}-lpm-sup - specifies whether the supply can be kept in low power mode.
Boolean? Please specify types on properties.
Can you elaborate on what this means? When can a supply not be kept in low power mode?
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 36
Quoted 4 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +4
-0+- qcom,{vdd,vdd-io}-voltage-level - specifies voltage levels for the supply. + Should be specified in pairs (min, max), units uV. +- qcom,{vdd,vdd-io}-current-level - specifies load levels for the supply in lpm + or high power mode (hpm). Should be specified in pairs (lpm, hpm), units uA.
Can you not query these from the regulator framework?
If these are configuration, why are they necessary?
Thanks,
Mark.
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Georgi DjakovQuoted 11 lines · Georgi Djakov
This platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Signed-off-by Georgi Djakov <[email protected]>--- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-msm.c | 651 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 665 insertions(+) create mode 100644 drivers/mmc/host/sdhci-msm.c
[...]
drivers/mmc/host/sdhci-msm.c line 94
Quoted 6 lines
drivers/mmc/host/sdhci-msm.c new file +6
-0+static int sdhci_msm_dt_parse_vreg_info (struct device *dev, +struct sdhci_msm_reg_data *vreg, +const char *vreg_name) +{ +int len; +const __be32 *prop;
Seeing raw property handling in drivers worries me. If there's a reason to touch the raw DTB we should add helpers to do it rather than leaking binary format issues into drivers.
Quoted 14 lines
drivers/mmc/host/sdhci-msm.c new file +14
-0+char prop_name[MAX_PROP_SIZE ]; +struct device_node *np = dev->of_node; + +snprintf (prop_name,MAX_PROP_SIZE ,"%s-supply" , vreg_name); +if (!of_parse_phandle (np, prop_name,0 )) { +dev_info (dev,"No vreg data found for %s\n" , vreg_name); +return -EINVAL ; + } + + vreg->name = vreg_name; + +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-lpm-sup" , vreg_name); +if (of_get_property (np, prop_name,NULL )) + vreg->lpm_sup = true;
drivers/mmc/host/sdhci-msm.c line 118
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+ +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-voltage-level" , vreg_name); + prop =of_get_property (np, prop_name, &len); +if (!prop || (len != (2 *sizeof (__be32)))) { +dev_warn (dev,"%s %s property\n" , + prop ?"invalid format" :"no" , prop_name); + }else { + vreg->low_vol_level =be32_to_cpup (&prop[0 ]); + vreg->high_vol_level =be32_to_cpup (&prop[1 ]); + }
You can use of_property_read_u32_array here.
drivers/mmc/host/sdhci-msm.c line 128
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+ +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-current-level" , vreg_name); + prop =of_get_property (np, prop_name, &len); +if (!prop || (len != (2 *sizeof (__be32)))) { +dev_warn (dev,"%s %s property\n" , + prop ?"invalid format" :"no" , prop_name); + }else { + vreg->lpm_uA =be32_to_cpup (&prop[0 ]); + vreg->hpm_uA =be32_to_cpup (&prop[1 ]); + }
Likewise.
[...]
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL );
drivers/mmc/host/sdhci-msm.c line 543
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC. +*/ +mb ();
Does this guarantee that the device has finished responding to the write and deasserted the interrupt line (i.e. does the device only acknowledge the write once that is true)?
Thanks,
Mark.
Re: [PATCH v7 1/2] mmc: sdhci-msm: Initial SDHCI MSM driver documentation
In reply to Mark RutlandQuoted 3 lines · Mark Rutland
Hi,
Apologies for the late reply.
Hi Mark, thanks for the review!
Quoted 8 lines · Georgi Djakov
Quoted 3 lines
This patch adds documentation for Qualcomm SDHCI MSM driver. It contains the differences between the core properties in mmc.txt and the properties used by the sdhci-msm driver.
Nit, but this is documentation of the binding, not the driver.
Ok, sure!
Quoted 16 lines
Quoted 16 lines
Signed-off-by Georgi Djakov <[email protected]>--- .../devicetree/bindings/mmc/sdhci-msm.txt | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/mmc/sdhci-msm.txtDocumentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0@@ -0,0 +1,92 @@ +* Qualcomm SDHCI controller (sdhci-msm) + +This file documents differences between the core properties in mmc.txt
Quoted 10 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 8
Quoted 5 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +5
-0+and the properties used by the sdhci-msm driver. + +Required properties: +- compatible: should contain "qcom,sdhci-msm" +- reg: should contain SDHC, SD Core register mapAs this seems to depend on reg-names, it would be nice to write this in terms of reg-names (as with clocks and clock-names).
Ok, thanks!
Quoted 7 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 10
Quoted 2 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +2
-0+- reg-names: indicates various resources passed to driver (via reg proptery) by name + "reg-names" examples are "hc_mem" and "core_mem"Either there are a fixed set of names you expect (and therefore these aren't examples but rather a definition), or this property is useless. Please either define the set of names or remove this property.
Quoted 6 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 13
Quoted 3 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0+- interrupts: should contain SDHC interrupts +- interrupt-names: indicates interrupts passed to driver (via interrupts property) by name + "interrupt-names" examples are "hc_irq" and "pwr_irq"Likewise for both points.
Ok!
Quoted 23 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 22
Quoted 9 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +9
-0+- vdd-supply: phandle to the regulator for the vdd (flash core voltage) supply. +- vddio-supply: phandle to the regulator for the vdd-io (i/o voltage) supply. +- pinctrl-names: Should contain only one value - "default". +- pinctrl-0: Should specify pin control groups used for this controller. +- clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names +- clock-names: Should contain the following: + "iface" - Main peripheral bus clock (PCLK/HCLK - AHB Bus clock) (required) + "core" - SDC MMC clock (MCLK) (required) + "bus" - SDCC bus voter clock (optional)This looks good :)
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +8
-0+ +Optional properties: +- qcom,bus-speed-mode: specifies the supported bus speed modes by host + The supported bus speed modes are: + "HS200_1p8v" - indicates that host can support HS200 at 1.8v + "HS200_1p2v" - indicates that host can support HS200 at 1.2v + "DDR_1p8v" - indicates that host can support DDR mode at 1.8v + "DDR_1p2v" - indicates that host can support DDR mode at 1.2vIs this a list of strings, or does the unit only support one of these?
Quoted 3 lines
This could be a set of boolean properties instead, is this likely to expand in future?
It is meant to be list of strings, and many can be supported. But i will drop this property from this initial version, and maybe add it later as boolean properties! Thanks!
Quoted 4 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 32
Quoted 2 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +2
-0+ +- qcom,{vdd,vdd-io}-lpm-sup - specifies whether the supply can be kept in low power mode.Boolean? Please specify types on properties.
Yes, it is boolean. I'll note it in the documentation. Thanks!
Quoted 3 lines
Can you elaborate on what this means? When can a supply not be kept in low power mode?
The vdd-io for example is a regulator that is always-on and may be shared with multiple other peripherals as well. It should not be disabled by the driver, but instead put in low power mode when unused.
Quoted 10 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 36
Quoted 5 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +4
-0+- qcom,{vdd,vdd-io}-voltage-level - specifies voltage levels for the supply. + Should be specified in pairs (min, max), units uV. +- qcom,{vdd,vdd-io}-current-level - specifies load levels for the supply in lpm + or high power mode (hpm). Should be specified in pairs (lpm, hpm), units uA.Can you not query these from the regulator framework?
If these are configuration, why are they necessary?
As some regulators are shared and can have multiple consumers, these properties can be used for voltage and load current aggregation.
The voltage-level is the "supported voltage" by the controller, that also (at least on my platform) matches the corresponding regulator voltage. I probably can drop the voltage-level property and get voltage via the regulator framework helper functions, but the load current values are different for each sdhc. From the very limited documentation that i have, i think this is describing the hardware configuration and should be in the device-tree.
Thanks,
Georgi
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Mark RutlandQuoted 64 lines · Mark Rutland
Quoted 11 lines · Georgi Djakov
This platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Signed-off-by Georgi Djakov <[email protected]>--- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci-msm.c | 651 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 665 insertions(+)create mode 100644
drivers/mmc/host/sdhci-msm.c[...]
drivers/mmc/host/sdhci-msm.c line 94
Quoted 6 lines
drivers/mmc/host/sdhci-msm.c new file +6
-0+static int sdhci_msm_dt_parse_vreg_info (struct device *dev, +struct sdhci_msm_reg_data *vreg, +const char *vreg_name) +{ +int len; +const __be32 *prop;Seeing raw property handling in drivers worries me. If there's a reason to touch the raw DTB we should add helpers to do it rather than leaking binary format issues into drivers.
Quoted 14 lines
drivers/mmc/host/sdhci-msm.c new file +14
-0+char prop_name[MAX_PROP_SIZE ]; +struct device_node *np = dev->of_node; + +snprintf (prop_name,MAX_PROP_SIZE ,"%s-supply" , vreg_name); +if (!of_parse_phandle (np, prop_name,0 )) { +dev_info (dev,"No vreg data found for %s\n" , vreg_name); +return -EINVAL ; + } + + vreg->name = vreg_name; + +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-lpm-sup" , vreg_name); +if (of_get_property (np, prop_name,NULL )) + vreg->lpm_sup = true;drivers/mmc/host/sdhci-msm.c line 118
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+ +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-voltage-level" , vreg_name); + prop =of_get_property (np, prop_name, &len); +if (!prop || (len != (2 *sizeof (__be32)))) { +dev_warn (dev,"%s %s property\n" , + prop ?"invalid format" :"no" , prop_name); + }else { + vreg->low_vol_level =be32_to_cpup (&prop[0 ]); + vreg->high_vol_level =be32_to_cpup (&prop[1 ]); + }You can use
of_property_read_u32_arrayhere.drivers/mmc/host/sdhci-msm.c line 128
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+ +snprintf (prop_name,MAX_PROP_SIZE ,"qcom,%s-current-level" , vreg_name); + prop =of_get_property (np, prop_name, &len); +if (!prop || (len != (2 *sizeof (__be32)))) { +dev_warn (dev,"%s %s property\n" , + prop ?"invalid format" :"no" , prop_name); + }else { + vreg->lpm_uA =be32_to_cpup (&prop[0 ]); + vreg->hpm_uA =be32_to_cpup (&prop[1 ]); + }
Quoted 2 lines
Likewise.
I will clean this up use only of_property_read_u32_array() and of_property_read_bool() for DT parsing. Thanks!
Quoted 23 lines
[...]
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL );drivers/mmc/host/sdhci-msm.c line 543
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC. +*/ +mb ();
Quoted 4 lines
Does this guarantee that the device has finished responding to the write and deasserted the interrupt line (i.e. does the device only acknowledge the write once that is true)?
I am not sure that i understand your concern. The write to CORE_PWRCTL_CTL should acknowledge and deassert the interrupt.
Thanks,
Georgi
Re: [PATCH v7 1/2] mmc: sdhci-msm: Initial SDHCI MSM driver documentation
In reply to Georgi DjakovQuoted 94 lines · Georgi Djakov
Quoted 3 lines · Mark Rutland
Hi,
Apologies for the late reply.
Hi Mark, thanks for the review!
Quoted 8 lines · Georgi Djakov
Quoted 3 lines
This patch adds documentation for Qualcomm SDHCI MSM driver. It contains the differences between the core properties in mmc.txt and the properties used by the sdhci-msm driver.
Nit, but this is documentation of the binding, not the driver.
Ok, sure!
Quoted 16 lines
Quoted 16 lines
Signed-off-by Georgi Djakov <[email protected]>--- .../devicetree/bindings/mmc/sdhci-msm.txt | 92 ++++++++++++++++++++ 1 file changed, 92 insertions(+)create mode 100644
Documentation/devicetree/bindings/mmc/sdhci-msm.txtDocumentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0@@ -0,0 +1,92 @@ +* Qualcomm SDHCI controller (sdhci-msm) + +This file documents differences between the core properties in mmc.txtQuoted 10 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 8
Quoted 5 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +5
-0+and the properties used by the sdhci-msm driver. + +Required properties: +- compatible: should contain "qcom,sdhci-msm" +- reg: should contain SDHC, SD Core register mapAs this seems to depend on reg-names, it would be nice to write this in terms of reg-names (as with clocks and clock-names).
Ok, thanks!
Quoted 7 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 10
Quoted 2 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +2
-0+- reg-names: indicates various resources passed to driver (via reg proptery) by name + "reg-names" examples are "hc_mem" and "core_mem"Either there are a fixed set of names you expect (and therefore these aren't examples but rather a definition), or this property is useless. Please either define the set of names or remove this property.
Quoted 6 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 13
Quoted 3 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0+- interrupts: should contain SDHC interrupts +- interrupt-names: indicates interrupts passed to driver (via interrupts property) by name + "interrupt-names" examples are "hc_irq" and "pwr_irq"Likewise for both points.
Ok!
Quoted 23 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 22
Quoted 9 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +9
-0+- vdd-supply: phandle to the regulator for the vdd (flash core voltage) supply. +- vddio-supply: phandle to the regulator for the vdd-io (i/o voltage) supply. +- pinctrl-names: Should contain only one value - "default". +- pinctrl-0: Should specify pin control groups used for this controller. +- clocks: A list of phandle + clock-specifier pairs for the clocks listed in clock-names +- clock-names: Should contain the following: + "iface" - Main peripheral bus clock (PCLK/HCLK - AHB Bus clock) (required) + "core" - SDC MMC clock (MCLK) (required) + "bus" - SDCC bus voter clock (optional)This looks good :)
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 30
Quoted 8 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +8
-0+ +Optional properties: +- qcom,bus-speed-mode: specifies the supported bus speed modes by host + The supported bus speed modes are: + "HS200_1p8v" - indicates that host can support HS200 at 1.8v + "HS200_1p2v" - indicates that host can support HS200 at 1.2v + "DDR_1p8v" - indicates that host can support DDR mode at 1.8v + "DDR_1p2v" - indicates that host can support DDR mode at 1.2vIs this a list of strings, or does the unit only support one of these?
Quoted 3 lines
This could be a set of boolean properties instead, is this likely to expand in future?
It is meant to be list of strings, and many can be supported. But i will drop this property from this initial version, and maybe add it later as boolean properties! Thanks!
[...]
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
+
+- qcom,{vdd,vdd-io}-lpm-sup - specifies whether the supply can be kept in low power mode.Boolean? Please specify types on properties.
Yes, it is boolean. I'll note it in the documentation. Thanks!
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Can you elaborate on what this means? When can a supply not be kept in low power mode?
The vdd-io for example is a regulator that is always-on and may be shared with multiple other peripherals as well. It should not be disabled by the driver, but instead put in low power mode when unused.
The fact that the regulator is driving other peripherals doesn't seem like a property of the SDHCI to me. What are these other peripherals?
When you say should not be disabled by the driver, do you mean that another peripheral's driver shouldn't be able to disable the regulator feeding the SDHCI, or the SDHCI driver shouldn't be able to disable a regulator in use by another peripheral?
When in low power mode, is the SDHCI functional?
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 36
Quoted 6 lines
+- qcom,{vdd,vdd-io}-voltage-level - specifies voltage levels for the supply.
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0+ Should be specified in pairs (min, max), units uV. +- qcom,{vdd,vdd-io}-current-level - specifies load levels for the supply in lpm + or high power mode (hpm). Should be specified in pairs (lpm, hpm), units uA.Can you not query these from the regulator framework?
If these are configuration, why are they necessary?
Quoted 9 lines
As some regulators are shared and can have multiple consumers, these properties can be used for voltage and load current aggregation. The voltage-level is the "supported voltage" by the controller, that also (at least on my platform) matches the corresponding regulator voltage. I probably can drop the voltage-level property and get voltage via the regulator framework helper functions, but the load current values are different for each sdhc.
From the very limited documentation that i have, i think this is
describing the hardware configuration and should be in the device-tree.
If these are the voltages / currents supported by the SDHCI, then that seems like it makes sense to have in DT, if they're likely to be variable in practice. How variable do you expect these to be?
Also, I'd recommend splitting them in to separate -min and -max properties, it makes it far clearer what they're actually for.
Thanks
Mark.
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Georgi DjakovQuoted 23 lines
Quoted 23 lines
[...]
Quoted 20 lines
drivers/mmc/host/sdhci-msm.c new file +20
-0+/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL ); +if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC. +*/ +mb ();
Quoted 7 lines
Quoted 4 lines
Does this guarantee that the device has finished responding to the write and deasserted the interrupt line (i.e. does the device only acknowledge the write once that is true)?
I am not sure that i understand your concern. The write to
CORE_PWRCTL_CTLshould acknowledge and deassert the interrupt.
The mb() ensures that the write has reached the device, and the device's slave interface has acknowledged the write. On some devices this acknowledgement of the write can be asynchronous with respect to the device changing state in response to the write (i.e. the interrupt might get deasserted a short time after the write completes). Typically there is a register that should be polled to see whether the state change has completed.
Does the acknowledgement of the write only occur once the device has changed state? Or might it change state in the background?
Thanks,
Mark
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Georgi DjakovQuoted 5 lines · Georgi Djakov
This platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Signed-off-by Georgi Djakov <[email protected]>
[...]
Quoted 22 lines
drivers/mmc/host/sdhci-msm.c new file +22
-0+static int sdhci_msm_probe (struct platform_device *pdev) +{ +struct sdhci_host *host; +struct sdhci_pltfm_host *pltfm_host; +struct sdhci_msm_host *msm_host; +struct resource *core_memres =NULL ; +int ret, dead; +u16 host_version; +u32 irq_status, irq_ctl; + +if (!pdev->dev.of_node) { +dev_err (&pdev->dev,"No device tree data\n" ); +return -ENOENT ; + } + + msm_host =devm_kzalloc (&pdev->dev,sizeof (*msm_host),GFP_KERNEL ); +if (!msm_host) +return -ENOMEM ; + + msm_host->sdhci_msm_pdata.ops = &sdhci_msm_ops; + host =sdhci_pltfm_init (pdev, &msm_host->sdhci_msm_pdata,0 ); +if (IS_ERR (host)) {
drivers/mmc/host/sdhci-msm.c line 443
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+dev_err (mmc_dev (host->mmc),"sdhci_pltfm_init error\n" ); +return PTR_ERR (host); + } + + pltfm_host =sdhci_priv (host); + pltfm_host->priv = msm_host; + msm_host->mmc = host->mmc; + msm_host->pdev = pdev; + + ret =mmc_of_parse (host->mmc);
Can we please add a call to sdhci_get_of_property(pdev) somewhere around here too?
Quoted 98 lines
drivers/mmc/host/sdhci-msm.c new file +98
-0+if (ret) { +dev_err (&pdev->dev,"failed parsing mmc device tree\n" ); + goto pltfm_free; + } + + ret =sdhci_msm_populate_pdata (&pdev->dev, &msm_host->pdata); +if (ret) { +dev_err (&pdev->dev,"DT parsing error\n" ); + goto pltfm_free; + } + +/* Setup SDCC bus voter clock. */ + msm_host->bus_clk =devm_clk_get (&pdev->dev,"bus" ); +if (!IS_ERR (msm_host->bus_clk)) { +/* Vote for max. clk rate for max. performance */ + ret =clk_set_rate (msm_host->bus_clk,INT_MAX ); +if (ret) + goto pltfm_free; + ret =clk_prepare_enable (msm_host->bus_clk); +if (ret) + goto pltfm_free; + } + +/* Setup main peripheral bus clock */ + msm_host->pclk =devm_clk_get (&pdev->dev,"iface" ); +if (!IS_ERR (msm_host->pclk)) { + ret =clk_prepare_enable (msm_host->pclk); +if (ret) { +dev_err (&pdev->dev, +"Main peripheral clock setup fail (%d)\n" , + ret); + goto bus_clk_disable; + } + } + +/* Setup SDC MMC clock */ + msm_host->clk =devm_clk_get (&pdev->dev,"core" ); +if (IS_ERR (msm_host->clk)) { + ret =PTR_ERR (msm_host->clk); +dev_err (&pdev->dev,"SDC MMC clock setup fail (%d)\n" , ret); + goto pclk_disable; + } + + ret =clk_prepare_enable (msm_host->clk); +if (ret) + goto pclk_disable; + +/* Setup regulators */ + ret =sdhci_msm_vreg_init (&pdev->dev, &msm_host->pdata); +if (ret) { +if (ret != -EPROBE_DEFER ) +dev_err (&pdev->dev,"Regulator setup fail (%d)\n" , ret); + goto clk_disable; + } + + core_memres =platform_get_resource_byname (pdev, +IORESOURCE_MEM ,"core_mem" ); + msm_host->core_mem =devm_ioremap_resource (&pdev->dev, core_memres); + +if (IS_ERR (msm_host->core_mem)) { +dev_err (&pdev->dev,"Failed to remap registers\n" ); + ret =PTR_ERR (msm_host->core_mem); + goto vreg_disable; + } + +/* Reset the core and Enable SDHC mode */ +writel_relaxed (readl_relaxed (msm_host->core_mem +CORE_POWER ) | +CORE_SW_RST , msm_host->core_mem +CORE_POWER ); + +/* SW reset can take upto 10HCLK + 15MCLK cycles. (min 40us) */ +usleep_range (1000 ,5000 ); +if (readl (msm_host->core_mem +CORE_POWER ) &CORE_SW_RST ) { +dev_err (&pdev->dev,"Stuck in reset\n" ); + ret = -ETIMEDOUT ; + goto vreg_disable; + } + +/* Set HC_MODE_EN bit in HC_MODE register */ +writel_relaxed (HC_MODE_EN , (msm_host->core_mem +CORE_HC_MODE )); + +/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL ); +if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC.
drivers/mmc/host/sdhci-msm.c line 551
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+*/ +mb (); + +/* +* Following are the deviations from SDHC spec v3.0 - +* 1. Card detection is handled using separate GPIO. +* 2. Bus power control is handled by interacting with PMIC. +*/ + host->quirks |=SDHCI_QUIRK_BROKEN_CARD_DETECTION ; + host->quirks |=SDHCI_QUIRK_SINGLE_POWER_WRITE ;
I couldn't get v6 running without the 5 quirks you submitted in [1]. Aren't these also attributes of the controller itself? If so, shouldn't they be part of this patch series, and included here?
Quoted 55 lines
drivers/mmc/host/sdhci-msm.c new file +55
-0+ host_version =readw_relaxed ((host->ioaddr +SDHCI_HOST_VERSION )); +dev_dbg (&pdev->dev,"Host Version: 0x%x Vendor Version 0x%x\n" , + host_version, ((host_version &SDHCI_VENDOR_VER_MASK ) >> +SDHCI_VENDOR_VER_SHIFT )); + +/* Setup PWRCTL irq */ + msm_host->pwr_irq =platform_get_irq_byname (pdev,"pwr_irq" ); +if (msm_host->pwr_irq <0 ) { +dev_err (&pdev->dev,"Failed to get pwr_irq by name (%d)\n" , + msm_host->pwr_irq); + goto vreg_disable; + } + ret =devm_request_threaded_irq (&pdev->dev, msm_host->pwr_irq,NULL , + sdhci_msm_pwr_irq,IRQF_ONESHOT , +dev_name (&pdev->dev), host); +if (ret) { +dev_err (&pdev->dev,"Request threaded irq(%d) fail (%d)\n" , + msm_host->pwr_irq, ret); + goto vreg_disable; + } + +/* Enable pwr irq interrupts */ +writel_relaxed (INT_MASK , (msm_host->core_mem +CORE_PWRCTL_MASK )); + + msm_host->mmc->caps |= msm_host->pdata.caps; + msm_host->mmc->caps2 |= msm_host->pdata.caps2; + + ret =sdhci_add_host (host); +if (ret) { +dev_err (&pdev->dev,"Add host fail (%d)\n" , ret); + goto vreg_disable; + } + + ret =clk_set_rate (msm_host->clk, host->max_clk); +if (ret) { +dev_err (&pdev->dev,"MClk rate set fail (%d)\n" , ret); + goto remove_host; + } + + host->mmc->max_current_180 = host->mmc->max_current_300 = + host->mmc->max_current_330 =sdhci_msm_get_vdd_max_current (msm_host); + +return 0 ; + +remove_host: + dead = (readl_relaxed (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff ); +sdhci_remove_host (host, dead); +vreg_disable: +if (!IS_ERR (msm_host->pdata.vdd.reg)) +sdhci_msm_vreg_disable (&pdev->dev, &msm_host->pdata.vdd); +if (!IS_ERR (msm_host->pdata.vdd_io.reg)) +sdhci_msm_vreg_disable (&pdev->dev, &msm_host->pdata.vdd_io); +clk_disable: +if (!IS_ERR (msm_host->clk)) +clk_disable_unprepare (msm_host->clk);
drivers/mmc/host/sdhci-msm.c line 617
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c new file +10
-0+pclk_disable: +if (!IS_ERR (msm_host->pclk)) +clk_disable_unprepare (msm_host->pclk); +bus_clk_disable: +if (!IS_ERR (msm_host->bus_clk)) +clk_disable_unprepare (msm_host->bus_clk); +pltfm_free: +sdhci_pltfm_free (pdev); +return ret; +}
-Courtney
Re: [PATCH v7 1/2] mmc: sdhci-msm: Initial SDHCI MSM driver documentation
In reply to Mark RutlandHi,
Apologies for the delayed reply.
Quoted 2 lines · Mark Rutland
Quoted 1 line · Georgi Djakov
On 12/05/2013 11:52 AM, Mark Rutland wrote:
[...]
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
Quoted 3 lines
+
+- qcom,{vdd,vdd-io}-lpm-sup - specifies whether the supply can be kept in low power mode.Boolean? Please specify types on properties.
Yes, it is boolean. I'll note it in the documentation. Thanks!
Quoted 3 lines
Can you elaborate on what this means? When can a supply not be kept in low power mode?
Quoted 7 lines
Quoted 3 lines
The vdd-io for example is a regulator that is always-on and may be shared with multiple other peripherals as well. It should not be disabled by the driver, but instead put in low power mode when unused.
The fact that the regulator is driving other peripherals doesn't seem like a property of the SDHCI to me. What are these other peripherals?
Agree! I'll drop this property.
Quoted 5 lines
When you say should not be disabled by the driver, do you mean that another peripheral's driver shouldn't be able to disable the regulator feeding the SDHCI, or the SDHCI driver shouldn't be able to disable a regulator in use by another peripheral?
The regulator will not be disabled in any case as it will be marked as always-on.
Quoted 23 lines
When in low power mode, is the SDHCI functional?
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/mmc/sdhci-msm.txt line 36
Quoted 5 lines
+- qcom,{vdd,vdd-io}-voltage-level - specifies voltage levels for the supply.
Documentation/devicetree/bindings/mmc/sdhci-msm.txt new file +3
-0+ Should be specified in pairs (min, max), units uV. +- qcom,{vdd,vdd-io}-current-level - specifies load levels for the supply in lpm + or high power mode (hpm). Should be specified in pairs (lpm, hpm), units uA.Can you not query these from the regulator framework?
If these are configuration, why are they necessary?
Quoted 9 lines
As some regulators are shared and can have multiple consumers, these properties can be used for voltage and load current aggregation. The voltage-level is the "supported voltage" by the controller, that also (at least on my platform) matches the corresponding regulator voltage. I probably can drop the voltage-level property and get voltage via the regulator framework helper functions, but the load current values are different for each sdhc.
From the very limited documentation that i have, i think this is
describing the hardware configuration and should be in the device-tree.
Quoted 4 lines
If these are the voltages / currents supported by the SDHCI, then that seems like it makes sense to have in DT, if they're likely to be variable in practice. How variable do you expect these to be?
The voltages vary depending on the function. For example the vdd-io for eMMC is 1.2 - 1.8v, for SD cards 1.8 - 2.95v and for SDIO 1.8v.
So, one way is using -min/-max suffixes and the other can be introducing a for ex. "function" property (emmc/card/sdio) and moving the voltage range definitions into the driver.
Quoted 3 lines
Also, I'd recommend splitting them in to separate -min and -max properties, it makes it far clearer what they're actually for.
Thanks,
Georgi
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Mark RutlandQuoted 39 lines · Mark Rutland
Quoted 23 lines
Quoted 23 lines
[...]
Quoted 20 lines
drivers/mmc/host/sdhci-msm.c new file +20
-0+/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL ); +if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC. +*/ +mb ();Quoted 7 lines
Quoted 4 lines
Does this guarantee that the device has finished responding to the write and deasserted the interrupt line (i.e. does the device only acknowledge the write once that is true)?
I am not sure that i understand your concern. The write to
CORE_PWRCTL_CTLshould acknowledge and deassert the interrupt.The
mb()ensures that the write has reached the device, and the device's slave interface has acknowledged the write. On some devices this acknowledgement of the write can be asynchronous with respect to the device changing state in response to the write (i.e. the interrupt might get deasserted a short time after the write completes). Typically there is a register that should be polled to see whether the state change has completed.
Quoted 3 lines
Does the acknowledgement of the write only occur once the device has changed state? Or might it change state in the background?
Thanks for clarifying this. All this is correct, but it will be difficult to answer, because i don't have documentation and i can only be guessing how exactly the hardware behaves internally. I can remove this fragment from the initial version to keep it more simple. Meanwhile i can do some tests reading/polling the status register to see how and when exactly it changes.
Thanks,
Georgi
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
In reply to Courtney CavinHi,
Apologies for the delayed reply.
Quoted 34 lines · Courtney Cavin
Quoted 5 lines · Georgi Djakov
This platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Signed-off-by Georgi Djakov <[email protected]>[...]
Quoted 27 lines
drivers/mmc/host/sdhci-msm.c new file +27
-0+static int sdhci_msm_probe (struct platform_device *pdev) +{ +struct sdhci_host *host; +struct sdhci_pltfm_host *pltfm_host; +struct sdhci_msm_host *msm_host; +struct resource *core_memres =NULL ; +int ret, dead; +u16 host_version; +u32 irq_status, irq_ctl; + +if (!pdev->dev.of_node) { +dev_err (&pdev->dev,"No device tree data\n" ); +return -ENOENT ; + } + + msm_host =devm_kzalloc (&pdev->dev,sizeof (*msm_host),GFP_KERNEL ); +if (!msm_host) +return -ENOMEM ; + + msm_host->sdhci_msm_pdata.ops = &sdhci_msm_ops; + host =sdhci_pltfm_init (pdev, &msm_host->sdhci_msm_pdata,0 ); +if (IS_ERR (host)) { +dev_err (mmc_dev (host->mmc),"sdhci_pltfm_init error\n" ); +return PTR_ERR (host); + } + + pltfm_host =sdhci_priv (host);
Quoted 9 lines
drivers/mmc/host/sdhci-msm.c line 443
Quoted 5 lines
drivers/mmc/host/sdhci-msm.c new file +5
-0+ pltfm_host->priv = msm_host; + msm_host->mmc = host->mmc; + msm_host->pdev = pdev; + + ret =mmc_of_parse (host->mmc);Can we please add a call to
sdhci_get_of_property(pdev)somewhere around here too?
Thanks, I have added it to v8.
Quoted 104 lines
Quoted 104 lines
drivers/mmc/host/sdhci-msm.c new file +104
-0+if (ret) { +dev_err (&pdev->dev,"failed parsing mmc device tree\n" ); + goto pltfm_free; + } + + ret =sdhci_msm_populate_pdata (&pdev->dev, &msm_host->pdata); +if (ret) { +dev_err (&pdev->dev,"DT parsing error\n" ); + goto pltfm_free; + } + +/* Setup SDCC bus voter clock. */ + msm_host->bus_clk =devm_clk_get (&pdev->dev,"bus" ); +if (!IS_ERR (msm_host->bus_clk)) { +/* Vote for max. clk rate for max. performance */ + ret =clk_set_rate (msm_host->bus_clk,INT_MAX ); +if (ret) + goto pltfm_free; + ret =clk_prepare_enable (msm_host->bus_clk); +if (ret) + goto pltfm_free; + } + +/* Setup main peripheral bus clock */ + msm_host->pclk =devm_clk_get (&pdev->dev,"iface" ); +if (!IS_ERR (msm_host->pclk)) { + ret =clk_prepare_enable (msm_host->pclk); +if (ret) { +dev_err (&pdev->dev, +"Main peripheral clock setup fail (%d)\n" , + ret); + goto bus_clk_disable; + } + } + +/* Setup SDC MMC clock */ + msm_host->clk =devm_clk_get (&pdev->dev,"core" ); +if (IS_ERR (msm_host->clk)) { + ret =PTR_ERR (msm_host->clk); +dev_err (&pdev->dev,"SDC MMC clock setup fail (%d)\n" , ret); + goto pclk_disable; + } + + ret =clk_prepare_enable (msm_host->clk); +if (ret) + goto pclk_disable; + +/* Setup regulators */ + ret =sdhci_msm_vreg_init (&pdev->dev, &msm_host->pdata); +if (ret) { +if (ret != -EPROBE_DEFER ) +dev_err (&pdev->dev,"Regulator setup fail (%d)\n" , ret); + goto clk_disable; + } + + core_memres =platform_get_resource_byname (pdev, +IORESOURCE_MEM ,"core_mem" ); + msm_host->core_mem =devm_ioremap_resource (&pdev->dev, core_memres); + +if (IS_ERR (msm_host->core_mem)) { +dev_err (&pdev->dev,"Failed to remap registers\n" ); + ret =PTR_ERR (msm_host->core_mem); + goto vreg_disable; + } + +/* Reset the core and Enable SDHC mode */ +writel_relaxed (readl_relaxed (msm_host->core_mem +CORE_POWER ) | +CORE_SW_RST , msm_host->core_mem +CORE_POWER ); + +/* SW reset can take upto 10HCLK + 15MCLK cycles. (min 40us) */ +usleep_range (1000 ,5000 ); +if (readl (msm_host->core_mem +CORE_POWER ) &CORE_SW_RST ) { +dev_err (&pdev->dev,"Stuck in reset\n" ); + ret = -ETIMEDOUT ; + goto vreg_disable; + } + +/* Set HC_MODE_EN bit in HC_MODE register */ +writel_relaxed (HC_MODE_EN , (msm_host->core_mem +CORE_HC_MODE )); + +/* +* CORE_SW_RST above may trigger power irq if previous status of PWRCTL +* was either BUS_ON or IO_HIGH_V. So before we enable the power irq +* interrupt in GIC (by registering the interrupt handler), we need to +* ensure that any pending power irq interrupt status is acknowledged +* otherwise power irq interrupt handler would be fired prematurely. +*/ + irq_status =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_STATUS ); +writel_relaxed (irq_status, (msm_host->core_mem +CORE_PWRCTL_CLEAR )); + irq_ctl =readl_relaxed (msm_host->core_mem +CORE_PWRCTL_CTL ); +if (irq_status & (CORE_PWRCTL_BUS_ON |CORE_PWRCTL_BUS_OFF )) + irq_ctl |=CORE_PWRCTL_BUS_SUCCESS ; +if (irq_status & (CORE_PWRCTL_IO_HIGH |CORE_PWRCTL_IO_LOW )) + irq_ctl |=CORE_PWRCTL_IO_SUCCESS ; +writel_relaxed (irq_ctl, (msm_host->core_mem +CORE_PWRCTL_CTL )); +/* +* Ensure that above writes are propogated before interrupt enablement +* in GIC. +*/ +mb (); + +/* +* Following are the deviations from SDHC spec v3.0 - +* 1. Card detection is handled using separate GPIO.
Quoted 9 lines
drivers/mmc/host/sdhci-msm.c line 551
Quoted 4 lines
drivers/mmc/host/sdhci-msm.c new file +4
-0+* 2. Bus power control is handled by interacting with PMIC. +*/ + host->quirks |=SDHCI_QUIRK_BROKEN_CARD_DETECTION ; + host->quirks |=SDHCI_QUIRK_SINGLE_POWER_WRITE ;I couldn't get v6 running without the 5 quirks you submitted in [1]. Aren't these also attributes of the controller itself? If so, shouldn't they be part of this patch series, and included here?
Most of the quirks are for older hardware revisions. On what board/chip are you trying to run it? I will post v8 shortly. Could you try with it please?
Thanks,
Georgi
Re: [PATCH v7 2/2] mmc: sdhci-msm: Initial support for MSM chipsets
Quoted 11 lines · Georgi Djakov
Hi,
Apologies for the delayed reply.
Quoted 6 lines · Courtney Cavin
Quoted 5 lines · Georgi Djakov
This platform driver adds the initial support of Secure Digital Host Controller Interface compliant controller found in Qualcomm MSM chipsets.
Signed-off-by Georgi Djakov <[email protected]>
[...]
Quoted 9 lines
Quoted 5 lines
I couldn't get v6 running without the 5 quirks you submitted in [1]. Aren't these also attributes of the controller itself? If so, shouldn't they be part of this patch series, and included here?
Most of the quirks are for older hardware revisions. On what board/chip are you trying to run it? I will post v8 shortly. Could you try with it please?
I see. This was initially checked on a Rev 1 SoC. I will test v8 on a Rev 2.
-Courtney