ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
Subsystems (2)
PATCH 1/2 ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
From: Barry Song <[email protected]>
This patch adds lookup table for attaching a specific name and platform_data pointer to devices like i2c, spi, uart and pinctrl as they get created by of_platform_populate(). Ideally this table would not exist.
--- arch/arm/mach-prima2/prima2.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
arch/arm/mach-prima2/prima2.c +19 -1
@@ -13,8 +13,26 @@#include <asm/mach/arch.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/pinctrl/machine.h> #include "common.h" +/* +* Lookup table for attaching a specific name and platform_data pointer to +* devices as they get created by of_platform_populate(). Ideally this table +* would not exist. +*/ +struct of_dev_auxdata prima2_auxdata_lookup[]__initdata = { +OF_DEV_AUXDATA ("sirf,prima2-uart" ,0xb0050000 ,"uart0" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-uart" ,0xb0060000 ,"uart1" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-uart" ,0xb0070000 ,"uart2" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-spi" ,0xb00d0000 ,"spi0" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-spi" ,0xb0170000 ,"spi1" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-i2c" ,0xb00e0000 ,"i2c0" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-i2c" ,0xb00f0000 ,"i2c1" ,NULL ), +OF_DEV_AUXDATA ("sirf,prima2-gpio-pinmux" ,0xb0120000 ,"pinctrl0" ,NULL ), + {}, +}; +static struct of_device_id sirfsoc_of_bus_ids[]__initdata = { { .compatible ="simple-bus" , }, {},
@@ -22,7 +40,7 @@ static struct of_device_id sirfsoc_of_bus_ids[] __initdata = {void __init sirfsoc_mach_init (void ) { -of_platform_bus_probe (NULL , sirfsoc_of_bus_ids,NULL ); +of_platform_populate (NULL , sirfsoc_of_bus_ids, prima2_auxdata_lookup,NULL ); }void __init sirfsoc_init_late (void )
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 2/2 ARM: PRIMA2: add PINMUX map for primaII UART1 and SPI0/1
From: Barry Song <[email protected]>
--- arch/arm/mach-prima2/prima2.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/arm/mach-prima2/prima2.c +8 -0
@@ -33,6 +33,13 @@ struct of_dev_auxdata prima2_auxdata_lookup[] __initdata = { {}, }; +/* Padmux settings */ +static struct pinctrl_map prima2_padmux_map[] = { +PIN_MAP_MUX_GROUP_DEFAULT ("uart1" ,"pinctrl0" ,NULL ,"uart1" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi0" ,"pinctrl0" ,NULL ,"spi0" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi1" ,"pinctrl0" ,NULL ,"spi1" ), +}; +static struct of_device_id sirfsoc_of_bus_ids[]__initdata = { { .compatible ="simple-bus" , }, {},
@@ -41,6 +48,7 @@ static struct of_device_id sirfsoc_of_bus_ids[] __initdata = {void __init sirfsoc_mach_init (void ) {of_platform_populate (NULL , sirfsoc_of_bus_ids, prima2_auxdata_lookup,NULL ); +pinctrl_register_mappings (prima2_padmux_map,ARRAY_SIZE (prima2_padmux_map)); }void __init sirfsoc_init_late (void )
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 1/2 ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
In reply to Barry SongQuoted 7 lines · Barry Song
From: Barry Song <[email protected]>
This patch adds lookup table for attaching a specific name and
platform_datapointer to devices like i2c, spi, uart and pinctrl as they get created byof_platform_populate(). Ideally this table would not exist.Signed-off-by Barry Song <[email protected]>
Hi Barry,
I don't understand. Which subsystem relies on the short names here?
If it's about the pinctrl and clock parts, can't you just uses the generate names like "b0050000.uart" directly?
Arnd
PATCH 2/2 ARM: PRIMA2: add PINMUX map for primaII UART1 and SPI0/1
In reply to Barry SongQuoted 11 lines · Barry Song
arch/arm/mach-prima2/prima2.c +7
-0+/* Padmux settings */ +static struct pinctrl_map prima2_padmux_map[] = { +PIN_MAP_MUX_GROUP_DEFAULT ("uart1" ,"pinctrl0" ,NULL ,"uart1" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi0" ,"pinctrl0" ,NULL ,"spi0" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi1" ,"pinctrl0" ,NULL ,"spi1" ), +}; +static struct of_device_id sirfsoc_of_bus_ids[]__initdata = { { .compatible ="simple-bus" , }, {},
arch/arm/mach-prima2/prima2.c static struct of_device_id sirfsoc_of_bus_ids[] __initdata = { · line 52
Quoted 5 lines
arch/arm/mach-prima2/prima2.c +1
-0@@ -41,6 +48,7 @@ static struct of_device_id sirfsoc_of_bus_ids[] __initdata = {void __init sirfsoc_mach_init (void ) {of_platform_populate (NULL , sirfsoc_of_bus_ids, prima2_auxdata_lookup,NULL ); +pinctrl_register_mappings (prima2_padmux_map,ARRAY_SIZE (prima2_padmux_map)); }
I haven't been following pinctrl too closely, but isn't this something that would normally be represented by putting the lookup table into the device tree?
Arnd
PATCH 1/2 ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
In reply to Arnd BergmannHi Arnd,
2012/7/4 Arnd Bergmann <[email protected]>:
Quoted 7 lines · Barry Song
Quoted 6 lines
From: Barry Song <[email protected]>
This patch adds lookup table for attaching a specific name and
platform_datapointer to devices like i2c, spi, uart and pinctrl as they get created byof_platform_populate(). Ideally this table would not exist.
Quoted 8 lines
Quoted 1 line
Signed-off-by Barry Song <[email protected]>Hi Barry,
I don't understand. Which subsystem relies on the short names here?
If it's about the pinctrl and clock parts, can't you just uses the generate names like "b0050000.uart" directly?
yes. names like "b0050000.uart" really work, and i have enabled and tested names like that in clock driver.
but would people think them ugly?
and what would the clock driver support two SoCs whose uarts have different map base address?
Quoted 2 lines
Arnd
-barry
PATCH 1/2 ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
Quoted 6 lines · Barry Song
Quoted 2 lines
If it's about the pinctrl and clock parts, can't you just uses the generate names like "b0050000.uart" directly?
yes. names like "b0050000.uart" really work, and i have enabled and tested names like that in clock driver.
but would people think them ugly?
No, that's fine.
Quoted 2 lines
and what would the clock driver support two SoCs whose uarts have different map base address?
If they are different SoCs, then it would be likely be a different clock that is connected to the UART.
A better solution is to use the new DT clock bindings to replace the clock lookup in the source code. Have a look atgit://git.linaro.org/people/mturquette/linux.git to see how others do this in new kernels.
Arnd
PATCH 1/2 ARM: PRIMA2: add of_dev_auxdata table for I2C, SPI, UART and PINCTRL
2012/7/4 Arnd Bergmann <[email protected]>:
Quoted 13 lines · Barry Song
Quoted 6 lines
Quoted 2 lines
If it's about the pinctrl and clock parts, can't you just uses the generate names like "b0050000.uart" directly?
yes. names like "b0050000.uart" really work, and i have enabled and tested names like that in clock driver.
but would people think them ugly?No, that's fine.
Quoted 2 lines
and what would the clock driver support two SoCs whose uarts have different map base address?
Quoted 7 lines
If they are different SoCs, then it would be likely be a different clock that is connected to the UART.
A better solution is to use the new DT clock bindings to replace the clock lookup in the source code. Have a look at
git://git.linaro.org/people/mturquette/linux.gitto see how others do this in new kernels.
ok. thanks. recently i have missed many threads due to some other work issues. i'll look into Rob Herring's "clk: add DT clock binding support".
Quoted 2 lines
Arnd
-barry
PATCH 2/2 ARM: PRIMA2: add PINMUX map for primaII UART1 and SPI0/1
In reply to Arnd Bergmann2012/7/4 Arnd Bergmann <[email protected]>:
Quoted 13 lines · Barry Song
Quoted 12 lines
arch/arm/mach-prima2/prima2.c +7
-0+/* Padmux settings */ +static struct pinctrl_map prima2_padmux_map[] = { +PIN_MAP_MUX_GROUP_DEFAULT ("uart1" ,"pinctrl0" ,NULL ,"uart1" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi0" ,"pinctrl0" ,NULL ,"spi0" ), +PIN_MAP_MUX_GROUP_DEFAULT ("spi1" ,"pinctrl0" ,NULL ,"spi1" ), +}; +static struct of_device_id sirfsoc_of_bus_ids[]__initdata = { { .compatible ="simple-bus" , }, {},@@ -41,6 +48,7 @@ static struct of_device_id sirfsoc_of_bus_ids[] __initdata = {void __init sirfsoc_mach_init (void )
Quoted 8 lines
arch/arm/mach-prima2/prima2.c static struct of_device_id sirfsoc_of_bus_ids[] __initdata = { · line 52
Quoted 4 lines
arch/arm/mach-prima2/prima2.c +1
-0{of_platform_populate (NULL , sirfsoc_of_bus_ids, prima2_auxdata_lookup,NULL ); +pinctrl_register_mappings (prima2_padmux_map,ARRAY_SIZE (prima2_padmux_map)); }I haven't been following pinctrl too closely, but isn't this something that would normally be represented by putting the lookup table into the device tree?
i'd like to see that. i am not sure whether i have missed anything since i only saw the pinctrl_register_mappings samples. would linus clarify?
Quoted 3 lines
Arnd
-barry
PATCH 2/2 ARM: PRIMA2: add PINMUX map for primaII UART1 and SPI0/1
Quoted 7 lines · Barry Song
2012/7/4 Arnd Bergmann <[email protected]>:
Quoted 6 lines · Barry Song
Quoted 4 lines
of_platform_populate(NULL, sirfsoc_of_bus_ids, prima2_auxdata_lookup, NULL);+
pinctrl_register_mappings(prima2_padmux_map, ARRAY_SIZE(prima2_padmux_map));
}
Quoted 7 lines
Quoted 3 lines
I haven't been following pinctrl too closely, but isn't this something that would normally be represented by putting the lookup table into the device tree?
i'd like to see that. i am not sure whether i have missed anything since i only saw the
pinctrl_register_mappingssamples. would linus clarify?
You can do it either way, but for a DT:ed platform it makes sense to have it in device tree.
Check drivers/pinctrl/devicetree.c for how that code works, the bindings are in Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt There are example usecases in arch/arm/boot/dts/*
This was all implemented by Stephen Warren so he's the reference to this codepath.
Yours,
Linus Walleij