Add DT support for davinci_mmc driver
Subsystems (5)
v3 cover Add DT support for davinci_mmc driver
Patch set adds DT support for davinci_mmc driver and is verified on da850-evm without card_detect/write_protect and EDMA support.
This patch depends on below patches under review:
1) Patch "drivers/pinctrl: grab default handles from device core"
http://www.gossamer-threads.com/lists/linux/kernel/1664015?page=last
2) Patch "mmc: davinci: allow driver to work without DMA resource"
http://www.mail-archive.com/linux-mmc at vger.kernel.org/msg18771.html
Applies on top of v3.9/dt-2 branch of linux_davinci tree:git://gitorious.org/linux-davinci/linux-davinci.git
Since v2:
Modified the default value for bus-width and skipping the property specifications for highspeed card capabilties for now. Re-ordered patch 2 and 3. Since v1:
Modified the DT parse function to take default values, updated DT binding documentation accordingly.
Manjunathappa, Prakash (3):
mmc: davinci_mmc: add DT support
ARM: davinci: da850: add mmc DT entries
ARM: davinci: da850: override mmc DT node device name
.../devicetree/bindings/mmc/davinci_mmc.txt | 25 ++++++++ arch/arm/boot/dts/da850-evm.dts | 7 ++ arch/arm/boot/dts/da850.dtsi | 14 ++++ arch/arm/mach-davinci/da8xx-dt.c | 2 + drivers/mmc/host/davinci_mmc.c | 65 +++++++++++++++++++- 5 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/davinci_mmc.txt
Signature · 1 line
1.7.4.1
PATCH v3 1/3 mmc: davinci_mmc: add DT support
Adds device tree support for davinci_mmc. Also add binding documentation. As of now in non-dma PIO mode and without GPIO card_detect/write_protect option because of dependencies on EDMA and GPIO module DT support.
---
Since v2:
Modified the default value for bus-width and removed the support for highspeed card capabilties for now.
Since v1:
Modified DT parse function to take default values and accomodate controller version in compatible field.
.../devicetree/bindings/mmc/davinci_mmc.txt | 25 ++++++++ drivers/mmc/host/davinci_mmc.c | 65 +++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/davinci_mmc.txt
Documentation/devicetree/bindings/mmc/davinci_mmc.txt new file +25 -0
@@ -0,0 +1,25 @@ +* TI Highspeed MMC host controller for DaVinci + +The Highspeed MMC Host Controller on TI DaVinci family +provides an interface for MMC, SD and SDIO types of memory cards. + +This file documents the properties used by the davinci_mmc driver. + +Required properties: +- compatible: + Should be "ti,davinci-mmc-da830": for da830, da850, dm365 + Should be "ti,davinci-mmc-dm355": for dm355, dm644x + +Optional properties: +- bus-width: Number of data lines, can be <1>, <4>, or <8>, default <1> +- max-frequency: Maximum operating clock frequency, default 25MHz. + +Example: + mmc0: mmc@1c40000 { + compatible = "ti,davinci-mmc-da830", + reg = <0x40000 0x1000>; + interrupts = <16>; + status = "okay"; + bus-width = <4>; + max-frequency = <50000000>; + };
drivers/mmc/host/davinci_mmc.c +63 -2
91 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 1/3 mmc: davinci_mmc: add DT support
Hi Prakash,
I think this looks pretty good now :)
Thanks,
Mark.
Quoted 162 lines · Prakash
Adds device tree support for
davinci_mmc. Also add binding documentation. As of now in non-dma PIO mode and without GPIO card_detect/write_protect option because of dependencies on EDMA and GPIO module DT support.Signed-off-by Manjunathappa, Prakash <[email protected]>Cc linux-mmc at vger.kernel.orgCc linux-arm-kernel at lists.infradead.orgCc davinci-linux-open-source at linux.davincidsp.comCc devicetree-discuss at lists.ozlabs.orgCc cjb at laptop.orgCc Sekhar Nori <[email protected]>Cc mporter at ti.com---
Since v2:
Modified the default value for bus-width and removed the support for highspeed card capabilties for now.
Since v1:
Modified DT parse function to take default values and accomodate controller version in compatible field..../devicetree/bindings/mmc/davinci_mmc.txt | 25 ++++++++ drivers/mmc/host/davinci_mmc.c | 65 +++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/davinci_mmc.txtDocumentation/devicetree/bindings/mmc/davinci_mmc.txt new file +25
-0@@ -0,0 +1,25 @@ +* TI Highspeed MMC host controller for DaVinci + +The Highspeed MMC Host Controller on TI DaVinci family +provides an interface for MMC, SD and SDIO types of memory cards. + +This file documents the properties used by the davinci_mmc driver. + +Required properties: +- compatible: + Should be "ti,davinci-mmc-da830": for da830, da850, dm365 + Should be "ti,davinci-mmc-dm355": for dm355, dm644x + +Optional properties: +- bus-width: Number of data lines, can be <1>, <4>, or <8>, default <1> +- max-frequency: Maximum operating clock frequency, default 25MHz. + +Example: + mmc0: mmc at 1c40000 { + compatible = "ti,davinci-mmc-da830", + reg = <0x40000 0x1000>; + interrupts = <16>; + status = "okay"; + bus-width = <4>; + max-frequency = <50000000>; + };drivers/mmc/host/davinci_mmc.c +63
-2@@ -34,6 +34,8 @@#include <linux/dma-mapping.h> #include <linux/edma.h> #include <linux/mmc/mmc.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_data/mmc-davinci.h> @@ -1157,16 +1159,74 @@ static void __init init_mmcsd_host(struct mmc_davinci_host *host)mmc_davinci_reset_ctrl (host,0 ); } -static int __init davinci_mmcsd_probe (struct platform_device *pdev) +static const struct of_device_id davinci_mmc_dt_ids[] = { + { + .compatible ="ti,davinci-mmc-dm355" , + .data = (void *)MMC_CTLR_VERSION_1 , + }, + { + .compatible ="ti,davinci-mmc-da830" , + .data = (void *)MMC_CTLR_VERSION_2 , + }, + {}, +}; +MODULE_DEVICE_TABLE (of, davinci_mmc_dt_ids); + +static struct davinci_mmc_config + *mmc_parse_pdata (struct platform_device *pdev) { +struct device_node *np;struct davinci_mmc_config *pdata = pdev->dev.platform_data; +const struct of_device_id *match = +of_match_device (of_match_ptr (davinci_mmc_dt_ids), &pdev->dev); +u32 data; + + np = pdev->dev.of_node; +if (!np) +return pdata; + + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) { +dev_err (&pdev->dev,"Failed to allocate memory for struct davinci_mmc_config\n" ); + goto nodata; + } + +if (match->data) + pdata->version = (u8)((int )match->data); + +of_property_read_u32 (np,"max-frequency" , &pdata->max_freq); +if (!pdata->max_freq) +dev_info (&pdev->dev,"'max-frequency' property not specified, defaulting to 25MHz\n" ); + +of_property_read_u32 (np,"bus-width" , &data); +switch (data) { +case 1 : +case 4 : +case 8 : + pdata->wires = data; +break ; +default : + pdata->wires =1 ; +dev_info (&pdev->dev,"Unsupported buswidth, defaulting to 1 bit\n" ); + } +nodata: +return pdata; +} + +static int __init davinci_mmcsd_probe (struct platform_device *pdev) +{ +struct davinci_mmc_config *pdata =NULL ;struct mmc_davinci_host *host =NULL ;struct mmc_host *mmc =NULL ;struct resource *r, *mem =NULL ;int ret =0 , irq =0 ;size_t mem_size; -/* REVISIT: when we're fully converted, fail if pdata is NULL */ + pdata =mmc_parse_pdata (pdev); +if (pdata ==NULL ) { +dev_err (&pdev->dev,"Can not get platform data\n" ); +return -ENOENT ; + } ret = -ENODEV ; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -1408,6 +1468,7 @@ static struct platform_driver davinci_mmcsd_driver = { .name = "davinci_mmc", .owner = THIS_MODULE, .pm = davinci_mmcsd_pm_ops, + .of_match_table = of_match_ptr(davinci_mmc_dt_ids), }, .remove = __exit_p(davinci_mmcsd_remove), };Signature · 6 lines
1.7.4.1 _______________________________________________ devicetree-discuss mailing list devicetree-discuss at lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
PATCH v3 1/3 mmc: davinci_mmc: add DT support
Hi Mark,
Quoted 6 lines · Mark Rutland
Hi Prakash,
I think this looks pretty good now :)
Reviewed-by Mark Rutland <[email protected]>
Thanks for inputs, I will add your Reviewed-by for future versions of this patch.
Regards,
Prakash
Quoted 168 lines
Thanks,
Mark.Quoted 162 lines · Prakash
Adds device tree support for
davinci_mmc. Also add binding documentation. As of now in non-dma PIO mode and without GPIO card_detect/write_protect option because of dependencies on EDMA and GPIO module DT support.Signed-off-by Manjunathappa, Prakash <[email protected]>Cc linux-mmc at vger.kernel.orgCc linux-arm-kernel at lists.infradead.orgCc davinci-linux-open-source at linux.davincidsp.comCc devicetree-discuss at lists.ozlabs.orgCc cjb at laptop.orgCc Sekhar Nori <[email protected]>Cc mporter at ti.com---
Since v2:
Modified the default value for bus-width and removed the support for highspeed card capabilties for now.
Since v1:
Modified DT parse function to take default values and accomodate controller version in compatible field..../devicetree/bindings/mmc/davinci_mmc.txt | 25 ++++++++ drivers/mmc/host/davinci_mmc.c | 65 +++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/davinci_mmc.txtDocumentation/devicetree/bindings/mmc/davinci_mmc.txt new file +25
-0@@ -0,0 +1,25 @@ +* TI Highspeed MMC host controller for DaVinci + +The Highspeed MMC Host Controller on TI DaVinci family +provides an interface for MMC, SD and SDIO types of memory cards. + +This file documents the properties used by the davinci_mmc driver. + +Required properties: +- compatible: + Should be "ti,davinci-mmc-da830": for da830, da850, dm365 + Should be "ti,davinci-mmc-dm355": for dm355, dm644x + +Optional properties: +- bus-width: Number of data lines, can be <1>, <4>, or <8>, default <1> +- max-frequency: Maximum operating clock frequency, default 25MHz. + +Example: + mmc0: mmc at 1c40000 { + compatible = "ti,davinci-mmc-da830", + reg = <0x40000 0x1000>; + interrupts = <16>; + status = "okay"; + bus-width = <4>; + max-frequency = <50000000>; + };drivers/mmc/host/davinci_mmc.c +63
-2@@ -34,6 +34,8 @@#include <linux/dma-mapping.h> #include <linux/edma.h> #include <linux/mmc/mmc.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/platform_data/mmc-davinci.h> @@ -1157,16 +1159,74 @@ static void __init init_mmcsd_host(struct mmc_davinci_host *host)mmc_davinci_reset_ctrl (host,0 ); } -static int __init davinci_mmcsd_probe (struct platform_device *pdev) +static const struct of_device_id davinci_mmc_dt_ids[] = { + { + .compatible ="ti,davinci-mmc-dm355" , + .data = (void *)MMC_CTLR_VERSION_1 , + }, + { + .compatible ="ti,davinci-mmc-da830" , + .data = (void *)MMC_CTLR_VERSION_2 , + }, + {}, +}; +MODULE_DEVICE_TABLE (of, davinci_mmc_dt_ids); + +static struct davinci_mmc_config + *mmc_parse_pdata (struct platform_device *pdev) { +struct device_node *np;struct davinci_mmc_config *pdata = pdev->dev.platform_data; +const struct of_device_id *match = +of_match_device (of_match_ptr (davinci_mmc_dt_ids), &pdev->dev); +u32 data; + + np = pdev->dev.of_node; +if (!np) +return pdata; + + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) { +dev_err (&pdev->dev,"Failed to allocate memory for struct davinci_mmc_config\n" ); + goto nodata; + } + +if (match->data) + pdata->version = (u8)((int )match->data); + +of_property_read_u32 (np,"max-frequency" , &pdata->max_freq); +if (!pdata->max_freq) +dev_info (&pdev->dev,"'max-frequency' property not specified, defaulting to 25MHz\n" ); + +of_property_read_u32 (np,"bus-width" , &data); +switch (data) { +case 1 : +case 4 : +case 8 : + pdata->wires = data; +break ; +default : + pdata->wires =1 ; +dev_info (&pdev->dev,"Unsupported buswidth, defaulting to 1 bit\n" ); + } +nodata: +return pdata; +} + +static int __init davinci_mmcsd_probe (struct platform_device *pdev) +{ +struct davinci_mmc_config *pdata =NULL ;struct mmc_davinci_host *host =NULL ;struct mmc_host *mmc =NULL ;struct resource *r, *mem =NULL ;int ret =0 , irq =0 ;size_t mem_size; -/* REVISIT: when we're fully converted, fail if pdata is NULL */ + pdata =mmc_parse_pdata (pdev); +if (pdata ==NULL ) { +dev_err (&pdev->dev,"Can not get platform data\n" ); +return -ENOENT ; + } ret = -ENODEV ; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );@@ -1408,6 +1468,7 @@ static struct platform_driver davinci_mmcsd_driver = { .name = "davinci_mmc", .owner = THIS_MODULE, .pm = davinci_mmcsd_pm_ops, + .of_match_table = of_match_ptr(davinci_mmc_dt_ids), }, .remove = __exit_p(davinci_mmcsd_remove), };Signature · 6 lines
1.7.4.1 _______________________________________________ devicetree-discuss mailing list devicetree-discuss at lists.ozlabs.org https://lists.ozlabs.org/listinfo/devicetree-discuss
PATCH v3 2/3 ARM: davinci: da850: add mmc DT entries
In reply to Manjunathappa, PrakashAdd DT entry for MMC. Also add entry for pinmux information. Tested:
1) Without GPIO card detection and EDMA support as DT support for GPIO and EDMA are yet come.
2) By creating/deleting files and mounting/unmounting the partition.
---
Since v2:
Remove properties specifying for highspeed card capability. Since v1:
Removed bitfields for specifying the device capabilty and accomodate controller revision in compatible field.
arch/arm/boot/dts/da850-evm.dts | 7 +++++++ arch/arm/boot/dts/da850.dtsi | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/boot/dts/da850-evm.dts +7 -0
@@ -39,6 +39,13 @@ wdt: wdt@1c21000 { status = "okay"; }; + mmc0: mmc@1c40000 { + max-frequency = <50000000>; + bus-width = <4>; + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&mmc0_pins>; + }; }; nand_cs3@62000000 { status = "okay";
arch/arm/boot/dts/da850.dtsi +14 -0
@@ -67,6 +67,15 @@ 0x10 0x00002200 0x0000ff00 >; }; + mmc0_pins: pinmux_mmc_pins { + pinctrl-single,bits = < + /* MMCSD0_DAT[3] MMCSD0_DAT[2] + * MMCSD0_DAT[1] MMCSD0_DAT[0] + * MMCSD0_CMD MMCSD0_CLK + */ + 0x28 0x00222222 0x00ffffff + >; + }; }; serial0: serial@1c42000 { compatible = "ns16550a";
@@ -110,6 +119,11 @@ wdt: wdt@1c21000 { compatible = "ti,davinci-wdt"; reg = <0x21000 0x1000>; + }; + mmc0: mmc@1c40000 { + compatible = "ti,davinci-mmc-da830"; + reg = <0x40000 0x1000>; + interrupts = <16>; status = "disabled"; }; };
Signature · 1 line
1.7.4.1
PATCH v3 3/3 ARM: davinci: da850: override mmc DT node device name
In reply to Manjunathappa, PrakashPopulate OF_DEV_AUXDATA with desired device name expected by davinci_mmc driver. Without this clk_get of davinci_mmc DT driver fails.
---
Since v2:
Rebased on top of v3.9/dt-2 branch of linux_davinci and reordered this patch. Since v1:
No Change.
arch/arm/mach-davinci/da8xx-dt.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/da8xx-dt.c +2 -0
@@ -40,6 +40,8 @@ static void __init da8xx_init_irq(void)struct of_dev_auxdata da850_auxdata_lookup[]__initdata = {OF_DEV_AUXDATA ("ti,davinci-i2c" ,0x01c22000 ,"i2c_davinci.1" ,NULL ),OF_DEV_AUXDATA ("ti,davinci-wdt" ,0x01c21000 ,"watchdog" ,NULL ), +OF_DEV_AUXDATA ("ti,davinci-mmc-da830" ,0x01c40000 ,"davinci_mmc.0" , +NULL ), {} };
Signature · 1 line
1.7.4.1