linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 00/13] Add pinctrl sysfs and RZ/G2L POEG support
@ 2023-03-06  9:00 Biju Das
  2023-03-06  9:00 ` [PATCH v6 01/13] pinctrl: core: Add pinctrl_get_device() Biju Das
                   ` (11 more replies)
  0 siblings, 12 replies; 44+ messages in thread
From: Biju Das @ 2023-03-06  9:00 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Krzysztof Kozlowski
  Cc: Biju Das, Geert Uytterhoeven, Thierry Reding,
	Uwe Kleine-König, linux-renesas-soc, linux-gpio, devicetree,
	Chris Paterson, Biju Das, Prabhakar Mahadev Lad

The output pins of the general PWM timer (GPT) can be disabled by using
the port output enabling function for the GPT (POEG). Specifically, either
of the following ways can be used.

  * Input level detection of the GTETRGA to GTETRGD pins.
  * Output-disable request from the GPT.
  * Register setting(ie, by setting POEGGn.SSF to 1)

This patch series adds support for controlling output disable function using
sysfs in a generic way as described below.

|    A     |    |     B      |    |     C     |    |     D        |  | E |
|user space|--->|pinctrl core|<-->|SoC pinctrl|<-->|Output disable|--|PWM|
|          |    |            |    |           |    |              |  |   |

A executes command to configure a pin group for pin output disable operation
  echo "fname gname conf conf_val" > configure

B parses the command and identifies the binding device associated with that
  pin group

C matches the binding device against the device registered by D for
  configuration operation

D matches the pin group and configure the pins for Output disable operation

Both D and E are linked together by dt(i.e. PWM channel linked with Output
 disable Port)

eg: echo "gpt4-pins gpt4-pins 0 1" > configure ,will activate output 
    disable by the user.

