mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mach-at91: declare device tree clock
@ 2014-09-08 13:07 Raphaël Poggi
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: add driver data Raphaël Poggi
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Raphaël Poggi @ 2014-09-08 13:07 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

This commit use the clkdev_add_physbase function, to declare device tree and non device tree gpio clocks.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 arch/arm/mach-at91/at91sam9g45.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 9a50deb..f8d069f 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -192,11 +192,6 @@ static struct clk_lookup periph_clocks_lookups[] = {
 	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
 	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
-	CLKDEV_DEV_ID("at91rm9200-gpio0", &pioA_clk),
-	CLKDEV_DEV_ID("at91rm9200-gpio1", &pioB_clk),
-	CLKDEV_DEV_ID("at91rm9200-gpio2", &pioC_clk),
-	CLKDEV_DEV_ID("at91rm9200-gpio3", &pioDE_clk),
-	CLKDEV_DEV_ID("at91rm9200-gpio4", &pioDE_clk),
 	CLKDEV_DEV_ID("at91-pit", &mck),
 	CLKDEV_CON_DEV_ID("hck1", "atmel_lcdfb", &lcdc_clk),
 };
@@ -238,6 +233,14 @@ static void __init at91sam9g45_register_clocks(void)
 	clkdev_add_table(usart_clocks_lookups,
 			 ARRAY_SIZE(usart_clocks_lookups));
 
+	clkdev_add_physbase(&twi0_clk, 0xfff84000, NULL);
+	clkdev_add_physbase(&twi1_clk, 0xfff88000, NULL);
+        clkdev_add_physbase(&pioA_clk, 0xfffff200, NULL);
+        clkdev_add_physbase(&pioB_clk, 0xfffff400, NULL);
+        clkdev_add_physbase(&pioC_clk, 0xfffff600, NULL);
+        clkdev_add_physbase(&pioDE_clk, 0xfffff800, NULL);
+        clkdev_add_physbase(&pioDE_clk, 0xfffffa00, NULL);
+
 	if (cpu_is_at91sam9m10() || cpu_is_at91sam9m11())
 		clk_register(&vdec_clk);
 
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] pinctrl: at91: add driver data
  2014-09-08 13:07 [PATCH] mach-at91: declare device tree clock Raphaël Poggi
@ 2014-09-08 13:07 ` Raphaël Poggi
  2014-09-08 13:46   ` Sascha Hauer
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: fix the pin_to_controller function Raphaël Poggi
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Raphaël Poggi @ 2014-09-08 13:07 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

This commit adds the driver data for the gpio-at91 driver.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index d3423d0..29e54cf 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -606,8 +606,10 @@ static struct gpio_ops at91_gpio_ops = {
 static struct of_device_id at91_gpio_dt_ids[] = {
 	{
 		.compatible = "atmel,at91rm9200-gpio",
+                .data = (unsigned long)&at91rm9200_ops,
 	}, {
 		.compatible = "atmel,at91sam9x5-gpio",
+		.data = (unsigned long)&at91sam9x5_ops,
 	}, {
 		/* sentinel */
 	},
@@ -629,6 +631,12 @@ static int at91_gpio_probe(struct device_d *dev)
 
 	at91_gpio = &gpio_chip[alias_idx];
 
+	ret = dev_get_drvdata(dev, (unsigned long *)&at91_gpio->ops);
+        if (ret) {
+                dev_err(dev, "dev_get_drvdata failed: %d\n", ret);
+                return ret;
+        }
+
 	clk = clk_get(dev, NULL);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
@@ -667,8 +675,10 @@ static int at91_gpio_probe(struct device_d *dev)
 static struct platform_device_id at91_gpio_ids[] = {
 	{
 		.name = "at91rm9200-gpio",
+                .driver_data = (unsigned long)&at91rm9200_ops,
 	}, {
 		.name = "at91sam9x5-gpio",
+		.driver_data = (unsigned long)&at91sam9x5_ops,
 	}, {
 		/* sentinel */
 	},
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] pinctrl: at91: fix the pin_to_controller function
  2014-09-08 13:07 [PATCH] mach-at91: declare device tree clock Raphaël Poggi
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: add driver data Raphaël Poggi
@ 2014-09-08 13:07 ` Raphaël Poggi
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: retrieve device id in non dtb probe Raphaël Poggi
  2014-09-08 13:37 ` [PATCH] mach-at91: declare device tree clock Sascha Hauer
  3 siblings, 0 replies; 6+ messages in thread
From: Raphaël Poggi @ 2014-09-08 13:07 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

Other functions use pin_to_controller to retrieve a at91_gpio_chip structure,
so fix pin_to_controller to return the correct value.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index e212f7a..3dc81c7 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -71,11 +71,11 @@ static int gpio_banks;
 
 static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS];
 
-static inline void __iomem *pin_to_controller(unsigned pin)
+static inline struct at91_gpio_chip *pin_to_controller(unsigned pin)
 {
 	pin /= MAX_NB_GPIO_PER_BANK;
 	if (likely(pin < gpio_banks))
-		return gpio_chip[pin].regbase;
+		return &gpio_chip[pin];
 
 	return NULL;
 }
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] pinctrl: at91: retrieve device id in non dtb probe
  2014-09-08 13:07 [PATCH] mach-at91: declare device tree clock Raphaël Poggi
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: add driver data Raphaël Poggi
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: fix the pin_to_controller function Raphaël Poggi
@ 2014-09-08 13:07 ` Raphaël Poggi
  2014-09-08 13:37 ` [PATCH] mach-at91: declare device tree clock Sascha Hauer
  3 siblings, 0 replies; 6+ messages in thread
