From: Jason Liu r64343@freescale.com
This patchset adds Freescale i.mx51 device tree support. This is based on
git://git.secretlab.ca/git/linux-2.6 devicetree/test
This patch has been tested on MX51 babbage board and can boot up succesfully to linux console with DT enabled.
Grant, I think it's almost ready for you to merge it.
V5: - Add bidings for uart and fec - resolve s-o-b issue - move dt clock part to seperate file
V4: - Add Linaro sign off and copyrightt
V3: - prefix the property name with the vendor name as like: "fsl,has-rts-cts" and "fsl,irda-mode" - use the ttymxc0 as the console - add FEC support, nfs can be used now
Jason Liu (4): arm/dt: add basic mx51 device tree support arm/dt: add very basic dts file for babbage board serial/imx: parse from device tree support net/fec: add device tree matching support
.../devicetree/bindings/net/fsl-imx-fec.txt | 17 +++ .../bindings/tty/serial/fsl-imx-uart.txt | 19 +++ arch/arm/boot/dts/babbage.dts | 122 ++++++++++++++++++++ arch/arm/mach-mx5/Kconfig | 8 ++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-dt.c | 64 ++++++++++ arch/arm/mach-mx5/clock-dt.c | 52 +++++++++ arch/arm/plat-mxc/include/mach/common.h | 1 + drivers/net/fec.c | 17 +++ drivers/tty/serial/imx.c | 78 +++++++++++-- 10 files changed, 369 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/fsl-imx-fec.txt create mode 100644 Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt create mode 100644 arch/arm/boot/dts/babbage.dts create mode 100644 arch/arm/mach-mx5/board-dt.c create mode 100644 arch/arm/mach-mx5/clock-dt.c
Signed-off-by: Jason Liu jason.hui@linaro.org --- arch/arm/mach-mx5/Kconfig | 8 ++++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-dt.c | 64 +++++++++++++++++++++++++++++++ arch/arm/mach-mx5/clock-dt.c | 52 +++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/common.h | 1 + 5 files changed, 126 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig index de4fa99..6438f87 100644 --- a/arch/arm/mach-mx5/Kconfig +++ b/arch/arm/mach-mx5/Kconfig @@ -47,6 +47,14 @@ config MACH_MX51_BABBAGE u-boot. This includes specific configurations for the board and its peripherals.
+config MACH_MX51_DT + bool "Generic MX51 board (FDT support)" + select USE_OF + select SOC_IMX51 + help + Support for generic Freescale i.MX51 boards using Flattened Device + Tree. + config MACH_MX51_3DS bool "Support MX51PDK (3DS)" select SOC_IMX51 diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 0d43be9..bd4542d 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o +obj-$(CONFIG_MACH_MX51_DT) += board-dt.o clock-dt.o diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c new file mode 100644 index 0000000..62ca693 --- /dev/null +++ b/arch/arm/mach-mx5/board-dt.c @@ -0,0 +1,64 @@ +/* + * Copyright 2011 Linaro Ltd. + * Copyright 2011 Freescale Semiconductor, Inc. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include <linux/err.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/dma-mapping.h> +#include <linux/of_platform.h> +#include <linux/of_fdt.h> + +#include <mach/common.h> +#include <mach/hardware.h> +#include <mach/imx-uart.h> +#include <mach/iomux-mx51.h> + +#include <asm/irq.h> +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h> + +#include "devices.h" + +static struct of_device_id mx51_dt_match_table[] __initdata = { + { .compatible = "simple-bus", }, + {} +}; + +static void __init mx51_dt_board_init(void) +{ + of_platform_bus_probe(NULL, mx51_dt_match_table, NULL); +} + +static void __init mx51_dt_timer_init(void) +{ + mx51_clocks_init(32768, 24000000, 22579200, 0); + mx5_clk_dt_init(); +} + +static struct sys_timer mxc_timer = { + .init = mx51_dt_timer_init, +}; + +static const char *mx51_dt_board_compat[] = { + "fsl,mx51-babbage", + NULL +}; + +DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)") + .map_io = mx51_map_io, + .init_irq = mx51_init_irq, + .init_machine = mx51_dt_board_init, + .dt_compat = mx51_dt_board_compat, + .timer = &mxc_timer, +MACHINE_END diff --git a/arch/arm/mach-mx5/clock-dt.c b/arch/arm/mach-mx5/clock-dt.c new file mode 100644 index 0000000..9c04475 --- /dev/null +++ b/arch/arm/mach-mx5/clock-dt.c @@ -0,0 +1,52 @@ + +/* + * Copyright 2011 Linaro Ltd. + * Jason Liu jason.hui@linaro.org + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include <linux/err.h> +#include <linux/init.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_clk.h> + +static struct clk *mx5_dt_clk_get(struct device_node *np, + const char *output_id, void *data) +{ + return data; +} + +static __init void mx5_dt_scan_clks(void) +{ + struct device_node *node; + struct clk *clk; + const char *id; + int rc; + + for_each_compatible_node(node, NULL, "clock") { + id = of_get_property(node, "clock-outputs", NULL); + if (!id) + continue; + + clk = clk_get_sys(id, NULL); + if (IS_ERR(clk)) + continue; + + rc = of_clk_add_provider(node, mx5_dt_clk_get, clk); + if (rc) + pr_err("error adding fixed clk %s\n", node->name); + } +} + +void __init mx5_clk_dt_init(void) +{ + mx5_dt_scan_clks(); +} diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index aea2cd3..a28e84a 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -58,4 +58,5 @@ extern void mxc91231_arch_reset(int, const char *); extern void mxc91231_prepare_idle(void); extern void mx51_efikamx_reset(void); extern int mx53_revision(void); +extern void mx5_clk_dt_init(void); #endif
On Wed, Mar 16, 2011 at 11:51:38PM +0800, Jason Liu wrote:
Signed-off-by: Jason Liu jason.hui@linaro.org
arch/arm/mach-mx5/Kconfig | 8 ++++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-dt.c | 64 +++++++++++++++++++++++++++++++ arch/arm/mach-mx5/clock-dt.c | 52 +++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/common.h | 1 + 5 files changed, 126 insertions(+), 0 deletions(-)
I've picked up this series into my devicetree/test branch. I still have comments, but it has come a long way and I'm happy enough with it to start carrying it. Future patches can either build on top of this series, or completely replace it (your choice).
g.
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig index de4fa99..6438f87 100644 --- a/arch/arm/mach-mx5/Kconfig +++ b/arch/arm/mach-mx5/Kconfig @@ -47,6 +47,14 @@ config MACH_MX51_BABBAGE u-boot. This includes specific configurations for the board and its peripherals. +config MACH_MX51_DT
- bool "Generic MX51 board (FDT support)"
- select USE_OF
- select SOC_IMX51
- help
Support for generic Freescale i.MX51 boards using Flattened Device
Tree.
config MACH_MX51_3DS bool "Support MX51PDK (3DS)" select SOC_IMX51 diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 0d43be9..bd4542d 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile @@ -18,3 +18,4 @@ obj-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += board-cpuimx51sd.o obj-$(CONFIG_MACH_EUKREA_MBIMXSD51_BASEBOARD) += eukrea_mbimxsd-baseboard.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o +obj-$(CONFIG_MACH_MX51_DT) += board-dt.o clock-dt.o diff --git a/arch/arm/mach-mx5/board-dt.c b/arch/arm/mach-mx5/board-dt.c new file mode 100644 index 0000000..62ca693 --- /dev/null +++ b/arch/arm/mach-mx5/board-dt.c @@ -0,0 +1,64 @@ +/*
- Copyright 2011 Linaro Ltd.
- Copyright 2011 Freescale Semiconductor, Inc.
- The code contained herein is licensed under the GNU General Public
- License. You may obtain a copy of the GNU General Public License
- Version 2 or later at the following locations:
- */
+#include <linux/err.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/dma-mapping.h> +#include <linux/of_platform.h> +#include <linux/of_fdt.h>
+#include <mach/common.h> +#include <mach/hardware.h> +#include <mach/imx-uart.h> +#include <mach/iomux-mx51.h>
+#include <asm/irq.h> +#include <asm/setup.h> +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/mach/time.h>
+#include "devices.h"
+static struct of_device_id mx51_dt_match_table[] __initdata = {
- { .compatible = "simple-bus", },
- {}
+};
+static void __init mx51_dt_board_init(void) +{
- of_platform_bus_probe(NULL, mx51_dt_match_table, NULL);
+}
+static void __init mx51_dt_timer_init(void) +{
- mx51_clocks_init(32768, 24000000, 22579200, 0);
- mx5_clk_dt_init();
+}
+static struct sys_timer mxc_timer = {
- .init = mx51_dt_timer_init,
+};
+static const char *mx51_dt_board_compat[] = {
- "fsl,mx51-babbage",
- NULL
+};
+DT_MACHINE_START(MX51_DT, "Freescale MX51 (Flattened Device Tree)")
- .map_io = mx51_map_io,
- .init_irq = mx51_init_irq,
- .init_machine = mx51_dt_board_init,
- .dt_compat = mx51_dt_board_compat,
- .timer = &mxc_timer,
+MACHINE_END diff --git a/arch/arm/mach-mx5/clock-dt.c b/arch/arm/mach-mx5/clock-dt.c new file mode 100644 index 0000000..9c04475 --- /dev/null +++ b/arch/arm/mach-mx5/clock-dt.c @@ -0,0 +1,52 @@
+/*
- Copyright 2011 Linaro Ltd.
- Jason Liu jason.hui@linaro.org
- The code contained herein is licensed under the GNU General Public
- License. You may obtain a copy of the GNU General Public License
- Version 2 or later at the following locations:
- */
+#include <linux/err.h> +#include <linux/init.h> +#include <linux/clk.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_clk.h>
+static struct clk *mx5_dt_clk_get(struct device_node *np,
const char *output_id, void *data)
+{
- return data;
+}
+static __init void mx5_dt_scan_clks(void) +{
- struct device_node *node;
- struct clk *clk;
- const char *id;
- int rc;
- for_each_compatible_node(node, NULL, "clock") {
id = of_get_property(node, "clock-outputs", NULL);
if (!id)
continue;
clk = clk_get_sys(id, NULL);
if (IS_ERR(clk))
continue;
rc = of_clk_add_provider(node, mx5_dt_clk_get, clk);
if (rc)
pr_err("error adding fixed clk %s\n", node->name);
- }
+}
+void __init mx5_clk_dt_init(void) +{
- mx5_dt_scan_clks();
+} diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index aea2cd3..a28e84a 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -58,4 +58,5 @@ extern void mxc91231_arch_reset(int, const char *); extern void mxc91231_prepare_idle(void); extern void mx51_efikamx_reset(void); extern int mx53_revision(void); +extern void mx5_clk_dt_init(void);
#endif
1.7.1
On Thu, Mar 17, 2011 at 10:37:32AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:38PM +0800, Jason Liu wrote:
Signed-off-by: Jason Liu jason.hui@linaro.org
arch/arm/mach-mx5/Kconfig | 8 ++++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-dt.c | 64 +++++++++++++++++++++++++++++++ arch/arm/mach-mx5/clock-dt.c | 52 +++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/common.h | 1 + 5 files changed, 126 insertions(+), 0 deletions(-)
I've picked up this series into my devicetree/test branch. I still
Have you done that yet? I just checked and did not see it. I'm waiting for it to start the next spin of my patch sets.
have comments, but it has come a long way and I'm happy enough with it to start carrying it. Future patches can either build on top of this series, or completely replace it (your choice).
On Fri, Mar 18, 2011 at 10:19:19AM +0800, Shawn Guo wrote:
On Thu, Mar 17, 2011 at 10:37:32AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:38PM +0800, Jason Liu wrote:
Signed-off-by: Jason Liu jason.hui@linaro.org
arch/arm/mach-mx5/Kconfig | 8 ++++ arch/arm/mach-mx5/Makefile | 1 + arch/arm/mach-mx5/board-dt.c | 64 +++++++++++++++++++++++++++++++ arch/arm/mach-mx5/clock-dt.c | 52 +++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/common.h | 1 + 5 files changed, 126 insertions(+), 0 deletions(-)
I've picked up this series into my devicetree/test branch. I still
Have you done that yet? I just checked and did not see it. I'm waiting for it to start the next spin of my patch sets.
I just hadn't pushed it out. I've done so now. Sorry for the delay.
g.
Singed-off-by: Rob Herring robherring2@gmail.com Signed-off-by: Jason Liu jason.hui@linaro.org --- arch/arm/boot/dts/babbage.dts | 122 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/babbage.dts b/arch/arm/boot/dts/babbage.dts new file mode 100644 index 0000000..8f9b47c --- /dev/null +++ b/arch/arm/boot/dts/babbage.dts @@ -0,0 +1,122 @@ +/* + * Copyright 2011 Linaro Ltd. + * Copyright 2011 Freescale Semiconductor, Inc. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/dts-v1/; + +/ { + model = "Freescale i.MX51 Babbage"; + compatible = "fsl,mx51-babbage"; + #address-cells = <1>; + #size-cells = <1>; + #interrupt-cells = <1>; + interrupt-parent = <&tzic>; + + memory { + reg = <0x90000000 0x20000000>; + }; + + chosen { + bootargs = "console=ttymxc0,115200n8 debug earlyprintk ip=dhcp"; + }; + + soc { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + + tzic: tz-interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0xe0000000 0x1000>; + compatible = "fsl,imx51-tzic"; + }; + }; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + + uart0_clk: uart0 { + compatible = "clock"; + clock-outputs = "imx-uart.0"; + }; + + uart1_clk: uart1 { + compatible = "clock"; + clock-outputs = "imx-uart.1"; + }; + + uart2_clk: uart2 { + compatible = "clock"; + clock-outputs = "imx-uart.2"; + }; + + fec_clk: fec { + compatible = "clock"; + clock-outputs = "fec.0"; + }; + }; + + aips@73f00000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges = <0x0 0x73f00000 0x100000>; + + imx-uart@bc000 { + compatible = "fsl,imx51-uart"; + reg = <0xbc000 0x1000>; + interrupts = <0x1f>; + fsl,has-rts-cts; + uart-clock = <&uart0_clk>, "uart"; + }; + + imx-uart@c0000 { + compatible = "fsl,imx51-uart"; + reg = <0xc0000 0x1000>; + interrupts = <0x20>; + fsl,has-rts-cts; + uart-clock = <&uart1_clk>, "uart"; + }; + }; + + spba@70000000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges = <0x0 0x70000000 0x100000>; + + imx-uart@c000 { + compatible = "fsl,imx51-uart"; + reg = <0xc000 0x1000>; + interrupts = <0x21>; + fsl,has-rts-cts; + uart-clock = <&uart2_clk>, "uart"; + }; + }; + + aips@83f00000 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges = <0x0 0x83f00000 0x100000>; + + fec@ec000 { + compatible = "fsl,imx51-fec"; + reg = <0xec000 0x1000>; + interrupts = <0x57>; + fec_clk-clock = <&fec_clk>, "fec"; + }; + }; +};
On Wed, Mar 16, 2011 at 11:51:39PM +0800, Jason Liu wrote:
Singed-off-by: Rob Herring robherring2@gmail.com Signed-off-by: Jason Liu jason.hui@linaro.org
arch/arm/boot/dts/babbage.dts | 122 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/babbage.dts b/arch/arm/boot/dts/babbage.dts new file mode 100644 index 0000000..8f9b47c --- /dev/null +++ b/arch/arm/boot/dts/babbage.dts @@ -0,0 +1,122 @@ +/*
- Copyright 2011 Linaro Ltd.
- Copyright 2011 Freescale Semiconductor, Inc.
- The code contained herein is licensed under the GNU General Public
- License. You may obtain a copy of the GNU General Public License
- Version 2 or later at the following locations:
- */
+/dts-v1/;
+/ {
- model = "Freescale i.MX51 Babbage";
- compatible = "fsl,mx51-babbage";
- #address-cells = <1>;
- #size-cells = <1>;
- #interrupt-cells = <1>;
- interrupt-parent = <&tzic>;
- memory {
reg = <0x90000000 0x20000000>;
- };
- chosen {
bootargs = "console=ttymxc0,115200n8 debug earlyprintk ip=dhcp";
- };
- soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges;
tzic: tz-interrupt-controller {
#address-cells = <0>;
#interrupt-cells = <1>;
interrupt-controller;
reg = <0xe0000000 0x1000>;
compatible = "fsl,imx51-tzic";
};
- };
- clocks {
#address-cells = <1>;
#size-cells = <0>;
uart0_clk: uart0 {
compatible = "clock";
clock-outputs = "imx-uart.0";
};
uart1_clk: uart1 {
compatible = "clock";
clock-outputs = "imx-uart.1";
};
uart2_clk: uart2 {
compatible = "clock";
clock-outputs = "imx-uart.2";
};
fec_clk: fec {
compatible = "clock";
clock-outputs = "fec.0";
};
As previously discussed, 'compatible = "clock";' isn't a very good binding; but I won't say any more on this here since Shawn reworks this code in his series.
- };
- aips@73f00000 {
Since aips isn't addressable, and there is no 'reg' property in this node, the name can simply be 'aips' or 'aips1' (or whatever name is used in the imx reference manual). Same goes for the spba node below.
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x73f00000 0x100000>;
imx-uart@bc000 {
compatible = "fsl,imx51-uart";
reg = <0xbc000 0x1000>;
interrupts = <0x1f>;
fsl,has-rts-cts;
uart-clock = <&uart0_clk>, "uart";
};
imx-uart@c0000 {
compatible = "fsl,imx51-uart";
reg = <0xc0000 0x1000>;
interrupts = <0x20>;
fsl,has-rts-cts;
uart-clock = <&uart1_clk>, "uart";
};
- };
- spba@70000000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x70000000 0x100000>;
imx-uart@c000 {
compatible = "fsl,imx51-uart";
reg = <0xc000 0x1000>;
interrupts = <0x21>;
fsl,has-rts-cts;
uart-clock = <&uart2_clk>, "uart";
};
- };
- aips@83f00000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x83f00000 0x100000>;
fec@ec000 {
compatible = "fsl,imx51-fec";
reg = <0xec000 0x1000>;
interrupts = <0x57>;
fec_clk-clock = <&fec_clk>, "fec";
Unfortunately we're leaking Linux implementation details here by needing to use the name "fec_clk". This will require some more thought on the best way to handle (but I'm not asking you to change anything yet).
g.
On Thu, Mar 17, 2011 at 10:42:38AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:39PM +0800, Jason Liu wrote:
[...]
- aips@83f00000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x83f00000 0x100000>;
fec@ec000 {
compatible = "fsl,imx51-fec";
reg = <0xec000 0x1000>;
interrupts = <0x57>;
fec_clk-clock = <&fec_clk>, "fec";
Unfortunately we're leaking Linux implementation details here by needing to use the name "fec_clk". This will require some more thought on the best way to handle (but I'm not asking you to change anything yet).
This constraint comes from function of_clk_get in drivers/of/clock.c:
struct clk *of_clk_get(struct device *dev, const char *id) { [...] dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
snprintf(prop_name, 32, "%s-clock", id ? id : "bus"); prop = of_get_property(dev->of_node, prop_name, &sz); [...] }
The 'id' here is clk_lookup->con_id. If we choose to use some fixed prop name here, the name leaking Linux implementation like 'fec_clk' will not need to be there.
What about fixing the name as 'bus-clock' used by the current implementation, or 'module-clock', or anything you can think of better?
On Fri, Mar 18, 2011 at 09:49:17AM +0800, Shawn Guo wrote:
On Thu, Mar 17, 2011 at 10:42:38AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:39PM +0800, Jason Liu wrote:
[...]
- aips@83f00000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x83f00000 0x100000>;
fec@ec000 {
compatible = "fsl,imx51-fec";
reg = <0xec000 0x1000>;
interrupts = <0x57>;
fec_clk-clock = <&fec_clk>, "fec";
Unfortunately we're leaking Linux implementation details here by needing to use the name "fec_clk". This will require some more thought on the best way to handle (but I'm not asking you to change anything yet).
This constraint comes from function of_clk_get in drivers/of/clock.c:
struct clk *of_clk_get(struct device *dev, const char *id) { [...] dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
snprintf(prop_name, 32, "%s-clock", id ? id : "bus"); prop = of_get_property(dev->of_node, prop_name, &sz);
[...] }
The 'id' here is clk_lookup->con_id. If we choose to use some fixed prop name here, the name leaking Linux implementation like 'fec_clk' will not need to be there.
What about fixing the name as 'bus-clock' used by the current implementation, or 'module-clock', or anything you can think of better?
Yeah, I though about that, but I'm being very careful about hard coding anything in the core DT code because every platform seems to want something different here, or want a different set of clocks. I don't have a good solution for this yet.
g.
On Thu, Mar 17, 2011 at 11:43:34PM -0600, Grant Likely wrote:
On Fri, Mar 18, 2011 at 09:49:17AM +0800, Shawn Guo wrote:
On Thu, Mar 17, 2011 at 10:42:38AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:39PM +0800, Jason Liu wrote:
[...]
- aips@83f00000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x83f00000 0x100000>;
fec@ec000 {
compatible = "fsl,imx51-fec";
reg = <0xec000 0x1000>;
interrupts = <0x57>;
fec_clk-clock = <&fec_clk>, "fec";
Unfortunately we're leaking Linux implementation details here by needing to use the name "fec_clk". This will require some more thought on the best way to handle (but I'm not asking you to change anything yet).
This constraint comes from function of_clk_get in drivers/of/clock.c:
struct clk *of_clk_get(struct device *dev, const char *id) { [...] dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
snprintf(prop_name, 32, "%s-clock", id ? id : "bus"); prop = of_get_property(dev->of_node, prop_name, &sz);
[...] }
The 'id' here is clk_lookup->con_id. If we choose to use some fixed prop name here, the name leaking Linux implementation like 'fec_clk' will not need to be there.
What about fixing the name as 'bus-clock' used by the current implementation, or 'module-clock', or anything you can think of better?
Yeah, I though about that, but I'm being very careful about hard coding anything in the core DT code because every platform seems to want something different here, or want a different set of clocks. I don't have a good solution for this yet.
We are not hard coding anything but a property name here. We are hard coding property name everywhere in dt code, aren't we?
On Fri, Mar 18, 2011 at 03:54:32PM +0800, Shawn Guo wrote:
On Thu, Mar 17, 2011 at 11:43:34PM -0600, Grant Likely wrote:
On Fri, Mar 18, 2011 at 09:49:17AM +0800, Shawn Guo wrote:
On Thu, Mar 17, 2011 at 10:42:38AM -0600, Grant Likely wrote:
On Wed, Mar 16, 2011 at 11:51:39PM +0800, Jason Liu wrote:
[...]
- aips@83f00000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges = <0x0 0x83f00000 0x100000>;
fec@ec000 {
compatible = "fsl,imx51-fec";
reg = <0xec000 0x1000>;
interrupts = <0x57>;
fec_clk-clock = <&fec_clk>, "fec";
Unfortunately we're leaking Linux implementation details here by needing to use the name "fec_clk". This will require some more thought on the best way to handle (but I'm not asking you to change anything yet).
This constraint comes from function of_clk_get in drivers/of/clock.c:
struct clk *of_clk_get(struct device *dev, const char *id) { [...] dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
snprintf(prop_name, 32, "%s-clock", id ? id : "bus"); prop = of_get_property(dev->of_node, prop_name, &sz);
[...] }
The 'id' here is clk_lookup->con_id. If we choose to use some fixed prop name here, the name leaking Linux implementation like 'fec_clk' will not need to be there.
What about fixing the name as 'bus-clock' used by the current implementation, or 'module-clock', or anything you can think of better?
Yeah, I though about that, but I'm being very careful about hard coding anything in the core DT code because every platform seems to want something different here, or want a different set of clocks. I don't have a good solution for this yet.
We are not hard coding anything but a property name here. We are hard coding property name everywhere in dt code, aren't we?
In this case, each platform seems to have a different naming conventions for the set of clocks, and a different number of clocks. I'm not willing to hard code the translations until I've got a better understanding of the different needs between platforms.
What I might do is allow platform code to supply the core code with a clock name translation table which might solve the problem nicely.
g.
Signed-off-by: Jeremy Kerr jeremy.kerr@canonical.com Signed-off-by: Jason Liu jason.hui@linaro.org --- .../bindings/tty/serial/fsl-imx-uart.txt | 19 +++++ drivers/tty/serial/imx.c | 78 +++++++++++++++++--- 2 files changed, 87 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt new file mode 100644 index 0000000..b7ece32 --- /dev/null +++ b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt @@ -0,0 +1,19 @@ +* UART (Universal Asynchronous Receiver/Transmitter) + +Required properties: +- compatible : "fsl,imx51-uart". +- reg : Offset and length of the register set for the device. +- interrupts : should contain uart interrupt. +- fsl,has-rts-cts : indicate it has rts-cts. +- uart-clock : the uart clock input information. + +Example: + +imx-uart@bc000 { + compatible = "fsl,imx51-uart"; + reg = <0xbc000 0x1000>; + interrupts = <0x1f>; + fsl,has-rts-cts; + uart-clock = <&uart0_clk>, "uart"; +}; + diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index dfcf4b1..568550d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -47,6 +47,8 @@ #include <linux/delay.h> #include <linux/rational.h> #include <linux/slab.h> +#include <linux/of.h> +#include <linux/of_address.h>
#include <asm/io.h> #include <asm/irq.h> @@ -1224,6 +1226,53 @@ static int serial_imx_resume(struct platform_device *dev) return 0; }
+#ifdef CONFIG_OF +static int serial_imx_probe_dt(struct imx_port *sport, + struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + static int line; + + if (!node) + return -ENODEV; + + if (of_get_property(node, "fsl,has-rts-cts", NULL)) + sport->have_rtscts = 1; + + if (of_get_property(node, "fsl,irda-mode", NULL)) + sport->use_irda = 1; + + sport->port.line = line++; + + return 0; +} +#else +static int serial_imx_probe_dt(struct imx_port *sport, + struct platform_device *pdev) +{ + return -ENODEV; +} +#endif + +static int serial_imx_probe_pdata(struct imx_port *sport, + struct platform_device *pdev) +{ + struct imxuart_platform_data *pdata = pdev->dev.platform_data; + + if (!pdata) + return 0; + + if (pdata->flags & IMXUART_HAVE_RTSCTS) + sport->have_rtscts = 1; + +#ifdef CONFIG_IRDA + if (pdata->flags & IMXUART_IRDA) + sport->use_irda = 1; +#endif + sport->port.line = pdev->id; + + return 0; +} static int serial_imx_probe(struct platform_device *pdev) { struct imx_port *sport; @@ -1236,6 +1285,12 @@ static int serial_imx_probe(struct platform_device *pdev) if (!sport) return -ENOMEM;
+ ret = serial_imx_probe_dt(sport, pdev); + if (ret == -ENODEV) + ret = serial_imx_probe_pdata(sport, pdev); + if (ret) + goto free; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { ret = -ENODEV; @@ -1260,7 +1315,6 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.fifosize = 32; sport->port.ops = &imx_pops; sport->port.flags = UPF_BOOT_AUTOCONF; - sport->port.line = pdev->id; init_timer(&sport->timer); sport->timer.function = imx_timeout; sport->timer.data = (unsigned long)sport; @@ -1274,17 +1328,13 @@ static int serial_imx_probe(struct platform_device *pdev)
sport->port.uartclk = clk_get_rate(sport->clk);
- imx_ports[pdev->id] = sport; + if (imx_ports[sport->port.line]) { + ret = -EBUSY; + goto clkput; + } + imx_ports[sport->port.line] = sport;
pdata = pdev->dev.platform_data; - if (pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) - sport->have_rtscts = 1; - -#ifdef CONFIG_IRDA - if (pdata && (pdata->flags & IMXUART_IRDA)) - sport->use_irda = 1; -#endif - if (pdata && pdata->init) { ret = pdata->init(pdev); if (ret) @@ -1336,6 +1386,11 @@ static int serial_imx_remove(struct platform_device *pdev) return 0; }
+static struct of_device_id imx_uart_matches[] = { + { .compatible = "fsl,imx51-uart" }, + {}, +}; + static struct platform_driver serial_imx_driver = { .probe = serial_imx_probe, .remove = serial_imx_remove, @@ -1345,6 +1400,9 @@ static struct platform_driver serial_imx_driver = { .driver = { .name = "imx-uart", .owner = THIS_MODULE, +#if defined(CONFIG_OF) + .of_match_table = imx_uart_matches, +#endif }, };
On Wed, Mar 16, 2011 at 11:51:40PM +0800, Jason Liu wrote:
Signed-off-by: Jeremy Kerr jeremy.kerr@canonical.com Signed-off-by: Jason Liu jason.hui@linaro.org
.../bindings/tty/serial/fsl-imx-uart.txt | 19 +++++ drivers/tty/serial/imx.c | 78 +++++++++++++++++--- 2 files changed, 87 insertions(+), 10 deletions(-)
diff --git a/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt new file mode 100644 index 0000000..b7ece32 --- /dev/null +++ b/Documentation/devicetree/bindings/tty/serial/fsl-imx-uart.txt @@ -0,0 +1,19 @@ +* UART (Universal Asynchronous Receiver/Transmitter)
+Required properties: +- compatible : "fsl,imx51-uart". +- reg : Offset and length of the register set for the device. +- interrupts : should contain uart interrupt. +- fsl,has-rts-cts : indicate it has rts-cts. +- uart-clock : the uart clock input information.
+Example:
+imx-uart@bc000 {
- compatible = "fsl,imx51-uart";
- reg = <0xbc000 0x1000>;
- interrupts = <0x1f>;
- fsl,has-rts-cts;
- uart-clock = <&uart0_clk>, "uart";
+};
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index dfcf4b1..568550d 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -47,6 +47,8 @@ #include <linux/delay.h> #include <linux/rational.h> #include <linux/slab.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <asm/io.h> #include <asm/irq.h> @@ -1224,6 +1226,53 @@ static int serial_imx_resume(struct platform_device *dev) return 0; } +#ifdef CONFIG_OF +static int serial_imx_probe_dt(struct imx_port *sport,
struct platform_device *pdev)
+{
- struct device_node *node = pdev->dev.of_node;
- static int line;
- if (!node)
return -ENODEV;
- if (of_get_property(node, "fsl,has-rts-cts", NULL))
sport->have_rtscts = 1;
- if (of_get_property(node, "fsl,irda-mode", NULL))
sport->use_irda = 1;
- sport->port.line = line++;
- return 0;
+} +#else +static int serial_imx_probe_dt(struct imx_port *sport,
struct platform_device *pdev)
+{
- return -ENODEV;
+} +#endif
+static int serial_imx_probe_pdata(struct imx_port *sport,
struct platform_device *pdev)
+{
- struct imxuart_platform_data *pdata = pdev->dev.platform_data;
- if (!pdata)
return 0;
- if (pdata->flags & IMXUART_HAVE_RTSCTS)
sport->have_rtscts = 1;
+#ifdef CONFIG_IRDA
- if (pdata->flags & IMXUART_IRDA)
sport->use_irda = 1;
+#endif
- sport->port.line = pdev->id;
- return 0;
+} static int serial_imx_probe(struct platform_device *pdev) { struct imx_port *sport; @@ -1236,6 +1285,12 @@ static int serial_imx_probe(struct platform_device *pdev) if (!sport) return -ENOMEM;
- ret = serial_imx_probe_dt(sport, pdev);
- if (ret == -ENODEV)
ret = serial_imx_probe_pdata(sport, pdev);
- if (ret)
goto free;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { ret = -ENODEV;
@@ -1260,7 +1315,6 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.fifosize = 32; sport->port.ops = &imx_pops; sport->port.flags = UPF_BOOT_AUTOCONF;
- sport->port.line = pdev->id; init_timer(&sport->timer); sport->timer.function = imx_timeout; sport->timer.data = (unsigned long)sport;
@@ -1274,17 +1328,13 @@ static int serial_imx_probe(struct platform_device *pdev) sport->port.uartclk = clk_get_rate(sport->clk);
- imx_ports[pdev->id] = sport;
- if (imx_ports[sport->port.line]) {
ret = -EBUSY;
goto clkput;
- }
- imx_ports[sport->port.line] = sport;
pdata = pdev->dev.platform_data;
- if (pdata && (pdata->flags & IMXUART_HAVE_RTSCTS))
sport->have_rtscts = 1;
-#ifdef CONFIG_IRDA
- if (pdata && (pdata->flags & IMXUART_IRDA))
sport->use_irda = 1;
-#endif
- if (pdata && pdata->init) { ret = pdata->init(pdev); if (ret)
@@ -1336,6 +1386,11 @@ static int serial_imx_remove(struct platform_device *pdev) return 0; } +static struct of_device_id imx_uart_matches[] = {
- { .compatible = "fsl,imx51-uart" },
- {},
+};
static struct platform_driver serial_imx_driver = { .probe = serial_imx_probe, .remove = serial_imx_remove, @@ -1345,6 +1400,9 @@ static struct platform_driver serial_imx_driver = { .driver = { .name = "imx-uart", .owner = THIS_MODULE, +#if defined(CONFIG_OF)
.of_match_table = imx_uart_matches,
+#endif
This #if defined(CONFIG_OF) is no longer needed in my tree. I removed it when I committed this patch.
g.
}, }; -- 1.7.1
Signed-off-by: Jason Liu jason.hui@linaro.org --- .../devicetree/bindings/net/fsl-imx-fec.txt | 17 +++++++++++++++++ drivers/net/fec.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/fsl-imx-fec.txt b/Documentation/devicetree/bindings/net/fsl-imx-fec.txt new file mode 100644 index 0000000..cff97cf --- /dev/null +++ b/Documentation/devicetree/bindings/net/fsl-imx-fec.txt @@ -0,0 +1,17 @@ +* FEC (Fast Ethernet Controller) + +Required properties: +- compatible : "fsl,imx51-fec". +- reg : Offset and length of the register set for the device. +- interrupts : should contain uart interrupt. +- fec_clk-clock : the fec clock input information. + +Example: + +fec@ec000 { + compatible = "fsl,imx51-fec"; + reg = <0xec000 0x1000>; + interrupts = <0x57>; + fec_clk-clock = <&fec_clk>, "fec"; +} ; + diff --git a/drivers/net/fec.c b/drivers/net/fec.c index 2a71373..b6b7446 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -44,6 +44,8 @@ #include <linux/platform_device.h> #include <linux/phy.h> #include <linux/fec.h> +#include <linux/of.h> +#include <linux/of_device.h>
#include <asm/cacheflush.h>
@@ -77,6 +79,13 @@ static struct platform_device_id fec_devtype[] = { } };
+#ifdef CONFIG_OF +static const struct of_device_id fec_dt_ids[] = { + { .compatible = "fsl,imx51-fec", .data = &fec_devtype[0], }, + {}, +}; +#endif + static unsigned char macaddr[ETH_ALEN]; module_param_array(macaddr, byte, NULL, 0); MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address"); @@ -1366,6 +1375,11 @@ fec_probe(struct platform_device *pdev) struct net_device *ndev; int i, irq, ret = 0; struct resource *r; + const struct of_device_id *of_id; + + of_id = of_match_device(fec_dt_ids, &pdev->dev); + if (of_id) + pdev->id_entry = (struct platform_device_id *)of_id->data;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) @@ -1530,6 +1544,9 @@ static struct platform_driver fec_driver = { #ifdef CONFIG_PM .pm = &fec_pm_ops, #endif +#ifdef CONFIG_OF + .of_match_table = fec_dt_ids, +#endif }, .id_table = fec_devtype, .probe = fec_probe,