Add dt_compat field to struct s3c_gpio_chip
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 Add dt_compat field to struct s3c_gpio_chip
From: Domenico Andreoli <[email protected]>
This new field allows easy creation of GPIO chips in base of struct arrays.
--- arch/arm/plat-samsung/include/plat/gpio-core.h | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/plat-samsung/include/plat/gpio-core.h +3 -0
@@ -71,6 +71,9 @@#ifdef CONFIG_PM u32 pm_save[4 ];#endif +#ifdef CONFIG_OF_GPIO +const char *dt_compat; +#endif };static inline struct s3c_gpio_chip *to_s3c_gpio (struct gpio_chip *gpc)
PATCH 1/2 Add dt_compat field to struct s3c_gpio_chip
Quoted 15 lines · Domenico Andreoli
From: Domenico Andreoli <[email protected]>
This new field allows easy creation of GPIO chips in base of struct arrays.
Signed-off-by Domenico Andreoli <[email protected]>--- arch/arm/plat-samsung/include/plat/gpio-core.h | 3 +++ 1 file changed, 3 insertions(+)Index:
b/arch/arm/plat-samsung/include/plat/gpio-core.h
===================================================================
arch/arm/plat-samsung/include/plat/gpio-core.h line 76
Quoted 6 lines
arch/arm/plat-samsung/include/plat/gpio-core.h +3
-0@@ -71,6 +71,9 @@#ifdef CONFIG_PM u32 pm_save[4 ];#endif +#ifdef CONFIG_OF_GPIO +const char *dt_compat; +#endif
I think you can merge this with the next patch.
g.
PATCH 2/2 Add GPIO DT support to s3c24xx
In reply to a message not in the archiveFrom: Domenico Andreoli <[email protected]>
Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip.
--- arch/arm/plat-s3c24xx/gpiolib.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/arm/plat-s3c24xx/gpiolib.c +45 -0
@@ -19,6 +19,8 @@#include <linux/ioport.h> #include <linux/io.h> #include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <plat/gpio-core.h> #include <plat/gpio-cfg.h>
@@ -97,6 +99,9 @@ .direction_input = s3c24xx_gpiolib_banka_input, .direction_output = s3c24xx_gpiolib_banka_output, }, +#ifdef CONFIG_OF_GPIO + .dt_compat = "samsung,s3c2410-gpio-a", +#endif }, [1] = { .base = S3C2410_GPBCON,
@@ -210,6 +215,45 @@ }, }; +#ifdef CONFIG_OF_GPIO +static int s3c24xx_of_base_match (struct s3c_gpio_chip *chip,struct device_node *dn) +{ +const u32 *addrp; +u64 addr; + + addrp =of_get_address (dn,0 ,0 ,NULL ); +if (!addrp) +return 0 ; + + addr =of_translate_address (dn, addrp); +if (addr ==OF_BAD_ADDR ) +return 0 ; + +return chip->base == (addr -S3C24XX_PA_GPIO +S3C24XX_VA_GPIO ); +} + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +struct device_node *dn; + +if (!chip->dt_compat) + chip->dt_compat ="samsung,s3c2410-gpio" ; + +for_each_compatible_node (dn,NULL , chip->dt_compat) { +if (s3c24xx_of_base_match (chip, dn)) { + chip->chip.of_node = dn; +break ; + } + } +} + +#else + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +} + +#endif static __init int s3c24xx_gpiolib_init (void ) {
@@ -220,6 +264,7 @@if (!chip->config) chip->config = &s3c24xx_gpiocfg_default; +s3c24xx_attach_of_node (chip);s3c_gpiolib_add (chip); }
PATCH 2/2 Add GPIO DT support to s3c24xx
Quoted 6 lines · Domenico Andreoli
From: Domenico Andreoli <[email protected]>
Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip.
Signed-off-by Domenico Andreoli <[email protected]>
Looks pretty good. Minor comments below.
g.
Quoted 19 lines
--- arch/arm/plat-s3c24xx/gpiolib.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)Index:
b/arch/arm/plat-s3c24xx/gpiolib.c
===================================================================arch/arm/plat-s3c24xx/gpiolib.c +2
-0@@ -19,6 +19,8 @@#include <linux/ioport.h> #include <linux/io.h> #include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <plat/gpio-core.h> #include <plat/gpio-cfg.h>
arch/arm/plat-s3c24xx/gpiolib.c line 104
Quoted 6 lines
arch/arm/plat-s3c24xx/gpiolib.c +3
-0@@ -97,6 +99,9 @@ .direction_input = s3c24xx_gpiolib_banka_input, .direction_output = s3c24xx_gpiolib_banka_output, }, +#ifdef CONFIG_OF_GPIO + .dt_compat = "samsung,s3c2410-gpio-a", +#endif
The '-a' bit I suspect is wrong. Aren't all the gpio banks of the same type?
Quoted 10 lines
arch/arm/plat-s3c24xx/gpiolib.c +3
-0}, [1] = { .base = S3C2410_GPBCON,@@ -210,6 +215,45 @@ }, }; +#ifdef CONFIG_OF_GPIO +static int s3c24xx_of_base_match (struct s3c_gpio_chip *chip,struct device_node *dn) +{
arch/arm/plat-s3c24xx/gpiolib.c line 230
Quoted 10 lines
arch/arm/plat-s3c24xx/gpiolib.c +10
-0+const u32 *addrp; +u64 addr; + + addrp =of_get_address (dn,0 ,0 ,NULL ); +if (!addrp) +return 0 ; + + addr =of_translate_address (dn, addrp); +if (addr ==OF_BAD_ADDR ) +return 0 ;
Use of_address_to_resource() instead.
Quoted 42 lines
arch/arm/plat-s3c24xx/gpiolib.c +27
-0+ + return chip->base == (addr - S3C24XX_PA_GPIO + S3C24XX_VA_GPIO); +} + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +struct device_node *dn; + +if (!chip->dt_compat) + chip->dt_compat ="samsung,s3c2410-gpio" ; + +for_each_compatible_node (dn,NULL , chip->dt_compat) { +if (s3c24xx_of_base_match (chip, dn)) { + chip->chip.of_node = dn; +break ; + } + } +} + +#else + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +} + +#endif static __init int s3c24xx_gpiolib_init (void ) {@@ -220,6 +264,7 @@if (!chip->config) chip->config = &s3c24xx_gpiocfg_default; +s3c24xx_attach_of_node (chip);s3c_gpiolib_add (chip); }_______________________________________________
devicetree-discuss mailing list
devicetree-discuss at lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
PATCH 2/2 Add GPIO DT support to s3c24xx
Quoted 16 lines · Grant Likely
Quoted 15 lines · Domenico Andreoli
?arch/arm/plat-s3c24xx/gpiolib.c | ? 45 ++++++++++++++++++++++++++++++++++++++++ ?1 file changed, 45 insertions(+)
Index:
b/arch/arm/plat-s3c24xx/gpiolib.c
===================================================================arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 renamed from arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 +0
-0@@ -19,6 +19,8 @@?#include <
linux/ioport.h>
?#include <linux/io.h>
?#include <linux/gpio.h>arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 renamed from arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 +2
-0+#include <linux/of.h> +#include <linux/of_address.h>
Quoted 11 lines
arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 line 104
Quoted 9 lines
?#include <
plat/gpio-core.h>
?#include <plat/gpio-cfg.h>arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 renamed from arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 +3
-0@@ -97,6 +99,9 @@ ? ? ? ? ? ? ? ? ? ? ? .direction_input ? ? ? ?= s3c24xx_gpiolib_banka_input, ? ? ? ? ? ? ? ? ? ? ? .direction_output ? ? ? = s3c24xx_gpiolib_banka_output, ? ? ? ? ? ? ? }, +#ifdef CONFIG_OF_GPIO + ? ? ? ? ? ? .dt_compat = "samsung,s3c2410-gpio-a", +#endifThe '-a' bit I suspect is wrong. ?Aren't all the gpio banks of the same type?
no, the first bank is made of output-only gpio.
-----[ Domenico Andreoli, aka cavok
?--[ http://www.dandreoli.com/gpgkey.asc
?? ---[ 3A0F 2F80 F79C 678A 8936? 4FEE 0677 9033 A20E BC50
PATCH v3 1/1 Add GPIO DT support to s3c24xx
In reply to Grant LikelyFrom: Domenico Andreoli <[email protected]>
Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip.
---
With this new patch there is no need to add the dt_compat field to s3c_gpio_chip, such string is now chosen in base of the s3c gpio chip base address.
Respect to v2, s3c24xx_attach_of_node() now uses of_address_to_resource() instead of of_get_address()+of_translate_address(). I don't see where is the gain.
--- arch/arm/plat-s3c24xx/gpiolib.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
arch/arm/plat-s3c24xx/gpiolib.c +36 -0
@@ -19,6 +19,8 @@#include <linux/ioport.h> #include <linux/io.h> #include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <plat/gpio-core.h> #include <plat/gpio-cfg.h>
@@ -210,6 +212,39 @@ }, }; +#ifdef CONFIG_OF_GPIO + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +struct device_node *dn; +struct resource res; +const char *dt_compat; + +if (chip->base ==S3C2410_GPACON ) + dt_compat ="samsung,s3c2410-gpio-a" ; +else + dt_compat ="samsung,s3c2410-gpio" ; + +for_each_compatible_node (dn,NULL , dt_compat) { +if (of_address_to_resource (dn,0 , &res) <0 ) { +printk (KERN_ERR "%s: unable to translate DT address\n" , dn->full_name); +continue ; + } + +if (chip->base == (res.start -S3C24XX_PA_GPIO +S3C24XX_VA_GPIO )) { + chip->chip.of_node = dn; +break ; + } + } +} + +#else + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +} + +#endif static __init int s3c24xx_gpiolib_init (void ) {
@@ -220,6 +255,7 @@if (!chip->config) chip->config = &s3c24xx_gpiocfg_default; +s3c24xx_attach_of_node (chip);s3c_gpiolib_add (chip); }
PATCH v3 1/1 Add GPIO DT support to s3c24xx
Quoted 58 lines · Domenico Andreoli
From: Domenico Andreoli <[email protected]>
Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip.
Signed-off-by Domenico Andreoli <[email protected]>---
With this new patch there is no need to add the
dt_compatfield tos3c_gpio_chip, such string is now chosen in base of the s3c gpio chip base address.Respect to v2,
s3c24xx_attach_of_node()now usesof_address_to_resource()instead of of_get_address()+of_translate_address(). I don't see where is the gain.--- arch/arm/plat-s3c24xx/gpiolib.c | 36++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
Index:
b/arch/arm/plat-s3c24xx/gpiolib.c
===================================================================arch/arm/plat-s3c24xx/gpiolib.c +21
-0@@ -19,6 +19,8 @@#include <linux/ioport.h> #include <linux/io.h> #include <linux/gpio.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <plat/gpio-core.h> #include <plat/gpio-cfg.h> @@ -210,6 +212,39 @@ }, }; +#ifdef CONFIG_OF_GPIO + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip) +{ +struct device_node *dn; +struct resource res; +const char *dt_compat; + +if (chip->base ==S3C2410_GPACON ) + dt_compat ="samsung,s3c2410-gpio-a" ; +else + dt_compat ="samsung,s3c2410-gpio" ; + +for_each_compatible_node (dn,NULL , dt_compat) { +if (of_address_to_resource (dn,0 , &res) <0 ) { +printk (KERN_ERR "%s: unable to translate DT address\n" , dn- full_name); +continue ; + } +
arch/arm/plat-s3c24xx/gpiolib.c line 244
Quoted 10 lines
arch/arm/plat-s3c24xx/gpiolib.c +10
-0+if (chip->base == (res.start -S3C24XX_PA_GPIO +S3C24XX_VA_GPIO )) { + chip->chip.of_node = dn; +break ; + } + } +} + +#else + +static void s3c24xx_attach_of_node (struct s3c_gpio_chip *chip)
static inline void maybe ;)
Quoted 20 lines
arch/arm/plat-s3c24xx/gpiolib.c +4
-0+{ +} + +#endif static __init int s3c24xx_gpiolib_init (void ){
arch/arm/plat-s3c24xx/gpiolib.c +1
-0@@ -220,6 +255,7 @@if (!chip->config) chip->config = &s3c24xx_gpiocfg_default; +s3c24xx_attach_of_node (chip);s3c_gpiolib_add (chip); }_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel