diff options
author | Ying-Chun Liu (PaulLiu) <paulliu@debian.org> | 2021-08-18 05:14:10 +0800 |
---|---|---|
committer | Ying-Chun Liu (PaulLiu) <paulliu@debian.org> | 2021-08-18 08:34:54 +0800 |
commit | 944e6fd5b0f796bbe59970f4615da1396fd302a8 (patch) | |
tree | f3e33b36e293e4c957f6e508a36d616c14d6d9b8 | |
parent | 2b8ae6e0ed8e120f9c3b2dca34c19676da548146 (diff) |
tpm2 test commit by paulliu.paulliu-rsb3720-tpm2
Signed-off-by: Ying-Chun Liu (PaulLiu) <paulliu@debian.org>
-rw-r--r-- | arch/arm/dts/imx8mm-cl-iot-gate.dts | 241 | ||||
-rw-r--r-- | board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c | 314 |
2 files changed, 523 insertions, 32 deletions
diff --git a/arch/arm/dts/imx8mm-cl-iot-gate.dts b/arch/arm/dts/imx8mm-cl-iot-gate.dts index 62e8d039493..59ba2eb55c9 100644 --- a/arch/arm/dts/imx8mm-cl-iot-gate.dts +++ b/arch/arm/dts/imx8mm-cl-iot-gate.dts @@ -45,6 +45,46 @@ startup-delay-us = <100>; off-on-delay-us = <12000>; }; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + clk40m: clk@1 { + compatible = "fixed-clock"; + reg = <1>; + #clock-cells = <0>; + clock-frequency = <40000000>; + clock-output-names = "clk40m"; + }; + }; + + regulatot-tpm0-rst { + compatible = "regulator-fixed"; + regulator-name = "tpm0-rst"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + gpio = <&gpio4 31 GPIO_ACTIVE_HIGH>; + regulator-always-on; + enable-active-high; + }; + + regulator-tpm1-rst { + compatible = "regulator-fixed"; + regulator-name = "tpm1-rst"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + gpio = <&gpio4 31 GPIO_ACTIVE_HIGH>; + regulator-always-on; + enable-active-high; + }; + + vref_adc: regulator-vref-adc { + compatible = "regulator-fixed"; + regulator-name = "vref_adc"; + regulator-min-microvolt = <2400000>; + regulator-max-microvolt = <2400000>; + regulator-always-on; + }; }; &A53_0 { @@ -236,33 +276,10 @@ }; }; - ptn5110: tcpc@50 { - compatible = "nxp,ptn5110"; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_typec1>; + eeprom@50 { + compatible = "atmel,24c08"; reg = <0x50>; - interrupt-parent = <&gpio2>; - interrupts = <11 8>; - status = "okay"; - - port { - typec1_dr_sw: endpoint { - remote-endpoint = <&usb1_drd_sw>; - }; - }; - - typec1_con: connector { - compatible = "usb-c-connector"; - label = "USB-C"; - power-role = "dual"; - data-role = "dual"; - try-power-role = "sink"; - source-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)>; - sink-pdos = <PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM) - PDO_VAR(5000, 20000, 3000)>; - op-sink-microwatt = <15000000>; - self-powered; - }; + pagesize = <16>; }; }; @@ -305,12 +322,6 @@ usb-role-switch; vbus-supply = <®_vusb_5v>; status = "okay"; - - port { - usb1_drd_sw: endpoint { - remote-endpoint = <&typec1_dr_sw>; - }; - }; }; &usbotg2 { @@ -350,13 +361,111 @@ status = "okay"; }; +&ecspi1 { + #address-cells = <1>; + #size-cells = <0>; + fsl,spi-num-chipselects = <1>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ecspi1 &pinctrl_ecspi1_cs>; + cs-gpios = <&gpio5 9 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&ecspi2 { + #address-cells = <1>; + #size-cells = <0>; + fsl,spi-num-chipselects = <1>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ecspi2 &pinctrl_ecspi2_cs>; + cs-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>; + status = "okay"; + + can0: can@0 { + compatible = "microchip,mcp2518fd"; + reg = <0>; + microchip,rx-int = <&gpio4 31 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_can0>; + interrupt-parent = <&gpio5>; + interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + spi-max-frequency = <20000000>; + clocks = <&clk40m>; + status = "disabled"; + }; + + tpm0: tpm@0 { + compatible = "infineon,slb9670", "tcg,tpm_tis-spi"; + reg = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_tpm0>; + spi-max-frequency = <5000000>; + status = "okay"; + }; + + adc0: adc@0 { + compatible = "maxim,max11108"; + reg = <0>; + vref-supply = <&vref_adc>; + spi-max-frequency = <20000000>; + status = "disabled"; + }; +}; + +&ecspi3 { + #address-cells = <1>; + #size-cells = <0>; + fsl,spi-num-chipselects = <1>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ecspi3 &pinctrl_ecspi3_cs>; + cs-gpios = <&gpio5 25 GPIO_ACTIVE_LOW>; + status = "okay"; + + can1: can@0 { + compatible = "microchip,mcp2518fd"; + reg = <0>; + microchip,rx-int = <&gpio5 28 IRQ_TYPE_LEVEL_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_can1>; + interrupt-parent = <&gpio5>; + interrupts = <29 IRQ_TYPE_LEVEL_LOW>; + spi-max-frequency = <20000000>; + clocks = <&clk40m>; + status = "disabled"; + }; + + tpm1: tpm@0 { + compatible = "infineon,slb9670", "tcg,tpm_tis-spi"; + reg = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_tpm1>; + spi-max-frequency = <5000000>; + status = "disabled"; + }; + + adc1: adc@0 { + compatible = "maxim,max11108"; + reg = <0>; + vref-supply = <&vref_adc>; + spi-max-frequency = <20000000>; + status = "disabled"; + }; +}; + &iomuxc { pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog>; pinctrl_hog: hoggrp { fsl,pins = < /* USB VBUS enable GPIO */ MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28 0x00 + /* IED-DI4O4 */ + MX8MM_IOMUXC_NAND_ALE_GPIO3_IO0 0x100 /* IN 0 */ + MX8MM_IOMUXC_NAND_CE0_B_GPIO3_IO1 0x100 /* IN 1 */ + MX8MM_IOMUXC_NAND_DATA00_GPIO3_IO6 0x100 /* IN 2 */ + MX8MM_IOMUXC_NAND_DATA01_GPIO3_IO7 0x100 /* IN 3 */ + MX8MM_IOMUXC_NAND_DATA02_GPIO3_IO8 0x100 /* OUT 0 */ + MX8MM_IOMUXC_NAND_DATA03_GPIO3_IO9 0x100 /* OUT 1 */ >; }; @@ -550,4 +659,72 @@ MX8MM_IOMUXC_GPIO1_IO02_WDOG1_WDOG_B 0xc6 >; }; + + pinctrl_ecspi1: ecspi1grp { + fsl,pins = < + MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x82 + MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x82 + MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x82 + >; + }; + + pinctrl_ecspi1_cs: ecspi1cs { + fsl,pins = < + MX8MM_IOMUXC_ECSPI1_SS0_GPIO5_IO9 0x40000 + >; + }; + + pinctrl_ecspi2: ecspi2grp { + fsl,pins = < + MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0x02 + MX8MM_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0x02 + MX8MM_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0x102 + >; + }; + + pinctrl_ecspi2_cs: ecspi2_csgrp { + fsl,pins = < + MX8MM_IOMUXC_ECSPI2_SS0_GPIO5_IO13 0x40000 + >; + }; + + pinctrl_ecspi3: ecspi3grp { + fsl,pins = < + MX8MM_IOMUXC_UART1_RXD_ECSPI3_SCLK 0x02 + MX8MM_IOMUXC_UART1_TXD_ECSPI3_MOSI 0x02 + MX8MM_IOMUXC_UART2_RXD_ECSPI3_MISO 0x102 + >; + }; + + pinctrl_ecspi3_cs: ecspi3_csgrp { + fsl,pins = < + MX8MM_IOMUXC_UART2_TXD_GPIO5_IO25 0x40000 + >; + }; + + pinctrl_can0: can0grp { + fsl,pins = < + MX8MM_IOMUXC_SAI3_TXC_GPIO5_IO0 0x00 + MX8MM_IOMUXC_SAI3_TXFS_GPIO4_IO31 0x00 + >; + }; + + pinctrl_can1: can1grp { + fsl,pins = < + MX8MM_IOMUXC_UART4_TXD_GPIO5_IO29 0x00 + MX8MM_IOMUXC_UART4_RXD_GPIO5_IO28 0x00 + >; + }; + + pinctrl_tpm0: tpm0grp { + fsl,pins = < + MX8MM_IOMUXC_SAI3_TXFS_GPIO4_IO31 0x0 + >; + }; + + pinctrl_tpm1: tpm1grp { + fsl,pins = < + MX8MM_IOMUXC_UART4_RXD_GPIO5_IO28 0x0 + >; + }; }; diff --git a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c index eabcc842a48..6f9115207be 100644 --- a/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c +++ b/board/compulab/imx8mm-cl-iot-gate/imx8mm-cl-iot-gate.c @@ -6,16 +6,29 @@ #include <common.h> #include <env.h> +#include <i2c.h> #include <init.h> #include <miiphy.h> #include <netdev.h> #include <asm/arch/clock.h> +#include <asm/arch/imx8mm_pins.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> +#include <asm/mach-imx/gpio.h> +#include <asm/mach-imx/mxc_i2c.h> DECLARE_GLOBAL_DATA_PTR; +/* IOT_GATE-iMX8 extension boards ID */ +typedef enum { + IOT_GATE_EXT_EMPTY, /* No extension */ + IOT_GATE_EXT_CAN, /* CAN bus */ + IOT_GATE_EXT_IED, /* Bridge */ + IOT_GATE_EXT_POE, /* POE */ + IOT_GATE_EXT_POEV2, /* POEv2 */ +} iot_gate_imx8_ext; + static int setup_fec(void) { if (IS_ENABLED(CONFIG_FEC_MXC)) { @@ -60,6 +73,280 @@ int board_mmc_get_env_dev(int devno) return devno; } +#define IOT_GATE_IMX8_EXT_I2C 3 /* I2C ID of the extension board */ +#define IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM 0x54 /* I2C address of the EEPROM */ + +/* I2C address of the EEPROM in the POE extension */ +#define IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM_POE 0x50 +#define IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM_POEV2 0x51 +#define IOT_GATE_IMX8_EXT_I2C_ADDR_GPIO 0x22 /* I2C address of the GPIO + extender */ + +static int iot_gate_imx8_ext_id = IOT_GATE_EXT_EMPTY; /* Extension board ID */ + +/* + * iot_gate_imx8_detect_ext() - extended board detection + * The detection is done according to the detected I2C devices. + */ +static void iot_gate_imx8_detect_ext(void) +{ + int ret; + struct udevice *i2c_bus, *i2c_dev; + + ret = uclass_get_device_by_seq(UCLASS_I2C, IOT_GATE_IMX8_EXT_I2C, + &i2c_bus); + if (ret) { + printf("%s: Failed getting i2c device\n", __func__); + return; + } + + ret = dm_i2c_probe(i2c_bus, IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM_POE, 0, + &i2c_dev); + if (!ret) { + iot_gate_imx8_ext_id = IOT_GATE_EXT_POE; + return; + } + + ret = dm_i2c_probe(i2c_bus, IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM_POEV2, 0, + &i2c_dev); + if (!ret) { + iot_gate_imx8_ext_id = IOT_GATE_EXT_POEV2; + return; + } + + ret = dm_i2c_probe(i2c_bus, IOT_GATE_IMX8_EXT_I2C_ADDR_EEPROM, 0, + &i2c_dev); + if (ret){ + iot_gate_imx8_ext_id = IOT_GATE_EXT_EMPTY; + return; + } + /* Only the bridge extension includes the GPIO extender */ + ret = dm_i2c_probe(i2c_bus, IOT_GATE_IMX8_EXT_I2C_ADDR_GPIO, 0, + &i2c_dev); + if (ret) /* GPIO extender not detected */ + iot_gate_imx8_ext_id = IOT_GATE_EXT_CAN; + else /* GPIO extender detected */ + iot_gate_imx8_ext_id = IOT_GATE_EXT_IED; +} + +static iomux_v3_cfg_t const iot_gate_imx8_ext_ied_pads[] = { + IMX8MM_PAD_NAND_ALE_GPIO3_IO0 | MUX_PAD_CTRL(PAD_CTL_PE), + IMX8MM_PAD_NAND_CE0_B_GPIO3_IO1 | MUX_PAD_CTRL(PAD_CTL_PE), + IMX8MM_PAD_NAND_DATA00_GPIO3_IO6 | MUX_PAD_CTRL(PAD_CTL_PE), + IMX8MM_PAD_NAND_DATA01_GPIO3_IO7 | MUX_PAD_CTRL(PAD_CTL_PE), + IMX8MM_PAD_NAND_DATA02_GPIO3_IO8 | MUX_PAD_CTRL(PAD_CTL_PE), + IMX8MM_PAD_NAND_DATA03_GPIO3_IO9 | MUX_PAD_CTRL(PAD_CTL_PE), +}; + +static iomux_v3_cfg_t const iot_gate_imx8_ext_poev2_pads[] = { + IMX8MM_PAD_SAI3_TXD_GPIO5_IO1 | MUX_PAD_CTRL(PAD_CTL_PE | + PAD_CTL_PUE), +}; + +/* Extension board bridge GPIOs */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_I0 IMX_GPIO_NR(3, 0) /* IN 0 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_I1 IMX_GPIO_NR(3, 1) /* IN 1 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_I2 IMX_GPIO_NR(3, 6) /* IN 2 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_I3 IMX_GPIO_NR(3, 7) /* IN 3 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_O0 IMX_GPIO_NR(3, 8) /* OUT 0 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_O1 IMX_GPIO_NR(3, 9) /* OUT 1 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_O2 IMX_GPIO_NR(6, 9) /* OUT 2 */ +#define IOT_GATE_IMX8_GPIO_EXT_IED_O3 IMX_GPIO_NR(6, 10)/* OUT 3 */ + +/* Extension board POE GPIOs */ +#define IOT_GATE_IMX8_GPIO_EXT_POE_MUX IMX_GPIO_NR(5, 1)/* USB_MUX */ + +/* + * iot_gate_imx8_update_pinmux() - update the pinmux + * Update the pinmux according to the detected extended board. + */ +static void iot_gate_imx8_update_pinmux(void) +{ + if (iot_gate_imx8_ext_id == IOT_GATE_EXT_POEV2) { + imx_iomux_v3_setup_multiple_pads(iot_gate_imx8_ext_poev2_pads, + ARRAY_SIZE(iot_gate_imx8_ext_poev2_pads)); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_POE_MUX, "poev2_usb-mux"); + /* Update USB MUX state */ + gpio_direction_output(IOT_GATE_IMX8_GPIO_EXT_POE_MUX, 1); + + return; + } + if (iot_gate_imx8_ext_id != IOT_GATE_EXT_IED) + return; + + imx_iomux_v3_setup_multiple_pads(iot_gate_imx8_ext_ied_pads, + ARRAY_SIZE(iot_gate_imx8_ext_ied_pads)); + + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_I0, "ied-di4o4_i0"); + gpio_direction_input(IOT_GATE_IMX8_GPIO_EXT_IED_I0); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_I1, "ied-di4o4_i1"); + gpio_direction_input(IOT_GATE_IMX8_GPIO_EXT_IED_I1); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_I2, "ied-di4o4_i2"); + gpio_direction_input(IOT_GATE_IMX8_GPIO_EXT_IED_I2); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_I3, "ied-di4o4_i3"); + gpio_direction_input(IOT_GATE_IMX8_GPIO_EXT_IED_I3); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_O0, "ied-di4o4_o0"); + gpio_direction_output(IOT_GATE_IMX8_GPIO_EXT_IED_O0, 0); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_O1, "ied-di4o4_o1"); + gpio_direction_output(IOT_GATE_IMX8_GPIO_EXT_IED_O1, 0); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_O2, "ied-di4o4_o2"); + gpio_direction_output(IOT_GATE_IMX8_GPIO_EXT_IED_O2, 0); + gpio_request(IOT_GATE_IMX8_GPIO_EXT_IED_O3, "ied-di4o4_o3"); + gpio_direction_output(IOT_GATE_IMX8_GPIO_EXT_IED_O3, 0); +} + +#define IOT_GATE_IMX8_GPIO_S0B0 IMX_GPIO_NR(6, 0) /* Slot ID slot 0 bit 0 */ +#define IOT_GATE_IMX8_GPIO_S0B1 IMX_GPIO_NR(6, 1) /* Slot ID slot 0 bit 1 */ +#define IOT_GATE_IMX8_GPIO_S0B2 IMX_GPIO_NR(6, 2) /* Slot ID slot 0 bit 2 */ +#define IOT_GATE_IMX8_GPIO_S1B0 IMX_GPIO_NR(6, 3) /* Slot ID slot 1 bit 0 */ +#define IOT_GATE_IMX8_GPIO_S1B1 IMX_GPIO_NR(6, 4) /* Slot ID slot 1 bit 1 */ +#define IOT_GATE_IMX8_GPIO_S1B2 IMX_GPIO_NR(6, 5) /* Slot ID slot 1 bit 2 */ +#define IOT_GATE_IMX8_GPIO_S2B0 IMX_GPIO_NR(6, 6) /* Slot ID slot 2 bit 0 */ +#define IOT_GATE_IMX8_GPIO_S2B1 IMX_GPIO_NR(6, 7) /* Slot ID slot 2 bit 1 */ +#define IOT_GATE_IMX8_GPIO_S2B2 IMX_GPIO_NR(6, 8) /* Slot ID slot 2 bit 2 */ +#define IOT_GATE_IMX8_CARD_ID_EMPTY 0 /* card id - uninhabited */ +#define IOT_GATE_IMX8_CARD_ID_DI4O4 1 /* Card ID - IED-DI4O4 */ +#define IOT_GATE_IMX8_CARD_ID_RS_485 2 /* Card ID - IED-RS485 */ +#define IOT_GATE_IMX8_CARD_ID_TPM 3 /* Card ID - IED-TPM */ +#define IOT_GATE_IMX8_CARD_ID_CAN 4 /* Card ID - IED-CAN */ +#define IOT_GATE_IMX8_CARD_ID_CL420 5 /* Card ID - IED-CL420 */ +#define IOT_GATE_IMX8_CARD_ID_RS_232 6 /* Card ID - IED-RS232 */ +#define IOT_GATE_IMX8_DTB_PATH_UART2 "/soc@0/bus@30800000/serial@30890000" +#define IOT_GATE_IMX8_DTB_PATH_UART4 "/soc@0/bus@30800000/serial@30a60000" +#define IOT_GATE_IMX8_DTB_PATH_ECSPI2 "/soc@0/bus@30800000/spi@30830000" +#define IOT_GATE_IMX8_DTB_PATH_ECSPI3 "/soc@0/bus@30800000/spi@30840000" +#define IOT_GATE_IMX8_DTB_PATH_CAN0 "/soc@0/bus@30800000/spi@30830000/can@0" +#define IOT_GATE_IMX8_DTB_PATH_CAN1 "/soc@0/bus@30800000/spi@30840000/can@0" +#define IOT_GATE_IMX8_DTB_PATH_TPM0 "/soc@0/bus@30800000/spi@30830000/tpm@0" +#define IOT_GATE_IMX8_DTB_PATH_TPM1 "/soc@0/bus@30800000/spi@30840000/tpm@0" +#define IOT_GATE_IMX8_DTB_PATH_ADC0 "/soc@0/bus@30800000/spi@30830000/adc@0" +#define IOT_GATE_IMX8_DTB_PATH_ADC1 "/soc@0/bus@30800000/spi@30840000/adc@0" + +/* + * iot_gate_imx8_update_ext_ied() + * Update device tree of the extended board IED-BASE. + * The device tree is updated according to the detected sub modules. + * + * @blob: ptr to device tree + * + * Return 0 for success, 1 for failure. + */ +static int iot_gate_imx8_update_ext_ied(void *blob) +{ + int revision; + + if (iot_gate_imx8_ext_id != IOT_GATE_EXT_IED) + return 0; + + /* ID GPIO initializations */ + if (gpio_request(IOT_GATE_IMX8_GPIO_S0B0, "id_s0b0") || + gpio_request(IOT_GATE_IMX8_GPIO_S0B1, "id_s0b1") || + gpio_request(IOT_GATE_IMX8_GPIO_S0B2, "id_s0b2") || + gpio_request(IOT_GATE_IMX8_GPIO_S1B0, "id_s1b0") || + gpio_request(IOT_GATE_IMX8_GPIO_S1B1, "id_s1b1") || + gpio_request(IOT_GATE_IMX8_GPIO_S1B2, "id_s1b2") || + gpio_request(IOT_GATE_IMX8_GPIO_S2B0, "id_s2b0") || + gpio_request(IOT_GATE_IMX8_GPIO_S2B1, "id_s2b1") || + gpio_request(IOT_GATE_IMX8_GPIO_S2B2, "id_s2b2")) { + printf("%s: ID GPIO request failure\n", __func__); + return 1; + } + gpio_direction_input(IOT_GATE_IMX8_GPIO_S0B0); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S0B1); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S0B2); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S1B0); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S1B1); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S1B2); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S2B0); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S2B1); + gpio_direction_input(IOT_GATE_IMX8_GPIO_S2B2); + + /* Get slot 0 card ID */ + revision = gpio_get_value(IOT_GATE_IMX8_GPIO_S0B0) | + gpio_get_value(IOT_GATE_IMX8_GPIO_S0B1) << 1 | + gpio_get_value(IOT_GATE_IMX8_GPIO_S0B2) << 2; + /* Slot 0 device tree blob manipulation */ + switch (revision) + { + case IOT_GATE_IMX8_CARD_ID_EMPTY: + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_EMPTY\n"); + break; + case IOT_GATE_IMX8_CARD_ID_RS_485: + case IOT_GATE_IMX8_CARD_ID_RS_232: + if (revision == IOT_GATE_IMX8_CARD_ID_RS_485) + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_RS_485\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_RS_232) + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_RS_232\n"); + break; + case IOT_GATE_IMX8_CARD_ID_CAN: + case IOT_GATE_IMX8_CARD_ID_TPM: + case IOT_GATE_IMX8_CARD_ID_CL420: + if (revision == IOT_GATE_IMX8_CARD_ID_CAN) + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_CAN\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_TPM) + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_TPM\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_CL420) + printf("IED slot 0: IOT_GATE_IMX8_CARD_ID_CL420\n"); + break; + default: + printf("%s: invalid slot 0 card ID: %d\n", __func__, revision); + return 1; + } + + /* Get slot 1 card ID */ + revision = gpio_get_value(IOT_GATE_IMX8_GPIO_S1B0) | + gpio_get_value(IOT_GATE_IMX8_GPIO_S1B1) << 1 | + gpio_get_value(IOT_GATE_IMX8_GPIO_S1B2) << 2; + /* Slot 1 device tree blob manipulation */ + switch (revision) + { + case IOT_GATE_IMX8_CARD_ID_EMPTY: + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_EMPTY\n"); + break; + case IOT_GATE_IMX8_CARD_ID_RS_485: + case IOT_GATE_IMX8_CARD_ID_RS_232: + if (revision == IOT_GATE_IMX8_CARD_ID_RS_485) + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_RS_485\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_RS_232) + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_RS_232\n"); + break; + case IOT_GATE_IMX8_CARD_ID_CAN: + case IOT_GATE_IMX8_CARD_ID_TPM: + case IOT_GATE_IMX8_CARD_ID_CL420: + if (revision == IOT_GATE_IMX8_CARD_ID_CAN) + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_CAN\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_TPM) + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_TPM\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_CL420) + printf("IED slot 1: IOT_GATE_IMX8_CARD_ID_CL420\n"); + break; + default: + printf("%s: invalid slot 1 card ID: %d\n", __func__, revision); + return 1; + } + + /* Get slot 2 card ID */ + revision = gpio_get_value(IOT_GATE_IMX8_GPIO_S2B0) | + gpio_get_value(IOT_GATE_IMX8_GPIO_S2B1) << 1 | + gpio_get_value(IOT_GATE_IMX8_GPIO_S2B2) << 2; + /* Slot 2 device tree blob manipulation */ + switch (revision) + { + case IOT_GATE_IMX8_CARD_ID_EMPTY: + case IOT_GATE_IMX8_CARD_ID_DI4O4: + if (revision == IOT_GATE_IMX8_CARD_ID_EMPTY) + printf("IED slot 2: IOT_GATE_IMX8_CARD_ID_EMPTY\n"); + else if (revision == IOT_GATE_IMX8_CARD_ID_DI4O4) + printf("IED slot 2: IOT_GATE_IMX8_CARD_ID_DI4O4\n"); + break; + default: + printf("%s: invalid slot 2 card ID: %d\n", __func__, revision); + return 1; + } + + return 0; +} + int board_late_init(void) { if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { @@ -67,5 +354,32 @@ int board_late_init(void) env_set("board_rev", "SBC-IOTMX8"); } + iot_gate_imx8_detect_ext(); /* Extended board detection */ + + switch(iot_gate_imx8_ext_id) { + case IOT_GATE_EXT_EMPTY: + printf("IOT_GATE-iMX8 extension board: IOT_GATE_EXT_EMPTY\n"); + break; + case IOT_GATE_EXT_CAN: + printf("IOT_GATE-iMX8 extension board: IOT_GATE_EXT_CAN\n"); + break; + case IOT_GATE_EXT_IED: + printf("IOT_GATE-iMX8 extension board: IOT_GATE_EXT_IED\n"); + break; + case IOT_GATE_EXT_POE: + printf("IOT_GATE-iMX8 extension board: IOT_GATE_EXT_POE\n"); + break; + case IOT_GATE_EXT_POEV2: + printf("IOT_GATE-iMX8 extension board: IOT_GATE_EXT_POEV2\n"); + break; + default: + printf("IOT_GATE-iMX8 extension board: unknown\n"); + break; + } + + //iot_gate_imx8_select_dtb(); /* Kernel device tree blob selection */ + iot_gate_imx8_update_pinmux(); + iot_gate_imx8_update_ext_ied(NULL); + return 0; } |