From: Dario Binacchi <dariobin@libero.it>
To: linux-kernel@vger.kernel.org
Cc: Dario Binacchi <dariobin@libero.it>,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
Tony Lindgren <tony@atomide.com>,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-omap@vger.kernel.org
Subject: [PATCH 2/2] pinctrl: single: set pinmux from pins debug file
Date: Sun, 16 May 2021 15:55:31 +0200 [thread overview]
Message-ID: <20210516135531.2203-3-dariobin@libero.it> (raw)
In-Reply-To: <20210516135531.2203-1-dariobin@libero.it>
As described in section 9.1 of the TI reference manual for AM335x [1],
"For writing to the control module registers, the MPU will need to be in
privileged mode of operation and writes will not work from user mode".
By adding the pin_dbg_set helper to pcs_pinctrl_ops it will be possible
to write these registers from the pins debug:
cd /sys/kernel/debug/pinctrl/44e10800.pinmux-pinctrl-single/
echo <pin-number> <reg-value> >pins
[1] https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf
Signed-off-by: Dario Binacchi <dariobin@libero.it>
---
drivers/pinctrl/pinctrl-single.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 2c9c9835f375..cdbc2298360d 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -313,6 +313,23 @@ static void pcs_pin_dbg_show(struct pinctrl_dev *pctldev,
seq_printf(s, "%zx %08x %s ", pa, val, DRIVER_NAME);
}
+static int pcs_pin_dbg_set(struct pinctrl_dev *pctldev, unsigned int pin,
+ char *buf)
+{
+ struct pcs_device *pcs;
+ unsigned int val, mux_bytes;
+
+ buf = skip_spaces(buf);
+ if (kstrtouint(buf, 0, &val))
+ return -EINVAL;
+
+ pcs = pinctrl_dev_get_drvdata(pctldev);
+
+ mux_bytes = pcs->width / BITS_PER_BYTE;
+ pcs->write(val, pcs->base + pin * mux_bytes);
+ return 0;
+}
+
static void pcs_dt_free_map(struct pinctrl_dev *pctldev,
struct pinctrl_map *map, unsigned num_maps)
{
@@ -331,6 +348,9 @@ static const struct pinctrl_ops pcs_pinctrl_ops = {
.get_group_name = pinctrl_generic_get_group_name,
.get_group_pins = pinctrl_generic_get_group_pins,
.pin_dbg_show = pcs_pin_dbg_show,
+#if IS_ENABLED(CONFIG_DEVMEM) && IS_ENABLED(CONFIG_SOC_AM33XX)
+ .pin_dbg_set = pcs_pin_dbg_set,
+#endif
.dt_node_to_map = pcs_dt_node_to_map,
.dt_free_map = pcs_dt_free_map,
};
--
2.17.1
next prev parent reply other threads:[~2021-05-16 13:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-16 13:55 [PATCH 0/2] am335x: set pinmux registers from pins debug file Dario Binacchi
2021-05-16 13:55 ` [PATCH 1/2] pinctrl: core: configure pinmux " Dario Binacchi
2021-05-17 20:02 ` Andy Shevchenko
2021-05-17 22:57 ` Drew Fustini
2021-05-18 9:38 ` Dario Binacchi
2021-05-18 10:21 ` Drew Fustini
2021-05-18 10:41 ` Andy Shevchenko
2021-05-18 13:57 ` Dario Binacchi
2021-05-18 14:01 ` Andy Shevchenko
2021-05-19 10:02 ` Drew Fustini
2021-05-19 11:27 ` Andy Shevchenko
2021-05-20 4:17 ` Drew Fustini
2021-05-20 8:10 ` Andy Shevchenko
2021-05-16 13:55 ` Dario Binacchi [this message]
2021-05-17 5:57 ` [PATCH 2/2] pinctrl: single: set " Tony Lindgren
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=20210516135531.2203-3-dariobin@libero.it \
--to=dariobin@libero.it \
--cc=haojian.zhuang@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
/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).