Re: [PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-21 Thread Thomas Abraham
On 21 August 2012 17:32, Linus Walleij  wrote:
> On Wed, Aug 15, 2012 at 9:57 PM, Thomas Abraham
>  wrote:
>
>> Add information about the Exynos4210 pin banks and driver data which is
>> used by the Samsung pinctrl driver. In addition to this, the support for
>> external gpio and wakeup interrupt support is included and hooked up with
>> the Samsung pinctrl driver.
>
> OK...
>
>> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
>> +config PINCTRL_EXYNOS4
>> +   bool "Pinctrl driver data for Exynos4 SoC"
>> +   depends on ARCH_EXYNOS4 && OF
>
> Since you depend on PINCTRL_SAMSUNG which depends
> on OF you don't need to depend on OF here.

Ok.

>
>> +   depends on PINCTRL_SAMSUNG
>> +   select PINMUX
>> +   select PINCONF
>
> So as noted in the main driver, let PINCTRL_SAMSUNG
> select PINMUX and PINCONF and you need only select
> PINCTRL_SAMSUNG here.

Ok.

>
>> diff --git a/drivers/pinctrl/pinctrl-exynos.c 
>> b/drivers/pinctrl/pinctrl-exynos.c
> (...)
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>
> Do you need these includes? Didn't you put them
> all in "pinctrl-samsung.h"?

Yes, I will fix this.

>
> Overall this looks good and straight-forward, but I cannot figure
> out how the samsung_pinctrl_soc_data is passed to the main
> driver, it seems to be through some DT node but I cannot figure
> this out. Can you explain this?

The main driver uses the .data field of the of_device_id structure to
pass the pointer of the SoC data. So, upon match of a compatible value
which is supported by the main driver with that in dt, the
of_match_node() call can be used to find out the corresponding SoC
data. There are included in the first patch (reference:
samsung_pinctrl_get_soc_data() function and samsung_pinctrl_dt_mach
structure).

>
> Yours,
> Linus Walleij

Thanks,
Thomas.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-21 Thread Linus Walleij
On Wed, Aug 15, 2012 at 9:57 PM, Thomas Abraham
 wrote:

> Add information about the Exynos4210 pin banks and driver data which is
> used by the Samsung pinctrl driver. In addition to this, the support for
> external gpio and wakeup interrupt support is included and hooked up with
> the Samsung pinctrl driver.

OK...

> diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
> +config PINCTRL_EXYNOS4
> +   bool "Pinctrl driver data for Exynos4 SoC"
> +   depends on ARCH_EXYNOS4 && OF

Since you depend on PINCTRL_SAMSUNG which depends
on OF you don't need to depend on OF here.

> +   depends on PINCTRL_SAMSUNG
> +   select PINMUX
> +   select PINCONF

So as noted in the main driver, let PINCTRL_SAMSUNG
select PINMUX and PINCONF and you need only select
PINCTRL_SAMSUNG here.

> diff --git a/drivers/pinctrl/pinctrl-exynos.c 
> b/drivers/pinctrl/pinctrl-exynos.c
(...)
> +#include 
> +#include 
> +#include 
> +#include 

Do you need these includes? Didn't you put them
all in "pinctrl-samsung.h"?

Overall this looks good and straight-forward, but I cannot figure
out how the samsung_pinctrl_soc_data is passed to the main
driver, it seems to be through some DT node but I cannot figure
this out. Can you explain this?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-21 Thread Thomas Abraham
On 21 August 2012 17:32, Linus Walleij linus.wall...@linaro.org wrote:
 On Wed, Aug 15, 2012 at 9:57 PM, Thomas Abraham
 thomas.abra...@linaro.org wrote:

 Add information about the Exynos4210 pin banks and driver data which is
 used by the Samsung pinctrl driver. In addition to this, the support for
 external gpio and wakeup interrupt support is included and hooked up with
 the Samsung pinctrl driver.

 OK...

 diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
 +config PINCTRL_EXYNOS4
 +   bool Pinctrl driver data for Exynos4 SoC
 +   depends on ARCH_EXYNOS4  OF

 Since you depend on PINCTRL_SAMSUNG which depends
 on OF you don't need to depend on OF here.

Ok.


 +   depends on PINCTRL_SAMSUNG
 +   select PINMUX
 +   select PINCONF

 So as noted in the main driver, let PINCTRL_SAMSUNG
 select PINMUX and PINCONF and you need only select
 PINCTRL_SAMSUNG here.

Ok.


 diff --git a/drivers/pinctrl/pinctrl-exynos.c 
 b/drivers/pinctrl/pinctrl-exynos.c
 (...)
 +#include linux/interrupt.h
 +#include linux/irqdomain.h
 +#include linux/irq.h
 +#include linux/of_irq.h

 Do you need these includes? Didn't you put them
 all in pinctrl-samsung.h?

Yes, I will fix this.


 Overall this looks good and straight-forward, but I cannot figure
 out how the samsung_pinctrl_soc_data is passed to the main
 driver, it seems to be through some DT node but I cannot figure
 this out. Can you explain this?

The main driver uses the .data field of the of_device_id structure to
pass the pointer of the SoC data. So, upon match of a compatible value
which is supported by the main driver with that in dt, the
of_match_node() call can be used to find out the corresponding SoC
data. There are included in the first patch (reference:
samsung_pinctrl_get_soc_data() function and samsung_pinctrl_dt_mach
structure).


 Yours,
 Linus Walleij

Thanks,
Thomas.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-21 Thread Linus Walleij
On Wed, Aug 15, 2012 at 9:57 PM, Thomas Abraham
thomas.abra...@linaro.org wrote:

 Add information about the Exynos4210 pin banks and driver data which is
 used by the Samsung pinctrl driver. In addition to this, the support for
 external gpio and wakeup interrupt support is included and hooked up with
 the Samsung pinctrl driver.

OK...

 diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
 +config PINCTRL_EXYNOS4
 +   bool Pinctrl driver data for Exynos4 SoC
 +   depends on ARCH_EXYNOS4  OF

Since you depend on PINCTRL_SAMSUNG which depends
on OF you don't need to depend on OF here.

 +   depends on PINCTRL_SAMSUNG
 +   select PINMUX
 +   select PINCONF

So as noted in the main driver, let PINCTRL_SAMSUNG
select PINMUX and PINCONF and you need only select
PINCTRL_SAMSUNG here.

 diff --git a/drivers/pinctrl/pinctrl-exynos.c 
 b/drivers/pinctrl/pinctrl-exynos.c
(...)
 +#include linux/interrupt.h
 +#include linux/irqdomain.h
 +#include linux/irq.h
 +#include linux/of_irq.h

Do you need these includes? Didn't you put them
all in pinctrl-samsung.h?

Overall this looks good and straight-forward, but I cannot figure
out how the samsung_pinctrl_soc_data is passed to the main
driver, it seems to be through some DT node but I cannot figure
this out. Can you explain this?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-15 Thread Thomas Abraham
Add information about the Exynos4210 pin banks and driver data which is
used by the Samsung pinctrl driver. In addition to this, the support for
external gpio and wakeup interrupt support is included and hooked up with
the Samsung pinctrl driver.

Cc: Linus Walleij 
Cc: Kukjin Kim 
Signed-off-by: Thomas Abraham 
---
 drivers/pinctrl/Kconfig  |7 +
 drivers/pinctrl/Makefile |1 +
 drivers/pinctrl/pinctrl-exynos.c |  555 ++
 drivers/pinctrl/pinctrl-exynos.h |  213 +++
 4 files changed, 776 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pinctrl/pinctrl-exynos.c
 create mode 100644 drivers/pinctrl/pinctrl-exynos.h

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 0d2398f..858afa5 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -165,6 +165,13 @@ config PINCTRL_SAMSUNG
bool "Samsung pinctrl driver"
depends on OF
 
+config PINCTRL_EXYNOS4
+   bool "Pinctrl driver data for Exynos4 SoC"
+   depends on ARCH_EXYNOS4 && OF
+   depends on PINCTRL_SAMSUNG
+   select PINMUX
+   select PINCONF
+
 source "drivers/pinctrl/spear/Kconfig"
 
 endmenu
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 7155301..9665411 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -33,5 +33,6 @@ obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o
 obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o
 obj-$(CONFIG_PINCTRL_COH901)   += pinctrl-coh901.o
 obj-$(CONFIG_PINCTRL_SAMSUNG)  += pinctrl-samsung.o
+obj-$(CONFIG_PINCTRL_EXYNOS4)  += pinctrl-exynos.o
 
 obj-$(CONFIG_PLAT_SPEAR)   += spear/
diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c
new file mode 100644
index 000..f279506
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-exynos.c
@@ -0,0 +1,555 @@
+/*
+ * Exynos specific support for Samsung pinctrl/gpiolib driver with eint 
support.
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Copyright (c) 2012 Linaro Ltd
+ * http://www.linaro.org
+ *
+ * Author: Thomas Abraham 
+ *
+ * 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 file contains the Samsung Exynos specific information required by the
+ * the Samsung pinctrl/gpiolib driver. It also includes the implementation of
+ * external gpio and wakeup interrupt support.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "pinctrl-samsung.h"
+#include "pinctrl-exynos.h"
+
+/* list of external wakeup controllers supported */
+static const struct of_device_id exynos_wkup_irq_ids[] = {
+   { .compatible = "samsung,exynos4210-wakeup-eint", },
+};
+
+static void exynos_gpio_irq_unmask(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd->domain->host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_mask = d->ctrl->geint_mask + edata->eint_offset;
+   unsigned long mask;
+
+   mask = readl(d->virt_base + reg_mask);
+   mask &= ~(1 << edata->pin);
+   writel(mask, d->virt_base + reg_mask);
+}
+
+static void exynos_gpio_irq_mask(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd->domain->host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_mask = d->ctrl->geint_mask + edata->eint_offset;
+   unsigned long mask;
+
+   mask = readl(d->virt_base + reg_mask);
+   mask |= ~(1 << edata->pin);
+   writel(mask, d->virt_base + reg_mask);
+}
+
+static void exynos_gpio_irq_ack(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd->domain->host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_pend = d->ctrl->geint_pend + edata->eint_offset;
+
+   writel(1 << edata->pin, d->virt_base + reg_pend);
+}
+
+static int exynos_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
+{
+   struct samsung_pinctrl_drv_data *d = irqd->domain->host_data;
+   struct samsung_pin_ctrl *ctrl = d->ctrl;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned int shift = EXYNOS_EINT_CON_LEN * edata->pin;
+   unsigned int con, trig_type;
+   unsigned long reg_con = ctrl->geint_con + edata->eint_offset;
+
+   switch (type) {
+   case IRQ_TYPE_EDGE_RISING:
+   trig_type = EXYNOS_EINT_EDGE_RISING;
+   break;
+   case IRQ_TYPE_EDGE_FALLING:
+   trig_type = EXYNOS_EINT_EDGE_FALLING;
+   break;
+   case IRQ_TYPE_EDGE_BOTH:
+   trig_type = EXYNOS_EINT_EDGE_BOTH;
+   break;
+ 

[PATCH v2 2/4] pinctrl: add exynos4210 specific extensions for samsung pinctrl driver

2012-08-15 Thread Thomas Abraham
Add information about the Exynos4210 pin banks and driver data which is
used by the Samsung pinctrl driver. In addition to this, the support for
external gpio and wakeup interrupt support is included and hooked up with
the Samsung pinctrl driver.

Cc: Linus Walleij linus.wall...@linaro.org
Cc: Kukjin Kim kgene@samsung.com
Signed-off-by: Thomas Abraham thomas.abra...@linaro.org
---
 drivers/pinctrl/Kconfig  |7 +
 drivers/pinctrl/Makefile |1 +
 drivers/pinctrl/pinctrl-exynos.c |  555 ++
 drivers/pinctrl/pinctrl-exynos.h |  213 +++
 4 files changed, 776 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pinctrl/pinctrl-exynos.c
 create mode 100644 drivers/pinctrl/pinctrl-exynos.h

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 0d2398f..858afa5 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -165,6 +165,13 @@ config PINCTRL_SAMSUNG
bool Samsung pinctrl driver
depends on OF
 
+config PINCTRL_EXYNOS4
+   bool Pinctrl driver data for Exynos4 SoC
+   depends on ARCH_EXYNOS4  OF
+   depends on PINCTRL_SAMSUNG
+   select PINMUX
+   select PINCONF
+
 source drivers/pinctrl/spear/Kconfig
 
 endmenu
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile
index 7155301..9665411 100644
--- a/drivers/pinctrl/Makefile
+++ b/drivers/pinctrl/Makefile
@@ -33,5 +33,6 @@ obj-$(CONFIG_PINCTRL_TEGRA30) += pinctrl-tegra30.o
 obj-$(CONFIG_PINCTRL_U300) += pinctrl-u300.o
 obj-$(CONFIG_PINCTRL_COH901)   += pinctrl-coh901.o
 obj-$(CONFIG_PINCTRL_SAMSUNG)  += pinctrl-samsung.o
+obj-$(CONFIG_PINCTRL_EXYNOS4)  += pinctrl-exynos.o
 
 obj-$(CONFIG_PLAT_SPEAR)   += spear/
diff --git a/drivers/pinctrl/pinctrl-exynos.c b/drivers/pinctrl/pinctrl-exynos.c
new file mode 100644
index 000..f279506
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-exynos.c
@@ -0,0 +1,555 @@
+/*
+ * Exynos specific support for Samsung pinctrl/gpiolib driver with eint 
support.
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Copyright (c) 2012 Linaro Ltd
+ * http://www.linaro.org
+ *
+ * Author: Thomas Abraham thomas...@samsung.com
+ *
+ * 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 file contains the Samsung Exynos specific information required by the
+ * the Samsung pinctrl/gpiolib driver. It also includes the implementation of
+ * external gpio and wakeup interrupt support.
+ */
+
+#include linux/interrupt.h
+#include linux/irqdomain.h
+#include linux/irq.h
+#include linux/of_irq.h
+
+#include asm/mach/irq.h
+
+#include pinctrl-samsung.h
+#include pinctrl-exynos.h
+
+/* list of external wakeup controllers supported */
+static const struct of_device_id exynos_wkup_irq_ids[] = {
+   { .compatible = samsung,exynos4210-wakeup-eint, },
+};
+
+static void exynos_gpio_irq_unmask(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd-domain-host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_mask = d-ctrl-geint_mask + edata-eint_offset;
+   unsigned long mask;
+
+   mask = readl(d-virt_base + reg_mask);
+   mask = ~(1  edata-pin);
+   writel(mask, d-virt_base + reg_mask);
+}
+
+static void exynos_gpio_irq_mask(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd-domain-host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_mask = d-ctrl-geint_mask + edata-eint_offset;
+   unsigned long mask;
+
+   mask = readl(d-virt_base + reg_mask);
+   mask |= ~(1  edata-pin);
+   writel(mask, d-virt_base + reg_mask);
+}
+
+static void exynos_gpio_irq_ack(struct irq_data *irqd)
+{
+   struct samsung_pinctrl_drv_data *d = irqd-domain-host_data;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned long reg_pend = d-ctrl-geint_pend + edata-eint_offset;
+
+   writel(1  edata-pin, d-virt_base + reg_pend);
+}
+
+static int exynos_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)
+{
+   struct samsung_pinctrl_drv_data *d = irqd-domain-host_data;
+   struct samsung_pin_ctrl *ctrl = d-ctrl;
+   struct exynos_geint_data *edata = irq_data_get_irq_handler_data(irqd);
+   unsigned int shift = EXYNOS_EINT_CON_LEN * edata-pin;
+   unsigned int con, trig_type;
+   unsigned long reg_con = ctrl-geint_con + edata-eint_offset;
+
+   switch (type) {
+   case IRQ_TYPE_EDGE_RISING:
+   trig_type = EXYNOS_EINT_EDGE_RISING;
+   break;
+   case IRQ_TYPE_EDGE_FALLING:
+   trig_type = EXYNOS_EINT_EDGE_FALLING;
+