mmc: sdhci-pxa: Add device tree support
Subsystems (3)
PATCH 1/1 mmc: sdhci-pxa: Add device tree support
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3, CONFIG_MACH_MMP2_DT=y)
--- .../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++ drivers/mmc/host/sdhci-pxav2.c | 52 ++++++++++++++++++++ drivers/mmc/host/sdhci-pxav3.c | 50 +++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
Documentation/devicetree/bindings/mmc/sdhci-pxa.txt new file +21 -0
@@ -0,0 +1,21 @@ +* Marvell sdhci-pxa v2/v3 controller + +This file documents differences between the core properties in mmc.txt +and the properties used by the sdhci-pxav2 and sdhci-pxav3 drivers. + +Required properties: +- compatible: Should be "mrvl,pxav2-mmc" or "mrvl,pxav3-mmc". + +Optional properties: +- clk-delay-cycles: Specify a number of cycles to delay for tuning. + +Example: + +sdhci@d4280800 { + compatible = "mrvl,pxav3-mmc"; + reg = <0xd4280800 0x800>; + interrupts = <27>; + bus-width = <8>; + clk-delay-cycles = <31>; + non-removable; +};
drivers/mmc/host/sdhci-pxav2.c +52 -0
82 lines not on this page · raw message
drivers/mmc/host/sdhci-pxav3.c +50 -0
80 lines not on this page · raw message
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Quoted 9 lines · Chris Ball
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3,
CONFIG_MACH_MMP2_DT=y)Signed-off-by Chris Ball <[email protected]>---
.../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++drivers/mmc/host/sdhci-pxav2.c| 52 ++++++++++++++++++++drivers/mmc/host/sdhci-pxav3.c| 50 +++++++++++++++++++3 files changed, 123 insertions(+)create mode 100644
Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
Thanks Chris for the great help, compile error if CONFIG_OF not defined.
Quoted 12 lines
drivers/mmc/host/sdhci-pxav2.c +11
-0+#ifdef CONFIG_OF +static const struct of_device_id sdhci_pxav2_of_match[] = { + { + .compatible = "mrvl,pxav2-mmc", + }, + {}, +}; +MODULE_DEVICE_TABLE (of, sdhci_pxav2_of_match); + +static struct sdhci_pxa_platdata *pxav2_get_mmc_pdata (struct device *dev) +{
drivers/mmc/host/sdhci-pxav2.c static struct sdhci_ops pxav2_sdhci_ops = { · line 163
Quoted 10 lines
drivers/mmc/host/sdhci-pxav2.c +9
-0+ struct sdhci_pxa_platdata *pdata; + struct device_node *np = dev->of_node; + u32 bus_width; + u32 clk_delay_cycles; + + return pdata; +} +#else +static inline struct sdhci_pxa_platdata pxav2_get_mmc_pdata (struct device *dev)
Should be static struct sdhci_pxa_platdata *pxav2_get_mmc_pdata(struct device *dev)
Quoted 29 lines
drivers/mmc/host/sdhci-pxav2.c +5
-0+{ + return NULL; +} +#endif +static int
__devinitsdhci_pxav2_probe(struct platform_device *pdev){
structsdhci_pltfm_host*pltfm_host;drivers/mmc/host/sdhci-pxav2.c +2
-0@@ -128,6 +173,8 @@ static int __devinit sdhci_pxav2_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct sdhci_host *host = NULL; struct sdhci_pxa *pxa = NULL; + const struct of_device_id *match; + int ret; struct clk *clk;@@ -156,6 +203,10 @@ static int __devinit sdhci_pxav2_probe(struct platform_device *pdev)|
SDHCI_QUIRK_BROKEN_TIMEOUT_VAL|SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN;+ match =
of_match_device(of_match_ptr(sdhci_pxav2_of_match), &pdev->dev);
+ if (match) {
+ pdata =pxav2_get_mmc_pdata(dev);
+ }
if (pdata) {
if (pdata->flags&PXA_FLAG_CARD_PERMANENT) {
/* on-chip device */
drivers/mmc/host/sdhci-pxav2.c static struct platform_driver sdhci_pxav2_driver = { · line 271
Quoted 3 lines
drivers/mmc/host/sdhci-pxav2.c +0
-0@@ -218,6 +269,7 @@ static struct platform_driver sdhci_pxav2_driver = { .driver = { .name = "sdhci-pxav2", .owner = THIS_MODULE,
#ifdef CONFIG_OF required, otherwise build fail.
drivers/mmc/host/sdhci-pxav2.c static struct platform_driver sdhci_pxav2_driver = { · line 272
Quoted 1 line
drivers/mmc/host/sdhci-pxav2.c +1
-0+ .of_match_table = sdhci_pxav2_of_match,
#endif
Quoted 13 lines
drivers/mmc/host/sdhci-pxav2.c +0
-0.pm = SDHCI_PLTFM_PMOPS, }, .probe = sdhci_pxav2_probe,drivers/mmc/host/sdhci-pxav3.c +5
-0+#ifdef CONFIG_OF +static const struct of_device_id sdhci_pxav3_of_match[] = { + { + .compatible = "mrvl,pxav3-mmc", + },
drivers/mmc/host/sdhci-pxav3.c static struct sdhci_ops pxav3_sdhci_ops = { · line 204
Quoted 10 lines
drivers/mmc/host/sdhci-pxav3.c +9
-0+ {}, +}; +MODULE_DEVICE_TABLE (of, sdhci_pxav3_of_match); + +static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata (struct device *dev) +{ +} +#else +static inline struct sdhci_pxa_platdata pxav3_get_mmc_pdata (struct device *dev)
Should be static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
drivers/mmc/host/sdhci-pxav3.c static int __devexit sdhci_pxav3_remove(struct platform_device *pdev) · line 314
Quoted 9 lines
drivers/mmc/host/sdhci-pxav3.c +5
-0+{ + return NULL; +} +#endif +@@ -263,6 +312,7 @@ static int __devexit sdhci_pxav3_remove(struct platform_device *pdev) static struct platform_driver sdhci_pxav3_driver = { .driver = { .name = "sdhci-pxav3",
#ifdef CONFIG_OF required, otherwise build fail.
drivers/mmc/host/sdhci-pxav3.c static int __devexit sdhci_pxav3_remove(struct platform_device *pdev) · line 315
Quoted 1 line
drivers/mmc/host/sdhci-pxav3.c +1
-0+ .of_match_table = sdhci_pxav3_of_match,
#endif
Quoted 10 lines
drivers/mmc/host/sdhci-pxav3.c +0
-1.owner = THIS_MODULE, .pm = SDHCI_PLTFM_PMOPS, }, --Chris Ball <[email protected]> <http://printf.net/>
One Laptop Per Child
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Zhangfei,
Quoted 11 lines · zhangfei gao
Quoted 9 lines · Chris Ball
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3,
CONFIG_MACH_MMP2_DT=y)Signed-off-by Chris Ball <[email protected]>---
.../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++drivers/mmc/host/sdhci-pxav2.c| 52 ++++++++++++++++++++drivers/mmc/host/sdhci-pxav3.c| 50 +++++++++++++++++++3 files changed, 123 insertions(+)create mode 100644
Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
Quoted 1 line
Thanks Chris for the great help, compile error if
CONFIG_OFnot defined.
Thanks for catching this!
How do you feel about having the compatible node say "sdhci-pxav3" instead of "mrvl,pxav3-mmc"? I used the mrvl prefix because it fits in with the rest of your existing DT, but it seems like it would be better to name the driver directly. The DTs here live inside the source tree, so we're not depending on anyone else's terminology.
If you're okay with sdhci-pxav{2,3} in compatible, I'll include that in v2 of the patch with the rest of your fixes.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Chris Ball
Hi Zhangfei,
Quoted 1 line · zhangfei gao
On Wed, Jun 13, 2012 at 3:05 AM, Chris Ball [email protected]> wrote:
Quoted 8 lines
How do you feel about having the compatible node say "sdhci-pxav3" instead of "mrvl,pxav3-mmc"? I used the mrvl prefix because it fits in with the rest of your existing DT, but it seems like it would be better to name the driver directly. The DTs here live inside the source tree, so we're not depending on anyone else's terminology.
If you're okay with sdhci-pxav{2,3} in compatible, I'll include that in v2 of the patch with the rest of your fixes.
Compatible node could be "mrvl,pxav3-mmc" or "mrvl,sdhci-pxav3". It's depend on your choice. I prefer to use vendor name in compatible property. And we could avoid naming conflict.
+ if (of_find_property(np, "non-removable", NULL))
+ pdata->flags |= PXA_FLAG_CARD_PERMANENT;
+
+ of_property_read_u32(np, "bus-width", &bus_width);
+ if (bus_width == 8)
+ pdata->flags |= PXA_FLAG_SD_8_BIT_CAPABLE_SLOT;
+
+ of_property_read_u32(np, "clk-delay-cycles", &clk_delay_cycles);
+ if (clk_delay_cycles > 0)
+ pdata->clk_delay_cycles = clk_delay_cycles;
+
These properties should be "mrvl,non-removable", "mrvl,bus-width", "mrvl,clk-delay-cycles". Since it's mentioned in Documentations/devicetree/booting-without-of.txt. "It is recommended that if you add any "custom" property whose name may clash with standard defined ones, you prefix them with your vendor name and a comma."
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
Hi Haojian,
Quoted 4 lines · On Wed, Jun 13 2012, [email protected] wrote:
Compatible node could be "mrvl,pxav3-mmc" or "mrvl,sdhci-pxav3". It's depend on your choice. I prefer to use vendor name in compatible property.
And we could avoid naming conflict.
Okay, I'll just stick with mrvl,pxav3-mmc.
Quoted 12 lines
+ if (
of_find_property(np, "non-removable", NULL))
+pdata->flags|=PXA_FLAG_CARD_PERMANENT;drivers/mmc/host/sdhci-pxav3.c +9
-0+ +of_property_read_u32 (np,"bus-width" , &bus_width); +if (bus_width ==8 ) + pdata->flags |=PXA_FLAG_SD_8_BIT_CAPABLE_SLOT ; + +of_property_read_u32 (np,"clk-delay-cycles" , &clk_delay_cycles); +if (clk_delay_cycles >0 ) + pdata->clk_delay_cycles = clk_delay_cycles; +
Quoted 6 lines
These properties should be "mrvl,non-removable", "mrvl,bus-width", "mrvl,clk-delay-cycles". Since it's mentioned in
Documentations/devicetree/booting-without-of.txt. "It is recommended that if you add any "custom" property whose name may clash with standard defined ones, you prefix them with your vendor name and a comma."
Not quite -- the "non-removable" and "bus-width" properties are part of the MMC core DT bindings as defined in:
Documentation/devicetree/bindings/mmc/mmc.txt
They are not custom Marvell properties. So, these two need to stay as they are (one day we'll interpret them in the sdhci driver instead of in sdhci-pxa) but I've changed clk_delay_cycles to mrvl,clk_delay_cycles in v2 of the patch, which I'm about to send out. I also applied all of Zhangfei's changes.
Thanks for the review!
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3, CONFIG_MACH_MMP2_DT=y)
---
Changes since v1:
* Add CONFIG_OF guard around of_match_table, per Zhangfei.
* Fix function prototypes under !CONFIG_OF, per Zhangfei.
* Change "clk-delay-cycles" to "mrvl,clk-delay-cycles", per Haojian.
.../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++ drivers/mmc/host/sdhci-pxav2.c | 54 ++++++++++++++++++++ drivers/mmc/host/sdhci-pxav3.c | 52 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-pxa.txt
Documentation/devicetree/bindings/mmc/sdhci-pxa.txt new file +21 -0
@@ -0,0 +1,21 @@ +* Marvell sdhci-pxa v2/v3 controller + +This file documents differences between the core properties in mmc.txt +and the properties used by the sdhci-pxav2 and sdhci-pxav3 drivers. + +Required properties: +- compatible: Should be "mrvl,pxav2-mmc" or "mrvl,pxav3-mmc". + +Optional properties: +- mrvl,clk-delay-cycles: Specify a number of cycles to delay for tuning. + +Example: + +sdhci@d4280800 { + compatible = "mrvl,pxav3-mmc"; + reg = <0xd4280800 0x800>; + interrupts = <27>; + bus-width = <8>; + mrvl,clk-delay-cycles = <31>; + non-removable; +};
drivers/mmc/host/sdhci-pxav2.c +54 -0
84 lines not on this page · raw message
drivers/mmc/host/sdhci-pxav3.c +52 -0
82 lines not on this page · raw message
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Haojian Zhuang
Acked-byQuoted 6 lines · Chris Ball
Tested on an OLPC XO-1.75. (MMP2, sdhci-pxav3,
CONFIG_MACH_MMP2_DT=y)Signed-off-by Chris Ball <[email protected]>---
Changes since v1:
Quoted 8 lines
* Add
CONFIG_OFguard aroundof_match_table, per Zhangfei.
* Fix function prototypes under !CONFIG_OF, per Zhangfei.
* Change "clk-delay-cycles" to "mrvl,clk-delay-cycles", per Haojian..../devicetree/bindings/mmc/sdhci-pxa.txt | 21 ++++++++
drivers/mmc/host/sdhci-pxav2.c| 54 ++++++++++++++++++++drivers/mmc/host/sdhci-pxav3.c| 52 +++++++++++++++++++3 files changed, 127 insertions(+)