* [patch 1/2] Add dt_compat field to struct s3c_gpio_chip [not found] <20110410152735.338798127@gmail.com> @ 2011-04-10 15:33 ` Domenico Andreoli 2011-04-11 6:41 ` Grant Likely 2011-04-10 15:33 ` [patch 2/2] Add GPIO DT support to s3c24xx Domenico Andreoli 1 sibling, 1 reply; 7+ messages in thread From: Domenico Andreoli @ 2011-04-10 15:33 UTC (permalink / raw) To: linux-arm-kernel From: Domenico Andreoli <cavokz@gmail.com> This new field allows easy creation of GPIO chips in base of struct arrays. Signed-off-by: Domenico Andreoli <cavokz@gmail.com> --- 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 =================================================================== --- a/arch/arm/plat-samsung/include/plat/gpio-core.h 2011-04-07 22:43:45.000000000 +0200 +++ b/arch/arm/plat-samsung/include/plat/gpio-core.h 2011-04-10 16:00:39.000000000 +0200 @@ -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) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch 1/2] Add dt_compat field to struct s3c_gpio_chip 2011-04-10 15:33 ` [patch 1/2] Add dt_compat field to struct s3c_gpio_chip Domenico Andreoli @ 2011-04-11 6:41 ` Grant Likely 0 siblings, 0 replies; 7+ messages in thread From: Grant Likely @ 2011-04-11 6:41 UTC (permalink / raw) To: linux-arm-kernel On Sun, Apr 10, 2011 at 05:33:12PM +0200, Domenico Andreoli wrote: > From: Domenico Andreoli <cavokz@gmail.com> > > This new field allows easy creation of GPIO chips in base of struct arrays. > > Signed-off-by: Domenico Andreoli <cavokz@gmail.com> > > --- > 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 > =================================================================== > --- a/arch/arm/plat-samsung/include/plat/gpio-core.h 2011-04-07 22:43:45.000000000 +0200 > +++ b/arch/arm/plat-samsung/include/plat/gpio-core.h 2011-04-10 16:00:39.000000000 +0200 > @@ -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. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch 2/2] Add GPIO DT support to s3c24xx [not found] <20110410152735.338798127@gmail.com> 2011-04-10 15:33 ` [patch 1/2] Add dt_compat field to struct s3c_gpio_chip Domenico Andreoli @ 2011-04-10 15:33 ` Domenico Andreoli 2011-04-11 6:47 ` Grant Likely 1 sibling, 1 reply; 7+ messages in thread From: Domenico Andreoli @ 2011-04-10 15:33 UTC (permalink / raw) To: linux-arm-kernel From: Domenico Andreoli <cavokz@gmail.com> Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip. Signed-off-by: Domenico Andreoli <cavokz@gmail.com> --- arch/arm/plat-s3c24xx/gpiolib.c | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) Index: b/arch/arm/plat-s3c24xx/gpiolib.c =================================================================== --- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 +++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 @@ -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); } ^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch 2/2] Add GPIO DT support to s3c24xx 2011-04-10 15:33 ` [patch 2/2] Add GPIO DT support to s3c24xx Domenico Andreoli @ 2011-04-11 6:47 ` Grant Likely 2011-04-11 8:53 ` Domenico Andreoli 2011-04-11 9:33 ` [PATCH v3] " Domenico Andreoli 0 siblings, 2 replies; 7+ messages in thread From: Grant Likely @ 2011-04-11 6:47 UTC (permalink / raw) To: linux-arm-kernel On Sun, Apr 10, 2011 at 05:33:16PM +0200, Domenico Andreoli wrote: > From: Domenico Andreoli <cavokz@gmail.com> > > Assign proper OF node (= with matching physical base address) to each > s3c24xx GPIO chip. > > Signed-off-by: Domenico Andreoli <cavokz@gmail.com> Looks pretty good. Minor comments below. g. > > --- > arch/arm/plat-s3c24xx/gpiolib.c | 45 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > Index: b/arch/arm/plat-s3c24xx/gpiolib.c > =================================================================== > --- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 > +++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 > @@ -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 The '-a' bit I suspect is wrong. Aren't all the gpio banks of the same type? > }, > [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; Use of_address_to_resource() instead. > + > + 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch 2/2] Add GPIO DT support to s3c24xx 2011-04-11 6:47 ` Grant Likely @ 2011-04-11 8:53 ` Domenico Andreoli 2011-04-11 9:33 ` [PATCH v3] " Domenico Andreoli 1 sibling, 0 replies; 7+ messages in thread From: Domenico Andreoli @ 2011-04-11 8:53 UTC (permalink / raw) To: linux-arm-kernel On Mon, Apr 11, 2011 at 8:47 AM, Grant Likely <grant.likely@secretlab.ca> wrote: > On Sun, Apr 10, 2011 at 05:33:16PM +0200, Domenico Andreoli wrote: >> >> ?arch/arm/plat-s3c24xx/gpiolib.c | ? 45 ++++++++++++++++++++++++++++++++++++++++ >> ?1 file changed, 45 insertions(+) >> >> Index: b/arch/arm/plat-s3c24xx/gpiolib.c >> =================================================================== >> --- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 16:24:59.000000000 +0200 >> +++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 17:12:32.000000000 +0200 >> @@ -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 > > The '-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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] Add GPIO DT support to s3c24xx 2011-04-11 6:47 ` Grant Likely 2011-04-11 8:53 ` Domenico Andreoli @ 2011-04-11 9:33 ` Domenico Andreoli 2011-04-15 0:08 ` Marek Vasut 1 sibling, 1 reply; 7+ messages in thread From: Domenico Andreoli @ 2011-04-11 9:33 UTC (permalink / raw) To: linux-arm-kernel From: Domenico Andreoli <cavokz@gmail.com> Assign proper OF node (= with matching physical base address) to each s3c24xx GPIO chip. Signed-off-by: Domenico Andreoli <cavokz@gmail.com> --- 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(+) Index: b/arch/arm/plat-s3c24xx/gpiolib.c =================================================================== --- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 23:28:31.000000000 +0200 +++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-11 11:23:36.000000000 +0200 @@ -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); } ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] Add GPIO DT support to s3c24xx 2011-04-11 9:33 ` [PATCH v3] " Domenico Andreoli @ 2011-04-15 0:08 ` Marek Vasut 0 siblings, 0 replies; 7+ messages in thread From: Marek Vasut @ 2011-04-15 0:08 UTC (permalink / raw) To: linux-arm-kernel On Monday, April 11, 2011 11:33:04 AM Domenico Andreoli wrote: > From: Domenico Andreoli <cavokz@gmail.com> > > Assign proper OF node (= with matching physical base address) to each > s3c24xx GPIO chip. > > Signed-off-by: Domenico Andreoli <cavokz@gmail.com> > > --- > > 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(+) > > Index: b/arch/arm/plat-s3c24xx/gpiolib.c > =================================================================== > --- a/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-10 23:28:31.000000000 +0200 > +++ b/arch/arm/plat-s3c24xx/gpiolib.c 2011-04-11 11:23:36.000000000 +0200 > @@ -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) static inline void maybe ;) > +{ > +} > + > +#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); > } > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel at lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-04-15 0:08 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20110410152735.338798127@gmail.com> 2011-04-10 15:33 ` [patch 1/2] Add dt_compat field to struct s3c_gpio_chip Domenico Andreoli 2011-04-11 6:41 ` Grant Likely 2011-04-10 15:33 ` [patch 2/2] Add GPIO DT support to s3c24xx Domenico Andreoli 2011-04-11 6:47 ` Grant Likely 2011-04-11 8:53 ` Domenico Andreoli 2011-04-11 9:33 ` [PATCH v3] " Domenico Andreoli 2011-04-15 0:08 ` Marek Vasut
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).