* [PATCH v3 0/3] am335x: set pinmux registers from pins debug file @ 2021-05-20 20:27 Dario Binacchi 2021-05-20 20:27 ` [PATCH v3 3/3] pinctrl: single: set pinmux " Dario Binacchi 2021-05-25 0:18 ` [PATCH v3 0/3] am335x: set pinmux registers " Linus Walleij 0 siblings, 2 replies; 4+ messages in thread From: Dario Binacchi @ 2021-05-20 20:27 UTC (permalink / raw) To: linux-kernel Cc: Dario Binacchi, Tony Lindgren, Drew Fustini, Linus Walleij, Andy Shevchenko, Haojian Zhuang, Jonathan Corbet, linux-arm-kernel, linux-doc, linux-gpio, linux-omap The patch was born from the need to change the slew rate of the LCD pins of a custom AM335x board during EMC tests. The AM335x, as described in a note in section 9.1 of its reference manual [1], is unable to write pinmux registers from user space. The series now makes it possible to write these registers from the pins debug file. [1] https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf Changes in v3: - Use strncpy_from_user() instead of copy_from_user(). - Do not shadow the error code returned by kstrtouint(). - Change pin_dbg_set() interface (char *buf --> unsigned int val). - Describe pin_dbg_set(). - Remove CONFIG_DEV_MEM dependency. - Change pcs_pin_dbg_set() interface (char *buf -> unsigned int val). Changes in v2: - Remove CONFIG_SOC_AM33XX dependency. Dario Binacchi (3): docs/pinctrl: update `pins' description under debugfs pinctrl: core: configure pinmux from pins debug file pinctrl: single: set pinmux from pins debug file Documentation/driver-api/pin-control.rst | 3 ++ drivers/pinctrl/core.c | 63 +++++++++++++++++++++++- drivers/pinctrl/pinctrl-single.c | 13 +++++ include/linux/pinctrl/pinctrl.h | 4 ++ 4 files changed, 81 insertions(+), 2 deletions(-) -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 3/3] pinctrl: single: set pinmux from pins debug file 2021-05-20 20:27 [PATCH v3 0/3] am335x: set pinmux registers from pins debug file Dario Binacchi @ 2021-05-20 20:27 ` Dario Binacchi 2021-05-21 6:44 ` Vladimir Zapolskiy 2021-05-25 0:18 ` [PATCH v3 0/3] am335x: set pinmux registers " Linus Walleij 1 sibling, 1 reply; 4+ messages in thread From: Dario Binacchi @ 2021-05-20 20:27 UTC (permalink / raw) To: linux-kernel Cc: Dario Binacchi, Tony Lindgren, Drew Fustini, Linus Walleij, Andy Shevchenko, Haojian Zhuang, linux-arm-kernel, linux-gpio, linux-omap 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> --- Changes in v3: - Remove CONFIG_DEV_MEM dependency. - Change pcs_pin_dbg_set() interface (char *buf -> unsigned int val). Changes in v2: - Remove CONFIG_SOC_AM33XX dependency. drivers/pinctrl/pinctrl-single.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 2c9c9835f375..1b75236563cf 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -313,6 +313,18 @@ 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, + unsigned int val) +{ + struct pcs_device *pcs; + unsigned int mux_bytes; + + 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 +343,7 @@ 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, + .pin_dbg_set = pcs_pin_dbg_set, .dt_node_to_map = pcs_dt_node_to_map, .dt_free_map = pcs_dt_free_map, }; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 3/3] pinctrl: single: set pinmux from pins debug file 2021-05-20 20:27 ` [PATCH v3 3/3] pinctrl: single: set pinmux " Dario Binacchi @ 2021-05-21 6:44 ` Vladimir Zapolskiy 0 siblings, 0 replies; 4+ messages in thread From: Vladimir Zapolskiy @ 2021-05-21 6:44 UTC (permalink / raw) To: Dario Binacchi, linux-kernel Cc: Tony Lindgren, Drew Fustini, Linus Walleij, Andy Shevchenko, Haojian Zhuang, linux-arm-kernel, linux-gpio, linux-omap Hello Dario, On 5/20/21 11:27 PM, Dario Binacchi wrote: > 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: this makes little sense, because it should be possible to write to the registers without introduction of this interface, pin group/function is the right level of abstraction for your particular task. > 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> I strongly object against this new interface to be added. -- Best wishes, Vladimir _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/3] am335x: set pinmux registers from pins debug file 2021-05-20 20:27 [PATCH v3 0/3] am335x: set pinmux registers from pins debug file Dario Binacchi 2021-05-20 20:27 ` [PATCH v3 3/3] pinctrl: single: set pinmux " Dario Binacchi @ 2021-05-25 0:18 ` Linus Walleij 1 sibling, 0 replies; 4+ messages in thread From: Linus Walleij @ 2021-05-25 0:18 UTC (permalink / raw) To: Dario Binacchi Cc: linux-kernel, Tony Lindgren, Drew Fustini, Andy Shevchenko, Haojian Zhuang, Jonathan Corbet, Linux ARM, Linux Doc Mailing List, open list:GPIO SUBSYSTEM, Linux-OMAP On Thu, May 20, 2021 at 10:27 PM Dario Binacchi <dariobin@libero.it> wrote: > The patch was born from the need to change the slew rate of the LCD pins > of a custom AM335x board during EMC tests. The AM335x, as described in a > note in section 9.1 of its reference manual [1], is unable to write > pinmux registers from user space. The series now makes it possible to > write these registers from the pins debug file. I am going to hold this series back pending more discussion on the ABI and whether it is useful. Yours, Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-25 3:06 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-05-20 20:27 [PATCH v3 0/3] am335x: set pinmux registers from pins debug file Dario Binacchi 2021-05-20 20:27 ` [PATCH v3 3/3] pinctrl: single: set pinmux " Dario Binacchi 2021-05-21 6:44 ` Vladimir Zapolskiy 2021-05-25 0:18 ` [PATCH v3 0/3] am335x: set pinmux registers " 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).