Skip to contentSkip to conversation

Add support of the FXL6408 GPIO expander

PATCH In review Oleksandr Suvorov 4 participants 7 messages Nov 21, 2021 – Feb 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover Add support of the FXL6408 GPIO expander

Add support of the Fairchild's FXL6408 i2c gpio expander and enable this driver for Toradex Colibri iMX8QXP SoM.

Changes in v4:
- fix misuse of MF_ID_x instead of FW_REV_x in fxl6408_probe().
- fix kernel doc formatting.
- sort headers.
- fix hex numbers style.
- explicitly claim values of enum io_direction.
- simplify fxl6408_get_function().
- make variable naming better in fxl6408_probe().

Changes in v3:
- fix a warning:
"drivers/gpio/gpio-fxl6408.c:348:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]"
- add Tested-by record.

Changes in v2:
- Kconfig: add better description for the config option.
- gpio-fxl6408.c:
-- improve registers' naming.
-- fix code style (comments, etc.).
-- reimplement fxl6408_read() reducing number of parameters. -- change return value of fxl6408_is_output() to bool.
-- replace IS_ERR_VALUE() macros with simple x < 0 where it's
possible.
-- fxl6408_set_direction(): fix type of parameter "dir". -- fix return error codes to avoid using the predefined in the driver
model ones.
-- removed extra debug code.
-- expand TODO list.

Oleksandr Suvorov (2):
GPIO: fxl6408: Add support for FXL6408 GPIO expander
colibri-imx8x: add on-module gpio expander fxl6408

 arch/arm/dts/fsl-imx8qxp-colibri.dts |  27 ++
 configs/colibri-imx8x_defconfig      |   1 +
 drivers/gpio/Kconfig                 |   7 +
 drivers/gpio/Makefile                |   1 +
 drivers/gpio/gpio-fxl6408.c          | 380 +++++++++++++++++++++++++++
 5 files changed, 416 insertions(+)
 create mode 100644 drivers/gpio/gpio-fxl6408.c
Signature · 1 line
2.33.1
#1 lore raw

PATCH v4 1/2 GPIO: fxl6408: Add support for FXL6408 GPIO expander

From: Oleksandr Suvorov <[email protected]>

Initial support for Fairchild's 8 bit I2C gpio expander FXL6408. The CONFIG_FXL6408_GPIO define enables support for such devices.

Based on: https://patchwork.kernel.org/patch/9148419/

---

(no changes since v3)

Changes in v3:
- fix a warning:
...drivers/gpio/gpio-fxl6408.c:348:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]...
- add Tested-by record.

 drivers/gpio/Kconfig        |   7 +
 drivers/gpio/Makefile       |   1 +
 drivers/gpio/gpio-fxl6408.c | 380 ++++++++++++++++++++++++++++++++++++
 3 files changed, 388 insertions(+)
 create mode 100644 drivers/gpio/gpio-fxl6408.c
drivers/gpio/Kconfig +7 -0
index 40abc33772e..9ddda0ec41f 100644
@@ -131,6 +131,13 @@ config DA8XX_GPIO
 	help
 	  This driver supports the DA8xx GPIO controller
 
+config FXL6408_GPIO
+	bool "FXL6408 I2C GPIO expander driver"
+	depends on DM_GPIO && DM_I2C
+	help
+	  This driver supports the Fairchild FXL6408 device. FXL6408 is a
+	  fully configurable 8-bit I2C-controlled GPIO expander.
+
 config INTEL_BROADWELL_GPIO
 	bool "Intel Broadwell GPIO driver"
 	depends on DM
drivers/gpio/Makefile +1 -0
index 3c851b38c7c..68f541bba48 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_AT91_GPIO)	+= at91_gpio.o
 obj-$(CONFIG_ATMEL_PIO4)	+= atmel_pio4.o
 obj-$(CONFIG_BCM6345_GPIO)	+= bcm6345_gpio.o
 obj-$(CONFIG_CORTINA_GPIO)      += cortina_gpio.o
+obj-$(CONFIG_FXL6408_GPIO)	+= gpio-fxl6408.o
 obj-$(CONFIG_INTEL_GPIO)	+= intel_gpio.o
 obj-$(CONFIG_INTEL_ICH6_GPIO)	+= intel_ich6_gpio.o
 obj-$(CONFIG_INTEL_BROADWELL_GPIO)	+= intel_broadwell_gpio.o
drivers/gpio/gpio-fxl6408.c new file +380 -0

380 lines not on this page · raw message

Signature · 1 line
2.33.1
#2 lore raw

PATCH v4 2/2 colibri-imx8x: add on-module gpio expander fxl6408

From: Oleksandr Suvorov <[email protected]>

The FXL6408 GPIO expander manages critical devices, including on-module USB hub. Configure the expander to switch the USB hub into bypass mode, allowing to use on-carrier-board USB hub.

---

Changes in v4:
- fix misuse of MF_ID_x instead of FW_REV_x in fxl6408_probe().
- fix kernel doc formatting.
- sort headers.
- fix hex numbers style.
- explicitly claim values of enum io_direction.
- simplify fxl6408_get_function().
- make variable naming better in fxl6408_probe().

Changes in v3:
- fix a warning:
"drivers/gpio/gpio-fxl6408.c:348:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]"
- add Tested-by record.

Changes in v2:
- Kconfig: add better description for the config option.
- gpio-fxl6408.c:
-- improve registers' naming.
-- fix code style (comments, etc.).
-- reimplement fxl6408_read() reducing number of parameters. -- change return value of fxl6408_is_output() to bool.
-- replace IS_ERR_VALUE() macros with simple x < 0 where it's
possible.
-- fxl6408_set_direction(): fix type of parameter "dir". -- fix return error codes to avoid using the predefined in the driver
model ones.
-- removed extra debug code.
-- expand TODO list.

 arch/arm/dts/fsl-imx8qxp-colibri.dts | 27 +++++++++++++++++++++++++++
 configs/colibri-imx8x_defconfig      |  1 +
 2 files changed, 28 insertions(+)