As part of this added a simple sysfs interface to the generic pinctrl
framework.

  /sys/class/pinctrl/
  `-- output-disable/
      |-- configure         (w/o) ask the kernel to configure a pin group
				  for output disable operation.

Patch #1 to #5 crate a framework for registering pin output disable
device to pincontroller.

Patch #7 to patch #13 are just for testing only(GPT Output-disable
request to POEG)

When dead time error occurs or the GTIOCA pin output value is
the same as the GTIOCB pin output value, output protection is
required. GPT detects this condition and generates output disable
requests to POEG based on the settings in the output disable request
permission bits, such as GTINTAD.GRPDTE, GTINTAD.GRPABH,
GTINTAD.GRPABL. After the POEG receives output disable requests from
each channel and calculates external input using an OR operation, the
POEG generates output disable requests to GPT.

POEG handles output disable request and send an event to userspace.
Userspace clears the fault condition and request poeg to cancel
the output disable request.

Logs:
root@smarc-rzg2l:~# /poeg-generic.sh
[POEG]open
16
pwmchip0
Test case 1 user POEG control
 74:          0          0     GICv3 357 Level     10049400.poeg
Read at address  0x10048434 (0xffffb00b0434): 0x0200031B
Read at address  0x10048438 (0xffff911ef438): 0x03000000
Read at address  0x10049400 (0xffffa8dff400): 0x00000030
Test case 2 user GPT control both high
Read at address  0x10048434 (0xffff8537e434): 0x021B031B
Read at address  0x10048438 (0xffffbb73c438): 0x23000000
Read at address  0x10049400 (0xffffa5742400): 0x00000030
gpt ch:3, irq=2
gpt ch:3, irq=2
Read at address  0x10048434 (0xffffb0193434): 0x021B031B
Read at address  0x10048438 (0xffffae0b4438): 0x03000000
Read at address  0x10049400 (0xffff873f5400): 0x00000030
gpt ch:3, irq=2
 74:          6          0     GICv3 357 Level     10049400.poeg
Test case 3 user GPT control both low
Read at address  0x10048434 (0xffffbadb1434): 0x021B031B
Read at address  0x10048438 (0xffff88720438): 0x43000000
Read at address  0x10049400 (0xffff9d7a9400): 0x00000030
gpt ch:3, irq=4
gpt ch:3, irq=4
Read at address  0x10048434 (0xffff95d68434): 0x021B031B
Read at address  0x10048438 (0xffff82428438): 0x03000000
Read at address  0x10049400 (0xffff92716400): 0x00000030
gpt ch:3, irq=4
 74:         12          0     GICv3 357 Level     10049400.poeg
root@smarc-rzg2l:~#

v5->v6:
 * Dropped binding patch as it is accepted for 6.4.
 * Added sysfs support for configuring pin output disable 
   function in a generic way.
v4->v5:
 * Added Rb tag from Rob.
 * Updated kernel version in sysfs doc.
v3->v4:
 * Replaced companion->renesas,gpt for the phandle to gpt instance
 * Replaced renesas,id->renesas,poeg-id
 * Removed default from renesas,poeg-id as default for a required
   property doesn't make much sense.
 * Updated the example and required properties with above changes
v2->v3:
 * Removed Rb tag from Rob as there are some changes introduced.
 * Added companion property, so that poeg can link with gpt device
 * Documented renesas,id, as identifier for POEGG{A,B,C,D}.
 * Updated the binding example.
 * Added sysfs documentation for output_disable
 * PWM_RZG2L_GPT implies ARCH_RZG2L. So removed ARCH_RZG2L dependency
 * Used dev_get_drvdata to get device data
 * Replaced sprintf->sysfs_emit in show().
v1->v2:
 * Updated binding description.
 * Renamed the file poeg-rzg2l->rzg2l-poeg
 * Removed the macro POEGG as there is only single register and
   updated rzg2l_poeg_write() and rzg2l_poeg_read()
 * Updated error handling in probe()
REF->v1:
 * Modelled as pincontrol as most of its configuration is intended to be
   static and moved driver files from soc to pincontrol directory.
 * Updated reg size in dt binding example.
 * Updated Kconfig

REF:
https://lore.kernel.org/linux-renesas-soc/20220510151112.16249-1-biju.das.jz@bp.renesas.com/

Biju Das (13):
  pinctrl: core: Add pinctrl_get_device()
  pinctrl: Add poutdisops variable to struct pinctrl_desc
  pinctrl: Add sysfs support
  pinctrl: renesas: rzg2l: Add pin output disable support
  soc: renesas: Kconfig: Enable pin output disable for RZ/G2L SoC
  drivers: pinctrl: renesas: Add RZ/G2L POEG driver support
  pwm: rzg2l-gpt: Add support for output disable request from gpt
  pinctrl: renesas: rzg2l-poeg: Add support for GPT Output-Disable
    Request
  pwm: rzg2l-gpt: Add support for output disable when both output low
  pinctrl: renesas: rzg2l-poeg: output-disable request from GPT when
    both outputs are low.
  pwm: rzg2l-gpt: Add support for output disable on dead time error
  pinctrl: renesas: rzg2l-poeg: output-disable request from GPT on dead
    time error
  tools/poeg: Add test app for poeg

 Documentation/ABI/testing/sysfs-class-pinctrl |  32 ++
 drivers/pinctrl/Kconfig                       |   4 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/core.c                        |  52 ++
 drivers/pinctrl/output-disable.c              | 148 ++++++
 drivers/pinctrl/output-disable.h              |  32 ++
 drivers/pinctrl/renesas/Kconfig               |   2 +
 drivers/pinctrl/renesas/Makefile              |   2 +
 drivers/pinctrl/renesas/pinctrl-rzg2l.c       |  44 ++
 drivers/pinctrl/renesas/poeg/Kconfig          |  11 +
 drivers/pinctrl/renesas/poeg/Makefile         |   2 +
 drivers/pinctrl/renesas/poeg/rzg2l-poeg.c     | 486 ++++++++++++++++++
 drivers/pwm/pwm-rzg2l-gpt.c                   | 129 +++++
 drivers/soc/renesas/Kconfig                   |   1 +
 include/linux/pinctrl/consumer.h              |   9 +
 include/linux/pinctrl/output-disable.h        |  42 ++
 include/linux/pinctrl/pinctrl-rzg2l.h         |  35 ++
 include/linux/pinctrl/pinctrl.h               |   4 +
 include/linux/pwm/rzg2l-gpt.h                 |  44 ++
 tools/poeg/Build                              |   1 +
 tools/poeg/Makefile                           |  53 ++
 tools/poeg/poeg_app.c                         |  60 +++
 22 files changed, 1194 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-pinctrl
 create mode 100644 drivers/pinctrl/output-disable.c
 create mode 100644 drivers/pinctrl/output-disable.h
 create mode 100644 drivers/pinctrl/renesas/poeg/Kconfig
 create mode 100644 drivers/pinctrl/renesas/poeg/Makefile
 create mode 100644 drivers/pinctrl/renesas/poeg/rzg2l-poeg.c
 create mode 100644 include/linux/pinctrl/output-disable.h
 create mode 100644 include/linux/pinctrl/pinctrl-rzg2l.h
 create mode 100644 include/linux/pwm/rzg2l-gpt.h
 create mode 100644 tools/poeg/Build
 create mode 100644 tools/poeg/Makefile
 create mode 100644 tools/poeg/poeg_app.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2023-03-28  7:08 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-06  9:00 [PATCH v6 00/13] Add pinctrl sysfs and RZ/G2L POEG support Biju Das
2023-03-06  9:00 ` [PATCH v6 01/13] pinctrl: core: Add pinctrl_get_device() Biju Das
2023-03-06 23:33   ` andy.shevchenko
2023-03-07  8:13     ` Biju Das
2023-03-09 12:54       ` Andy Shevchenko
2023-03-09 13:26         ` Biju Das
2023-03-09 13:44           ` Andy Shevchenko
2023-03-09 14:19             ` Biju Das
2023-03-13 20:42               ` Biju Das
2023-03-13 22:05               ` Linus Walleij
2023-03-14  8:27                 ` Biju Das
2023-03-14  8:42                   ` Linus Walleij
2023-03-28  7:08                     ` Biju Das
2023-03-14  9:33                   ` Geert Uytterhoeven
2023-03-14 11:33                     ` Biju Das
2023-03-15  8:00                       ` Geert Uytterhoeven
2023-03-09 13:05       ` Linus Walleij
2023-03-09 13:18         ` Biju Das
2023-03-06  9:00 ` [PATCH v6 02/13] pinctrl: Add poutdisops variable to struct pinctrl_desc Biju Das
2023-03-06  9:00 ` [PATCH v6 03/13] pinctrl: Add sysfs support Biju Das
2023-03-06 23:38   ` andy.shevchenko
2023-03-07  8:54     ` Biju Das
2023-03-07 13:41   ` Linus Walleij
2023-03-07 14:43     ` Biju Das
2023-03-07 15:15       ` Greg KH
2023-03-28  7:07         ` Biju Das
2023-03-07 14:46     ` Greg KH
2023-03-06  9:00 ` [PATCH v6 04/13] pinctrl: renesas: rzg2l: Add pin output disable support Biju Das
2023-03-06  9:00 ` [PATCH v6 06/13] drivers: pinctrl: renesas: Add RZ/G2L POEG driver support Biju Das
2023-03-06 23:35   ` andy.shevchenko
2023-03-07  8:53     ` Biju Das
2023-03-07  9:58       ` Andy Shevchenko
2023-03-07 10:10         ` Biju Das
2023-03-07 12:30           ` Andy Shevchenko
2023-03-07 12:39             ` Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 07/13] pwm: rzg2l-gpt: Add support for output disable request from gpt Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 08/13] pinctrl: renesas: rzg2l-poeg: Add support for GPT Output-Disable Request Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 09/13] pwm: rzg2l-gpt: Add support for output disable when both output low Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 10/13] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT when both outputs are low Biju Das
2023-03-06 23:39   ` andy.shevchenko
2023-03-07  8:57     ` Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 11/13] pwm: rzg2l-gpt: Add support for output disable on dead time error Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 12/13] pinctrl: renesas: rzg2l-poeg: output-disable request from GPT " Biju Das
2023-03-06  9:00 ` [DO NOT APPLY PATCH v6 13/13] tools/poeg: Add test app for poeg Biju Das

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).