From: Raphaël Poggi @ 2014-09-08 13:07 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

We need to retrieve the device id in device tree/non device tree case.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 3dc81c7..d3423d0 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -618,9 +618,14 @@ static int at91_gpio_probe(struct device_d *dev)
 	struct at91_gpio_chip *at91_gpio;
 	struct clk *clk;
 	int ret;
-	int alias_idx = of_alias_get_id(dev->device_node, "gpio");
+	int alias_idx;
 
-	BUG_ON(dev->id > MAX_GPIO_BANKS);
+	if (dev->device_node)
+		alias_idx = of_alias_get_id(dev->device_node, "gpio");
+	else
+		alias_idx = dev->id;
+
+	BUG_ON(alias_idx > MAX_GPIO_BANKS);
 
 	at91_gpio = &gpio_chip[alias_idx];
 
@@ -646,7 +651,7 @@ static int at91_gpio_probe(struct device_d *dev)
 	at91_gpio->chip.ops = &at91_gpio_ops;
 	at91_gpio->chip.ngpio = MAX_NB_GPIO_PER_BANK;
 	at91_gpio->chip.dev = dev;
-	at91_gpio->chip.base = dev->id * MAX_NB_GPIO_PER_BANK;
+	at91_gpio->chip.base = alias_idx * MAX_NB_GPIO_PER_BANK;
 
 	ret = gpiochip_add(&at91_gpio->chip);
 	if (ret) {
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mach-at91: declare device tree clock
  2014-09-08 13:07 [PATCH] mach-at91: declare device tree clock Raphaël Poggi
                   ` (2 preceding siblings ...)
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: retrieve device id in non dtb probe Raphaël Poggi
@ 2014-09-08 13:37 ` Sascha Hauer
  3 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2014-09-08 13:37 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

On Mon, Sep 08, 2014 at 03:07:54PM +0200, Raphaël Poggi wrote:
> This commit use the clkdev_add_physbase function, to declare device tree and non device tree gpio clocks.
> 
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  arch/arm/mach-at91/at91sam9g45.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
> index 9a50deb..f8d069f 100644
> --- a/arch/arm/mach-at91/at91sam9g45.c
> +++ b/arch/arm/mach-at91/at91sam9g45.c
> @@ -192,11 +192,6 @@ static struct clk_lookup periph_clocks_lookups[] = {
>  	CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci1", &mmc1_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi0", &spi0_clk),
>  	CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi1", &spi1_clk),
> -	CLKDEV_DEV_ID("at91rm9200-gpio0", &pioA_clk),
> -	CLKDEV_DEV_ID("at91rm9200-gpio1", &pioB_clk),
> -	CLKDEV_DEV_ID("at91rm9200-gpio2", &pioC_clk),
> -	CLKDEV_DEV_ID("at91rm9200-gpio3", &pioDE_clk),
> -	CLKDEV_DEV_ID("at91rm9200-gpio4", &pioDE_clk),
>  	CLKDEV_DEV_ID("at91-pit", &mck),
>  	CLKDEV_CON_DEV_ID("hck1", "atmel_lcdfb", &lcdc_clk),
>  };
> @@ -238,6 +233,14 @@ static void __init at91sam9g45_register_clocks(void)
>  	clkdev_add_table(usart_clocks_lookups,
>  			 ARRAY_SIZE(usart_clocks_lookups));
>  
> +	clkdev_add_physbase(&twi0_clk, 0xfff84000, NULL);
> +	clkdev_add_physbase(&twi1_clk, 0xfff88000, NULL);
> +        clkdev_add_physbase(&pioA_clk, 0xfffff200, NULL);
> +        clkdev_add_physbase(&pioB_clk, 0xfffff400, NULL);
> +        clkdev_add_physbase(&pioC_clk, 0xfffff600, NULL);
> +        clkdev_add_physbase(&pioDE_clk, 0xfffff800, NULL);
> +        clkdev_add_physbase(&pioDE_clk, 0xfffffa00, NULL);
> +

Indentation is done with tabs here, please fix. Also the other patches
contain spaces for indentation.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: at91: add driver data
  2014-09-08 13:07 ` [PATCH] pinctrl: at91: add driver data Raphaël Poggi
@ 2014-09-08 13:46   ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2014-09-08 13:46 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

On Mon, Sep 08, 2014 at 03:07:55PM +0200, Raphaël Poggi wrote:
> This commit adds the driver data for the gpio-at91 driver.


Could you explain what exactly this patch fixes? It seems without this
patch the pinctrl part is non functional. Is this correct?

Sascha

> 
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  drivers/pinctrl/pinctrl-at91.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> index d3423d0..29e54cf 100644
> --- a/drivers/pinctrl/pinctrl-at91.c
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -606,8 +606,10 @@ static struct gpio_ops at91_gpio_ops = {
>  static struct of_device_id at91_gpio_dt_ids[] = {
>  	{
>  		.compatible = "atmel,at91rm9200-gpio",
> +                .data = (unsigned long)&at91rm9200_ops,
>  	}, {
>  		.compatible = "atmel,at91sam9x5-gpio",
> +		.data = (unsigned long)&at91sam9x5_ops,
>  	}, {
>  		/* sentinel */
>  	},
> @@ -629,6 +631,12 @@ static int at91_gpio_probe(struct device_d *dev)
>  
>  	at91_gpio = &gpio_chip[alias_idx];
>  
> +	ret = dev_get_drvdata(dev, (unsigned long *)&at91_gpio->ops);
> +        if (ret) {
> +                dev_err(dev, "dev_get_drvdata failed: %d\n", ret);
> +                return ret;
> +        }
> +
>  	clk = clk_get(dev, NULL);
>  	if (IS_ERR(clk)) {
>  		ret = PTR_ERR(clk);
> @@ -667,8 +675,10 @@ static int at91_gpio_probe(struct device_d *dev)
>  static struct platform_device_id at91_gpio_ids[] = {
>  	{
>  		.name = "at91rm9200-gpio",
> +                .driver_data = (unsigned long)&at91rm9200_ops,
>  	}, {
>  		.name = "at91sam9x5-gpio",
> +		.driver_data = (unsigned long)&at91sam9x5_ops,
>  	}, {
>  		/* sentinel */
>  	},
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-08 13:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-08 13:07 [PATCH] mach-at91: declare device tree clock Raphaël Poggi
2014-09-08 13:07 ` [PATCH] pinctrl: at91: add driver data Raphaël Poggi
2014-09-08 13:46   ` Sascha Hauer
2014-09-08 13:07 ` [PATCH] pinctrl: at91: fix the pin_to_controller function Raphaël Poggi
2014-09-08 13:07 ` [PATCH] pinctrl: at91: retrieve device id in non dtb probe Raphaël Poggi
2014-09-08 13:37 ` [PATCH] mach-at91: declare device tree clock Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox