Skip to contentSkip to conversation

gio: add support for PCAL6408 chip to the pca953x driver

PATCH In review Michael Kopfensteiner 2 participants 4 messages Feb 23, 2023 – Feb 27, 2023

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

PATCH v2 1/3 gio: add support for PCAL6408 chip to the pca953x driver

The PCAL6408 chip similar enough to the PCA95xx chip series such that it can be handled by the pca953x driver as well.

This solution is copied from the linux kernel's pca953x driver.

---
 drivers/gpio/gpio-pca953x.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpio/gpio-pca953x.c +6 -0
index 4633d4f15d..2d3f8a8871 100644
@@ -37,6 +37,8 @@
 
 #define PCA_GPIO_MASK		0x00FF
 #define PCA_INT			0x0100
+#define PCA_PCAL		0x0200
+#define PCA_LATCH_INT		(PCA_PCAL | PCA_INT)
 #define PCA953X_TYPE		0x1000
 #define PCA957X_TYPE		0x2000
 
@@ -56,6 +58,8 @@ static struct platform_device_id pca953x_id[] = {
 	{ "pca9575", 16 | PCA957X_TYPE | PCA_INT, },
 	{ "pca9698", 40 | PCA953X_TYPE, },
 
+	{ "pcal6408", 8 | PCA953X_TYPE | PCA_LATCH_INT, },
+
 	{ "max7310", 8  | PCA953X_TYPE, },
 	{ "max7312", 16 | PCA953X_TYPE | PCA_INT, },
 	{ "max7313", 16 | PCA953X_TYPE | PCA_INT, },
@@ -483,6 +487,8 @@ static const struct of_device_id pca953x_dt_ids[] = {
 	{ .compatible = "nxp,pca9575", .data = OF_957X(16, PCA_INT), },
 	{ .compatible = "nxp,pca9698", .data = OF_953X(40, 0), },
 
+	{ .compatible = "nxp,pcal6408", .data = OF_953X(8, PCA_LATCH_INT), },
+
 	{ .compatible = "maxim,max7310", .data = OF_953X( 8, 0), },
 	{ .compatible = "maxim,max7312", .data = OF_953X(16, PCA_INT), },
 	{ .compatible = "maxim,max7313", .data = OF_953X(16, PCA_INT), },
Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 2/3 ARM: IMX8MP: add initial support for Variscite DT8MCustomBoard with iMX8MP

The Variscite DT8MCustomBoard is an eval board for the several Variscite SOMs of their "DART" product line. This commit adds support for that baseboard in combination with a DART-MX8M-PLUS SOM. The commit contains an adapted version of the vendors device tree [1] and the vendors DDR timings, taken from Variscite's public U-Boot sources [2].

Both files have been slightly changed to integrate well with barebox.

The boardsupport added with this commit does not yet support every feature of the DT8MCustomBoard. Yet it already supports all basic necessities to make use of barebox.

[1] https://github.com/varigit/linux-imx/tree/3f94f35bda827e8aa06beadb10c77358cfb6dad9
[2] https://github.com/varigit/uboot-imx/tree/7cad2ff68a508c71c572151a85bc786711bab969

---
 arch/arm/boards/Makefile                      |    1 +
 .../variscite-dt8mcustomboard-imx8mp/Makefile |    4 +
 .../variscite-dt8mcustomboard-imx8mp/board.c  |   84 ++
 .../flash-header-imx8mp-dart.imxcfg           |    7 +
 .../lowlevel.c                                |  136 ++
 .../lpddr4-timing.c                           | 1128 +++++++++++++++++
 arch/arm/configs/imx_v8_defconfig             |    3 +
 arch/arm/dts/Makefile                         |    1 +
 .../dts/imx8mp-var-dart-dt8mcustomboard.dts   |  681 ++++++++++
 arch/arm/dts/imx8mp-var-dart.dtsi             |  389 ++++++
 arch/arm/mach-imx/Kconfig                     |   10 +
 images/Makefile.imx                           |    5 +
 12 files changed, 2449 insertions(+)
 create mode 100644 arch/arm/boards/variscite-dt8mcustomboard-imx8mp/Makefile
 create mode 100644 arch/arm/boards/variscite-dt8mcustomboard-imx8mp/board.c
 create mode 100644 arch/arm/boards/variscite-dt8mcustomboard-imx8mp/flash-header-imx8mp-dart.imxcfg
 create mode 100644 arch/arm/boards/variscite-dt8mcustomboard-imx8mp/lowlevel.c
 create mode 100644 arch/arm/boards/variscite-dt8mcustomboard-imx8mp/lpddr4-timing.c
 create mode 100644 arch/arm/dts/imx8mp-var-dart-dt8mcustomboard.dts
 create mode 100644 arch/arm/dts/imx8mp-var-dart.dtsi
arch/arm/boards/Makefile +1 -0
index f92094d15b..671f07c7bc 100644
@@ -200,3 +200,4 @@ obj-$(CONFIG_MACH_RK3568_EVB)			+= rockchip-rk3568-evb/
 obj-$(CONFIG_MACH_RK3568_BPI_R2PRO)			+= rockchip-rk3568-bpi-r2pro/
 obj-$(CONFIG_MACH_PINE64_QUARTZ64)		+= pine64-quartz64/
 obj-$(CONFIG_MACH_RADXA_ROCK3)			+= radxa-rock3/
+obj-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP)	+= variscite-dt8mcustomboard-imx8mp/
arch/arm/boards/variscite-dt8mcustomboard-imx8mp/Makefile new file +4 -0
new file mode 100644
index 0000000000..35d8640087
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-y += board.o
+lwl-y += lowlevel.o lpddr4-timing.o
arch/arm/boards/variscite-dt8mcustomboard-imx8mp/board.c new file +84 -0

84 lines not on this page · raw message

arch/arm/boards/variscite-dt8mcustomboard-imx8mp/flash-header-imx8mp-dart.imxcfg new file +7 -0
new file mode 100644
index 0000000000..2b104edfb7
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+soc imx8mp
+
+loadaddr 0x918000
+max_load_size 0x3f000
+ivtofs 0x0
arch/arm/boards/variscite-dt8mcustomboard-imx8mp/lowlevel.c new file +136 -0

136 lines not on this page · raw message

arch/arm/boards/variscite-dt8mcustomboard-imx8mp/lpddr4-timing.c new file +1128 -0

1,128 lines not on this page · raw message

arch/arm/configs/imx_v8_defconfig +3 -0
index 62762959d5..5cd2bab035 100644
@@ -10,6 +10,7 @@ CONFIG_MACH_NXP_IMX8MQ_EVK=y
 CONFIG_MACH_PHYTEC_SOM_IMX8MQ=y
 CONFIG_MACH_TQ_MBA8MPXL=y
 CONFIG_MACH_POLYHEX_DEBIX=y
+CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_MMU=y
 CONFIG_MALLOC_SIZE=0x0
@@ -90,6 +91,7 @@ CONFIG_NET_NETCONSOLE=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_SERIAL_DEV_BUS=y
+CONFIG_DRIVER_NET_DESIGNWARE_IMX8=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 CONFIG_AT803X_PHY=y
 CONFIG_DP83867_PHY=y
@@ -129,6 +131,7 @@ CONFIG_EEPROM_AT24=y
 CONFIG_WATCHDOG=y
 CONFIG_WATCHDOG_IMX=y
 CONFIG_RAVE_SP_WATCHDOG=y
+CONFIG_GPIO_PCA953X=y
 CONFIG_IMX_OCOTP=y
 CONFIG_RAVE_SP_EEPROM=y
 CONFIG_REGULATOR=y
arch/arm/dts/Makefile +1 -0
index 07cb62dc1b..7f0d589d89 100644
@@ -204,5 +204,6 @@ lwl-$(CONFIG_MACH_LS1046ARDB) += fsl-ls1046a-rdb.dtb.o
 lwl-$(CONFIG_MACH_TQMLS1046A) += fsl-tqmls1046a-mbls10xxa.dtb.o
 lwl-$(CONFIG_MACH_ZEDBOARD) += zynq-zed.dtb.o
 lwl-$(CONFIG_MACH_MNT_REFORM) += imx8mq-mnt-reform2.dtb.o
+lwl-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += imx8mp-var-dart-dt8mcustomboard.dtb.o
 
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z
arch/arm/dts/imx8mp-var-dart-dt8mcustomboard.dts new file +681 -0

681 lines not on this page · raw message

arch/arm/dts/imx8mp-var-dart.dtsi new file +389 -0

389 lines not on this page · raw message

arch/arm/mach-imx/Kconfig +10 -0
index 1f788fe528..2e49fdb9d5 100644
@@ -650,6 +650,16 @@ config MACH_POLYHEX_DEBIX
 	select IMX8M_DRAM
 	select I2C_IMX_EARLY
 
+config MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP
+	bool "Variscite DT8MCustomBoard with DART-MX8M-PLUS"
+	select ARCH_IMX8MP
+	select FIRMWARE_IMX_LPDDR4_PMU_TRAIN
+	select FIRMWARE_IMX8MP_ATF
+	select ARM_SMCCC
+	select MCI_IMX_ESDHC_PBL
+	select IMX8M_DRAM
+	select I2C_IMX_EARLY
+
 config MACH_GRINN_LITEBOARD
 	bool "Grinn liteboard"
 	select ARCH_IMX6UL
images/Makefile.imx +5 -0
index ece8ea8197..9e70ba50a1 100644
@@ -468,6 +468,11 @@ CFG_start_polyhex_debix.pblb.imximg = $(board)/polyhex-debix/flash-header-polyhe
 FILE_barebox-polyhex-debix.img = start_polyhex_debix.pblb.pimximg
 image-$(CONFIG_MACH_POLYHEX_DEBIX) += barebox-polyhex-debix.img
 
+pblb-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += start_variscite_imx8mp_dart
+CFG_start_variscite_imx8mp_dart.pblb.imximg = $(board)/variscite-dt8mcustomboard-imx8mp/flash-header-imx8mp-dart.imxcfg
+FILE_barebox-variscite-imx8mp-dart-cb.img = start_variscite_imx8mp_dart.pblb.pimximg
+image-$(CONFIG_MACH_VARISCITE_DT8MCUSTOMBOARD_IMX8MP) += barebox-variscite-imx8mp-dart-cb.img
+
 # ----------------------- i.MX8mq based boards --------------------------
 pblb-$(CONFIG_MACH_NXP_IMX8MQ_EVK) += start_nxp_imx8mq_evk
 CFG_start_nxp_imx8mq_evk.pblb.imximg = $(board)/nxp-imx8mq-evk/flash-header-imx8mq-evk.imxcfg
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH v2 2/3] ARM: IMX8MP: add initial support for Variscite DT8MCustomBoard with iMX8MP

Hi Michael,

Looks good now. I squashed in some things while applying, see below.

Quoted 17 lines · Michael Kopfensteiner

The Variscite DT8MCustomBoard is an eval board for the several Variscite SOMs of their "DART" product line. This commit adds support for that baseboard in combination with a DART-MX8M-PLUS SOM. The commit contains an adapted version of the vendors device tree [1] and the vendors DDR timings, taken from Variscite's public U-Boot sources [2].

Both files have been slightly changed to integrate well with barebox.

The boardsupport added with this commit does not yet support every feature of the DT8MCustomBoard. Yet it already supports all basic necessities to make use of barebox.

[1] https://github.com/varigit/linux-imx/tree/3f94f35bda827e8aa06beadb10c77358cfb6dad9
[2] https://github.com/varigit/uboot-imx/tree/7cad2ff68a508c71c572151a85bc786711bab969

---

[...]

arch/arm/dts/imx8mp-var-dart-dt8mcustomboard.dts line 70

Quoted 10 lines
arch/arm/dts/imx8mp-var-dart-dt8mcustomboard.dts new file +10 -0
+	gpio-leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_gpio_leds>;
+
+		gp-led1 {
+			label = "led1";
+			gpios = <&pca6408_2 7 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "heartbeat";
+			barebox,default-trigger = "heartbeat";

Dropped the barebox,default-trigger property. barebox evaluates the linux,default-trigger as well and as long as both properties don't differ there shouldn't be a need to have both.

Quoted 7 lines

+&i2c1 {

arch/arm/dts/imx8mp-var-dart.dtsi new file +6 -0
+	clock-frequency = <400000>;
+	pinctrl-names = "default", "gpio";
+	pinctrl-0 = <&pinctrl_i2c1>;
+	pinctrl-1 = <&pinctrl_i2c1_gpio>;
+	scl-gpios = <&gpio5 14 GPIO_ACTIVE_HIGH>;
+	sda-gpios = <&gpio5 15 GPIO_ACTIVE_HIGH>;

arch/arm/dts/imx8mp-var-dart.dtsi line 103

Quoted 10 lines
arch/arm/dts/imx8mp-var-dart.dtsi new file +10 -0
+	status = "okay";
+
+	pca9450@25 {
+		reg = <0x25>;
+		compatible = "nxp,pca9450c";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_pmic>;
+		interrupt-parent = <&gpio1>;
+		interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+		status = "okay";

Dropped this status property, shouldn't be needed.

Quoted 6 lines

+&usdhc1 {

arch/arm/dts/imx8mp-var-dart.dtsi new file +5 -0
+	#address-cells = <1>;
+	#size-cells = <0>;
+	pinctrl-names = "default", "state_100mhz", "state_200mhz";
+	pinctrl-0 = <&pinctrl_usdhc1>, <&pinctrl_wifi>;
+	pinctrl-1 = <&pinctrl_usdhc1_100mhz>, <&pinctrl_wifi>;

arch/arm/dts/imx8mp-var-dart.dtsi line 209

Quoted 10 lines
arch/arm/dts/imx8mp-var-dart.dtsi new file +10 -0
+	pinctrl-2 = <&pinctrl_usdhc1_200mhz>, <&pinctrl_wifi>;
+	bus-width = <4>;
+	non-removable;
+	keep-power-in-suspend;
+	status = "okay";
+
+	brcmf: bcrmf@1 {
+		reg = <1>;
+		compatible = "brcm,bcm4329-fmac";
+		laird,regdomain = "US";

Dropped this property. It is not evaluated by mainline Linux and it also doesn't make sense to compile this in statically.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw

PATCH v2 3/3 Documentation: IMX: add doc for the Variscite DT8MCustomBoard

In reply to Michael Kopfensteiner

This commit adds a page for the newly added Variscite board.

The information about downloading the NXP firmware blobs was obtained from NXP's public U-Boot sources for the i.MX processors [1].

[1] https://github.com/nxp-imx/uboot-imx

---
 .../imx/variscite-dt8mcustomboard-imx8mp.rst  | 149 ++++++++++++++++++
 1 file changed, 149 insertions(+)
 create mode 100644 Documentation/boards/imx/variscite-dt8mcustomboard-imx8mp.rst
Documentation/boards/imx/variscite-dt8mcustomboard-imx8mp.rst new file +149 -0
new file mode 100644
index 0000000000..0e986a1086
@@ -0,0 +1,149 @@
+Variscite DT8MCustomBoard with DART-MX8M-PLUS SOM
+=================================================
+
+This board is an eval-kit for the Variscite DART-MX8M-PLUS SOM. The latter is a
+SOM based on the i.MX8M Plus processor. As seen in official Variscite documents there exist
+several hardware revisions for this board. Currently only revision 3.0 could was tested
+with Barebox.
+
+The Variscite DART-MX8M-PLUS SOM is available in different configurations. For a rough overview,
+these are some of the possible options:
+
+* Processor: NXP i.MX8M Plus, either @1.6GHz or @1.8GHz
+* 1 to 8 GiB LPDDR4 RAM
+* 8 to 128 GiB eMMC
+* (optional) GigE PHY on module
+* (optional) Wifi + Bluetooth Chip on module
+
+Besides that the SOM offers a lot of interfaces. Among some of the interfaces that are
+made available by the eval-board are:
+
+* USB3
+* GigE Ethernet
+* PCIe
+* SD-card slot
+* HDMI
+
+More Information about the eval-board can be found at
+https://www.variscite.com/product/single-board-computers/var-dt8mcustomboard/
+
+More Information about the targeted SOM can be found at
+https://www.variscite.com/product/system-on-module-som/cortex-a53-krait/dart-mx8m-plus-nxp-i-mx-8m-plus
+
+Providing necessary binary files
+--------------------------------
+
+Barebox requires some blobs to successfully bringup the system. These blobs
+serve different use cases. Barebox's build system will look for these files
+in the configured firmware directory (``firmware`` by default). The build
+systems expects these files to have certain names.
+
+Hence the very first thing before building Barebox is to obtain these files and
+placing them in the firmware folder.
+
+The DDR4 training files are part of a set of files that is provided by NXP.
+They are provided under the terms of a proprietary EULA one has to agree to,
+before getting access to the blobs. They are provided as self-extracting
+archive. To get a hand on them, perform the following::
+
+   $ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.10.bin
+   $ chmod u+x firmware-imx-8.10.bin
+   $ ./firmware-imx-8.10.bin
+
+Assuming that the downloaded executable was run from inside the toplevel directory of the Barebox repo,
+the necessary DDR4 training files can simply be hardlinked (or copied)::
+
+   $ ln firmware-imx-8.10/firmware/ddr/synopsys/lpddr4_pmu_train_1d_dmem_202006.bin firmware/lpddr4_pmu_train_1d_dmem.bin
+   $ ln firmware-imx-8.10/firmware/ddr/synopsys/lpddr4_pmu_train_1d_imem_202006.bin firmware/lpddr4_pmu_train_1d_imem.bin
+   $ ln firmware-imx-8.10/firmware/ddr/synopsys/lpddr4_pmu_train_2d_dmem_202006.bin firmware/lpddr4_pmu_train_2d_dmem.bin
+   $ ln firmware-imx-8.10/firmware/ddr/synopsys/lpddr4_pmu_train_2d_imem_202006.bin firmware/lpddr4_pmu_train_2d_imem.bin
+
+Another required binary is the Secure Monitor Firmware (BL31). This is build by some ARM Trusted Firmware project (ATF).
+One fork is provided by NXP and can be downloaded from https://github.com/nxp-imx/imx-atf. Variscite does maintain it's
+own fork of NXP's ATF project. This can be found at https://github.com/varigit/imx-atf/.
+
+Once the ATF has been built successfully, the resulting BL31 binary needs to be placed in the ``firmware`` directory
+under the filename ``imx8mp-bl31.bin``.
+
+After those files are in place, one can proceed with the usual Barebox build routine.
+
+Compiling Barebox
+-----------------
+
+A quick way to configure and compile Barebox for this board is by starting from
+the `imx_v8_defconfig`::
+
+   export ARCH=arm
+   export CROSS_COMPILE=/path/to/your/toolchain/bin/aarch64-v8a-linux-gnu-
+   make imx_v8_defconfig
+   make
+
+With this procedure one might need some additional firmware files in place to
+successfully build the Barebox images for all selected boards. A solution to this is
+either to copy the necessary files to the `firmware` directory or simply run
+`make menuconfig` and deselect the unwanted boards under "System Type".
+
+When the build succeeds, the Barebox image `barebox-variscite-imx8mp-dart-cb.img`
+can be found in the `images` subdirectory.
+
+Boot Configuration
+------------------
+
+The DT8MCustomBoard allows the user to choose whether to proceed with the *internal*
+or *external boot mode*. With this board, *internal boot mode* refers to booting
+from the eMMC memory, while *external boot mode* refers to booting from an SD-card.
+
+The mode is selected with switch SW7, located below the buttons on the board.
+
+Set the switch to **ON** for the BootROM to perform an *internal boot*. Otherwise
+set the switch to **OFF** to follow the *external boot* procedure.
+
+If in doubt, refer to the silk screen on the board, to select the correct switch
+position.
+
+If the BootROM cannot find a valid bootloader image in the selected source,
+it'll try several fallbacks until it finally ends in USB download mode or finds
+a valid bootloader image to load.
+
+To load an image when the board is in USB download mode the imx-usb-loader tool
+is required. To build this tool alongside the Barebox image, select it in the
+config menu under "Host Tools".
+
+Starting Barebox
+----------------
+
+An easy solution to start Barebox bare metal is to use the *external boot* mode and
+copy Barebox onto a SD-card.
+
+To copy the Barebox binary onto a SD-card, use the `dd` tool on linux::
+
+   dd if=images/barebox-variscite-imx8mp-dart-cb.img of=/dev/mmcblk0 bs=512 seek=1 skip=1
+
+Next, you insert the SD-card into the eval board and select *external boot mode* on
+switch SW7.
+
+When you power up the board, you should now see Barebox's output appearing on your
+serial console.
+
+Currently Supported Features
+----------------------------
+
+The Barebox binary configured by the `variscite_imx8mp_dart_cb_defconfig` does currently
+not support all possible features of the DT8MCustomBoard. Yet the binary does contain
+everything necessary to boot an operating system on the i.MX8MP.
+
+Some of the currently supported features:
+
+* general i.MX8MP bringup, including DRAM initialisation
+* working eMMC and SD-card support
+* serial console on UART 1 - available through the micro-USB connector on the board
+* working gigabit ethernet on the first port (labeled ETH, named `eth0` in Barebox and linux)
+* working LED and GPIO support
+
+Some functionality that is currently missing or untested:
+
+* secondary ethernet interface (labeled ETH2) will currently not work
+* secure boot (not tested)
+* framebuffer support (missing driver)
+* OP-TEE integration (not tested - early loading currently not supported by the startup code)
+* running on other hardware revisions of the DT8MCustomBoard than v3.0 (not tested)
\ No newline at end of file
Signature · 1 line
2.30.2