Skip to content

linux-imx: Add P3H2840 GPIO controller support for SE051 NFC mode#1

Open
bperseghetti wants to merge 3 commits intolf-6.12.20-2.0.0-walnascar-navq95from
se051-gpio-support
Open

linux-imx: Add P3H2840 GPIO controller support for SE051 NFC mode#1
bperseghetti wants to merge 3 commits intolf-6.12.20-2.0.0-walnascar-navq95from
se051-gpio-support

Conversation

@bperseghetti
Copy link
Member

Add kernel patches to enable GPIO control of SE051C2 secure element power for NFC energy harvesting mode on NavQ95.

Changes:

  • 0007: Add gpio_chip support to P3H2840 I3C hub driver
    • Exposes target port SCL/SDA pins as GPIO lines
    • GPIO 0-7 = SCL (TP0-TP7), GPIO 8-15 = SDA (TP0-TP7)
  • 0008: Configure TP0 as GPIO mode in imx95-navqb device tree
    • SE_ENABLE signal connected to TP0 SDA (GPIO 8)
    • Pull low to enable NFC energy harvesting mode

Usage:
gpioset p3h2x4x-gpio 8=0 # Enable NFC mode
gpioset p3h2x4x-gpio 8=1 # Enable I2C mode

Add kernel patches to enable GPIO control of SE051C2 secure element
power for NFC energy harvesting mode on NavQ95.

Changes:
- 0007: Add gpio_chip support to P3H2840 I3C hub driver
  - Exposes target port SCL/SDA pins as GPIO lines
  - GPIO 0-7 = SCL (TP0-TP7), GPIO 8-15 = SDA (TP0-TP7)
- 0008: Configure TP0 as GPIO mode in imx95-navqb device tree
  - SE_ENABLE signal connected to TP0 SDA (GPIO 8)
  - Pull low to enable NFC energy harvesting mode

Usage:
  gpioset p3h2x4x-gpio 8=0  # Enable NFC mode
  gpioset p3h2x4x-gpio 8=1  # Enable I2C mode
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
Add kernel patch to enable I2C bus recovery for the P3H2840 I3C hub.
This implements the standard 9-SCL-pulse bus clear procedure as
documented in the P3H2840 datasheet section 8.2.4.

The SE051C2 secure element can leave SDA stuck LOW when switching
between NFC and I2C modes during active NFC communication. This
recovery mechanism allows userspace to clear the stuck bus via sysfs.

Changes:
- 0009: Add bus recovery functions and sysfs interface
  - p3h2x4x_tp_check_bus_stuck(): Check SCL/SDA status
  - p3h2x4x_tp_bus_recover(): Perform 9-SCL-pulse recovery
  - /sys/devices/.../bus_status_tpN: Read bus status
  - /sys/devices/.../bus_recover_tpN: Trigger recovery

Usage:
  cat /sys/devices/.../bus_status_tp5
  echo 1 > /sys/devices/.../bus_recover_tp5
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
The 0008 patch incorrectly changed TP0 from smbus to gpio mode,
assuming SE_ENABLE was on GPIO 8 (TP0 SDA). However, SE_ENABLE is
actually connected to GPIO line 2 (TP2 SCL), and TP2 was already
configured as GPIO mode in the upstream DTS.

This patch was unnecessary and may have caused interference with
devices that were using TP0 for SMBus communication.

Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
+ *
+ * Return: 1 if SDA is stuck LOW, 0 if bus is OK, negative on error
+ */
+int p3h2x4x_tp_check_bus_stuck(struct p3h2x4x_i3c_hub_dev *hub, int tp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants