[PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-01 Thread Raphaël Poggi
This driver is based on mach-at91/gpio.c and linux pinctrl driver.
The driver contains the gpio and pinctrl parts (like in linux) because the two 
parts
share some structures and logics.

Signed-off-by: Raphaël Poggi 
---
 drivers/pinctrl/Kconfig|6 +
 drivers/pinctrl/Makefile   |1 +
 drivers/pinctrl/pinctrl-at91.c |  529 
 drivers/pinctrl/pinctrl-at91.h |  148 +++
 4 files changed, 684 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-at91.c
 create mode 100644 drivers/pinctrl/pinctrl-at91.h

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index dffaa4e..ce55c7b 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -7,6 +7,12 @@ config PINCTRL
  from the devicetree. Legacy drivers here may not need this core
  support but instead provide their own SoC specific APIs
 
+config PINCTRL_AT91
+   select PINCTRL
+   bool
+   help
+   The pinmux controller found on AT91 SoCs.
+
 config PINCTRL_IMX_IOMUX_V1
select PINCTRL if OFDEVICE
bool
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 566ba11..3ea8649 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PINCTRL)  += pinctrl.o
+obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
new file mode 100644
index 000..a92a898
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -0,0 +1,529 @@
+/*
+ * Copyright (C) 2005 HP Labs
+ * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 

+ * Copyright (C) 2014 Raphaël Poggi
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include "pinctrl-at91.h"
+
+struct at91_pinctrl {
+struct pinctrl_device pctl;
+struct at91_pinctrl_mux_ops*ops;
+};
+
+struct at91_gpio_chip {
+   struct gpio_chipchip;
+   void __iomem*regbase;   /* PIO bank virtual address */
+   struct at91_pinctrl_mux_ops *ops;   /* ops */
+};
+
+enum at91_mux {
+   AT91_MUX_GPIO = 0,
+   AT91_MUX_PERIPH_A = 1,
+   AT91_MUX_PERIPH_B = 2,
+   AT91_MUX_PERIPH_C = 3,
+   AT91_MUX_PERIPH_D = 4,
+};
+
+#define MAX_GPIO_BANKS 5
+#define to_at91_pinctrl(c) container_of(c, struct at91_pinctrl, pctl);
+#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
+
+#define PULL_UP (1 << 0)
+#define MULTI_DRIVE (1 << 1)
+#define DEGLITCH(1 << 2)
+#define PULL_DOWN   (1 << 3)
+#define DIS_SCHMIT  (1 << 4)
+#define DEBOUNCE(1 << 16)
+#define DEBOUNCE_VAL_SHIFT  17
+#define DEBOUNCE_VAL(0x3fff << DEBOUNCE_VAL_SHIFT)
+
+static int gpio_banks = 0;
+
+static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS];
+
+static inline void __iomem *pin_to_controller(struct at91_pinctrl *info, 
unsigned pin)
+{
+   pin /= MAX_NB_GPIO_PER_BANK;
+   if (likely(pin < gpio_banks))
+   return gpio_chip[pin].regbase;
+
+   return NULL;
+}
+
+/**
+ * struct at91_pinctrl_mux_ops - describes an At91 mux ops group
+ * on new IP with support for periph C and D the way to mux in
+ * periph A and B has changed
+ * So provide the right call back
+ * if not present means the IP does not support it
+ * @get_periph: return the periph mode configured
+ * @mux_A_periph: mux as periph A
+ * @mux_B_periph: mux as periph B
+ * @mux_C_periph: mux as periph C
+ * @mux_D_periph: mux as periph D
+ * @set_deglitch: enable/disable deglitch
+ * @set_debounce: enable/disable debounce
+ * @set_pulldown: enable/disable pulldown
+ * @disable_schmitt_trig: disable schmitt trigger
+ */
+struct at91_pinctrl_mux_ops {
+   enum at91_mux (*get_periph)(void __iomem *pio, unsigned mask);
+   void (*mux_A_periph)(void __iomem *pio, unsigned mask);
+   void (*mux_B_periph)(void __iomem *pio, unsigned mask);
+   void (*mux_C_periph)(void __iomem *pio, unsigned mask);
+   void (*mux_D_periph)(void __iomem *pio, unsigned mask);
+   bool (*get_deglitch)(void __iomem *pio, unsigned pin);
+   void (*se

Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-04 Thread Sascha Hauer
Looks mostly fine.

On Fri, Aug 01, 2014 at 03:24:23PM +0200, Raphaël Poggi wrote:
> This driver is based on mach-at91/gpio.c and linux pinctrl driver.
> The driver contains the gpio and pinctrl parts (like in linux) because the 
> two parts
> share some structures and logics.
> 
> Signed-off-by: Raphaël Poggi 
> ---
> +static struct at91_pinctrl_mux_ops *at91_pinctrl_get_driver_data(struct 
> device_d *dev)
> +{
> +struct at91_pinctrl_mux_ops *ops_data = NULL;
> +int rc;
> +
> +if (dev->device_node) {
> + const struct of_device_id *match;
> + match = of_match_node(at91_pinctrl_dt_ids, dev->device_node);
> + if (!match)
> + ops_data = NULL;
> + else
> + ops_data = (struct at91_pinctrl_mux_ops *)match->data;
> +}
> +else {
> + rc = dev_get_drvdata(dev, (unsigned long *)&ops_data);
> + if (rc)
> + ops_data = NULL;
> +}

Indentation looks garbled in this function.

> +
> + ret = pinctrl_register(&info->pctl);
> + if (ret)
> + return ret;
> +
> + dev_info(dev, "AT91 pinctrl registred\n");

s/registred/registered/

> +
> + ret = gpiochip_add(&at91_gpio->chip);
> + if (ret) {
> + dev_err(dev, "couldn't add gpiochip, ret = %d\n", ret);
> + return ret;
> + }
> +
> + dev_info(dev, "AT91 gpio driver registred\n");

here aswell.

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- |

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


Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-04 Thread Jean-Christophe PLAGNIOL-VILLARD
why do we need it on barebox?

this driver was design for dt-only in linux

Best Regards,
J.
On Aug 1, 2014, at 9:24 PM, Raphaël Poggi  wrote:

> This driver is based on mach-at91/gpio.c and linux pinctrl driver.
> The driver contains the gpio and pinctrl parts (like in linux) because the 
> two parts
> share some structures and logics.
> 
> Signed-off-by: Raphaël Poggi 
> ---
> drivers/pinctrl/Kconfig|6 +
> drivers/pinctrl/Makefile   |1 +
> drivers/pinctrl/pinctrl-at91.c |  529 
> drivers/pinctrl/pinctrl-at91.h |  148 +++
> 4 files changed, 684 insertions(+)
> create mode 100644 drivers/pinctrl/pinctrl-at91.c
> create mode 100644 drivers/pinctrl/pinctrl-at91.h
> 
> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
> index dffaa4e..ce55c7b 100644
> --- a/drivers/pinctrl/Kconfig
> +++ b/drivers/pinctrl/Kconfig
> @@ -7,6 +7,12 @@ config PINCTRL
> from the devicetree. Legacy drivers here may not need this core
> support but instead provide their own SoC specific APIs
> 
> +config PINCTRL_AT91
> + select PINCTRL
> + bool
> + help
> + The pinmux controller found on AT91 SoCs.
> +
> config PINCTRL_IMX_IOMUX_V1
>   select PINCTRL if OFDEVICE
>   bool
> diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
> index 566ba11..3ea8649 100644
> --- a/drivers/pinctrl/Makefile
> +++ b/drivers/pinctrl/Makefile
> @@ -1,4 +1,5 @@
> obj-$(CONFIG_PINCTRL) += pinctrl.o
> +obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
> new file mode 100644
> index 000..a92a898
> --- /dev/null
> +++ b/drivers/pinctrl/pinctrl-at91.c
> @@ -0,0 +1,529 @@
> +/*
> + * Copyright (C) 2005 HP Labs
> + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
> 
> + * Copyright (C) 2014 Raphaël Poggi
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * 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.
> + *
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +
> +#include "pinctrl-at91.h"
> +
> +struct at91_pinctrl {
> +struct pinctrl_device pctl;
> +struct at91_pinctrl_mux_ops  *ops;
> +};
> +
> +struct at91_gpio_chip {
> + struct gpio_chipchip;
> + void __iomem*regbase;   /* PIO bank virtual address */
> + struct at91_pinctrl_mux_ops *ops;   /* ops */
> +};
> +
> +enum at91_mux {
> + AT91_MUX_GPIO = 0,
> + AT91_MUX_PERIPH_A = 1,
> + AT91_MUX_PERIPH_B = 2,
> + AT91_MUX_PERIPH_C = 3,
> + AT91_MUX_PERIPH_D = 4,
> +};
> +
> +#define MAX_GPIO_BANKS   5
> +#define to_at91_pinctrl(c) container_of(c, struct at91_pinctrl, pctl);
> +#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
> +
> +#define PULL_UP (1 << 0)
> +#define MULTI_DRIVE (1 << 1)
> +#define DEGLITCH(1 << 2)
> +#define PULL_DOWN   (1 << 3)
> +#define DIS_SCHMIT  (1 << 4)
> +#define DEBOUNCE(1 << 16)
> +#define DEBOUNCE_VAL_SHIFT  17
> +#define DEBOUNCE_VAL(0x3fff << DEBOUNCE_VAL_SHIFT)
> +
> +static int gpio_banks = 0;
> +
> +static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS];
> +
> +static inline void __iomem *pin_to_controller(struct at91_pinctrl *info, 
> unsigned pin)
> +{
> + pin /= MAX_NB_GPIO_PER_BANK;
> + if (likely(pin < gpio_banks))
> + return gpio_chip[pin].regbase;
> +
> + return NULL;
> +}
> +
> +/**
> + * struct at91_pinctrl_mux_ops - describes an At91 mux ops group
> + * on new IP with support for periph C and D the way to mux in
> + * periph A and B has changed
> + * So provide the right call back
> + * if not present means the IP does not support it
> + * @get_periph: return the periph mode configured
> + * @mux_A_periph: mux as periph A
> + * @mux_B_periph: mux as periph B
> + * @mux_C_periph: mux as periph C
> + * @mux_D_periph: mux as periph D
> + * @set_deglitch: enable/disable deglitch
> + * @set_debounce: enable/disable debounce
> + * @set_pulldown: enable/disable pulldown
> + * @disable_schmitt_trig: disable schmitt trigger
> + */
> +struct at91_pinctrl_mux_ops {
> + enum 

Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-04 Thread Raphaël Poggi
I have planned to add device tree support for the AT91 port.

So I port the pinctrl driver from linux to barebox to be able to use
the pinctrl in device tree, but maybe I made a mistake and there is
another solution.

Best Regards,
Raphaël

2014-08-04 20:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
:
> why do we need it on barebox?
>
> this driver was design for dt-only in linux
>
> Best Regards,
> J.
> On Aug 1, 2014, at 9:24 PM, Raphaël Poggi  wrote:
>
>> This driver is based on mach-at91/gpio.c and linux pinctrl driver.
>> The driver contains the gpio and pinctrl parts (like in linux) because the 
>> two parts
>> share some structures and logics.
>>
>> Signed-off-by: Raphaël Poggi 
>> ---
>> drivers/pinctrl/Kconfig|6 +
>> drivers/pinctrl/Makefile   |1 +
>> drivers/pinctrl/pinctrl-at91.c |  529 
>> 
>> drivers/pinctrl/pinctrl-at91.h |  148 +++
>> 4 files changed, 684 insertions(+)
>> create mode 100644 drivers/pinctrl/pinctrl-at91.c
>> create mode 100644 drivers/pinctrl/pinctrl-at91.h
>>
>> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
>> index dffaa4e..ce55c7b 100644
>> --- a/drivers/pinctrl/Kconfig
>> +++ b/drivers/pinctrl/Kconfig
>> @@ -7,6 +7,12 @@ config PINCTRL
>> from the devicetree. Legacy drivers here may not need this core
>> support but instead provide their own SoC specific APIs
>>
>> +config PINCTRL_AT91
>> + select PINCTRL
>> + bool
>> + help
>> + The pinmux controller found on AT91 SoCs.
>> +
>> config PINCTRL_IMX_IOMUX_V1
>>   select PINCTRL if OFDEVICE
>>   bool
>> diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
>> index 566ba11..3ea8649 100644
>> --- a/drivers/pinctrl/Makefile
>> +++ b/drivers/pinctrl/Makefile
>> @@ -1,4 +1,5 @@
>> obj-$(CONFIG_PINCTRL) += pinctrl.o
>> +obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
>> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
>> new file mode 100644
>> index 000..a92a898
>> --- /dev/null
>> +++ b/drivers/pinctrl/pinctrl-at91.c
>> @@ -0,0 +1,529 @@
>> +/*
>> + * Copyright (C) 2005 HP Labs
>> + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
>> 
>> + * Copyright (C) 2014 Raphaël Poggi
>> + *
>> + * See file CREDITS for list of people who contributed to this
>> + * project.
>> + *
>> + * 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.
>> + *
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#include 
>> +
>> +#include "pinctrl-at91.h"
>> +
>> +struct at91_pinctrl {
>> +struct pinctrl_device pctl;
>> +struct at91_pinctrl_mux_ops  *ops;
>> +};
>> +
>> +struct at91_gpio_chip {
>> + struct gpio_chipchip;
>> + void __iomem*regbase;   /* PIO bank virtual address */
>> + struct at91_pinctrl_mux_ops *ops;   /* ops */
>> +};
>> +
>> +enum at91_mux {
>> + AT91_MUX_GPIO = 0,
>> + AT91_MUX_PERIPH_A = 1,
>> + AT91_MUX_PERIPH_B = 2,
>> + AT91_MUX_PERIPH_C = 3,
>> + AT91_MUX_PERIPH_D = 4,
>> +};
>> +
>> +#define MAX_GPIO_BANKS   5
>> +#define to_at91_pinctrl(c) container_of(c, struct at91_pinctrl, pctl);
>> +#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
>> +
>> +#define PULL_UP (1 << 0)
>> +#define MULTI_DRIVE (1 << 1)
>> +#define DEGLITCH(1 << 2)
>> +#define PULL_DOWN   (1 << 3)
>> +#define DIS_SCHMIT  (1 << 4)
>> +#define DEBOUNCE(1 << 16)
>> +#define DEBOUNCE_VAL_SHIFT  17
>> +#define DEBOUNCE_VAL(0x3fff << DEBOUNCE_VAL_SHIFT)
>> +
>> +static int gpio_banks = 0;
>> +
>> +static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS];
>> +
>> +static inline void __iomem *pin_to_controller(struct at91_pinctrl *info, 
>> unsigned pin)
>> +{
>> + pin /= MAX_NB_GPIO_PER_BANK;
>> + if (likely(pin < gpio_banks))
>> + return gpio_chip[pin].regbase;
>> +
>> + return NULL;
>> +}
>> +
>> +/**
>> + * struct at91_pinctrl_mux_ops - describes an At91 mux ops group
>> + * on new IP with support for periph C and D the way to mux in
>> + * periph A and B has changed
>> + * So provide the right call back
>> + * if not present means the IP does n

Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-04 Thread Sascha Hauer
On Mon, Aug 04, 2014 at 08:37:35PM +0200, Raphaël Poggi wrote:
> I have planned to add device tree support for the AT91 port.
> 
> So I port the pinctrl driver from linux to barebox to be able to use
> the pinctrl in device tree, but maybe I made a mistake and there is
> another solution.

Nope. When you want to add device tree support for AT91 that's exactly
the way to go.
I'm unsure about the duplication of at91_mux_set_A_periph() and friends
here. We already have them in the tree.

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- |

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


Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-05 Thread Jean-Christophe PLAGNIOL-VILLARD

On Aug 5, 2014, at 2:37 AM, Raphaël Poggi  wrote:

> 
> I have planned to add device tree support for the AT91 port.
> 
> So I port the pinctrl driver from linux to barebox to be able to use
> the pinctrl in device tree, but maybe I made a mistake and there is
> another solution.
> 

I’ve a version already that I need to update and send

Best Regards,
J.
> Best Regards,
> Raphaël
> 
> 2014-08-04 20:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
> :
>> why do we need it on barebox?
>> 
>> this driver was design for dt-only in linux
>> 
>> Best Regards,
>> J.
>> On Aug 1, 2014, at 9:24 PM, Raphaël Poggi  wrote:
>> 
>>> This driver is based on mach-at91/gpio.c and linux pinctrl driver.
>>> The driver contains the gpio and pinctrl parts (like in linux) because the 
>>> two parts
>>> share some structures and logics.
>>> 
>>> Signed-off-by: Raphaël Poggi 
>>> ---
>>> drivers/pinctrl/Kconfig|6 +
>>> drivers/pinctrl/Makefile   |1 +
>>> drivers/pinctrl/pinctrl-at91.c |  529 
>>> 
>>> drivers/pinctrl/pinctrl-at91.h |  148 +++
>>> 4 files changed, 684 insertions(+)
>>> create mode 100644 drivers/pinctrl/pinctrl-at91.c
>>> create mode 100644 drivers/pinctrl/pinctrl-at91.h
>>> 
>>> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
>>> index dffaa4e..ce55c7b 100644
>>> --- a/drivers/pinctrl/Kconfig
>>> +++ b/drivers/pinctrl/Kconfig
>>> @@ -7,6 +7,12 @@ config PINCTRL
>>>from the devicetree. Legacy drivers here may not need this core
>>>support but instead provide their own SoC specific APIs
>>> 
>>> +config PINCTRL_AT91
>>> + select PINCTRL
>>> + bool
>>> + help
>>> + The pinmux controller found on AT91 SoCs.
>>> +
>>> config PINCTRL_IMX_IOMUX_V1
>>>  select PINCTRL if OFDEVICE
>>>  bool
>>> diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
>>> index 566ba11..3ea8649 100644
>>> --- a/drivers/pinctrl/Makefile
>>> +++ b/drivers/pinctrl/Makefile
>>> @@ -1,4 +1,5 @@
>>> obj-$(CONFIG_PINCTRL) += pinctrl.o
>>> +obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
>>> diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
>>> new file mode 100644
>>> index 000..a92a898
>>> --- /dev/null
>>> +++ b/drivers/pinctrl/pinctrl-at91.c
>>> @@ -0,0 +1,529 @@
>>> +/*
>>> + * Copyright (C) 2005 HP Labs
>>> + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
>>> 
>>> + * Copyright (C) 2014 Raphaël Poggi
>>> + *
>>> + * See file CREDITS for list of people who contributed to this
>>> + * project.
>>> + *
>>> + * 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.
>>> + *
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include "pinctrl-at91.h"
>>> +
>>> +struct at91_pinctrl {
>>> +struct pinctrl_device pctl;
>>> +struct at91_pinctrl_mux_ops  *ops;
>>> +};
>>> +
>>> +struct at91_gpio_chip {
>>> + struct gpio_chipchip;
>>> + void __iomem*regbase;   /* PIO bank virtual address */
>>> + struct at91_pinctrl_mux_ops *ops;   /* ops */
>>> +};
>>> +
>>> +enum at91_mux {
>>> + AT91_MUX_GPIO = 0,
>>> + AT91_MUX_PERIPH_A = 1,
>>> + AT91_MUX_PERIPH_B = 2,
>>> + AT91_MUX_PERIPH_C = 3,
>>> + AT91_MUX_PERIPH_D = 4,
>>> +};
>>> +
>>> +#define MAX_GPIO_BANKS   5
>>> +#define to_at91_pinctrl(c) container_of(c, struct at91_pinctrl, pctl);
>>> +#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
>>> +
>>> +#define PULL_UP (1 << 0)
>>> +#define MULTI_DRIVE (1 << 1)
>>> +#define DEGLITCH(1 << 2)
>>> +#define PULL_DOWN   (1 << 3)
>>> +#define DIS_SCHMIT  (1 << 4)
>>> +#define DEBOUNCE(1 << 16)
>>> +#define DEBOUNCE_VAL_SHIFT  17
>>> +#define DEBOUNCE_VAL(0x3fff << DEBOUNCE_VAL_SHIFT)
>>> +
>>> +static int gpio_banks = 0;
>>> +
>>> +static struct at91_gpio_chip gpio_chip[MAX_GPIO_BANKS];
>>> +
>>> +static inline void __iomem *pin_to_controller(struct at91_pinctrl *info, 
>>> unsigned pin)
>>> +{
>>> + pin /= MAX_NB_GPIO_PER_BANK;
>>> + if (likely(pin < gpio_banks))
>>> + return gpio_chip[pin].regbase;
>>> +

Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-05 Thread Raphaël Poggi
Ok, so I drop my patch ? Or your version is very similar of my patch
and you can review mine to improve/clean it ?

Best regards,
Raphaël Poggi

2014-08-05 12:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
:
>
> On Aug 5, 2014, at 2:37 AM, Raphaël Poggi  wrote:
>
>>
>> I have planned to add device tree support for the AT91 port.
>>
>> So I port the pinctrl driver from linux to barebox to be able to use
>> the pinctrl in device tree, but maybe I made a mistake and there is
>> another solution.
>>
>
> I’ve a version already that I need to update and send
>
> Best Regards,
> J.
>> Best Regards,
>> Raphaël
>>
>> 2014-08-04 20:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
>> :
>>> why do we need it on barebox?
>>>
>>> this driver was design for dt-only in linux
>>>
>>> Best Regards,
>>> J.
>>> On Aug 1, 2014, at 9:24 PM, Raphaël Poggi  wrote:
>>>
 This driver is based on mach-at91/gpio.c and linux pinctrl driver.
 The driver contains the gpio and pinctrl parts (like in linux) because the 
 two parts
 share some structures and logics.

 Signed-off-by: Raphaël Poggi 
 ---
 drivers/pinctrl/Kconfig|6 +
 drivers/pinctrl/Makefile   |1 +
 drivers/pinctrl/pinctrl-at91.c |  529 
 
 drivers/pinctrl/pinctrl-at91.h |  148 +++
 4 files changed, 684 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-at91.c
 create mode 100644 drivers/pinctrl/pinctrl-at91.h

 diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
 index dffaa4e..ce55c7b 100644
 --- a/drivers/pinctrl/Kconfig
 +++ b/drivers/pinctrl/Kconfig
 @@ -7,6 +7,12 @@ config PINCTRL
from the devicetree. Legacy drivers here may not need this core
support but instead provide their own SoC specific APIs

 +config PINCTRL_AT91
 + select PINCTRL
 + bool
 + help
 + The pinmux controller found on AT91 SoCs.
 +
 config PINCTRL_IMX_IOMUX_V1
  select PINCTRL if OFDEVICE
  bool
 diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
 index 566ba11..3ea8649 100644
 --- a/drivers/pinctrl/Makefile
 +++ b/drivers/pinctrl/Makefile
 @@ -1,4 +1,5 @@
 obj-$(CONFIG_PINCTRL) += pinctrl.o
 +obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
 obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
 diff --git a/drivers/pinctrl/pinctrl-at91.c 
 b/drivers/pinctrl/pinctrl-at91.c
 new file mode 100644
 index 000..a92a898
 --- /dev/null
 +++ b/drivers/pinctrl/pinctrl-at91.c
 @@ -0,0 +1,529 @@
 +/*
 + * Copyright (C) 2005 HP Labs
 + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
 
 + * Copyright (C) 2014 Raphaël Poggi
 + *
 + * See file CREDITS for list of people who contributed to this
 + * project.
 + *
 + * 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.
 + *
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#include 
 +
 +#include 
 +
 +#include "pinctrl-at91.h"
 +
 +struct at91_pinctrl {
 +struct pinctrl_device pctl;
 +struct at91_pinctrl_mux_ops  *ops;
 +};
 +
 +struct at91_gpio_chip {
 + struct gpio_chipchip;
 + void __iomem*regbase;   /* PIO bank virtual address 
 */
 + struct at91_pinctrl_mux_ops *ops;   /* ops */
 +};
 +
 +enum at91_mux {
 + AT91_MUX_GPIO = 0,
 + AT91_MUX_PERIPH_A = 1,
 + AT91_MUX_PERIPH_B = 2,
 + AT91_MUX_PERIPH_C = 3,
 + AT91_MUX_PERIPH_D = 4,
 +};
 +
 +#define MAX_GPIO_BANKS   5
 +#define to_at91_pinctrl(c) container_of(c, struct at91_pinctrl, pctl);
 +#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
 +
 +#define PULL_UP (1 << 0)
 +#define MULTI_DRIVE (1 << 1)
 +#define DEGLITCH(1 << 2)
 +#define PULL_DOWN   (1 << 3)
 +#define DIS_SCHMIT  (1 << 4)
 +#define DEBOUNCE(1 << 16)
 +#define DEBOUNCE_VAL_SHIFT  17
 +#define DEBOUNCE_VAL(0x3fff << DEBOUNCE

Re: [PATCH 1/2] pinctrl: at91: add pinctrl driver

2014-08-06 Thread Raphaël Poggi
Ok, let's do it like that

Best regards,
Raphaël Poggi

2014-08-06 5:48 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
:
>
> On Aug 6, 2014, at 11:46 AM, Jean-Christophe PLAGNIOL-VILLARD 
>  wrote:
>
>>
>> On Aug 5, 2014, at 7:38 PM, Raphaël Poggi  wrote:
>>
>>>
>>> Ok, so I drop my patch ? Or your version is very similar of my patch
>>> and you can review mine to improve/clean it ?
>>
>> I’ve a patch series to have dt on at91, my patch for the pinctrl is not 
>> finish
>>
>
> sorry I mean my patch series is not yet fully clean
>
>> give me few days to send it and we see after
>>
>> Best Regards,
>> J.
>>>
>>> Best regards,
>>> Raphaël Poggi
>>>
>>> 2014-08-05 12:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
>>> :

 On Aug 5, 2014, at 2:37 AM, Raphaël Poggi  wrote:

>
> I have planned to add device tree support for the AT91 port.
>
> So I port the pinctrl driver from linux to barebox to be able to use
> the pinctrl in device tree, but maybe I made a mistake and there is
> another solution.
>

 I’ve a version already that I need to update and send

 Best Regards,
 J.
> Best Regards,
> Raphaël
>
> 2014-08-04 20:26 GMT+02:00 Jean-Christophe PLAGNIOL-VILLARD
> :
>> why do we need it on barebox?
>>
>> this driver was design for dt-only in linux
>>
>> Best Regards,
>> J.
>> On Aug 1, 2014, at 9:24 PM, Raphaël Poggi  wrote:
>>
>>> This driver is based on mach-at91/gpio.c and linux pinctrl driver.
>>> The driver contains the gpio and pinctrl parts (like in linux) because 
>>> the two parts
>>> share some structures and logics.
>>>
>>> Signed-off-by: Raphaël Poggi 
>>> ---
>>> drivers/pinctrl/Kconfig|6 +
>>> drivers/pinctrl/Makefile   |1 +
>>> drivers/pinctrl/pinctrl-at91.c |  529 
>>> 
>>> drivers/pinctrl/pinctrl-at91.h |  148 +++
>>> 4 files changed, 684 insertions(+)
>>> create mode 100644 drivers/pinctrl/pinctrl-at91.c
>>> create mode 100644 drivers/pinctrl/pinctrl-at91.h
>>>
>>> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
>>> index dffaa4e..ce55c7b 100644
>>> --- a/drivers/pinctrl/Kconfig
>>> +++ b/drivers/pinctrl/Kconfig
>>> @@ -7,6 +7,12 @@ config PINCTRL
>>>  from the devicetree. Legacy drivers here may not need this core
>>>  support but instead provide their own SoC specific APIs
>>>
>>> +config PINCTRL_AT91
>>> + select PINCTRL
>>> + bool
>>> + help
>>> + The pinmux controller found on AT91 SoCs.
>>> +
>>> config PINCTRL_IMX_IOMUX_V1
>>>select PINCTRL if OFDEVICE
>>>bool
>>> diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
>>> index 566ba11..3ea8649 100644
>>> --- a/drivers/pinctrl/Makefile
>>> +++ b/drivers/pinctrl/Makefile
>>> @@ -1,4 +1,5 @@
>>> obj-$(CONFIG_PINCTRL) += pinctrl.o
>>> +obj-$(CONFIG_PINCTRL_AT91) += pinctrl-at91.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V1) += imx-iomux-v1.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V2) += imx-iomux-v2.o
>>> obj-$(CONFIG_PINCTRL_IMX_IOMUX_V3) += imx-iomux-v3.o
>>> diff --git a/drivers/pinctrl/pinctrl-at91.c 
>>> b/drivers/pinctrl/pinctrl-at91.c
>>> new file mode 100644
>>> index 000..a92a898
>>> --- /dev/null
>>> +++ b/drivers/pinctrl/pinctrl-at91.c
>>> @@ -0,0 +1,529 @@
>>> +/*
>>> + * Copyright (C) 2005 HP Labs
>>> + * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD 
>>> 
>>> + * Copyright (C) 2014 Raphaël Poggi
>>> + *
>>> + * See file CREDITS for list of people who contributed to this
>>> + * project.
>>> + *
>>> + * 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.
>>> + *
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include "pinctrl-at91.h"
>>> +
>>> +struct at91_pinctrl {
>>> +struct pinctrl_device pctl;
>>> +struct at91_pinctrl_mux_ops  *ops;
>>> +};
>>> +
>>> +struct at91_gpio_chip {
>>> + struct gpio_chipchip;
>>> + void __iomem