This patch adds support for the zynqmp modepin GPIO controller and
documented for the same. GPIO modepin driver set and get the value and
status of the PS_MODE pin, based on device-tree pin configuration.
These four-bits boot-mode pins are dedicated configurable as input/output.
After the stabilization of the system,these mode pins are sampled.
To access GPIO pins, added Xilinx ZynqMP firmware MDIO API support to
set and get PS_MODE pins value and status. These APIs are interface
APIs, between the mode pin controller driver and low-level API.
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
- DT Documentation- Addressed review comments: Update commit message
- Modepin driver- Addressed review comments:
- Update APIs
- Removed unwanted variables
- Handle return path for probe function
Review Comments:
https://lore.kernel.org/linux-arm-kernel/20210624205055.GA1961487@robh.at.kernel.org/T/#u
---
Piyush Mehta (3):
firmware: zynqmp: Add MMIO read and write support for PS_MODE pin
dt-bindings: gpio: zynqmp: Add binding documentation for modepin
gpio: modepin: Add driver support for modepin GPIO controller
.../bindings/gpio/xlnx,zynqmp-gpio-modepin.yaml | 41 ++++++
drivers/firmware/xilinx/zynqmp.c | 46 ++++++
drivers/gpio/Kconfig | 12 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-zynqmp-modepin.c | 158 +++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 14 ++
6 files changed, 272 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/xlnx,zynqmp-gpio-modepin.yaml
create mode 100644 drivers/gpio/gpio-zynqmp-modepin.c
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
---
drivers/firmware/xilinx/zynqmp.c | 46 ++++++++++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 14 +++++++++++
2 files changed, 60 insertions(+)
@@ -28,6 +28,13 @@/* Max HashMap Order for PM API feature check (1<<7 = 128) */#define PM_API_FEATURE_CHECK_MAX_ORDER 7+/* CRL registers and bitfields */+#define CRL_APB_BASE 0xFF5E0000U+/* BOOT_PIN_CTRL- Used to control the mode pins after boot */+#define CRL_APB_BOOT_PIN_CTRL (CRL_APB_BASE + (0x250U))+/* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */+#define CRL_APB_BOOTPIN_CTRL_MASK 0xF0FU+staticboolfeature_check_enabled;staticDEFINE_HASHTABLE(pm_api_features_map,PM_API_FEATURE_CHECK_MAX_ORDER);
@@ -0,0 +1,41 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:"http://devicetree.org/schemas/gpio/xlnx,zynqmp-gpio-modepin.yaml#"+$schema:"http://devicetree.org/meta-schemas/core.yaml#"++title:ZynqMP Mode Pin GPIO controller++description:+PS_MODE is 4-bits boot mode pins sampled on POR deassertion. Mode Pin+GPIO controller with configurable from numbers of pins (from 0 to 3 per+PS_MODE). Every pin can be configured as input/output.++maintainers:+-Piyush Mehta <piyush.mehta@xilinx.com>++properties:+compatible:+const:xlnx,zynqmp-gpio-modepin++gpio-controller:true++"#gpio-cells":+const:2++required:+-compatible+-gpio-controller+-"#gpio-cells"++additionalProperties:false++examples:+-|+modepin_gpio:gpio {+compatible = "xlnx,zynqmp-gpio-modepin";+gpio-controller;+#gpio-cells = <2>;+};++...
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
This patch adds driver support for the zynqmp modepin GPIO controller.
GPIO modepin driver set and get the value and status of the PS_MODE pin,
based on device-tree pin configuration. These four mode pins are
configurable as input/output. The mode pin has a control register, which
have lower four-bits [0:3] are configurable as input/output, next four-bits
can be used for reading the data as input[4:7], and next setting the
output pin state output[8:11].
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Modepin driver- Addressed review comments:
- Update APIs
- Removed unwanted variables
- Handle return path for probe function
https://lore.kernel.org/linux-arm-kernel/20210615080553.2021061-2-piyush.mehta@xilinx.com/T/#m276c8a5c52f8dc1ed1cd91a2d660f78d498e4ae5
---
drivers/gpio/Kconfig | 12 +++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-zynqmp-modepin.c | 158 +++++++++++++++++++++++++++++++++++++
3 files changed, 171 insertions(+)
create mode 100644 drivers/gpio/gpio-zynqmp-modepin.c
From: Michal Simek <hidden> Date: 2021-08-06 05:49:14
On 8/5/21 7:42 PM, Piyush Mehta wrote:
quoted hunk
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
---
drivers/firmware/xilinx/zynqmp.c | 46 ++++++++++++++++++++++++++++++++++++
include/linux/firmware/xlnx-zynqmp.h | 14 +++++++++++
2 files changed, 60 insertions(+)
@@ -28,6 +28,13 @@/* Max HashMap Order for PM API feature check (1<<7 = 128) */#define PM_API_FEATURE_CHECK_MAX_ORDER 7+/* CRL registers and bitfields */+#define CRL_APB_BASE 0xFF5E0000U+/* BOOT_PIN_CTRL- Used to control the mode pins after boot */+#define CRL_APB_BOOT_PIN_CTRL (CRL_APB_BASE + (0x250U))+/* BOOT_PIN_CTRL_MASK- out_val[11:8], out_en[3:0] */+#define CRL_APB_BOOTPIN_CTRL_MASK 0xF0FU+staticboolfeature_check_enabled;staticDEFINE_HASHTABLE(pm_api_features_map,PM_API_FEATURE_CHECK_MAX_ORDER);
Hi Piyush,
thanks for your patch!
Can you explain one thing to me: since this is now a GPIO driver
that means "General Purpos Input/Output", then these bits are
accessed like this:
On Thu, Aug 5, 2021 at 7:43 PM Piyush Mehta [off-list ref] wrote:
+ ret = zynqmp_pm_bootmode_read(&bootpin_val);
This does not look very general purpose. These seem to be all about
boot mode, right?
So can you explain why this should be a GPIO driver at all?
I understand it is sometimes convenient to describe stuff as GPIO even
if it is not (for example to get a convenient userspace interface) but
as maintainers
we really need to make sure that the subsystem is not being abused
for things not GPIO.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Aug 5, 2021 at 7:42 PM Piyush Mehta [off-list ref] wrote:
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
I doubt this is "GPIO".
General Purpose? I think not. It seems to be about boot mode.
If you need a userspace ABI, then add sysfs files to this firmware
driver instead of bridging it to the GPIO subsystem.
However I can be argued down from usecases etc that it is used as
GPIO but I need to push back on this.
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Michal Simek <hidden> Date: 2021-08-11 13:30:17
Hi Linus,
On 8/11/21 2:59 PM, Linus Walleij wrote:
Hi Piyush,
thanks for your patch!
Can you explain one thing to me: since this is now a GPIO driver
that means "General Purpos Input/Output", then these bits are
accessed like this:
On Thu, Aug 5, 2021 at 7:43 PM Piyush Mehta [off-list ref] wrote:
quoted
+ ret = zynqmp_pm_bootmode_read(&bootpin_val);
This does not look very general purpose. These seem to be all about
boot mode, right?
So can you explain why this should be a GPIO driver at all?
I understand it is sometimes convenient to describe stuff as GPIO even
if it is not (for example to get a convenient userspace interface) but
as maintainers
we really need to make sure that the subsystem is not being abused
for things not GPIO.
They are bootmode pins because that pins are designed and used by ROM to
get information which boot device should be used.
But after this is it is really behaving as generic purpose I/O pins.
Xilinx is using them for years for usb phy resets. I have also seen them
to be used for other reset functionality.
And that's exactly what we are trying to do here by this driver. Because
usb hubs/phys have reset normally connected via gpio pin which is
toggled. And we have boards where these resets are connected via these
pins or via hard gpio IP or via i2c-gpio expanders that's why IMHO this
option should be designed in the same way to have gpio reset
functionality added dwc3 and based on DT/board bootmode gpio, ps gpio,
pl gpio, i2c gpio or gpio over power regulators, etc will be used.
Please let me know if you want to get more information about it.
Thanks,
Michal
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Aug 11, 2021 at 3:08 PM Linus Walleij [off-list ref] wrote:
On Thu, Aug 5, 2021 at 7:42 PM Piyush Mehta [off-list ref] wrote:
quoted
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
I doubt this is "GPIO".
General Purpose? I think not. It seems to be about boot mode.
Agreed.
If you need a userspace ABI, then add sysfs files to this firmware
driver instead of bridging it to the GPIO subsystem.
I don't really want custom user interfaces in firmware drivers either.
What is the high-level description of the 'PS_MODE' here? Is
this perhaps something we already have a user interface for?
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Michal Simek <hidden> Date: 2021-08-11 14:07:13
Hi Arnd,
On 8/11/21 3:46 PM, Arnd Bergmann wrote:
On Wed, Aug 11, 2021 at 3:08 PM Linus Walleij [off-list ref] wrote:
quoted
On Thu, Aug 5, 2021 at 7:42 PM Piyush Mehta [off-list ref] wrote:
quoted
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
- Added Xilinx ZynqMP firmware MMIO API support to set and get pin
value and status.
I doubt this is "GPIO".
General Purpose? I think not. It seems to be about boot mode.
If you need a userspace ABI, then add sysfs files to this firmware
driver instead of bridging it to the GPIO subsystem.
I don't really want custom user interfaces in firmware drivers either.
What is the high-level description of the 'PS_MODE' here? Is
this perhaps something we already have a user interface for?
The reason why this can't be mapped as memory mapped device is that it
is in IP which has be secure. That's why routing is done via firmware
driver.
Based on
https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
page 46
PS_MODE Input/Output Dedicated 4-bit boot mode pins sampled on POR
deassertion
It means ROM just capture boot mode at start that's why they have
special meaning and after it is free to use for whatever purpose you
want which seems to pretty much as generic purpose I/O.
I wrote more comments in reply to Linus already.
Thanks,
Michal
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Wed, Aug 11, 2021 at 3:30 PM Michal Simek [off-list ref] wrote:
They are bootmode pins because that pins are designed and used by ROM to
get information which boot device should be used.
But after this is it is really behaving as generic purpose I/O pins.
Xilinx is using them for years for usb phy resets. I have also seen them
to be used for other reset functionality.
OK if they are used for general purpose tasks then a GPIO driver
is fine, I was worried that it was just a way to read these pins from
userspace.
Go ahead with this patch series!
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Aug 5, 2021 at 7:43 PM Piyush Mehta [off-list ref] wrote:
This patch adds driver support for the zynqmp modepin GPIO controller.
GPIO modepin driver set and get the value and status of the PS_MODE pin,
based on device-tree pin configuration. These four mode pins are
configurable as input/output. The mode pin has a control register, which
have lower four-bits [0:3] are configurable as input/output, next four-bits
can be used for reading the data as input[4:7], and next setting the
output pin state output[8:11].
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
After discussion with Michal:
Reviewed-by: Linus Walleij <redacted>
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, Aug 5, 2021 at 7:42 PM Piyush Mehta [off-list ref] wrote:
Add Xilinx ZynqMP firmware MMIO APIs support to set and get PS_MODE
pins value and status. These APIs create an interface path between
mode pin controller driver and low-level API to access GPIO pins.
Signed-off-by: Piyush Mehta <redacted>
---
Changes in v2:
After Michals description of how this is controlling USB
PHY and misc resets I'm OK with the concept.
Acked-by: Linus Walleij <redacted>
Yours,
Linus Walleij
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
@@ -0,0 +1,41 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:"http://devicetree.org/schemas/gpio/xlnx,zynqmp-gpio-modepin.yaml#"+$schema:"http://devicetree.org/meta-schemas/core.yaml#"++title:ZynqMP Mode Pin GPIO controller++description:+PS_MODE is 4-bits boot mode pins sampled on POR deassertion. Mode Pin+GPIO controller with configurable from numbers of pins (from 0 to 3 per+PS_MODE). Every pin can be configured as input/output.++maintainers:+-Piyush Mehta <piyush.mehta@xilinx.com>++properties:+compatible:+const:xlnx,zynqmp-gpio-modepin++gpio-controller:true++"#gpio-cells":+const:2++required:+-compatible+-gpio-controller+-"#gpio-cells"++additionalProperties:false++examples:+-|+modepin_gpio:gpio {+compatible = "xlnx,zynqmp-gpio-modepin";+gpio-controller;+#gpio-cells = <2>;
No way to interact with this h/w?
As it is part of the firmware interface, it must be a child node in the
firmware node schema.
@@ -0,0 +1,41 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:"http://devicetree.org/schemas/gpio/xlnx,zynqmp-gpio-modepin.yaml#"+$schema:"http://devicetree.org/meta-schemas/core.yaml#"++title:ZynqMP Mode Pin GPIO controller++description:+PS_MODE is 4-bits boot mode pins sampled on POR deassertion. Mode Pin+GPIO controller with configurable from numbers of pins (from 0 to 3 per+PS_MODE). Every pin can be configured as input/output.++maintainers:+-Piyush Mehta <piyush.mehta@xilinx.com>++properties:+compatible:+const:xlnx,zynqmp-gpio-modepin++gpio-controller:true++"#gpio-cells":+const:2++required:+-compatible+-gpio-controller+-"#gpio-cells"++additionalProperties:false++examples:+-|+modepin_gpio:gpio {+compatible = "xlnx,zynqmp-gpio-modepin";+gpio-controller;+#gpio-cells = <2>;
No way to interact with this h/w?
As it is part of the firmware interface, it must be a child node in the
firmware node schema.