Initial Device Tree system for Snowball
Subsystems (4)
PATCH 1/1 Initial Device Tree system for Snowball
From: Niklas Hernaeus <[email protected]>
This is the base system for using Device Tree for Snowball. The new boardfile is a slightly modified copy of the original board file, so new Device Tree stuff can simply be added and code removed, while functionality stays the same.
--- arch/arm/boot/dts/snowball.dts | 32 ++ arch/arm/mach-ux500/Kconfig | 17 +- arch/arm/mach-ux500/Makefile | 5 +- arch/arm/mach-ux500/board-mop500-dt.c | 729 +++++++++++++++++++++++++++++++ arch/arm/mach-ux500/include/mach/irqs.h | 2 +- 5 files changed, 779 insertions(+), 6 deletions(-) create mode 100644 arch/arm/boot/dts/snowball.dts create mode 100644 arch/arm/mach-ux500/board-mop500-dt.c
arch/arm/boot/dts/snowball.dts new file +32 -0
@@ -0,0 +1,32 @@ +/* + * Copyright 2011 ST-Ericsson AB + * + * 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 = "Calao Systems Snowball platform with device tree"; + compatible = "calaosystems,snowball-a9500"; + + #address-cells = <1>; + #size-cells = <1>; + + memory { + device_type = "memory"; + reg = <0x00000000 0x20000000>; + }; + + soc-u9500 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + }; +};
arch/arm/mach-ux500/Kconfig +13 -4
@@ -27,19 +27,22 @@ menu "Ux500 target platform (boards)" config MACH_U8500 bool "U8500 Development platform" depends on UX500_SOC_DB8500 + depends on !USE_OF select TPS6105X help Include support for the mop500 development platform. config MACH_HREFV60 - bool "U85000 Development platform, HREFv60 version" - depends on UX500_SOC_DB8500 - help - Include support for the HREFv60 new development platform. + bool "U85000 Development platform, HREFv60 version" + depends on UX500_SOC_DB8500 + depends on !USE_OF + help + Include support for the HREFv60 new development platform. config MACH_SNOWBALL bool "U8500 Snowball platform" depends on UX500_SOC_DB8500 + depends on !USE_OF select MACH_U8500 help Include support for the snowball development platform.
@@ -49,6 +52,12 @@ config MACH_U5500 depends on UX500_SOC_DB5500 help Include support for the U5500 development platform. +config MACH_UX500_DT + def_bool y if USE_OF + depends on UX500_SOC_DB8500 || UX500_SOC_DB5500 + +config MACH_MOP500 + def_bool y if MACH_U8500 || MACH_UX500_DT endmenu config UX500_DEBUG_UART
arch/arm/mach-ux500/Makefile +4 -1
@@ -7,7 +7,10 @@ obj-y := clock.o cpu.o devices.o devices-common.o \ obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o dma-db5500.o obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o -obj-$(CONFIG_MACH_U8500) += board-mop500.o board-mop500-sdi.o \ + +obj-$(CONFIG_MACH_UX500_DT) += board-mop500-dt.o +obj-$(CONFIG_MACH_U8500) += board-mop500.o +obj-$(CONFIG_MACH_MOP500) += board-mop500-sdi.o \ board-mop500-regulators.o \ board-mop500-uib.o board-mop500-stuib.o \ board-mop500-u8500uib.o \
arch/arm/mach-ux500/board-mop500-dt.c new file +729 -0
729 lines not on this page · raw message
arch/arm/mach-ux500/include/mach/irqs.h +1 -1
@@ -43,7 +43,7 @@/* This will be overridden by board-specific irq headers */ #define IRQ_BOARD_END IRQ_BOARD_START -#ifdef CONFIG_MACH_U8500 +#if defined(CONFIG_MACH_U8500 ) || defined(CONFIG_MACH_MOP500 )#include <mach/irqs-board-mop500.h> #endif
Signature · 1 line
1.7.5.4
PATCH 1/1 Initial Device Tree system for Snowball
Quoted 6 lines · Niklas Hernaeus
From: Niklas Hernaeus <[email protected]>
This is the base system for using Device Tree for Snowball. The new boardfile is a slightly modified copy of the original board file, so new Device Tree stuff can simply be added and code removed, while functionality stays the same.
duplicating the code is not a good idea
do the invert put the minimum in c and then add the rest slowly via DT
Best Regards,
J.
PATCH 1/1 Initial Device Tree system for Snowball
In reply to Niklas HernaeusQuoted 8 lines · Niklas Hernaeus
From: Niklas Hernaeus <[email protected]>
This is the base system for using Device Tree for Snowball. The new boardfile is a slightly modified copy of the original board file, so new Device Tree stuff can simply be added and code removed, while functionality stays the same.
Signed-off-by Niklas Hernaeus <[email protected]>
Hi Niklas,
Great to see this has finally worked.
As Jean-Christophe already commented, we should drastically limit the amount of code duplication between this platform and the one that is already there. I can see two ways out of here:
a) Make sure that all hardware that was working with the existing code still works with this one, and just replace it (or patch it to look like what you have), mandating the use of device tree blobs on u8500 right away. We should get there anyway over time, so we could just as well do it now.
b) keep using your patch as a work-in-progress copy of the existing code, but when we get to merge it into upstream make sure that any part of it that is just duplicated either gets replaced with a device node and associated properties, or calls the respective function from a common location.
In any case, I would suggest you remove the platform_device definitions for all devices and just leave the platform_data that you can pass using the auxdata mechanism.
Quoted 33 lines
arch/arm/mach-ux500/Kconfig +7
-4@@ -27,19 +27,22 @@ menu "Ux500 target platform (boards)" config MACH_U8500 bool "U8500 Development platform" depends on UX500_SOC_DB8500 + depends on !USE_OF select TPS6105X help Include support for the mop500 development platform. config MACH_HREFV60 - bool "U85000 Development platform, HREFv60 version" - depends on UX500_SOC_DB8500 - help - Include support for the HREFv60 new development platform. + bool "U85000 Development platform, HREFv60 version" + depends on UX500_SOC_DB8500 + depends on !USE_OF + help + Include support for the HREFv60 new development platform. config MACH_SNOWBALL bool "U8500 Snowball platform" depends on UX500_SOC_DB8500 + depends on !USE_OF select MACH_U8500 help Include support for the snowball development platform.@@ -49,6 +52,12 @@ config MACH_U5500 depends on UX500_SOC_DB5500
arch/arm/mach-ux500/Kconfig config MACH_U5500 · line 62
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +6
-0help Include support for the U5500 development platform. +config MACH_UX500_DT + def_bool y if USE_OF + depends on UX500_SOC_DB8500 || UX500_SOC_DB5500 + +config MACH_MOP500 + def_bool y if MACH_U8500 || MACH_UX500_DT endmenu
This change conflicts with some other patches that we have been discussing recently. I'd suggest rebasing your change on top of the others as soon as they are merged into arm-soc/next/fixes-non-critical.
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +10
-0+ +static struct gpio_led snowball_led_array[] = { + { + .name = "user_led", + .default_trigger = "none", + .gpio = 142, + }, +}; + +static struct gpio_led_platform_data snowball_led_data = {
arch/arm/mach-ux500/Kconfig config MACH_U5500
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +10
-0+ .leds = snowball_led_array, + .num_leds = ARRAY_SIZE(snowball_led_array), +}; + +static struct platform_device snowball_led_dev = { + .name = "leds-gpio", + .dev = { + .platform_data = &snowball_led_data, + }, +};
I would prefer if we could move those devices that have binding already into the device tree right away and leave only the ones that are missing in the initial merge of this.
gpio-leds has bindings according toDocumentation/devicetree/bindings/gpio/led.txt
Converting those should be straightforward as soon as the gpio node is converted. The same is true for gpio-keys.
Quoted 41 lines
arch/arm/mach-ux500/Kconfig +41
-0+static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { + .gpio_base = MOP500_AB8500_GPIO(0), + .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE, + /* config_reg is the initial configuration of ab8500 pins. + * The pins can be configured as GPIO or alt functions based + * on value present in GpioSel1 to GpioSel6 and AlternatFunction + * register. This is the array of 7 configuration settings. + * One has to compile time decide these settings. Below is the + * explanation of these setting + * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO + * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO + * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO + * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO + * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO + * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO + * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured + * as GPIO then this register selectes the alternate fucntions + */ + .config_reg = {0x00, 0x1E, 0x80, 0x01, + 0x7A, 0x00, 0x00}, +}; + +static struct smsc911x_platform_config snowball_sbnet_cfg = { + .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, + .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, + .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, + .shift = 1, +}; + +static struct resource sbnet_res[] = { + { + .name = "smsc911x-memory", + .start = (0x5000 << 16), + .end = (0x5000 << 16) + 0xffff, + .flags = IORESOURCE_MEM, + }, + { + .start = NOMADIK_GPIO_TO_IRQ(140), + .end = NOMADIK_GPIO_TO_IRQ(140), + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, + },
arch/arm/mach-ux500/Kconfig
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +10
-0+}; + +static struct platform_device snowball_sbnet_dev = { + .name = "smsc911x", + .num_resources = ARRAY_SIZE(sbnet_res), + .resource = sbnet_res, + .dev = { + .platform_data = &snowball_sbnet_cfg, + }, +};
This one does not have bindings yet, so let's leave it for now.
Quoted 16 lines
arch/arm/mach-ux500/Kconfig +16
-0+static struct ab8500_platform_data ab8500_platdata = { + .irq_base = MOP500_AB8500_IRQ_BASE, + .regulator_reg_init = ab8500_regulator_reg_init, + .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init), + .regulator = ab8500_regulators, + .num_regulator = ARRAY_SIZE(ab8500_regulators), + .gpio = &ab8500_gpio_pdata, +}; + +static struct resource ab8500_resources[] = { + [0] = { + .start = IRQ_DB8500_AB8500, + .end = IRQ_DB8500_AB8500, + .flags = IORESOURCE_IRQ + } +};
arch/arm/mach-ux500/Kconfig
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +10
-0+ +struct platform_device ab8500_device = { + .name = "ab8500-i2c", + .id = 0, + .dev = { + .platform_data = &ab8500_platdata, + }, + .num_resources = 1, + .resource = ab8500_resources, +};
Converting ab8500 to device tree is key here, because almost everything else is located below it. I'd suggest you use auxdata to replace the get the platform_data in unmodified as a start and then change the ab8500 mfd driver to scan its child buses.
arch/arm/mach-ux500/Kconfig
Quoted 9 lines
arch/arm/mach-ux500/Kconfig +9
-0+#ifdef CONFIG_STE_DMA40 +static struct stedma40_chan_cfg uart0_dma_cfg_rx = { + .mode = STEDMA40_MODE_LOGICAL, + .dir = STEDMA40_PERIPH_TO_MEM, + .src_dev_type = DB8500_DMA_DEV13_UART0_RX, + .dst_dev_type = STEDMA40_DEV_DST_MEMORY, + .src_info.data_width = STEDMA40_BYTE_WIDTH, + .dst_info.data_width = STEDMA40_BYTE_WIDTH, +};
It looks like the uart device could just as well work without DMA support, right? How about leaving the dma out for now, until we have bindings for it? That will also remove the need for platform_data in most of the uart devices.
Quoted 25 lines
arch/arm/mach-ux500/Kconfig +24
-0+static const char * snowball_dt_board_compat[] = { + "calaosystems,snowball-a9500", + NULL +}; +MACHINE_START(U8500, "ST-Ericsson MOP500 platform") + /* Maintainer: Srinidhi Kasagar <[email protected]> */ + .atag_offset = 0x100, + .map_io = u8500_map_io, + .init_irq = ux500_init_irq, + /* we re-use nomadik timer here */ + .timer = &ux500_timer, + .handle_irq = gic_handle_irq, + .init_machine = mop500_init_machine, +MACHINE_END + +MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+") + .atag_offset = 0x100, + .map_io = u8500_map_io, + .init_irq = ux500_init_irq, + .timer = &ux500_timer, + .handle_irq = gic_handle_irq, + .init_machine = hrefv60_init_machine, +MACHINE_END +
arch/arm/mach-ux500/Kconfig
Quoted 10 lines
arch/arm/mach-ux500/Kconfig +10
-0+DT_MACHINE_START(SNOWBALL, "Calao Systems Snowball platform") + .atag_offset = 0x100, + .map_io = u8500_map_io, + .init_irq = ux500_init_irq, + /* we re-use nomadik timer here */ + .timer = &ux500_timer, + .handle_irq = gic_handle_irq, + .init_machine = snowball_init_machine, + .dt_compat = snowball_dt_board_compat, +MACHINE_END
Here, you should really have only one DT_MACHINE_START for all three, and use a common init_machine function but a dt_compat list for all three.
Inside of the init_machine function, you can use of_machine_is_compatible() to find out which one you are on, and call the machine specific functions.
Arnd
PATCH 1/1 Initial Device Tree system for Snowball
In reply to Niklas HernaeusQuoted 61 lines · Niklas Hernaeus
From: Niklas Hernaeus <[email protected]>
This is the base system for using Device Tree for Snowball. The new boardfile is a slightly modified copy of the original board file, so new Device Tree stuff can simply be added and code removed, while functionality stays the same.
Signed-off-by Niklas Hernaeus <[email protected]>--- arch/arm/boot/dts/snowball.dts | 32 ++ arch/arm/mach-ux500/Kconfig | 17 +- arch/arm/mach-ux500/Makefile | 5 +- arch/arm/mach-ux500/board-mop500-dt.c | 729 +++++++++++++++++++++++++++++++ arch/arm/mach-ux500/include/mach/irqs.h | 2 +- 5 files changed, 779 insertions(+), 6 deletions(-) create mode 100644 arch/arm/boot/dts/snowball.dts create mode 100644 arch/arm/mach-ux500/board-mop500-dt.carch/arm/boot/dts/snowball.dts new file +32
-0@@ -0,0 +1,32 @@ +/* + * Copyright 2011 ST-Ericsson AB + * + * 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 = "Calao Systems Snowball platform with device tree"; + compatible = "calaosystems,snowball-a9500"; + + #address-cells = <1>; + #size-cells = <1>; + + memory { + device_type = "memory"; + reg = <0x00000000 0x20000000>; + }; + + soc-u9500 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "simple-bus"; + ranges; + }; +};arch/arm/mach-ux500/Kconfig +0
-0
arch/arm/mach-ux500/Kconfig menu "Ux500 target platform (boards)" · line 30
Quoted 4 lines
arch/arm/mach-ux500/Kconfig +1
-0@@ -27,19 +27,22 @@ menu "Ux500 target platform (boards)" config MACH_U8500 bool "U8500 Development platform" depends on UX500_SOC_DB8500 + depends on !USE_OF
Hi Niklas,
Don't make any configurations depend on !USE_OF. Turning on device tree support must not disable non-DT booting. This is a policy decision made a while ago. You'll need to ensure the code is structured so that the DT and non-DT code paths can co-exist.
arch/arm/mach-ux500/Kconfig menu "Ux500 target platform (boards)" · line 38
Quoted 12 lines
arch/arm/mach-ux500/Kconfig +3
-4select TPS6105X help Include support for the mop500 development platform. config MACH_HREFV60 - bool "U85000 Development platform, HREFv60 version" - depends on UX500_SOC_DB8500 - help - Include support for the HREFv60 new development platform. + bool "U85000 Development platform, HREFv60 version" + depends on UX500_SOC_DB8500 + depends on !USE_OF
Ditto here.
Quoted 21 lines
arch/arm/mach-ux500/Kconfig +9
-0+ help + Include support for the HREFv60 new development platform. config MACH_SNOWBALL bool "U8500 Snowball platform" depends on UX500_SOC_DB8500 + depends on !USE_OF select MACH_U8500 help Include support for the snowball development platform.@@ -49,6 +52,12 @@ config MACH_U5500 depends on UX500_SOC_DB5500 help Include support for the U5500 development platform. +config MACH_UX500_DT + def_bool y if USE_OF + depends on UX500_SOC_DB8500 || UX500_SOC_DB5500 + +config MACH_MOP500 + def_bool y if MACH_U8500 || MACH_UX500_DT endmenu
PATCH 1/1 Initial Device Tree system for Snowball
In reply to Niklas HernaeusQuoted 7 lines · Niklas Hernaeus
From: Niklas Hernaeus <[email protected]>
This is the base system for using Device Tree for Snowball. The new boardfile is a slightly modified copy of the original board file, so new Device Tree stuff can simply be added and code removed, while functionality stays the same.
I realized that this series is based on a version before Lee's patches to add the soc information, and things have changed quite a bit with that.
I've played a bit more with this and tried to merge the two, the result is a series in the testing/ux500/dt branch of arm-soc.git. I'm sure it's not actually all correct, but I've tried my best there and also added quite a bit of device tree source for illustration. Maybe the two of you can have a look there and see what you can make of it.
Arnd