arch/arm/dts/fsl-imx8qxp-colibri.dts +27 -0
index 11ece34c024..df992ac6396 100644
@@ -129,6 +129,14 @@
 			>;
 		};
 
+		/* On Module I2C */
+		pinctrl_i2c0: i2c0grp {
+			fsl,pins = <
+				SC_P_MIPI_CSI0_GPIO0_00_ADMA_I2C0_SCL	0x06000021
+				SC_P_MIPI_CSI0_GPIO0_01_ADMA_I2C0_SDA	0x06000021
+			>;
+		};
+
 		/* Off Module I2C */
 		pinctrl_i2c1: i2c1grp {
 			fsl,pins = <
@@ -298,6 +306,25 @@
 	};
 };
 
+&i2c0 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	clock-frequency = <100000>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c0>;
+	status = "okay";
+
+	/* GPIO expander */
+	gpio_expander_43: gpio-expander@43 {
+		compatible = "fcs,fxl6408";
+		gpio-controller;
+		#gpio-cells = <2>;
+		reg = <0x43>;
+		initial_io_dir = <0xff>;
+		initial_output = <0x05>;
+	};
+};
+
 &i2c1 {
 	#address-cells = <1>;
 	#size-cells = <0>;
configs/colibri-imx8x_defconfig +1 -0
index 22bed95324a..a9b0f357163 100644
@@ -41,6 +41,7 @@ CONFIG_TFTP_BLOCKSIZE=4096
 CONFIG_TFTP_TSIZE=y
 CONFIG_CLK_IMX8=y
 CONFIG_CPU=y
+CONFIG_FXL6408_GPIO=y
 CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_IMX_LPI2C=y
Signature · 1 line
2.33.1
#3 lore raw

PATCH v4 2/2 colibri-imx8x: add on-module gpio expander fxl6408

Quoted 7 lines

From: Oleksandr Suvorov <[email protected]> The FXL6408 GPIO expander manages critical devices, including on-module USB hub. Configure the expander to switch the USB hub into bypass mode, allowing to use on-carrier-board USB hub.

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#4 lore raw

PATCH v4 1/2 GPIO: fxl6408: Add support for FXL6408 GPIO expander

In reply to Oleksandr Suvorov
Quoted 9 lines

From: Oleksandr Suvorov <[email protected]> Initial support for Fairchild's 8 bit I2C gpio expander FXL6408. The CONFIG_FXL6408_GPIO define enables support for such devices. Based on: https://patchwork.kernel.org/patch/9148419/

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
#5 lore raw

Re: [PATCH v4 1/2] GPIO: fxl6408: Add support for FXL6408 GPIO expander

Quoted 11 lines · On Sat, Feb 5, 2022 at 6:54 PM <[email protected]> wrote:
Quoted 10 lines

From: Oleksandr Suvorov <[email protected]> Initial support for Fairchild's 8 bit I2C gpio expander FXL6408. The CONFIG_FXL6408_GPIO define enables support for such devices. Based on: https://patchwork.kernel.org/patch/9148419/

Applied to u-boot-imx, master, thanks !

Thank you, Stefano!

And thanks to Marcel Ziswiler for help!

Quoted 10 lines

Best regards,
Stefano Babic

--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================

Signature · 5 lines
Best regards
Oleksandr

Oleksandr Suvorov
[email protected]
#6 lore raw
In reply to Oleksandr Suvorov

Hi guys

Quoted 3 lines · Oleksandr Suvorov

Add support of the Fairchild's FXL6408 i2c gpio expander and enable this driver for Toradex Colibri iMX8QXP SoM.

Any progress in applying this patch series?

I just applied it again on today's master and it still cleanly applies. I even built, flashed and tested it again and it still all looks good and actually works.

Thanks!

Quoted 35 lines

Changes in v4:
- fix misuse of MF_ID_x instead of FW_REV_x in fxl6408_probe().
- fix kernel doc formatting.
- sort headers.
- fix hex numbers style.
- explicitly claim values of enum io_direction.
- simplify fxl6408_get_function().
- make variable naming better in fxl6408_probe().

Changes in v3:
- fix a warning:
    "drivers/gpio/gpio-fxl6408.c:348:15: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]"
- add Tested-by record.

Changes in v2:
- Kconfig: add better description for the config option.
- gpio-fxl6408.c:
-- improve registers' naming.
-- fix code style (comments, etc.).
-- reimplement fxl6408_read() reducing number of parameters. -- change return value of fxl6408_is_output() to bool.
-- replace IS_ERR_VALUE() macros with simple x < 0 where it's possible.
-- fxl6408_set_direction(): fix type of parameter "dir". -- fix return error codes to avoid using the predefined in the driver model ones.
-- removed extra debug code.
-- expand TODO list.

Oleksandr Suvorov (2):
  GPIO: fxl6408: Add support for FXL6408 GPIO expander
  colibri-imx8x: add on-module gpio expander fxl6408

Quoted 7 lines

 arch/arm/dts/fsl-imx8qxp-colibri.dts |  27 ++ configs/colibri-imx8x_defconfig      |   1 + drivers/gpio/Kconfig                 |   7 + drivers/gpio/Makefile                |   1 + drivers/gpio/gpio-fxl6408.c          | 380 +++++++++++++++++++++++++++

 5 files changed, 416 insertions(+)

 create mode 100644 drivers/gpio/gpio-fxl6408.c

Cheers

Marcel