linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Adamski <k@japko.eu>
To: inus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Maxime Ripard
	<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
	Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Lee Jones <lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Jens Kuske <jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Fabian Frederick <fabf-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org>,
	Vishnu Patekar
	<vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Cc: Krzysztof Adamski <k@japko.eu>
Subject: [PATCH v3 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set
Date: Thu,  4 Feb 2016 00:33:50 +0100	[thread overview]
Message-ID: <1454542430-16572-6-git-send-email-k@japko.eu> (raw)
In-Reply-To: <1454542430-16572-1-git-send-email-k-P4rZei/IPtg@public.gmane.org>

sunxi_pmx_set accepts pin number and then calculates offset by
subtracting pin_base from it. sunxi_pinctrl_gpio_get, on the other hand,
gets offset so we have to convert it to pin number so we won't get
negative value in sunxi_pmx_set.

This was only used on A10 so far, where there is only one GPIO chip with
pin_base set to 0 so it didn't matter. However H3 also requires this
workaround but have two pinmux sections, triggering problem for PL port.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
---
 drivers/pinctrl/sunxi/pinctrl-sunxi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index 7a2465f..96f64a1 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -459,15 +459,16 @@ static int sunxi_pinctrl_gpio_get(struct gpio_chip *chip, unsigned offset)
 	u8 index = sunxi_data_offset(offset);
 	u32 set_mux = pctl->desc->irq_read_needs_mux &&
 			test_bit(FLAG_USED_AS_IRQ, &chip->desc[offset].flags);
+	u32 pin = offset + chip->base;
 	u32 val;
 
 	if (set_mux)
-		sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_INPUT);
+		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_INPUT);
 
 	val = (readl(pctl->membase + reg) >> index) & DATA_PINS_MASK;
 
 	if (set_mux)
-		sunxi_pmx_set(pctl->pctl_dev, offset, SUN4I_FUNC_IRQ);
+		sunxi_pmx_set(pctl->pctl_dev, pin, SUN4I_FUNC_IRQ);
 
 	return !!val;
 }
-- 
2.1.4

  parent reply	other threads:[~2016-02-03 23:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 23:33 [PATCH v3 0/5] pinctrl: sunxi: Add H3 R_PIO controller support Krzysztof Adamski
     [not found] ` <1454542430-16572-1-git-send-email-k-P4rZei/IPtg@public.gmane.org>
2016-02-03 23:33   ` [PATCH v3 1/5] clk: sunxi: Add apb0 gates for H3 Krzysztof Adamski
     [not found]     ` <1454542430-16572-2-git-send-email-k-P4rZei/IPtg@public.gmane.org>
2016-02-04 14:47       ` Jean-Francois Moine
     [not found]         ` <20160204154752.4df7808be3364a98c496c030-GANU6spQydw@public.gmane.org>
2016-02-04 20:56           ` Krzysztof Adamski
     [not found]             ` <20160204205602.GC12071-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-02-05 11:14               ` Maxime Ripard
2016-02-05 11:11           ` Maxime Ripard
2016-02-05 11:58             ` Krzysztof Adamski
     [not found]               ` <20160205115837.GD12071-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-02-09 17:10                 ` Maxime Ripard
2016-02-10  7:17                   ` Krzysztof Adamski
     [not found]                     ` <20160210071713.GA19622-xLeyfSbClftGit24Ens98Q@public.gmane.org>
2016-02-10 15:06                       ` Maxime Ripard
2016-02-06 10:26             ` Jean-Francois Moine
2016-02-09 17:11               ` Maxime Ripard
2016-02-03 23:33   ` [PATCH v3 2/5] dts: sun8i-h3: Add APB0 related clocks and resets Krzysztof Adamski
2016-02-03 23:33   ` [PATCH v3 3/5] pinctrl: sunxi: Add H3 R_PIO controller support Krzysztof Adamski
2016-02-05  9:44     ` Chen-Yu Tsai
     [not found]     ` <1454542430-16572-4-git-send-email-k-P4rZei/IPtg@public.gmane.org>
2016-02-05  9:46       ` Maxime Ripard
2016-02-03 23:33   ` [PATCH v3 4/5] ARM: dts: sun8i-h3: Add R_PIO controller node to the dtsi Krzysztof Adamski
     [not found]     ` <1454542430-16572-5-git-send-email-k-P4rZei/IPtg@public.gmane.org>
2016-02-05  9:46       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v67ftGhjPHjHKQ0iYnOeRbi5qcqyT2P1gePW=UoMm5QRig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-08  8:39           ` Krzysztof Adamski
2016-02-03 23:33   ` Krzysztof Adamski [this message]
2016-02-05  9:45     ` [PATCH v3 5/5] pinctrl: sunxi: Use pin number when calling sunxi_pmx_set Chen-Yu Tsai
     [not found]     ` <1454542430-16572-6-git-send-email-k-P4rZei/IPtg@public.gmane.org>
2016-02-05 11:15       ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1454542430-16572-6-git-send-email-k@japko.eu \
    --to=k@japko.eu \
    --cc=fabf-AgBVmzD5pcezQB+pC5nmwQ@public.gmane.org \
    --cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jenskuske-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=lee-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=vishnupatekar0510-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).