From a352d85adbe8ed0c5c8c69e3ea0ee1833b3ee27e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 3 Jan 2013 23:39:44 +0100 Subject: [PATCH 01/11] ARM: nomadik: move last custom calls to pinctrl The I2C pins were still set up using custom nmk_* calls, move these to use the pinctrl mapping table instead. There was also a remaining call to turn the Ethernet pin to GPIO, and this is now done implicitly by the GPIO-to-pinctrl range translation calls. Signed-off-by: Linus Walleij --- arch/arm/mach-nomadik/board-nhk8815.c | 10 +++++++++- arch/arm/mach-nomadik/i2c-8815nhk.c | 11 ----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c index aaed48d94374..72ec3fad2ba6 100644 --- a/arch/arm/mach-nomadik/board-nhk8815.c +++ b/arch/arm/mach-nomadik/board-nhk8815.c @@ -238,7 +238,6 @@ static int __init nhk8815_eth_init(void) int err; err = gpio_request(gpio_nr, "eth_irq"); - if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO); if (!err) err = gpio_direction_input(gpio_nr); if (err) pr_err("Error %i in %s\n", err, __func__); @@ -321,6 +320,15 @@ static struct pinctrl_map __initdata nhk8815_pinmap[] = { PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO111_H21", in_nopull), /* CD bias drive */ PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO112_J21", out_low), + /* I2C0 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO62_D3", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO63_D2", in_pullup), + /* I2C1 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO53_L4", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO54_L3", in_pullup), + /* I2C2 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO73_C21", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO74_C20", in_pullup), }; static void __init nhk8815_platform_init(void) diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c index 0c2f6628299a..f0e9e64f731a 100644 --- a/arch/arm/mach-nomadik/i2c-8815nhk.c +++ b/arch/arm/mach-nomadik/i2c-8815nhk.c @@ -4,7 +4,6 @@ #include #include #include -#include /* * There are two busses in the 8815NHK. @@ -57,18 +56,8 @@ static struct platform_device nhk8815_i2c_dev2 = { }, }; -static pin_cfg_t cpu8815_pins_i2c[] = { - PIN_CFG_INPUT(62, GPIO, PULLUP), - PIN_CFG_INPUT(63, GPIO, PULLUP), - PIN_CFG_INPUT(53, GPIO, PULLUP), - PIN_CFG_INPUT(54, GPIO, PULLUP), - PIN_CFG_INPUT(73, GPIO, PULLUP), - PIN_CFG_INPUT(74, GPIO, PULLUP), -}; - static int __init nhk8815_i2c_init(void) { - nmk_config_pins(cpu8815_pins_i2c, ARRAY_SIZE(cpu8815_pins_i2c)); platform_device_register(&nhk8815_i2c_dev0); platform_device_register(&nhk8815_i2c_dev1); platform_device_register(&nhk8815_i2c_dev2); From f8635abd38776a413d1e84c79353693b8ecf45c9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 5 Jan 2013 00:29:31 +0100 Subject: [PATCH 02/11] ARM: nomadik: initial devicetree support Support basic device tree boot on the Nomadik. Implement the support in the cpu file with the intent of deleting the board files later. At this stage IRQ controllers, system timer, l2x0 cache, UARTs and thus console boot is fully functional. Patch out the code adding devices by initcalls for now so as not to disturb the boot. Signed-off-by: Linus Walleij --- .../devicetree/bindings/arm/ste-nomadik.txt | 19 +++++ arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/ste-nomadik-s8815.dts | 20 +++++ arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 80 +++++++++++++++++++ arch/arm/mach-nomadik/board-nhk8815.c | 4 + arch/arm/mach-nomadik/cpu-8815.c | 78 +++++++++++++++++- arch/arm/mach-nomadik/cpu-8815.h | 1 + arch/arm/mach-nomadik/i2c-8815nhk.c | 5 ++ 8 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/arm/ste-nomadik.txt create mode 100644 arch/arm/boot/dts/ste-nomadik-s8815.dts create mode 100644 arch/arm/boot/dts/ste-nomadik-stn8815.dtsi diff --git a/Documentation/devicetree/bindings/arm/ste-nomadik.txt b/Documentation/devicetree/bindings/arm/ste-nomadik.txt new file mode 100644 index 000000000000..23f32bddebf9 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/ste-nomadik.txt @@ -0,0 +1,19 @@ +ST-Ericsson Nomadik Device Tree Bindings + +For various board the "board" node may contain specific properties +that pertain to this particular board, such as board-specific GPIOs. + +Boards with the Nomadik SoC include: + +S8815 "MiniKit" manufactured by Calao Systems: + +Required root node property: + +compatible="calaosystems,usb-s8815"; + +Required node: usb-s8815 + +Example: + +usb-s8815 { +}; diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index e44da40d984f..7bc5ba738041 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \ imx28-m28evk.dtb \ imx28-sps1.dtb \ imx28-tx28.dtb +dtb-$(CONFIG_ARCH_NOMADIK) += ste-nomadik-s8815.dtb dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \ omap3-beagle.dtb \ omap3-beagle-xm.dtb \ diff --git a/arch/arm/boot/dts/ste-nomadik-s8815.dts b/arch/arm/boot/dts/ste-nomadik-s8815.dts new file mode 100644 index 000000000000..97b7d1df5aaa --- /dev/null +++ b/arch/arm/boot/dts/ste-nomadik-s8815.dts @@ -0,0 +1,20 @@ +/* + * Device Tree for the ST-Ericsson Nomadik S8815 board + * Produced by Calao Systems + */ + +/dts-v1/; +/include/ "ste-nomadik-stn8815.dtsi" + +/ { + model = "Calao Systems USB-S8815"; + compatible = "calaosystems,usb-s8815"; + + chosen { + bootargs = "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk"; + }; + + /* Custom board node with GPIO pins to active etc */ + usb-s8815 { + }; +}; diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi new file mode 100644 index 000000000000..0a5b670430de --- /dev/null +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -0,0 +1,80 @@ +/* + * Device Tree for the ST-Ericsson Nomadik 8815 STn8815 SoC + */ +/include/ "skeleton.dtsi" + +/ { + #address-cells = <1>; + #size-cells = <1>; + + memory { + reg = <0x00000000 0x04000000>, + <0x08000000 0x04000000>; + }; + + L2: l2-cache { + compatible = "arm,l210-cache"; + reg = <0x10210000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <30>; + cache-unified; + cache-level = <2>; + }; + + mtu0 { + /* Nomadik system timer */ + reg = <0x101e2000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <4>; + }; + + mtu1 { + /* Secondary timer */ + reg = <0x101e3000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <5>; + }; + + amba { + compatible = "arm,amba-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + vica: intc@0x10140000 { + compatible = "arm,versatile-vic"; + interrupt-controller; + #interrupt-cells = <1>; + reg = <0x10140000 0x20>; + }; + + vicb: intc@0x10140020 { + compatible = "arm,versatile-vic"; + interrupt-controller; + #interrupt-cells = <1>; + reg = <0x10140020 0x20>; + }; + + uart0: uart@101fd000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x101fd000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <12>; + }; + + uart1: uart@101fb000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x101fb000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <17>; + }; + + uart2: uart@101f2000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x101f2000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <28>; + status = "disabled"; + }; + }; +}; diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c index 72ec3fad2ba6..d152d7bdf411 100644 --- a/arch/arm/mach-nomadik/board-nhk8815.c +++ b/arch/arm/mach-nomadik/board-nhk8815.c @@ -204,6 +204,10 @@ static int __init nhk8815_mmcsd_init(void) { int ret; + /* For e.g. devicetree boot */ + if (!machine_is_nomadik()) + return 0; + ret = gpio_request(112, "card detect bias"); if (ret) return ret; diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 351404673f6c..7c8e3487f4eb 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -25,13 +25,19 @@ #include #include #include -#include +#include #include #include +#include +#include +#include +#include #include #include +#include #include +#include #include #include @@ -160,3 +166,73 @@ void cpu8815_restart(char mode, const char *cmd) /* Write anything to Reset status register */ writel(1, src_rstsr); } + +#ifdef CONFIG_OF + +/* Initial value for SRC control register: all timers use MXTAL/8 source */ +#define SRC_CR_INIT_MASK 0x00007fff +#define SRC_CR_INIT_VAL 0x2aaa8000 + +static void __init cpu8815_timer_init_of(void) +{ + struct device_node *mtu; + void __iomem *base; + int irq; + u32 src_cr; + + /* We need this to be up now */ + nomadik_clk_init(); + + mtu = of_find_node_by_path("/mtu0"); + if (!mtu) + return; + base = of_iomap(mtu, 0); + if (WARN_ON(!base)) + return; + irq = irq_of_parse_and_map(mtu, 0); + + pr_info("Remapped MTU @ %p, irq: %d\n", base, irq); + + /* Configure timer sources in "system reset controller" ctrl reg */ + src_cr = readl(base); + src_cr &= SRC_CR_INIT_MASK; + src_cr |= SRC_CR_INIT_VAL; + writel(src_cr, base); + + nmdk_timer_init(base, irq); +} + +/* These are mostly to get the right device names for the clock lookups */ +static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART0_BASE, + "uart0", NULL), + OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART1_BASE, + "uart1", NULL), + { /* sentinel */ }, +}; + +static void __init cpu8815_init_of(void) +{ +#ifdef CONFIG_CACHE_L2X0 + /* At full speed latency must be >=2, so 0x249 in low bits */ + l2x0_of_init(0x00730249, 0xfe000fff); +#endif + of_platform_populate(NULL, of_default_bus_match_table, + cpu8815_auxdata_lookup, NULL); +} + +static const char * cpu8815_board_compat[] = { + "calaosystems,usb-s8815", + NULL, +}; + +DT_MACHINE_START(NOMADIK_DT, "Nomadik STn8815") + .map_io = cpu8815_map_io, + .init_irq = irqchip_init, + .init_time = cpu8815_timer_init_of, + .init_machine = cpu8815_init_of, + .restart = cpu8815_restart, + .dt_compat = cpu8815_board_compat, +MACHINE_END + +#endif diff --git a/arch/arm/mach-nomadik/cpu-8815.h b/arch/arm/mach-nomadik/cpu-8815.h index 71c21e8a11dc..d6c7830e4799 100644 --- a/arch/arm/mach-nomadik/cpu-8815.h +++ b/arch/arm/mach-nomadik/cpu-8815.h @@ -2,3 +2,4 @@ extern void cpu8815_map_io(void); extern void cpu8815_platform_init(void); extern void cpu8815_init_irq(void); extern void cpu8815_restart(char, const char *); +extern struct sys_timer cpu8815_timer; diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c index f0e9e64f731a..299ff5a687bc 100644 --- a/arch/arm/mach-nomadik/i2c-8815nhk.c +++ b/arch/arm/mach-nomadik/i2c-8815nhk.c @@ -4,6 +4,7 @@ #include #include #include +#include /* * There are two busses in the 8815NHK. @@ -58,6 +59,10 @@ static struct platform_device nhk8815_i2c_dev2 = { static int __init nhk8815_i2c_init(void) { + /* For e.g. devicetree boot */ + if (!machine_is_nomadik()) + return 0; + platform_device_register(&nhk8815_i2c_dev0); platform_device_register(&nhk8815_i2c_dev1); platform_device_register(&nhk8815_i2c_dev2); From 1b542757179675162865f2b5b5fdbcc8b9118f2a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 5 Jan 2013 01:00:59 +0100 Subject: [PATCH 03/11] ARM: nomadik: move pin maps to cpu file Move the pinctrl maps over to the CPU file and register them right before the pin controller itself. This way the pinmaps will also benefit the device tree boot. Signed-off-by: Linus Walleij --- arch/arm/mach-nomadik/board-nhk8815.c | 45 --------------------------- arch/arm/mach-nomadik/cpu-8815.c | 44 ++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c index d152d7bdf411..2f2c96bee7df 100644 --- a/arch/arm/mach-nomadik/board-nhk8815.c +++ b/arch/arm/mach-nomadik/board-nhk8815.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include @@ -293,51 +291,8 @@ static struct i2c_board_info __initdata nhk8815_i2c2_devices[] = { }, }; -static unsigned long out_low[] = { PIN_OUTPUT_LOW }; -static unsigned long out_high[] = { PIN_OUTPUT_HIGH }; -static unsigned long in_nopull[] = { PIN_INPUT_NOPULL }; -static unsigned long in_pullup[] = { PIN_INPUT_PULLUP }; - -static struct pinctrl_map __initdata nhk8815_pinmap[] = { - PIN_MAP_MUX_GROUP_DEFAULT("uart0", "pinctrl-stn8815", "u0_a_1", "u0"), - PIN_MAP_MUX_GROUP_DEFAULT("uart1", "pinctrl-stn8815", "u1_a_1", "u1"), - /* Hog in MMC/SD card mux */ - PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-stn8815", "mmcsd_a_1", "mmcsd"), - /* MCCLK */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO8_B10", out_low), - /* MCCMD */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO9_A10", in_pullup), - /* MCCMDDIR */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO10_C11", out_high), - /* MCDAT3-0 */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO11_B11", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO12_A11", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO13_C12", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO14_B12", in_pullup), - /* MCDAT0DIR */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO15_A12", out_high), - /* MCDAT31DIR */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO16_C13", out_high), - /* MCMSFBCLK */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO24_C15", in_pullup), - /* CD input GPIO */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO111_H21", in_nopull), - /* CD bias drive */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO112_J21", out_low), - /* I2C0 */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO62_D3", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO63_D2", in_pullup), - /* I2C1 */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO53_L4", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO54_L3", in_pullup), - /* I2C2 */ - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO73_C21", in_pullup), - PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO74_C20", in_pullup), -}; - static void __init nhk8815_platform_init(void) { - pinctrl_register_mappings(nhk8815_pinmap, ARRAY_SIZE(nhk8815_pinmap)); cpu8815_platform_init(); nhk8815_onenand_init(); platform_add_devices(nhk8815_platform_devices, diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 7c8e3487f4eb..0114d4f878a1 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,48 @@ void cpu8815_add_gpios(resource_size_t *base, int num, int irq, } } +static unsigned long out_low[] = { PIN_OUTPUT_LOW }; +static unsigned long out_high[] = { PIN_OUTPUT_HIGH }; +static unsigned long in_nopull[] = { PIN_INPUT_NOPULL }; +static unsigned long in_pullup[] = { PIN_INPUT_PULLUP }; + +static struct pinctrl_map __initdata nhk8815_pinmap[] = { + PIN_MAP_MUX_GROUP_DEFAULT("uart0", "pinctrl-stn8815", "u0_a_1", "u0"), + PIN_MAP_MUX_GROUP_DEFAULT("uart1", "pinctrl-stn8815", "u1_a_1", "u1"), + /* Hog in MMC/SD card mux */ + PIN_MAP_MUX_GROUP_HOG_DEFAULT("pinctrl-stn8815", "mmcsd_a_1", "mmcsd"), + /* MCCLK */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO8_B10", out_low), + /* MCCMD */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO9_A10", in_pullup), + /* MCCMDDIR */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO10_C11", out_high), + /* MCDAT3-0 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO11_B11", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO12_A11", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO13_C12", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO14_B12", in_pullup), + /* MCDAT0DIR */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO15_A12", out_high), + /* MCDAT31DIR */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO16_C13", out_high), + /* MCMSFBCLK */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO24_C15", in_pullup), + /* CD input GPIO */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO111_H21", in_nopull), + /* CD bias drive */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO112_J21", out_low), + /* I2C0 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO62_D3", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO63_D2", in_pullup), + /* I2C1 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO53_L4", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO54_L3", in_pullup), + /* I2C2 */ + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO73_C21", in_pullup), + PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO74_C20", in_pullup), +}; + static inline void cpu8815_add_pinctrl(struct device *parent, const char *name) { @@ -98,6 +141,7 @@ cpu8815_add_pinctrl(struct device *parent, const char *name) .id = -1, }; + pinctrl_register_mappings(nhk8815_pinmap, ARRAY_SIZE(nhk8815_pinmap)); platform_device_register_full(&pdevinfo); } From 27bda036d246ae417af348d7868f96d2da208ecc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 5 Jan 2013 10:38:57 +0100 Subject: [PATCH 04/11] ARM: nomadik: move remaining PrimeCells to device tree The two remaining PrimeCells, RNG and RTC, are migrated to the device tree for device tree boot. Signed-off-by: Linus Walleij --- arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 12 ++++++++++++ arch/arm/mach-nomadik/cpu-8815.c | 11 +++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index 0a5b670430de..88fb98f910cf 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -76,5 +76,17 @@ interrupts = <28>; status = "disabled"; }; + + rng: rng@101b0000 { + compatible = "arm,primecell"; + reg = <0x101b0000 0x1000>; + }; + + rtc: rtc@101e8000 { + compatible = "arm,pl031", "arm,primecell"; + reg = <0x101e8000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <10>; + }; }; }; diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 0114d4f878a1..8d071d2769b5 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -154,8 +155,10 @@ static int __init cpu8815_init(void) cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), IRQ_GPIO0, &pdata); cpu8815_add_pinctrl(NULL, "pinctrl-stn8815"); - amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); - amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); + if (machine_is_nomadik()) { + amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); + amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); + } return 0; } arch_initcall(cpu8815_init); @@ -252,6 +255,10 @@ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { "uart0", NULL), OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART1_BASE, "uart1", NULL), + OF_DEV_AUXDATA("arm,primecell", NOMADIK_RNG_BASE, + "rng", NULL), + OF_DEV_AUXDATA("arm,primecell", NOMADIK_RTC_BASE, + "rtc-pl031", NULL), { /* sentinel */ }, }; From ba785205502f9a03d4ee31bdc3a1228ba5465f00 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 5 Jan 2013 22:28:32 +0100 Subject: [PATCH 05/11] ARM: nomadik: add FSMC NAND This adds the FSMC NAND driver and flash partitions to the Nomadik device tree. The only compatible string accepted by this driver is currently "st,spear600-fsmc-nand" which is inappropriate for this system, so this patch adds the compatible value "stericsson,fsmc-nand" as well. Cc: linux-mtd@vger.kernel.org Cc: David Woodhouse Cc: Artem Bityutskiy Signed-off-by: Linus Walleij --- .../devicetree/bindings/mtd/fsmc-nand.txt | 2 +- arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 38 +++++++++++++++++++ arch/arm/mach-nomadik/cpu-8815.c | 15 ++++++++ drivers/mtd/nand/fsmc_nand.c | 1 + 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/fsmc-nand.txt b/Documentation/devicetree/bindings/mtd/fsmc-nand.txt index e3ea32e7de3e..2240ac09f6ba 100644 --- a/Documentation/devicetree/bindings/mtd/fsmc-nand.txt +++ b/Documentation/devicetree/bindings/mtd/fsmc-nand.txt @@ -1,7 +1,7 @@ * FSMC NAND Required properties: -- compatible : "st,spear600-fsmc-nand" +- compatible : "st,spear600-fsmc-nand", "stericsson,fsmc-nand" - reg : Address range of the mtd chip - reg-names: Should contain the reg names "fsmc_regs", "nand_data", "nand_addr" and "nand_cmd" diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index 88fb98f910cf..c73df370373b 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -35,6 +35,44 @@ interrupts = <5>; }; + /* A NAND flash of 128 MiB */ + fsmc: flash@40000000 { + compatible = "stericsson,fsmc-nand"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x10100000 0x1000>, /* FSMC Register*/ + <0x40000000 0x2000>, /* NAND Base DATA */ + <0x41000000 0x2000>, /* NAND Base ADDR */ + <0x40800000 0x2000>; /* NAND Base CMD */ + reg-names = "fsmc_regs", "nand_data", "nand_addr", "nand_cmd"; + status = "okay"; + + partition@0 { + label = "X-Loader(NAND)"; + reg = <0x0 0x40000>; + }; + partition@40000 { + label = "MemInit(NAND)"; + reg = <0x40000 0x40000>; + }; + partition@80000 { + label = "BootLoader(NAND)"; + reg = <0x80000 0x200000>; + }; + partition@280000 { + label = "Kernel zImage(NAND)"; + reg = <0x280000 0x300000>; + }; + partition@580000 { + label = "Root Filesystem(NAND)"; + reg = <0x580000 0x1600000>; + }; + partition@1b80000 { + label = "User Filesystem(NAND)"; + reg = <0x1b80000 0x6480000>; + }; + }; + amba { compatible = "arm,amba-bus"; #address-cells = <1>; diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 8d071d2769b5..a3894ca45bb8 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -249,6 +250,17 @@ static void __init cpu8815_timer_init_of(void) nmdk_timer_init(base, irq); } +static struct fsmc_nand_timings cpu8815_nand_timings = { + .thiz = 0, + .thold = 0x10, + .twait = 0x0A, + .tset = 0, +}; + +static struct fsmc_nand_platform_data cpu8815_nand_data = { + .nand_timings = &cpu8815_nand_timings, +}; + /* These are mostly to get the right device names for the clock lookups */ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART0_BASE, @@ -259,6 +271,9 @@ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { "rng", NULL), OF_DEV_AUXDATA("arm,primecell", NOMADIK_RTC_BASE, "rtc-pl031", NULL), + OF_DEV_AUXDATA("stericsson,fsmc-nand", NOMADIK_FSMC_BASE, + "fsmc-nand", &cpu8815_nand_data), + { /* sentinel */ }, }; diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c index 67e62d3d495c..61043a92c007 100644 --- a/drivers/mtd/nand/fsmc_nand.c +++ b/drivers/mtd/nand/fsmc_nand.c @@ -1218,6 +1218,7 @@ static SIMPLE_DEV_PM_OPS(fsmc_nand_pm_ops, fsmc_nand_suspend, fsmc_nand_resume); #ifdef CONFIG_OF static const struct of_device_id fsmc_nand_id_table[] = { { .compatible = "st,spear600-fsmc-nand" }, + { .compatible = "stericsson,fsmc-nand" }, {} }; MODULE_DEVICE_TABLE(of, fsmc_nand_id_table); From 6010d40320f8827441414886c46a7dbc6460439a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sat, 5 Jan 2013 23:10:09 +0100 Subject: [PATCH 06/11] ARM: nomadik: move GPIO and pinctrl to device tree This moves the instances of the Nomadik pin controller and the Nomadik GPIO blocks (also handled by the GPIO driver) over to the device tree. A new compatible string is added to the pin control driver in the process. Signed-off-by: Linus Walleij --- arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 52 ++++++++++++++++++++++ arch/arm/mach-nomadik/cpu-8815.c | 21 +++++++-- drivers/pinctrl/pinctrl-nomadik.c | 4 ++ 3 files changed, 73 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index c73df370373b..2c8aaa5c6ac4 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -35,6 +35,58 @@ interrupts = <5>; }; + gpio0: gpio@101e4000 { + compatible = "st,nomadik-gpio"; + reg = <0x101e4000 0x80>; + interrupt-parent = <&vica>; + interrupts = <6>; + interrupt-controller; + #interrupt-cells = <2>; + gpio-controller; + #gpio-cells = <2>; + gpio-bank = <0>; + }; + + gpio1: gpio@101e5000 { + compatible = "st,nomadik-gpio"; + reg = <0x101e5000 0x80>; + interrupt-parent = <&vica>; + interrupts = <7>; + interrupt-controller; + #interrupt-cells = <2>; + gpio-controller; + #gpio-cells = <2>; + gpio-bank = <1>; + }; + + gpio2: gpio@101e6000 { + compatible = "st,nomadik-gpio"; + reg = <0x101e6000 0x80>; + interrupt-parent = <&vica>; + interrupts = <8>; + interrupt-controller; + #interrupt-cells = <2>; + gpio-controller; + #gpio-cells = <2>; + gpio-bank = <2>; + }; + + gpio3: gpio@101e7000 { + compatible = "st,nomadik-gpio"; + reg = <0x101e7000 0x80>; + interrupt-parent = <&vica>; + interrupts = <9>; + interrupt-controller; + #interrupt-cells = <2>; + gpio-controller; + #gpio-cells = <2>; + gpio-bank = <3>; + }; + + pinctrl { + compatible = "stericsson,nmk-pinctrl-stn8815"; + }; + /* A NAND flash of 128 MiB */ fsmc: flash@40000000 { compatible = "stericsson,fsmc-nand"; diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index a3894ca45bb8..3a59459d6e9a 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -153,13 +153,15 @@ static int __init cpu8815_init(void) /* No custom data yet */ }; + /* For e.g. device tree boots */ + if (!machine_is_nomadik()) + return 0; + cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), IRQ_GPIO0, &pdata); cpu8815_add_pinctrl(NULL, "pinctrl-stn8815"); - if (machine_is_nomadik()) { - amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); - amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); - } + amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); + amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); return 0; } arch_initcall(cpu8815_init); @@ -263,6 +265,16 @@ static struct fsmc_nand_platform_data cpu8815_nand_data = { /* These are mostly to get the right device names for the clock lookups */ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO0_BASE, + "gpio.0", NULL), + OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO1_BASE, + "gpio.1", NULL), + OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO2_BASE, + "gpio.2", NULL), + OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO3_BASE, + "gpio.3", NULL), + OF_DEV_AUXDATA("stericsson,nmk-pinctrl-stn8815", 0, + "pinctrl-stn8815", NULL), OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART0_BASE, "uart0", NULL), OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART1_BASE, @@ -283,6 +295,7 @@ static void __init cpu8815_init_of(void) /* At full speed latency must be >=2, so 0x249 in low bits */ l2x0_of_init(0x00730249, 0xfe000fff); #endif + pinctrl_register_mappings(nhk8815_pinmap, ARRAY_SIZE(nhk8815_pinmap)); of_platform_populate(NULL, of_default_bus_match_table, cpu8815_auxdata_lookup, NULL); } diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 1bb16ffb4e41..ef21a662b974 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -1845,6 +1845,10 @@ static struct pinctrl_desc nmk_pinctrl_desc = { }; static const struct of_device_id nmk_pinctrl_match[] = { + { + .compatible = "stericsson,nmk-pinctrl-stn8815", + .data = (void *)PINCTRL_NMK_STN8815, + }, { .compatible = "stericsson,nmk_pinctrl", .data = (void *)PINCTRL_NMK_DB8500, From 2ad6e39867cf026e668a4c566725c2c65dbde406 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Jan 2013 01:02:42 +0100 Subject: [PATCH 07/11] ARM: nomadik: convert SMSC91x ethernet to device tree This converts the SMSC91x ethernet controller to use device tree. The existing solution from the board file, to request the GPIO triggering the ethernet IRQ from the board file is kept for the time being, but the GPIO number assignment is moved over to the device tree. Signed-off-by: Linus Walleij --- .../devicetree/bindings/arm/ste-nomadik.txt | 5 +++ arch/arm/boot/dts/ste-nomadik-s8815.dts | 6 ++++ arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 12 +++++++ arch/arm/mach-nomadik/board-nhk8815.c | 2 ++ arch/arm/mach-nomadik/cpu-8815.c | 34 +++++++++++++++++++ 5 files changed, 59 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/ste-nomadik.txt b/Documentation/devicetree/bindings/arm/ste-nomadik.txt index 23f32bddebf9..a97316073afe 100644 --- a/Documentation/devicetree/bindings/arm/ste-nomadik.txt +++ b/Documentation/devicetree/bindings/arm/ste-nomadik.txt @@ -16,4 +16,9 @@ Required node: usb-s8815 Example: usb-s8815 { + ethernet-gpio { + gpios = <&gpio3 19 0x1>; + interrupts = <19 0x1>; + interrupt-parent = <&gpio3>; + }; }; diff --git a/arch/arm/boot/dts/ste-nomadik-s8815.dts b/arch/arm/boot/dts/ste-nomadik-s8815.dts index 97b7d1df5aaa..cc777109f98f 100644 --- a/arch/arm/boot/dts/ste-nomadik-s8815.dts +++ b/arch/arm/boot/dts/ste-nomadik-s8815.dts @@ -16,5 +16,11 @@ /* Custom board node with GPIO pins to active etc */ usb-s8815 { + /* The S8815 is using this very GPIO pin for the SMSC91x IRQs */ + ethernet-gpio { + gpios = <&gpio3 19 0x1>; + interrupts = <19 0x1>; + interrupt-parent = <&gpio3>; + }; }; }; diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index 2c8aaa5c6ac4..f129425883a4 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -125,6 +125,18 @@ }; }; + external-bus@34000000 { + compatible = "simple-bus"; + reg = <0x34000000 0x1000000>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x34000000 0x1000000>; + ethernet@300 { + compatible = "smsc,lan91c111"; + reg = <0x300 0x0fd00>; + }; + }; + amba { compatible = "arm,amba-bus"; #address-cells = <1>; diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c index 2f2c96bee7df..e7b216cb6802 100644 --- a/arch/arm/mach-nomadik/board-nhk8815.c +++ b/arch/arm/mach-nomadik/board-nhk8815.c @@ -239,6 +239,8 @@ static int __init nhk8815_eth_init(void) int gpio_nr = 115; /* hardwired in the board */ int err; + if (!machine_is_nomadik()) + return 0; err = gpio_request(gpio_nr, "eth_irq"); if (!err) err = gpio_direction_input(gpio_nr); if (err) diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 3a59459d6e9a..339496f15138 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -31,9 +31,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -263,6 +265,38 @@ static struct fsmc_nand_platform_data cpu8815_nand_data = { .nand_timings = &cpu8815_nand_timings, }; +/* + * The SMSC911x IRQ is connected to a GPIO pin, but the driver expects + * to simply request an IRQ passed as a resource. So the GPIO pin needs + * to be requested by this hog and set as input. + */ +static int __init cpu8815_eth_init(void) +{ + struct device_node *eth; + int gpio, irq, err; + + eth = of_find_node_by_path("/usb-s8815/ethernet-gpio"); + if (!eth) { + pr_info("could not find any ethernet GPIO\n"); + return 0; + } + gpio = of_get_gpio(eth, 0); + err = gpio_request(gpio, "eth_irq"); + if (err) { + pr_info("failed to request ethernet GPIO\n"); + return -ENODEV; + } + err = gpio_direction_input(gpio); + if (err) { + pr_info("failed to set ethernet GPIO as input\n"); + return -ENODEV; + } + irq = gpio_to_irq(gpio); + pr_info("enabled USB-S8815 ethernet GPIO %d, IRQ %d\n", gpio, irq); + return 0; +} +device_initcall(cpu8815_eth_init); + /* These are mostly to get the right device names for the clock lookups */ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO0_BASE, From 4fd243c6c083ea159ae1a9f9a24198c350034439 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Jan 2013 01:47:29 +0100 Subject: [PATCH 08/11] ARM: nomadik: migrate MMC/SD card support to device tree This moves over the MMC/SD card support to the device tree probe path. The special GPIO to bias the card detect line is kept, but the pin property is moved to the device tree as part of the MMC/SD card node. Signed-off-by: Linus Walleij --- .../devicetree/bindings/arm/ste-nomadik.txt | 3 ++ arch/arm/boot/dts/ste-nomadik-s8815.dts | 4 ++ arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 13 +++++ arch/arm/mach-nomadik/cpu-8815.c | 48 ++++++++++++++++++- 4 files changed, 67 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/arm/ste-nomadik.txt b/Documentation/devicetree/bindings/arm/ste-nomadik.txt index a97316073afe..19bca04b81c9 100644 --- a/Documentation/devicetree/bindings/arm/ste-nomadik.txt +++ b/Documentation/devicetree/bindings/arm/ste-nomadik.txt @@ -21,4 +21,7 @@ usb-s8815 { interrupts = <19 0x1>; interrupt-parent = <&gpio3>; }; + mmcsd-gpio { + gpios = <&gpio3 16 0x1>; + }; }; diff --git a/arch/arm/boot/dts/ste-nomadik-s8815.dts b/arch/arm/boot/dts/ste-nomadik-s8815.dts index cc777109f98f..b28fbf3408e3 100644 --- a/arch/arm/boot/dts/ste-nomadik-s8815.dts +++ b/arch/arm/boot/dts/ste-nomadik-s8815.dts @@ -22,5 +22,9 @@ interrupts = <19 0x1>; interrupt-parent = <&gpio3>; }; + /* This will bias the MMC/SD card detect line */ + mmcsd-gpio { + gpios = <&gpio3 16 0x1>; + }; }; }; diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index f129425883a4..0164edc78eed 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -190,5 +190,18 @@ interrupt-parent = <&vica>; interrupts = <10>; }; + + mmcsd: sdi@101f6000 { + compatible = "arm,pl18x", "arm,primecell"; + reg = <0x101f6000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <22>; + max-frequency = <48000000>; + bus-width = <4>; + mmc-cap-mmc-highspeed; + mmc-cap-sd-highspeed; + cd-gpios = <&gpio3 15 0x1>; + cd-inverted; + }; }; }; diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 339496f15138..5ad301e4eb2f 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -297,6 +298,50 @@ static int __init cpu8815_eth_init(void) } device_initcall(cpu8815_eth_init); +/* + * TODO: + * cannot be set from device tree, convert to a proper DT + * binding. + */ +static struct mmci_platform_data mmcsd_plat_data = { + .ocr_mask = MMC_VDD_29_30, +}; + +/* + * This GPIO pin turns on a line that is used to detect card insertion + * on this board. + */ +static int __init cpu8815_mmcsd_init(void) +{ + struct device_node *cdbias; + int gpio, err; + + cdbias = of_find_node_by_path("/usb-s8815/mmcsd-gpio"); + if (!cdbias) { + pr_info("could not find MMC/SD card detect bias node\n"); + return 0; + } + gpio = of_get_gpio(cdbias, 0); + if (gpio < 0) { + pr_info("could not obtain MMC/SD card detect bias GPIO\n"); + return 0; + } + err = gpio_request(gpio, "card detect bias"); + if (err) { + pr_info("failed to request card detect bias GPIO %d\n", gpio); + return -ENODEV; + } + err = gpio_direction_output(gpio, 0); + if (err){ + pr_info("failed to set GPIO %d as output, low\n", gpio); + return err; + } + pr_info("enabled USB-S8815 CD bias GPIO %d, low\n", gpio); + return 0; +} +device_initcall(cpu8815_mmcsd_init); + + /* These are mostly to get the right device names for the clock lookups */ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { OF_DEV_AUXDATA("st,nomadik-gpio", NOMADIK_GPIO0_BASE, @@ -319,7 +364,8 @@ static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = { "rtc-pl031", NULL), OF_DEV_AUXDATA("stericsson,fsmc-nand", NOMADIK_FSMC_BASE, "fsmc-nand", &cpu8815_nand_data), - + OF_DEV_AUXDATA("arm,primecell", NOMADIK_SDI_BASE, + "mmci", &mmcsd_plat_data), { /* sentinel */ }, }; From 09e02f4d1d3ba6e5ccfada24162817d00e4675bc Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Jan 2013 02:10:27 +0100 Subject: [PATCH 09/11] ARM: nomadik: add I2C devices to the device tree This adds the GPIO-based I2C devices to the Nomadik device tree. Signed-off-by: Linus Walleij --- arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index 0164edc78eed..4a4aab395141 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi @@ -137,6 +137,55 @@ }; }; + /* I2C0 connected to the STw4811 power management chip */ + i2c0 { + compatible = "i2c-gpio"; + gpios = <&gpio1 31 0>, /* sda */ + <&gpio1 30 0>; /* scl */ + #address-cells = <1>; + #size-cells = <0>; + + stw4811@2d { + compatible = "st,stw4811"; + reg = <0x2d>; + }; + }; + + /* I2C1 connected to various sensors */ + i2c1 { + compatible = "i2c-gpio"; + gpios = <&gpio1 22 0>, /* sda */ + <&gpio1 21 0>; /* scl */ + #address-cells = <1>; + #size-cells = <0>; + + camera@2d { + compatible = "st,camera"; + reg = <0x10>; + }; + stw5095@1a { + compatible = "st,stw5095"; + reg = <0x1a>; + }; + lis3lv02dl@1d { + compatible = "st,lis3lv02dl"; + reg = <0x1d>; + }; + }; + + /* I2C2 connected to the USB portions of the STw4811 only */ + i2c2 { + compatible = "i2c-gpio"; + gpios = <&gpio2 10 0>, /* sda */ + <&gpio2 9 0>; /* scl */ + #address-cells = <1>; + #size-cells = <0>; + stw4811@2d { + compatible = "st,stw4811-usb"; + reg = <0x2d>; + }; + }; + amba { compatible = "arm,amba-bus"; #address-cells = <1>; From 5f66d482af4e12e2a2d4cda0686820550b80ac8e Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Jan 2013 02:25:20 +0100 Subject: [PATCH 10/11] ARM: nomadik: delete old board files The Device Tree support on Nomadik can do everything the old board files could do, so delete the old board files and make the nomadik select CONFIG_OF. Signed-off-by: Linus Walleij --- arch/arm/Kconfig | 2 + arch/arm/mach-nomadik/Kconfig | 10 +- arch/arm/mach-nomadik/Makefile | 6 - arch/arm/mach-nomadik/board-nhk8815.c | 322 -------------------------- arch/arm/mach-nomadik/cpu-8815.c | 112 +-------- arch/arm/mach-nomadik/cpu-8815.h | 5 - arch/arm/mach-nomadik/i2c-8815nhk.c | 82 ------- 7 files changed, 6 insertions(+), 533 deletions(-) delete mode 100644 arch/arm/mach-nomadik/board-nhk8815.c delete mode 100644 arch/arm/mach-nomadik/cpu-8815.h delete mode 100644 arch/arm/mach-nomadik/i2c-8815nhk.c diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 67874b82a4ed..bef46edbe830 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -899,10 +899,12 @@ config ARCH_NOMADIK select ARCH_REQUIRE_GPIOLIB select ARM_AMBA select ARM_VIC + select CLKSRC_NOMADIK_MTU select COMMON_CLK select CPU_ARM926T select GENERIC_CLOCKEVENTS select MIGHT_HAVE_CACHE_L2X0 + select OF select PINCTRL select PINCTRL_STN8815 select SPARSE_IRQ diff --git a/arch/arm/mach-nomadik/Kconfig b/arch/arm/mach-nomadik/Kconfig index 706dc5727bbe..82226a5d60ef 100644 --- a/arch/arm/mach-nomadik/Kconfig +++ b/arch/arm/mach-nomadik/Kconfig @@ -4,19 +4,13 @@ menu "Nomadik boards" config MACH_NOMADIK_8815NHK bool "ST 8815 Nomadik Hardware Kit (evaluation board)" - select CLKSRC_NOMADIK_MTU select NOMADIK_8815 + select I2C + select I2C_ALGOBIT endmenu config NOMADIK_8815 bool -config I2C_BITBANG_8815NHK - tristate "Driver for bit-bang busses found on the 8815 NHK" - depends on I2C && MACH_NOMADIK_8815NHK - depends on PINCTRL_NOMADIK - default y - select I2C_ALGOBIT - endif diff --git a/arch/arm/mach-nomadik/Makefile b/arch/arm/mach-nomadik/Makefile index a42c9a33d3bf..1071c3b04d1a 100644 --- a/arch/arm/mach-nomadik/Makefile +++ b/arch/arm/mach-nomadik/Makefile @@ -9,9 +9,3 @@ # Cpu revision obj-$(CONFIG_NOMADIK_8815) += cpu-8815.o - -# Specific board support -obj-$(CONFIG_MACH_NOMADIK_8815NHK) += board-nhk8815.o - -# Nomadik extra devices -obj-$(CONFIG_I2C_BITBANG_8815NHK) += i2c-8815nhk.o diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c deleted file mode 100644 index e7b216cb6802..000000000000 --- a/arch/arm/mach-nomadik/board-nhk8815.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * linux/arch/arm/mach-nomadik/board-8815nhk.c - * - * Copyright (C) STMicroelectronics - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, as - * published by the Free Software Foundation. - * - * NHK15 board specifc driver definition - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "cpu-8815.h" - -/* Initial value for SRC control register: all timers use MXTAL/8 source */ -#define SRC_CR_INIT_MASK 0x00007fff -#define SRC_CR_INIT_VAL 0x2aaa8000 - -#define ALE_OFF 0x1000000 -#define CLE_OFF 0x800000 - -/* These addresses span 16MB, so use three individual pages */ -static struct resource nhk8815_nand_resources[] = { - { - .name = "nand_data", - .start = 0x40000000, - .end = 0x40000000 + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, { - .name = "nand_addr", - .start = 0x40000000 + ALE_OFF, - .end = 0x40000000 +ALE_OFF + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, { - .name = "nand_cmd", - .start = 0x40000000 + CLE_OFF, - .end = 0x40000000 + CLE_OFF + SZ_16K - 1, - .flags = IORESOURCE_MEM, - }, { - .name = "fsmc_regs", - .start = NOMADIK_FSMC_BASE, - .end = NOMADIK_FSMC_BASE + SZ_4K - 1, - .flags = IORESOURCE_MEM, - }, -}; - -/* - * These partitions are the same as those used in the 2.6.20 release - * shipped by the vendor; the first two partitions are mandated - * by the boot ROM, and the bootloader area is somehow oversized... - */ -static struct mtd_partition nhk8815_partitions[] = { - { - .name = "X-Loader(NAND)", - .offset = 0, - .size = SZ_256K, - }, { - .name = "MemInit(NAND)", - .offset = MTDPART_OFS_APPEND, - .size = SZ_256K, - }, { - .name = "BootLoader(NAND)", - .offset = MTDPART_OFS_APPEND, - .size = SZ_2M, - }, { - .name = "Kernel zImage(NAND)", - .offset = MTDPART_OFS_APPEND, - .size = 3 * SZ_1M, - }, { - .name = "Root Filesystem(NAND)", - .offset = MTDPART_OFS_APPEND, - .size = 22 * SZ_1M, - }, { - .name = "User Filesystem(NAND)", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - } -}; - -static struct fsmc_nand_timings nhk8815_nand_timings = { - .thiz = 0, - .thold = 0x10, - .twait = 0x0A, - .tset = 0, -}; - -static struct fsmc_nand_platform_data nhk8815_nand_platform_data = { - .nand_timings = &nhk8815_nand_timings, - .partitions = nhk8815_partitions, - .nr_partitions = ARRAY_SIZE(nhk8815_partitions), - .width = FSMC_NAND_BW8, -}; - -static struct platform_device nhk8815_nand_device = { - .name = "fsmc-nand", - .id = -1, - .resource = nhk8815_nand_resources, - .num_resources = ARRAY_SIZE(nhk8815_nand_resources), - .dev = { - .platform_data = &nhk8815_nand_platform_data, - }, -}; - -/* These are the partitions for the OneNand device, different from above */ -static struct mtd_partition nhk8815_onenand_partitions[] = { - { - .name = "X-Loader(OneNAND)", - .offset = 0, - .size = SZ_256K, - }, { - .name = "MemInit(OneNAND)", - .offset = MTDPART_OFS_APPEND, - .size = SZ_256K, - }, { - .name = "BootLoader(OneNAND)", - .offset = MTDPART_OFS_APPEND, - .size = SZ_2M-SZ_256K, - }, { - .name = "SysImage(OneNAND)", - .offset = MTDPART_OFS_APPEND, - .size = 4 * SZ_1M, - }, { - .name = "Root Filesystem(OneNAND)", - .offset = MTDPART_OFS_APPEND, - .size = 22 * SZ_1M, - }, { - .name = "User Filesystem(OneNAND)", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - } -}; - -static struct onenand_platform_data nhk8815_onenand_data = { - .parts = nhk8815_onenand_partitions, - .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions), -}; - -static struct resource nhk8815_onenand_resource[] = { - { - .start = 0x30000000, - .end = 0x30000000 + SZ_128K - 1, - .flags = IORESOURCE_MEM, - }, -}; - -static struct platform_device nhk8815_onenand_device = { - .name = "onenand-flash", - .id = -1, - .dev = { - .platform_data = &nhk8815_onenand_data, - }, - .resource = nhk8815_onenand_resource, - .num_resources = ARRAY_SIZE(nhk8815_onenand_resource), -}; - -/* bus control reg. and bus timing reg. for CS0..CS3 */ -#define FSMC_BCR(x) (NOMADIK_FSMC_VA + (x << 3)) -#define FSMC_BTR(x) (NOMADIK_FSMC_VA + (x << 3) + 0x04) - -static void __init nhk8815_onenand_init(void) -{ -#ifdef CONFIG_MTD_ONENAND - /* Set up SMCS0 for OneNand */ - writel(0x000030db, FSMC_BCR(0)); - writel(0x02100551, FSMC_BTR(0)); -#endif -} - -static struct mmci_platform_data mmcsd_plat_data = { - .ocr_mask = MMC_VDD_29_30, - .f_max = 48000000, - .gpio_wp = -1, - .gpio_cd = 111, - .cd_invert = true, - .capabilities = MMC_CAP_MMC_HIGHSPEED | - MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA, -}; - -static int __init nhk8815_mmcsd_init(void) -{ - int ret; - - /* For e.g. devicetree boot */ - if (!machine_is_nomadik()) - return 0; - - ret = gpio_request(112, "card detect bias"); - if (ret) - return ret; - gpio_direction_output(112, 0); - amba_apb_device_add(NULL, "mmci", NOMADIK_SDI_BASE, SZ_4K, IRQ_SDMMC, 0, &mmcsd_plat_data, 0x10180180); - return 0; -} -module_init(nhk8815_mmcsd_init); - -static struct resource nhk8815_eth_resources[] = { - { - .name = "smc91x-regs", - .start = 0x34000000 + 0x300, - .end = 0x34000000 + SZ_64K - 1, - .flags = IORESOURCE_MEM, - }, { - .start = NOMADIK_GPIO_TO_IRQ(115), - .end = NOMADIK_GPIO_TO_IRQ(115), - .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, - } -}; - -static struct platform_device nhk8815_eth_device = { - .name = "smc91x", - .resource = nhk8815_eth_resources, - .num_resources = ARRAY_SIZE(nhk8815_eth_resources), -}; - -static int __init nhk8815_eth_init(void) -{ - int gpio_nr = 115; /* hardwired in the board */ - int err; - - if (!machine_is_nomadik()) - return 0; - err = gpio_request(gpio_nr, "eth_irq"); - if (!err) err = gpio_direction_input(gpio_nr); - if (err) - pr_err("Error %i in %s\n", err, __func__); - return err; -} -device_initcall(nhk8815_eth_init); - -static struct platform_device *nhk8815_platform_devices[] __initdata = { - &nhk8815_nand_device, - &nhk8815_onenand_device, - &nhk8815_eth_device, - /* will add more devices */ -}; - -static void __init nomadik_timer_init(void) -{ - u32 src_cr; - - /* Configure timer sources in "system reset controller" ctrl reg */ - src_cr = readl(io_p2v(NOMADIK_SRC_BASE)); - src_cr &= SRC_CR_INIT_MASK; - src_cr |= SRC_CR_INIT_VAL; - writel(src_cr, io_p2v(NOMADIK_SRC_BASE)); - - nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE), IRQ_MTU0); -} - -static struct i2c_board_info __initdata nhk8815_i2c0_devices[] = { - { - I2C_BOARD_INFO("stw4811", 0x2d), - }, -}; - -static struct i2c_board_info __initdata nhk8815_i2c1_devices[] = { - { - I2C_BOARD_INFO("camera", 0x10), - }, - { - I2C_BOARD_INFO("stw5095", 0x1a), - }, - { - I2C_BOARD_INFO("lis3lv02dl", 0x1d), - }, -}; - -static struct i2c_board_info __initdata nhk8815_i2c2_devices[] = { - { - I2C_BOARD_INFO("stw4811-usb", 0x2d), - }, -}; - -static void __init nhk8815_platform_init(void) -{ - cpu8815_platform_init(); - nhk8815_onenand_init(); - platform_add_devices(nhk8815_platform_devices, - ARRAY_SIZE(nhk8815_platform_devices)); - - amba_apb_device_add(NULL, "uart0", NOMADIK_UART0_BASE, SZ_4K, IRQ_UART0, 0, NULL, 0); - amba_apb_device_add(NULL, "uart1", NOMADIK_UART1_BASE, SZ_4K, IRQ_UART1, 0, NULL, 0); - - i2c_register_board_info(0, nhk8815_i2c0_devices, - ARRAY_SIZE(nhk8815_i2c0_devices)); - i2c_register_board_info(1, nhk8815_i2c1_devices, - ARRAY_SIZE(nhk8815_i2c1_devices)); - i2c_register_board_info(2, nhk8815_i2c2_devices, - ARRAY_SIZE(nhk8815_i2c2_devices)); -} - -MACHINE_START(NOMADIK, "NHK8815") - /* Maintainer: ST MicroElectronics */ - .atag_offset = 0x100, - .map_io = cpu8815_map_io, - .init_irq = cpu8815_init_irq, - .init_time = nomadik_timer_init, - .init_machine = nhk8815_platform_init, - .restart = cpu8815_restart, -MACHINE_END diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 5ad301e4eb2f..60a18e12e6ce 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -48,53 +48,6 @@ #include #include -#include "cpu-8815.h" - -/* The 8815 has 4 GPIO blocks, let's register them immediately */ -static resource_size_t __initdata cpu8815_gpio_base[] = { - NOMADIK_GPIO0_BASE, - NOMADIK_GPIO1_BASE, - NOMADIK_GPIO2_BASE, - NOMADIK_GPIO3_BASE, -}; - -static struct platform_device * -cpu8815_add_gpio(int id, resource_size_t addr, int irq, - struct nmk_gpio_platform_data *pdata) -{ - struct resource resources[] = { - { - .start = addr, - .end = addr + 127, - .flags = IORESOURCE_MEM, - }, - { - .start = irq, - .end = irq, - .flags = IORESOURCE_IRQ, - } - }; - - return platform_device_register_resndata(NULL, "gpio", id, - resources, ARRAY_SIZE(resources), - pdata, sizeof(*pdata)); -} - -void cpu8815_add_gpios(resource_size_t *base, int num, int irq, - struct nmk_gpio_platform_data *pdata) -{ - int first = 0; - int i; - - for (i = 0; i < num; i++, first += 32, irq++) { - pdata->first_gpio = first; - pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); - pdata->num_gpio = 32; - - cpu8815_add_gpio(i, base[i], irq, pdata); - } -} - static unsigned long out_low[] = { PIN_OUTPUT_LOW }; static unsigned long out_high[] = { PIN_OUTPUT_HIGH }; static unsigned long in_nopull[] = { PIN_INPUT_NOPULL }; @@ -137,38 +90,6 @@ static struct pinctrl_map __initdata nhk8815_pinmap[] = { PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO74_C20", in_pullup), }; -static inline void -cpu8815_add_pinctrl(struct device *parent, const char *name) -{ - struct platform_device_info pdevinfo = { - .parent = parent, - .name = name, - .id = -1, - }; - - pinctrl_register_mappings(nhk8815_pinmap, ARRAY_SIZE(nhk8815_pinmap)); - platform_device_register_full(&pdevinfo); -} - -static int __init cpu8815_init(void) -{ - struct nmk_gpio_platform_data pdata = { - /* No custom data yet */ - }; - - /* For e.g. device tree boots */ - if (!machine_is_nomadik()) - return 0; - - cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), - IRQ_GPIO0, &pdata); - cpu8815_add_pinctrl(NULL, "pinctrl-stn8815"); - amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); - amba_apb_device_add(NULL, "rtc-pl031", NOMADIK_RTC_BASE, SZ_4K, IRQ_RTC_RTT, 0, NULL, 0); - return 0; -} -arch_initcall(cpu8815_init); - /* All SoC devices live in the same area (see hardware.h) */ static struct map_desc nomadik_io_desc[] __initdata = { { @@ -180,37 +101,12 @@ static struct map_desc nomadik_io_desc[] __initdata = { /* static ram and secured ram may be added later */ }; -void __init cpu8815_map_io(void) +static void __init cpu8815_map_io(void) { iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); } -void __init cpu8815_init_irq(void) -{ - /* This modified VIC cell has two register blocks, at 0 and 0x20 */ - vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0); - vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0); - - /* - * Init clocks here so that they are available for system timer - * initialization. - */ - nomadik_clk_init(); -} - -/* - * This function is called from the board init ("init_machine"). - */ - void __init cpu8815_platform_init(void) -{ -#ifdef CONFIG_CACHE_L2X0 - /* At full speed latency must be >=2, so 0x249 in low bits */ - l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff); -#endif - return; -} - -void cpu8815_restart(char mode, const char *cmd) +static void cpu8815_restart(char mode, const char *cmd) { void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18); @@ -220,8 +116,6 @@ void cpu8815_restart(char mode, const char *cmd) writel(1, src_rstsr); } -#ifdef CONFIG_OF - /* Initial value for SRC control register: all timers use MXTAL/8 source */ #define SRC_CR_INIT_MASK 0x00007fff #define SRC_CR_INIT_VAL 0x2aaa8000 @@ -393,5 +287,3 @@ DT_MACHINE_START(NOMADIK_DT, "Nomadik STn8815") .restart = cpu8815_restart, .dt_compat = cpu8815_board_compat, MACHINE_END - -#endif diff --git a/arch/arm/mach-nomadik/cpu-8815.h b/arch/arm/mach-nomadik/cpu-8815.h deleted file mode 100644 index d6c7830e4799..000000000000 --- a/arch/arm/mach-nomadik/cpu-8815.h +++ /dev/null @@ -1,5 +0,0 @@ -extern void cpu8815_map_io(void); -extern void cpu8815_platform_init(void); -extern void cpu8815_init_irq(void); -extern void cpu8815_restart(char, const char *); -extern struct sys_timer cpu8815_timer; diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c deleted file mode 100644 index 299ff5a687bc..000000000000 --- a/arch/arm/mach-nomadik/i2c-8815nhk.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -/* - * There are two busses in the 8815NHK. - * They could, in theory, be driven by the hardware component, but we - * use bit-bang through GPIO by now, to keep things simple - */ - -/* I2C0 connected to the STw4811 power management chip */ -static struct i2c_gpio_platform_data nhk8815_i2c_data0 = { - /* keep defaults for timeouts; pins are push-pull bidirectional */ - .scl_pin = 62, - .sda_pin = 63, -}; - -/* I2C1 connected to various sensors */ -static struct i2c_gpio_platform_data nhk8815_i2c_data1 = { - /* keep defaults for timeouts; pins are push-pull bidirectional */ - .scl_pin = 53, - .sda_pin = 54, -}; - -/* I2C2 connected to the USB portions of the STw4811 only */ -static struct i2c_gpio_platform_data nhk8815_i2c_data2 = { - /* keep defaults for timeouts; pins are push-pull bidirectional */ - .scl_pin = 73, - .sda_pin = 74, -}; - -static struct platform_device nhk8815_i2c_dev0 = { - .name = "i2c-gpio", - .id = 0, - .dev = { - .platform_data = &nhk8815_i2c_data0, - }, -}; - -static struct platform_device nhk8815_i2c_dev1 = { - .name = "i2c-gpio", - .id = 1, - .dev = { - .platform_data = &nhk8815_i2c_data1, - }, -}; - -static struct platform_device nhk8815_i2c_dev2 = { - .name = "i2c-gpio", - .id = 2, - .dev = { - .platform_data = &nhk8815_i2c_data2, - }, -}; - -static int __init nhk8815_i2c_init(void) -{ - /* For e.g. devicetree boot */ - if (!machine_is_nomadik()) - return 0; - - platform_device_register(&nhk8815_i2c_dev0); - platform_device_register(&nhk8815_i2c_dev1); - platform_device_register(&nhk8815_i2c_dev2); - - return 0; -} - -static void __exit nhk8815_i2c_exit(void) -{ - platform_device_unregister(&nhk8815_i2c_dev0); - platform_device_unregister(&nhk8815_i2c_dev1); - platform_device_unregister(&nhk8815_i2c_dev2); - return; -} - -module_init(nhk8815_i2c_init); -module_exit(nhk8815_i2c_exit); From dea3eacd087cfa692ea20aafbfaf4827607afe45 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 6 Jan 2013 02:58:43 +0100 Subject: [PATCH 11/11] ARM: nomadik: get rid of This was only used from the core machine, source it into the machine file and delete, also convert all direct references using the physical-to-virtual macros in this file to ioremap() and only default-remap the 4K used by the debug UART. Signed-off-by: Linus Walleij --- arch/arm/mach-nomadik/cpu-8815.c | 67 +++++++++++--- arch/arm/mach-nomadik/include/mach/hardware.h | 90 ------------------- arch/arm/mach-nomadik/include/mach/irqs.h | 2 - .../mach-nomadik/include/mach/uncompress.h | 1 - 4 files changed, 55 insertions(+), 105 deletions(-) delete mode 100644 arch/arm/mach-nomadik/include/mach/hardware.h diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c index 60a18e12e6ce..21c1aa512640 100644 --- a/arch/arm/mach-nomadik/cpu-8815.c +++ b/arch/arm/mach-nomadik/cpu-8815.c @@ -38,7 +38,6 @@ #include #include -#include #include #include #include @@ -48,6 +47,51 @@ #include #include +/* + * These are the only hard-coded address offsets we still have to use. + */ +#define NOMADIK_FSMC_BASE 0x10100000 /* FSMC registers */ +#define NOMADIK_SDRAMC_BASE 0x10110000 /* SDRAM Controller */ +#define NOMADIK_CLCDC_BASE 0x10120000 /* CLCD Controller */ +#define NOMADIK_MDIF_BASE 0x10120000 /* MDIF */ +#define NOMADIK_DMA0_BASE 0x10130000 /* DMA0 Controller */ +#define NOMADIK_IC_BASE 0x10140000 /* Vectored Irq Controller */ +#define NOMADIK_DMA1_BASE 0x10150000 /* DMA1 Controller */ +#define NOMADIK_USB_BASE 0x10170000 /* USB-OTG conf reg base */ +#define NOMADIK_CRYP_BASE 0x10180000 /* Crypto processor */ +#define NOMADIK_SHA1_BASE 0x10190000 /* SHA-1 Processor */ +#define NOMADIK_XTI_BASE 0x101A0000 /* XTI */ +#define NOMADIK_RNG_BASE 0x101B0000 /* Random number generator */ +#define NOMADIK_SRC_BASE 0x101E0000 /* SRC base */ +#define NOMADIK_WDOG_BASE 0x101E1000 /* Watchdog */ +#define NOMADIK_MTU0_BASE 0x101E2000 /* Multiple Timer 0 */ +#define NOMADIK_MTU1_BASE 0x101E3000 /* Multiple Timer 1 */ +#define NOMADIK_GPIO0_BASE 0x101E4000 /* GPIO0 */ +#define NOMADIK_GPIO1_BASE 0x101E5000 /* GPIO1 */ +#define NOMADIK_GPIO2_BASE 0x101E6000 /* GPIO2 */ +#define NOMADIK_GPIO3_BASE 0x101E7000 /* GPIO3 */ +#define NOMADIK_RTC_BASE 0x101E8000 /* Real Time Clock base */ +#define NOMADIK_PMU_BASE 0x101E9000 /* Power Management Unit */ +#define NOMADIK_OWM_BASE 0x101EA000 /* One wire master */ +#define NOMADIK_SCR_BASE 0x101EF000 /* Secure Control registers */ +#define NOMADIK_MSP2_BASE 0x101F0000 /* MSP 2 interface */ +#define NOMADIK_MSP1_BASE 0x101F1000 /* MSP 1 interface */ +#define NOMADIK_UART2_BASE 0x101F2000 /* UART 2 interface */ +#define NOMADIK_SSIRx_BASE 0x101F3000 /* SSI 8-ch rx interface */ +#define NOMADIK_SSITx_BASE 0x101F4000 /* SSI 8-ch tx interface */ +#define NOMADIK_MSHC_BASE 0x101F5000 /* Memory Stick(Pro) Host */ +#define NOMADIK_SDI_BASE 0x101F6000 /* SD-card/MM-Card */ +#define NOMADIK_I2C1_BASE 0x101F7000 /* I2C1 interface */ +#define NOMADIK_I2C0_BASE 0x101F8000 /* I2C0 interface */ +#define NOMADIK_MSP0_BASE 0x101F9000 /* MSP 0 interface */ +#define NOMADIK_FIRDA_BASE 0x101FA000 /* FIrDA interface */ +#define NOMADIK_UART1_BASE 0x101FB000 /* UART 1 interface */ +#define NOMADIK_SSP_BASE 0x101FC000 /* SSP interface */ +#define NOMADIK_UART0_BASE 0x101FD000 /* UART 0 interface */ +#define NOMADIK_SGA_BASE 0x101FE000 /* SGA interface */ +#define NOMADIK_L2CC_BASE 0x10210000 /* L2 Cache controller */ +#define NOMADIK_UART1_VBASE 0xF01FB000 + static unsigned long out_low[] = { PIN_OUTPUT_LOW }; static unsigned long out_high[] = { PIN_OUTPUT_HIGH }; static unsigned long in_nopull[] = { PIN_INPUT_NOPULL }; @@ -90,30 +134,29 @@ static struct pinctrl_map __initdata nhk8815_pinmap[] = { PIN_MAP_CONFIGS_PIN_HOG_DEFAULT("pinctrl-stn8815", "GPIO74_C20", in_pullup), }; -/* All SoC devices live in the same area (see hardware.h) */ -static struct map_desc nomadik_io_desc[] __initdata = { +/* This is needed for LL-debug/earlyprintk/debug-macro.S */ +static struct map_desc cpu8815_io_desc[] __initdata = { { - .virtual = NOMADIK_IO_VIRTUAL, - .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL), - .length = NOMADIK_IO_SIZE, - .type = MT_DEVICE, - } - /* static ram and secured ram may be added later */ + .virtual = NOMADIK_UART1_VBASE, + .pfn = __phys_to_pfn(NOMADIK_UART1_BASE), + .length = SZ_4K, + .type = MT_DEVICE, + }, }; static void __init cpu8815_map_io(void) { - iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); + iotable_init(cpu8815_io_desc, ARRAY_SIZE(cpu8815_io_desc)); } static void cpu8815_restart(char mode, const char *cmd) { - void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18); + void __iomem *srcbase = ioremap(NOMADIK_SRC_BASE, SZ_4K); /* FIXME: use egpio when implemented */ /* Write anything to Reset status register */ - writel(1, src_rstsr); + writel(1, srcbase + 0x18); } /* Initial value for SRC control register: all timers use MXTAL/8 source */ diff --git a/arch/arm/mach-nomadik/include/mach/hardware.h b/arch/arm/mach-nomadik/include/mach/hardware.h deleted file mode 100644 index 02035e459f50..000000000000 --- a/arch/arm/mach-nomadik/include/mach/hardware.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This file contains the hardware definitions of the Nomadik. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * YOU should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ASM_ARCH_HARDWARE_H -#define __ASM_ARCH_HARDWARE_H - -/* Nomadik registers live from 0x1000.0000 to 0x1023.0000 -- currently */ -#define NOMADIK_IO_VIRTUAL 0xF0000000 /* VA of IO */ -#define NOMADIK_IO_PHYSICAL 0x10000000 /* PA of IO */ -#define NOMADIK_IO_SIZE 0x00300000 /* 3MB for all regs */ - -/* used in C code, so cast to proper type */ -#define io_p2v(x) ((void __iomem *)(x) \ - - NOMADIK_IO_PHYSICAL + NOMADIK_IO_VIRTUAL) -#define io_v2p(x) ((unsigned long)(x) \ - - NOMADIK_IO_VIRTUAL + NOMADIK_IO_PHYSICAL) - -/* used in asm code, so no casts */ -#define IO_ADDRESS(x) IOMEM((x) - NOMADIK_IO_PHYSICAL + NOMADIK_IO_VIRTUAL) - -/* - * Base address defination for Nomadik Onchip Logic Block - */ -#define NOMADIK_FSMC_BASE 0x10100000 /* FSMC registers */ -#define NOMADIK_SDRAMC_BASE 0x10110000 /* SDRAM Controller */ -#define NOMADIK_CLCDC_BASE 0x10120000 /* CLCD Controller */ -#define NOMADIK_MDIF_BASE 0x10120000 /* MDIF */ -#define NOMADIK_DMA0_BASE 0x10130000 /* DMA0 Controller */ -#define NOMADIK_IC_BASE 0x10140000 /* Vectored Irq Controller */ -#define NOMADIK_DMA1_BASE 0x10150000 /* DMA1 Controller */ -#define NOMADIK_USB_BASE 0x10170000 /* USB-OTG conf reg base */ -#define NOMADIK_CRYP_BASE 0x10180000 /* Crypto processor */ -#define NOMADIK_SHA1_BASE 0x10190000 /* SHA-1 Processor */ -#define NOMADIK_XTI_BASE 0x101A0000 /* XTI */ -#define NOMADIK_RNG_BASE 0x101B0000 /* Random number generator */ -#define NOMADIK_SRC_BASE 0x101E0000 /* SRC base */ -#define NOMADIK_WDOG_BASE 0x101E1000 /* Watchdog */ -#define NOMADIK_MTU0_BASE 0x101E2000 /* Multiple Timer 0 */ -#define NOMADIK_MTU1_BASE 0x101E3000 /* Multiple Timer 1 */ -#define NOMADIK_GPIO0_BASE 0x101E4000 /* GPIO0 */ -#define NOMADIK_GPIO1_BASE 0x101E5000 /* GPIO1 */ -#define NOMADIK_GPIO2_BASE 0x101E6000 /* GPIO2 */ -#define NOMADIK_GPIO3_BASE 0x101E7000 /* GPIO3 */ -#define NOMADIK_RTC_BASE 0x101E8000 /* Real Time Clock base */ -#define NOMADIK_PMU_BASE 0x101E9000 /* Power Management Unit */ -#define NOMADIK_OWM_BASE 0x101EA000 /* One wire master */ -#define NOMADIK_SCR_BASE 0x101EF000 /* Secure Control registers */ -#define NOMADIK_MSP2_BASE 0x101F0000 /* MSP 2 interface */ -#define NOMADIK_MSP1_BASE 0x101F1000 /* MSP 1 interface */ -#define NOMADIK_UART2_BASE 0x101F2000 /* UART 2 interface */ -#define NOMADIK_SSIRx_BASE 0x101F3000 /* SSI 8-ch rx interface */ -#define NOMADIK_SSITx_BASE 0x101F4000 /* SSI 8-ch tx interface */ -#define NOMADIK_MSHC_BASE 0x101F5000 /* Memory Stick(Pro) Host */ -#define NOMADIK_SDI_BASE 0x101F6000 /* SD-card/MM-Card */ -#define NOMADIK_I2C1_BASE 0x101F7000 /* I2C1 interface */ -#define NOMADIK_I2C0_BASE 0x101F8000 /* I2C0 interface */ -#define NOMADIK_MSP0_BASE 0x101F9000 /* MSP 0 interface */ -#define NOMADIK_FIRDA_BASE 0x101FA000 /* FIrDA interface */ -#define NOMADIK_UART1_BASE 0x101FB000 /* UART 1 interface */ -#define NOMADIK_SSP_BASE 0x101FC000 /* SSP interface */ -#define NOMADIK_UART0_BASE 0x101FD000 /* UART 0 interface */ -#define NOMADIK_SGA_BASE 0x101FE000 /* SGA interface */ -#define NOMADIK_L2CC_BASE 0x10210000 /* L2 Cache controller */ - -/* Other ranges, not for p2v/v2p */ -#define NOMADIK_BACKUP_RAM 0x80010000 -#define NOMADIK_EBROM 0x80000000 /* Embedded boot ROM */ -#define NOMADIK_HAMACV_DMEM_BASE 0xA0100000 /* HAMACV Data Memory Start */ -#define NOMADIK_HAMACV_DMEM_END 0xA01FFFFF /* HAMACV Data Memory End */ -#define NOMADIK_HAMACA_DMEM 0xA0200000 /* HAMACA Data Memory Space */ - -#define NOMADIK_FSMC_VA IO_ADDRESS(NOMADIK_FSMC_BASE) -#define NOMADIK_MTU0_VA IO_ADDRESS(NOMADIK_MTU0_BASE) -#define NOMADIK_MTU1_VA IO_ADDRESS(NOMADIK_MTU1_BASE) - -#endif /* __ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/mach-nomadik/include/mach/irqs.h b/arch/arm/mach-nomadik/include/mach/irqs.h index 215f8cdb4004..90ac965a92fe 100644 --- a/arch/arm/mach-nomadik/include/mach/irqs.h +++ b/arch/arm/mach-nomadik/include/mach/irqs.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_IRQS_H #define __ASM_ARCH_IRQS_H -#include - #define IRQ_VIC_START 32 /* first VIC interrupt is 1 */ /* diff --git a/arch/arm/mach-nomadik/include/mach/uncompress.h b/arch/arm/mach-nomadik/include/mach/uncompress.h index 7d4687e9cbdf..f793ace27d29 100644 --- a/arch/arm/mach-nomadik/include/mach/uncompress.h +++ b/arch/arm/mach-nomadik/include/mach/uncompress.h @@ -21,7 +21,6 @@ #include #include -#include /* we need the constants in amba/serial.h, but it refers to amba_device */ struct amba_device;