atmel-mci device tree support
Subsystems (6)
cover atmel-mci device tree support
Hi,
This patch-set adds device tree support for atmel-mci.
Regards
Ludovic
.../devicetree/bindings/mmc/atmel-hsmci.txt | 55 +++++++++++++++ arch/arm/boot/dts/at91sam9g25ek.dts | 16 ++++ arch/arm/boot/dts/at91sam9x5.dtsi | 14 ++++ arch/arm/mach-at91/at91sam9x5.c | 2 + drivers/mmc/host/atmel-mci.c | 74 +++++++++++++++++++- 5 files changed, 158 insertions(+), 3 deletions(-)
PATCH 1/4 mmc: atmel-mci: add device tree support
From: Ludovic Desroches <[email protected]>
--- .../devicetree/bindings/mmc/atmel-hsmci.txt | 55 +++++++++++++++ drivers/mmc/host/atmel-mci.c | 74 +++++++++++++++++++- 2 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
Documentation/devicetree/bindings/mmc/atmel-hsmci.txt new file +55 -0
@@ -0,0 +1,55 @@ +* Atmel High Speed MultiMedia Card Interface + +This controller on atmel products provides an interface for MMC, SD and SDIO +types of memory cards. + +1) MCI node + +Required properties: +- compatible: no blank "atmel,hsmci" +- reg: should contain HSMCI registers location and length +- interrupts: should contain HSMCI interrupt number +- at least one slot node + +The node contains child nodes for each slot that the platform uses + +Example MCI node: + +mmc0: mmc@f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + + [ child node definitions...] +}; + +2) slot nodes + +Optional properties: +- bus-width: number of data lines connected to the controller +- cd-gpios: specify GPIOs for card detection +- cd-invert: invert the value of external card detect gpio line +- wp-gpios: specify GPIOs for write protection + +Example slot node: + +slot@0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; +}; + +Example full MCI node: +mmc0: mmc@f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + slot@0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; + }; + slot@1 { + bus-width = <4>; + }; +};
drivers/mmc/host/atmel-mci.c +71 -3
110 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 1/4 mmc: atmel-mci: add device tree support
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 187 lines
--- .../devicetree/bindings/mmc/atmel-hsmci.txt | 55 +++++++++++++++ drivers/mmc/host/atmel-mci.c | 74 +++++++++++++++++++- 2 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/atmel-hsmci.txtDocumentation/devicetree/bindings/mmc/atmel-hsmci.txt new file +55
-0@@ -0,0 +1,55 @@ +* Atmel High Speed MultiMedia Card Interface + +This controller on atmel products provides an interface for MMC, SD and SDIO +types of memory cards. + +1) MCI node + +Required properties: +- compatible: no blank "atmel,hsmci" +- reg: should contain HSMCI registers location and length +- interrupts: should contain HSMCI interrupt number +- at least one slot node + +The node contains child nodes for each slot that the platform uses + +Example MCI node: + +mmc0: mmc at f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + + [ child node definitions...] +}; + +2) slot nodes + +Optional properties: +- bus-width: number of data lines connected to the controller +- cd-gpios: specify GPIOs for card detection +- cd-invert: invert the value of external card detect gpio line +- wp-gpios: specify GPIOs for write protection + +Example slot node: + +slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; +}; + +Example full MCI node: +mmc0: mmc at f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; + }; + slot at 1 { + bus-width = <4>; + }; +};drivers/mmc/host/atmel-mci.c +71
-3@@ -19,6 +19,9 @@#include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> #include <linux/platform_device.h> #include <linux/scatterlist.h> #include <linux/seq_file.h> @@ -477,6 +480,54 @@ err:dev_err (&mmc->class_dev,"failed to initialize debugfs for slot\n" ); } +#if defined(CONFIG_OF ) +static const struct of_device_id atmci_dt_ids[] = { + { .compatible ="atmel,hsmci" }, + {/* sentinel */ } +}; + +MODULE_DEVICE_TABLE (of, atmci_dt_ids); + +static void __init +atmci_get_of_slots (struct device *dev,struct mci_platform_data *pdata) +{ +struct device_node *np = dev->of_node; +struct device_node *cnp; +unsigned int slot_nb =0 ; + +if (!np) +return ; + +for_each_child_of_node (np, cnp) { +if (slot_nb > (ATMCI_MAX_NR_SLOTS -1 )) { +dev_warn (dev,"can't have more than %d slots\n" , +ATMCI_MAX_NR_SLOTS ); +break ; + } +if (of_property_read_u32 (cnp,"bus-width" , + &pdata->slot[slot_nb].bus_width)) + pdata->slot[slot_nb].bus_width =1 ; + + pdata->slot[slot_nb].detect_pin = +of_get_named_gpio (cnp,"cd-gpios" ,0 ); + +if (of_find_property (cnp,"cd-invert" ,NULL )) + pdata->slot[slot_nb].detect_is_active_high = true; + + pdata->slot[slot_nb].wp_pin = +of_get_named_gpio (cnp,"wp-gpios" ,0 ); + + slot_nb++; + } +} +#else /* CONFIG_OF */ +static inline void +atmci_get_of_slots (struct device *dev,struct mci_platform_data *pdata) +{ +return ; +} +#endif +static inline unsigned int atmci_ns_to_clocks (struct atmel_mci *host,unsigned int ns) {@@ -1847,6 +1898,13 @@ static int __init atmci_init_slot(struct atmel_mci *host, slot->sdc_reg = sdc_reg; slot->sdio_irq = sdio_irq; +dev_dbg (&mmc->class_dev, +"slot[%u]: bus_width=%u, detect_pin=%d, " +"detect_is_active_high=%s, wp_pin=%d\n" , + id, slot_data->bus_width, slot_data->detect_pin, + slot_data->detect_is_active_high ?"true" :"false" , + slot_data->wp_pin); + mmc->ops = &atmci_ops; mmc->f_min =DIV_ROUND_UP (host->bus_hz,512 ); mmc->f_max = host->bus_hz /2 ;@@ -2047,9 +2105,17 @@ static int __init atmci_probe(struct platform_device *pdev) regs =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!regs)return -ENXIO ; - pdata = pdev->dev.platform_data; -if (!pdata) -return -ENXIO ; + +if (pdev->dev.of_node) { + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) +return -ENOMEM ; + }else { + pdata = pdev->dev.platform_data; +if (!pdata) +return -ENXIO ; + } + irq =platform_get_irq (pdev,0 );if (irq <0 )return irq;@@ -2109,6 +2175,7 @@ static int __init atmci_probe(struct platform_device *pdev)/* We need at least one slot to succeed */ nr_slots =0 ; ret = -ENODEV ; +atmci_get_of_slots (&pdev->dev, pdata);if (pdata->slot[0 ].bus_width) { ret =atmci_init_slot (host, &pdata->slot[0 ],0 ,ATMCI_SDCSEL_SLOT_A ,ATMCI_SDIOIRQA );@@ -2242,6 +2309,7 @@ static struct platform_driver atmci_driver = { .driver = { .name = "atmel_mci", .pm = ATMCI_PM_OPS, + .of_match_table = of_match_ptr(atmci_dt_ids), }, };
Signature · 1 line
Nicolas Ferre
PATCH 1/4 mmc: atmel-mci: add device tree support
Quoted 1 line · Nicolas Ferre
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
[...]
Quoted 61 lines
Quoted 61 lines
Documentation/devicetree/bindings/mmc/atmel-hsmci.txt new file +55
-0@@ -0,0 +1,55 @@ +* Atmel High Speed MultiMedia Card Interface + +This controller on atmel products provides an interface for MMC, SD and SDIO +types of memory cards. + +1) MCI node + +Required properties: +- compatible: no blank "atmel,hsmci" +- reg: should contain HSMCI registers location and length +- interrupts: should contain HSMCI interrupt number +- at least one slot node + +The node contains child nodes for each slot that the platform uses + +Example MCI node: + +mmc0: mmc at f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + + [ child node definitions...] +}; + +2) slot nodes + +Optional properties: +- bus-width: number of data lines connected to the controller +- cd-gpios: specify GPIOs for card detection +- cd-invert: invert the value of external card detect gpio line +- wp-gpios: specify GPIOs for write protection + +Example slot node: + +slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; +}; + +Example full MCI node: +mmc0: mmc at f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0> + cd-invert; + }; + slot at 1 { + bus-width = <4>; + }; +};
[...]
Quoted 24 lines
Quoted 24 lines
Documentation/devicetree/bindings/mmc/atmel-hsmci.txt new file +24
-0+static void __init +atmci_get_of_slots(struct device *dev, struct mci_platform_data *pdata) +{ + struct device_node *np = dev->of_node; + struct device_node *cnp; + unsigned int slot_nb = 0; + + if (!np) + return; + + for_each_child_of_node(np, cnp) { + if (slot_nb > (ATMCI_MAX_NR_SLOTS-1)) { + dev_warn(dev, "can't have more than %d slots\n", + ATMCI_MAX_NR_SLOTS); + break; + } + if (of_property_read_u32(cnp, "bus-width", + &pdata->slot[slot_nb].bus_width)) + pdata->slot[slot_nb].bus_width = 1; + + pdata->slot[slot_nb].detect_pin = + of_get_named_gpio(cnp, "cd-gpios", 0); + + if (of_find_property(cnp, "cd-invert", NULL))
Quoted 8 lines
Documentation/devicetree/bindings/mmc/atmel-hsmci.txt
Quoted 8 lines
Documentation/devicetree/bindings/mmc/atmel-hsmci.txt new file +8
-0+ pdata->slot[slot_nb].detect_is_active_high = true; + + pdata->slot[slot_nb].wp_pin = + of_get_named_gpio(cnp, "wp-gpios", 0); + + slot_nb++; + } +}
In fact this part of code is not correct. Each mci can have two slots: slot0 and slot1. If someone wants to use only slot1, I will fill only pdata->slot[0] that is incorrect because later in the driver there is:
if (pdata->slot[0].bus_width) {
ret = atmci_init_slot(host, &pdata->slot[0],
0, ATMCI_SDCSEL_SLOT_A, ATMCI_SDIOIRQA);
if (!ret)
nr_slots++;
}
if (pdata->slot[1].bus_width) {
ret = atmci_init_slot(host, &pdata->slot[1],
1, ATMCI_SDCSEL_SLOT_B, ATMCI_SDIOIRQB);
if (!ret)
nr_slots++;
}So what is the best solution to solve this issue?
- Adding a property slot id? I would like to use only existing bindings hoping we can have a generic binding for mmc.
- Using aliases?
aliases {
slot0 = &mmc-slot0;
}mmc0: mmc at f0008000 {
compatible = "atmel,hsmci";
reg = <0xf0008000 0x600>;
interrupts = <12 4>;
mmc-slot0: slot at 0 {
};
status = "disabled";
};- Using reg property as an index?
Thanks for your help.
Regards
Ludovic
PATCH 2/4 arm: at91: at91sam9x5 add mci clk_lookup
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
--- arch/arm/mach-at91/at91sam9x5.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/mach-at91/at91sam9x5.c +2 -0
@@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {CLKDEV_CON_DEV_ID ("t0_clk" ,"f800c000.timer" , &tcb0_clk),CLKDEV_CON_DEV_ID ("dma_clk" ,"ffffec00.dma-controller" , &dma0_clk),CLKDEV_CON_DEV_ID ("dma_clk" ,"ffffee00.dma-controller" , &dma1_clk), +CLKDEV_CON_DEV_ID ("mci_clk" ,"f0008000.mmc" , &mmc0_clk), +CLKDEV_CON_DEV_ID ("mci_clk" ,"f000c000.mmc" , &mmc1_clk),CLKDEV_CON_ID ("pioA" , &pioAB_clk),CLKDEV_CON_ID ("pioB" , &pioAB_clk), CLKDEV_CON_ID("pioC", &pioCD_clk),
Signature · 1 line
1.7.5.4
PATCH 2/4 arm: at91: at91sam9x5 add mci clk_lookup
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 17 lines
--- arch/arm/mach-at91/at91sam9x5.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)arch/arm/mach-at91/at91sam9x5.c +2
-0@@ -225,6 +225,8 @@ static struct clk_lookup periph_clocks_lookups[] = {CLKDEV_CON_DEV_ID ("t0_clk" ,"f800c000.timer" , &tcb0_clk),CLKDEV_CON_DEV_ID ("dma_clk" ,"ffffec00.dma-controller" , &dma0_clk),CLKDEV_CON_DEV_ID ("dma_clk" ,"ffffee00.dma-controller" , &dma1_clk), +CLKDEV_CON_DEV_ID ("mci_clk" ,"f0008000.mmc" , &mmc0_clk), +CLKDEV_CON_DEV_ID ("mci_clk" ,"f000c000.mmc" , &mmc1_clk),CLKDEV_CON_ID ("pioA" , &pioAB_clk),CLKDEV_CON_ID ("pioB" , &pioAB_clk), CLKDEV_CON_ID("pioC", &pioCD_clk),
Signature · 1 line
Nicolas Ferre
PATCH 3/4 arm: at91: dt: sam9x5 add mci support
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
--- arch/arm/boot/dts/at91sam9x5.dtsi | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/boot/dts/at91sam9x5.dtsi +14 -0
@@ -191,6 +191,20 @@ interrupts = <27 4>; status = "disabled"; }; + + mmc0: mmc@f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + status = "disabled"; + }; + + mmc1: mmc@f000c000 { + compatible = "atmel,hsmci"; + reg = <0xf000c000 0x600>; + interrupts = <26 4>; + status = "disabled"; + }; }; nand0: nand@40000000 {
Signature · 1 line
1.7.5.4
PATCH 3/4 arm: at91: dt: sam9x5 add mci support
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 29 lines
--- arch/arm/boot/dts/at91sam9x5.dtsi | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)arch/arm/boot/dts/at91sam9x5.dtsi +14
-0@@ -191,6 +191,20 @@ interrupts = <27 4>; status = "disabled"; }; + + mmc0: mmc at f0008000 { + compatible = "atmel,hsmci"; + reg = <0xf0008000 0x600>; + interrupts = <12 4>; + status = "disabled"; + }; + + mmc1: mmc at f000c000 { + compatible = "atmel,hsmci"; + reg = <0xf000c000 0x600>; + interrupts = <26 4>; + status = "disabled"; + }; }; nand0: nand at 40000000 {
Signature · 1 line
Nicolas Ferre
PATCH 4/4 arm: at91: dt: sam9g25ek add mci support
In reply to ludovic.desroches at atmel.comFrom: Ludovic Desroches <[email protected]>
--- arch/arm/boot/dts/at91sam9g25ek.dts | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/boot/dts/at91sam9g25ek.dts +16 -0
@@ -32,6 +32,22 @@ phy-mode = "rmii"; status = "okay"; }; + + mmc0: mmc@f0008000 { + status = "okay"; + slot@0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0>; + }; + }; + + mmc1: mmc@f000c000 { + status = "okay"; + slot@0 { + bus-width = <4>; + cd-gpios = <&pioD 14 0>; + }; + }; }; usb0: ohci@00600000 {
Signature · 1 line
1.7.5.4
PATCH 4/4 arm: at91: dt: sam9g25ek add mci support
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>
Quoted 31 lines
--- arch/arm/boot/dts/at91sam9g25ek.dts | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)arch/arm/boot/dts/at91sam9g25ek.dts +16
-0@@ -32,6 +32,22 @@ phy-mode = "rmii"; status = "okay"; }; + + mmc0: mmc at f0008000 { + status = "okay"; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0>; + }; + }; + + mmc1: mmc at f000c000 { + status = "okay"; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 14 0>; + }; + }; }; usb0: ohci at 00600000 {
Signature · 1 line
Nicolas Ferre
PATCH 4/4 arm: at91: dt: sam9g25ek add mci support
Quoted 6 lines · Nicolas Ferre
On 03/21/2012 07:03 PM, ludovic.desroches at atmel.com :
Quoted 3 lines
From: Ludovic Desroches <[email protected]>
Signed-off-by Ludovic Desroches <[email protected]>Signed-off-by Nicolas Ferre <[email protected]>
I think you really mean "Acked-by". It is only appropriate to add a "Signed-off-by" tag when you have actually picked up and either committed or reposted a patch. When replying to a patch on the mailing list and giving your okay, the correct tag is either "Acked-by" or "Reviewed-by" (The difference being that "Acked-by" infers that you have some authority over the areas touched by the patch).
See Documentation/SubmittingPatches
g.
Quoted 41 lines
Quoted 32 lines
--- arch/arm/boot/dts/at91sam9g25ek.dts | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)arch/arm/boot/dts/at91sam9g25ek.dts +16
-0@@ -32,6 +32,22 @@ phy-mode = "rmii"; status = "okay"; }; + + mmc0: mmc at f0008000 { + status = "okay"; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 15 0>; + }; + }; + + mmc1: mmc at f000c000 { + status = "okay"; + slot at 0 { + bus-width = <4>; + cd-gpios = <&pioD 14 0>; + }; + }; }; usb0: ohci at 00600000 {Signature · 6 lines
Nicolas Ferre _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies,Ltd.
cover atmel-mci device tree support
In reply to ludovic.desroches at atmel.comHi,
Quoted 3 lines · On Wed, Mar 21 2012, [email protected] wrote:
Hi,
This patch-set adds device tree support for atmel-mci.
Please can you resend after syncing up with Arnd's suggestions in:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/9216/focus=13659
(It looks like the main difference is just s/cd-invert;/cd-inverted;/.)
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
cover atmel-mci device tree support
Hi Chris,
Quoted 11 lines · Chris Ball
Hi,
Quoted 3 lines · ludovic.desroches at atmel.com
Hi,
This patch-set adds device tree support for atmel-mci.
Please can you resend after syncing up with Arnd's suggestions in:
http://thread.gmane.org/gmane.linux.kernel.samsung-soc/9216/focus=13659(It looks like the main difference is just s/cd-invert;/cd-inverted;/.)
I have already sent a v2 version. I will send the v3 version once a decision about bindings would be taken.
I think the cd-invert (or cd-inverted) property will be removed since we can get the information with gpio flags.
Quoted 8 lines
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Regards
Ludovic