* [PATCH 1/4] gpio: mpc8xxx: constify of_device_id
@ 2015-07-16 19:08 Uwe Kleine-König
2015-07-16 19:08 ` [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place Uwe Kleine-König
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2015-07-16 19:08 UTC (permalink / raw)
To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, kernel
This variable is not modified in the driver and all functions it it
passed to don't change it either. So it can and should be marked const.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/gpio/gpio-mpc8xxx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index da8e89205f37..0e2dbbb1645b 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -334,7 +334,7 @@ static const struct irq_domain_ops mpc8xxx_gpio_irq_ops = {
.xlate = irq_domain_xlate_twocell,
};
-static struct of_device_id mpc8xxx_gpio_ids[] = {
+static const struct of_device_id mpc8xxx_gpio_ids[] = {
{ .compatible = "fsl,mpc8349-gpio", },
{ .compatible = "fsl,mpc8572-gpio", },
{ .compatible = "fsl,mpc8610-gpio", },
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place
2015-07-16 19:08 [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Uwe Kleine-König
@ 2015-07-16 19:08 ` Uwe Kleine-König
2015-07-27 10:23 ` Linus Walleij
2015-07-16 19:08 ` [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125 Uwe Kleine-König
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2015-07-16 19:08 UTC (permalink / raw)
To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, kernel
The gpio controllers that are handled by the mpc8xxx driver differ
slightly. Up to now some differences were handled by use of
of_device_is_compatible, others by use of struct of_device_id's data.
To make this consistent and easily extendable handle the differences at
a single place.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/gpio/gpio-mpc8xxx.c | 49 +++++++++++++++++++++++++++++++++++----------
1 file changed, 38 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 0e2dbbb1645b..836494420a56 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -312,17 +312,13 @@ static struct irq_chip mpc8xxx_irq_chip = {
.irq_unmask = mpc8xxx_irq_unmask,
.irq_mask = mpc8xxx_irq_mask,
.irq_ack = mpc8xxx_irq_ack,
+ /* this might get overwritten in mpc8xxx_probe() */
.irq_set_type = mpc8xxx_irq_set_type,
};
static int mpc8xxx_gpio_irq_map(struct irq_domain *h, unsigned int irq,
irq_hw_number_t hwirq)
{
- struct mpc8xxx_gpio_chip *mpc8xxx_gc = h->host_data;
-
- if (mpc8xxx_gc->of_dev_id_data)
- mpc8xxx_irq_chip.irq_set_type = mpc8xxx_gc->of_dev_id_data;
-
irq_set_chip_data(irq, h->host_data);
irq_set_chip_and_handler(irq, &mpc8xxx_irq_chip, handle_level_irq);
@@ -334,11 +330,32 @@ static const struct irq_domain_ops mpc8xxx_gpio_irq_ops = {
.xlate = irq_domain_xlate_twocell,
};
+struct mpc8xxx_gpio_devtype {
+ int (*gpio_dir_out)(struct gpio_chip *, unsigned int, int);
+ int (*gpio_get)(struct gpio_chip *, unsigned int);
+ int (*irq_set_type)(struct irq_data *, unsigned int);
+};
+
+static const struct mpc8xxx_gpio_devtype mpc512x_gpio_devtype = {
+ .gpio_dir_out = mpc5121_gpio_dir_out,
+ .irq_set_type = mpc512x_irq_set_type,
+};
+
+static const struct mpc8xxx_gpio_devtype mpc8572_gpio_devtype = {
+ .gpio_get = mpc8572_gpio_get,
+};
+
+static const struct mpc8xxx_gpio_devtype mpc8xxx_gpio_devtype_default = {
+ .gpio_dir_out = mpc8xxx_gpio_dir_out,
+ .gpio_get = mpc8xxx_gpio_get,
+ .irq_set_type = mpc8xxx_irq_set_type,
+};
+
static const struct of_device_id mpc8xxx_gpio_ids[] = {
{ .compatible = "fsl,mpc8349-gpio", },
- { .compatible = "fsl,mpc8572-gpio", },
+ { .compatible = "fsl,mpc8572-gpio", .data = &mpc8572_gpio_devtype, },
{ .compatible = "fsl,mpc8610-gpio", },
- { .compatible = "fsl,mpc5121-gpio", .data = mpc512x_irq_set_type, },
+ { .compatible = "fsl,mpc5121-gpio", .data = &mpc512x_gpio_devtype, },
{ .compatible = "fsl,pq3-gpio", },
{ .compatible = "fsl,qoriq-gpio", },
{}
@@ -351,6 +368,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
struct of_mm_gpio_chip *mm_gc;
struct gpio_chip *gc;
const struct of_device_id *id;
+ const struct mpc8xxx_gpio_devtype *devtype =
+ of_device_get_match_data(&pdev->dev);
int ret;
mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL);
@@ -367,10 +386,18 @@ static int mpc8xxx_probe(struct platform_device *pdev)
mm_gc->save_regs = mpc8xxx_gpio_save_regs;
gc->ngpio = MPC8XXX_GPIO_PINS;
gc->direction_input = mpc8xxx_gpio_dir_in;
- gc->direction_output = of_device_is_compatible(np, "fsl,mpc5121-gpio") ?
- mpc5121_gpio_dir_out : mpc8xxx_gpio_dir_out;
- gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ?
- mpc8572_gpio_get : mpc8xxx_gpio_get;
+
+ if (!devtype)
+ devtype = &mpc8xxx_gpio_devtype_default;
+
+ /*
+ * It's assumed that only a single type of gpio controller is available
+ * on the current machine, so overwriting global data is fine.
+ */
+ mpc8xxx_irq_chip.irq_set_type = devtype->irq_set_type;
+
+ gc->direction_output = devtype->gpio_dir_out ?: mpc8xxx_gpio_dir_out;
+ gc->get = devtype->gpio_get ?: mpc8xxx_gpio_get;
gc->set = mpc8xxx_gpio_set;
gc->set_multiple = mpc8xxx_gpio_set_multiple;
gc->to_irq = mpc8xxx_gpio_to_irq;
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125
2015-07-16 19:08 [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Uwe Kleine-König
2015-07-16 19:08 ` [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place Uwe Kleine-König
@ 2015-07-16 19:08 ` Uwe Kleine-König
2015-07-27 11:52 ` Linus Walleij
2015-07-16 19:08 ` [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c Uwe Kleine-König
2015-07-27 10:21 ` [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Linus Walleij
3 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2015-07-16 19:08 UTC (permalink / raw)
To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, kernel
The gpio controller on MPC5125 is identical to the MPC5121 register
wise, the only difference is that the lines 0..3 are input only instead
of 28..31 on MPC5121.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/gpio/gpio-mpc8xxx.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 836494420a56..4c5137793431 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -174,6 +174,15 @@ static int mpc5121_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val
return mpc8xxx_gpio_dir_out(gc, gpio, val);
}
+static int mpc5125_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
+{
+ /* GPIO 0..3 are input only on MPC5125 */
+ if (gpio <= 3)
+ return -EINVAL;
+
+ return mpc8xxx_gpio_dir_out(gc, gpio, val);
+}
+
static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
{
struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
@@ -341,6 +350,11 @@ static const struct mpc8xxx_gpio_devtype mpc512x_gpio_devtype = {
.irq_set_type = mpc512x_irq_set_type,
};
+static const struct mpc8xxx_gpio_devtype mpc5125_gpio_devtype = {
+ .gpio_dir_out = mpc5125_gpio_dir_out,
+ .irq_set_type = mpc512x_irq_set_type,
+};
+
static const struct mpc8xxx_gpio_devtype mpc8572_gpio_devtype = {
.gpio_get = mpc8572_gpio_get,
};
@@ -356,6 +370,7 @@ static const struct of_device_id mpc8xxx_gpio_ids[] = {
{ .compatible = "fsl,mpc8572-gpio", .data = &mpc8572_gpio_devtype, },
{ .compatible = "fsl,mpc8610-gpio", },
{ .compatible = "fsl,mpc5121-gpio", .data = &mpc512x_gpio_devtype, },
+ { .compatible = "fsl,mpc5125-gpio", .data = &mpc5125_gpio_devtype, },
{ .compatible = "fsl,pq3-gpio", },
{ .compatible = "fsl,qoriq-gpio", },
{}
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c
2015-07-16 19:08 [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Uwe Kleine-König
2015-07-16 19:08 ` [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place Uwe Kleine-König
2015-07-16 19:08 ` [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125 Uwe Kleine-König
@ 2015-07-16 19:08 ` Uwe Kleine-König
2015-07-27 11:54 ` Linus Walleij
2015-07-27 10:21 ` [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Linus Walleij
3 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2015-07-16 19:08 UTC (permalink / raw)
To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, kernel
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
.../devicetree/bindings/gpio/gpio-mpc8xxx.txt | 24 ++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt b/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
new file mode 100644
index 000000000000..0449fc4013f2
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt
@@ -0,0 +1,24 @@
+* Freescale MPC512x/MPC8xxx GPIO controller
+
+Required properties:
+- compatible : Should be "fsl,<soc>-gpio"
+ The following <soc>s are known to be supported:
+ mpc5121, mpc5125, mpc8349, mpc8572, mpc8610, pq3, qoriq
+- reg : Address and length of the register set for the device
+- interrupts : Should be the port interrupt shared by all 32 pins.
+- #gpio-cells : Should be two. The first cell is the pin number and
+ the second cell is used to specify the gpio polarity:
+ 0 = active high
+ 1 = active low
+
+Example:
+
+gpio0: gpio@1100 {
+ compatible = "fsl,mpc5125-gpio";
+ #gpio-cells = <2>;
+ reg = <0x1100 0x080>;
+ interrupts = <78 0x8>;
+ status = "okay";
+};
+
+
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] gpio: mpc8xxx: constify of_device_id
2015-07-16 19:08 [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Uwe Kleine-König
` (2 preceding siblings ...)
2015-07-16 19:08 ` [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c Uwe Kleine-König
@ 2015-07-27 10:21 ` Linus Walleij
2015-07-27 12:32 ` Uwe Kleine-König
3 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2015-07-27 10:21 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
On Thu, Jul 16, 2015 at 9:08 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> This variable is not modified in the driver and all functions it it
> passed to don't change it either. So it can and should be marked const.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Patch applied.
I'll push the tree later today, pls verify that your diacritics look
right now!
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place
2015-07-16 19:08 ` [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place Uwe Kleine-König
@ 2015-07-27 10:23 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-07-27 10:23 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
On Thu, Jul 16, 2015 at 9:08 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> The gpio controllers that are handled by the mpc8xxx driver differ
> slightly. Up to now some differences were handled by use of
> of_device_is_compatible, others by use of struct of_device_id's data.
>
> To make this consistent and easily extendable handle the differences at
> a single place.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Patch applied.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125
2015-07-16 19:08 ` [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125 Uwe Kleine-König
@ 2015-07-27 11:52 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-07-27 11:52 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
On Thu, Jul 16, 2015 at 9:08 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> The gpio controller on MPC5125 is identical to the MPC5121 register
> wise, the only difference is that the lines 0..3 are input only instead
> of 28..31 on MPC5121.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Patch applied.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c
2015-07-16 19:08 ` [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c Uwe Kleine-König
@ 2015-07-27 11:54 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-07-27 11:54 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
On Thu, Jul 16, 2015 at 9:08 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Patch applied.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] gpio: mpc8xxx: constify of_device_id
2015-07-27 10:21 ` [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Linus Walleij
@ 2015-07-27 12:32 ` Uwe Kleine-König
2015-07-27 12:37 ` Linus Walleij
0 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2015-07-27 12:32 UTC (permalink / raw)
To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
Hello Linus,
On Mon, Jul 27, 2015 at 12:21:26PM +0200, Linus Walleij wrote:
> On Thu, Jul 16, 2015 at 9:08 PM, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
>
> > This variable is not modified in the driver and all functions it it
> > passed to don't change it either. So it can and should be marked const.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>
> Patch applied.
>
> I'll push the tree later today, pls verify that your diacritics look
> right now!
It's not urgent, right? (i.e. you pushed for inclusion in next, not for
the other Linus.) Then I have a script that will catch you :-)
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/4] gpio: mpc8xxx: constify of_device_id
2015-07-27 12:32 ` Uwe Kleine-König
@ 2015-07-27 12:37 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-07-27 12:37 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, Sascha Hauer
On Mon, Jul 27, 2015 at 2:32 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>> I'll push the tree later today, pls verify that your diacritics look
>> right now!
>
> It's not urgent, right?
Nope...
Ah, I mean check I got it RIGHT now, not check that
RIGHT NOW, hehehhhh.
> (i.e. you pushed for inclusion in next, not for
> the other Linus.) Then I have a script that will catch you :-)
Awesome, thanks!
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-07-27 12:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 19:08 [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Uwe Kleine-König
2015-07-16 19:08 ` [PATCH 2/4] gpio: mpc8xxx: handle differences between incarnations at a single place Uwe Kleine-König
2015-07-27 10:23 ` Linus Walleij
2015-07-16 19:08 ` [PATCH 3/4] gpio: mpc8xxx: add support for MPC5125 Uwe Kleine-König
2015-07-27 11:52 ` Linus Walleij
2015-07-16 19:08 ` [PATCH 4/4] dt-bindings: gpio: document bindings supported by gpio-mpc8xxx.c Uwe Kleine-König
2015-07-27 11:54 ` Linus Walleij
2015-07-27 10:21 ` [PATCH 1/4] gpio: mpc8xxx: constify of_device_id Linus Walleij
2015-07-27 12:32 ` Uwe Kleine-König
2015-07-27 12:37 ` Linus Walleij
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).