]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
nitrogen6x: convert to DM_I2C and DM_SERIAL
authorAnatolij Gustschin <agust@denx.de>
Sat, 20 Jul 2024 12:48:03 +0000 (14:48 +0200)
committerFabio Estevam <festevam@gmail.com>
Mon, 22 Jul 2024 20:55:35 +0000 (17:55 -0300)
Rework to remove use of legacy I2C API. Also switch
to DM_SERIAL to avoid board removal warning.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
board/boundary/nitrogen6x/nitrogen6x.c
configs/mx6qsabrelite_defconfig
configs/nitrogen6dl2g_defconfig
configs/nitrogen6dl_defconfig
configs/nitrogen6q2g_defconfig
configs/nitrogen6q_defconfig
configs/nitrogen6s1g_defconfig
configs/nitrogen6s_defconfig
include/configs/nitrogen6x.h

index 2b0cb2361c4061205805e9f4da3fff6054c7cfd7..b85fd806cba8fef6e65c29953a3c1ce69e8b1ef8 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/errno.h>
 #include <asm/gpio.h>
 #include <asm/mach-imx/iomux-v3.h>
-#include <asm/mach-imx/mxc_i2c.h>
 #include <asm/mach-imx/sata.h>
 #include <asm/mach-imx/spi.h>
 #include <asm/mach-imx/boot_mode.h>
@@ -56,10 +55,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define BUTTON_PAD_CTRL (PAD_CTL_PUS_100K_UP |                 \
        PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
 
-#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP |                  \
-       PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
-       PAD_CTL_ODE | PAD_CTL_SRE_FAST)
-
 #define RGB_PAD_CTRL   PAD_CTL_DSE_120ohm
 
 #define WEAK_PULLUP    (PAD_CTL_PUS_100K_UP |                  \
@@ -72,53 +67,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define OUTPUT_40OHM (PAD_CTL_SPEED_MED|PAD_CTL_DSE_40ohm)
 
-/* Prevent compiler error if gpio number 08 or 09 is used */
-#define not_octal(gp) ((((0x##gp >> 4) & 0xf) * 10) + ((0x##gp & 0xf)))
-
-#define _I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp,            \
-               sda_pad, sda_bank, sda_gp, pad_ctrl, join_io) {                \
-       .scl = {                                                               \
-               .i2c_mode = NEW_PAD_CTRL(cpu##_PAD_##scl_pad##__##i2cnum##_SCL,\
-                                        pad_ctrl),                            \
-               .gpio_mode = NEW_PAD_CTRL(                                     \
-                       cpu##_PAD_##scl_pad##__GPIO##scl_bank##join_io##scl_gp,\
-                       pad_ctrl),                                             \
-               .gp = IMX_GPIO_NR(scl_bank, not_octal(scl_gp))                 \
-       },                                                                     \
-       .sda = {                                                               \
-               .i2c_mode = NEW_PAD_CTRL(cpu##_PAD_##sda_pad##__##i2cnum##_SDA,\
-                                        pad_ctrl),                            \
-               .gpio_mode = NEW_PAD_CTRL(                                     \
-                       cpu##_PAD_##sda_pad##__GPIO##sda_bank##join_io##sda_gp,\
-                       pad_ctrl),                                             \
-                       .gp = IMX_GPIO_NR(sda_bank, not_octal(sda_gp))         \
-       }                                                                      \
-}
-
-#define I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp,             \
-               sda_pad, sda_bank, sda_gp, pad_ctrl)                           \
-               _I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp,     \
-                               sda_pad, sda_bank, sda_gp, pad_ctrl, _IO)
-
 #if defined(CONFIG_MX6QDL)
-#define I2C_PADS_INFO_ENTRY(i2cnum, scl_pad, scl_bank, scl_gp,         \
-               sda_pad, sda_bank, sda_gp, pad_ctrl)                    \
-       I2C_PADS_INFO_CPU(MX6Q, i2cnum, scl_pad, scl_bank, scl_gp,      \
-               sda_pad, sda_bank, sda_gp, pad_ctrl),                   \
-       I2C_PADS_INFO_CPU(MX6DL, i2cnum, scl_pad, scl_bank, scl_gp,     \
-               sda_pad, sda_bank, sda_gp, pad_ctrl)
-#define I2C_PADS_INFO_ENTRY_SPACING 2
-
 #define IOMUX_PAD_CTRL(name, pad_ctrl) \
                NEW_PAD_CTRL(MX6Q_PAD_##name, pad_ctrl),        \
                NEW_PAD_CTRL(MX6DL_PAD_##name, pad_ctrl)
 #else
-#define I2C_PADS_INFO_ENTRY(i2cnum, scl_pad, scl_bank, scl_gp,         \
-               sda_pad, sda_bank, sda_gp, pad_ctrl)                    \
-       I2C_PADS_INFO_CPU(MX6, i2cnum, scl_pad, scl_bank, scl_gp,       \
-               sda_pad, sda_bank, sda_gp, pad_ctrl)
-#define I2C_PADS_INFO_ENTRY_SPACING 1
-
 #define IOMUX_PAD_CTRL(name, pad_ctrl) NEW_PAD_CTRL(MX6_PAD_##name, pad_ctrl)
 #endif
 
@@ -139,18 +92,6 @@ static iomux_v3_cfg_t const uart2_pads[] = {
        IOMUX_PAD_CTRL(EIM_D27__UART2_RX_DATA, UART_PAD_CTRL),
 };
 
-static struct i2c_pads_info i2c_pads[] = {
-       /* I2C1, SGTL5000 */
-       I2C_PADS_INFO_ENTRY(I2C1, EIM_D21, 3, 21, EIM_D28, 3, 28, I2C_PAD_CTRL),
-       /* I2C2 Camera, MIPI */
-       I2C_PADS_INFO_ENTRY(I2C2, KEY_COL3, 4, 12, KEY_ROW3, 4, 13,
-                           I2C_PAD_CTRL),
-       /* I2C3, J15 - RGB connector */
-       I2C_PADS_INFO_ENTRY(I2C3, GPIO_5, 1, 05, GPIO_16, 7, 11, I2C_PAD_CTRL),
-};
-
-#define I2C_BUS_CNT    3
-
 static iomux_v3_cfg_t const usdhc2_pads[] = {
        IOMUX_PAD_CTRL(SD2_CLK__SD2_CLK, USDHC_PAD_CTRL),
        IOMUX_PAD_CTRL(SD2_CMD__SD2_CMD, USDHC_PAD_CTRL),
@@ -420,9 +361,11 @@ static void do_enable_hdmi(struct display_info_t const *dev)
 
 static int detect_i2c(struct display_info_t const *dev)
 {
-       return ((0 == i2c_set_bus_num(dev->bus))
-               &&
-               (0 == i2c_probe(dev->addr)));
+       struct udevice *udev = NULL;
+       int ret;
+
+       ret = i2c_get_chip_for_busnum(dev->bus, dev->addr, 1, &udev);
+       return ret ? 0 : 1;
 }
 
 static void enable_lvds(struct display_info_t const *dev)
@@ -831,15 +774,7 @@ int overwrite_console(void)
 int board_init(void)
 {
        struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
-       struct i2c_pads_info *p = i2c_pads;
-       int i;
-       int stride = 1;
 
-#if defined(CONFIG_MX6QDL)
-       stride = 2;
-       if (!is_mx6dq() && !is_mx6dqp())
-               p += 1;
-#endif
        clrsetbits_le32(&iomuxc_regs->gpr[1],
                        IOMUXC_GPR1_OTG_ID_MASK,
                        IOMUXC_GPR1_OTG_ID_GPIO1);
@@ -853,10 +788,6 @@ int board_init(void)
        setup_spi();
 #endif
        SETUP_IOMUX_PADS(usdhc2_pads);
-       for (i = 0; i < I2C_BUS_CNT; i++) {
-               setup_i2c(i, CONFIG_SYS_I2C_SPEED, 0x7f, p);
-               p += stride;
-       }
 
 #ifdef CONFIG_SATA
        setup_sata();
index ae9d1fa24473a9a5bc9adbdafea4032d1ae27477..bb830c429d0b7e7d751d790e8bc6042cec0d4ded 100644 (file)
@@ -10,9 +10,6 @@ CONFIG_ENV_OFFSET=0xC0000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6q.cfg"
 CONFIG_MX6Q=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=1024
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-sabrelite"
@@ -55,7 +52,7 @@ CONFIG_DWC_AHSATA=y
 CONFIG_LBA48=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -68,6 +65,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index 3ce26da1e77c8ed4a2968ee92ad5636d507e59fc..7060d3cf961bfb2027a5c51b41cc305dc4ae7d08 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6dl2g.cfg"
 CONFIG_MX6DL=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=2048
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6dl-nitrogen6x"
@@ -61,7 +58,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -74,6 +71,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index 6a0f48a73c626d69dcc5b9fb65be529019c76eaf..c2566c96aba11103c12d1ec06884986893a85083 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6dl.cfg"
 CONFIG_MX6DL=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=1024
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6dl-nitrogen6x"
@@ -61,7 +58,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -74,6 +71,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index 991311e7b6b3a642287bb27aeba3c6daccf5bb91..07800eff08a7b1d2b763efb4f802ceb3d3133679 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6q2g.cfg"
 CONFIG_MX6Q=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=2048
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-nitrogen6x"
@@ -64,7 +61,7 @@ CONFIG_DWC_AHSATA=y
 CONFIG_LBA48=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -77,6 +74,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index 72085fce630206624f5c24ac1f709000baee8f1a..c5e6ce52858637c3cebb2fd27b9b35dbbe0e543f 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6q.cfg"
 CONFIG_MX6Q=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=1024
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6q-nitrogen6x"
@@ -64,7 +61,7 @@ CONFIG_DWC_AHSATA=y
 CONFIG_LBA48=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -77,6 +74,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index b31182c1e3443319901ac2370cbba8cb35ff7704..e91c19d30e97cf44d0e395964a541cb9c1628a92 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6s1g.cfg"
 CONFIG_MX6S=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=1024
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6dl-nitrogen6x"
@@ -61,7 +58,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -74,6 +71,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index 4928f9c449522922906614c6341b6fd0e29d5313..b8b410c2cfe7fd8fb1f9dfaf5f38c55486f54c10 100644 (file)
@@ -11,9 +11,6 @@ CONFIG_ENV_SECT_SIZE=0x2000
 CONFIG_IMX_CONFIG="board/boundary/nitrogen6x/nitrogen6s.cfg"
 CONFIG_MX6S=y
 CONFIG_TARGET_NITROGEN6X=y
-CONFIG_SYS_I2C_MXC_I2C1=y
-CONFIG_SYS_I2C_MXC_I2C2=y
-CONFIG_SYS_I2C_MXC_I2C3=y
 CONFIG_DDR_MB=512
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6dl-nitrogen6x"
@@ -61,7 +58,7 @@ CONFIG_NETCONSOLE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_USB_FUNCTION_FASTBOOT=y
 CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_SYS_I2C_LEGACY=y
+CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_FSL_USDHC=y
 CONFIG_MTD=y
@@ -74,6 +71,8 @@ CONFIG_FEC_MXC=y
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_SPECIFY_CONSOLE_INDEX=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
index c9c599d07621d126d822254c3f962c522a0fa82b..c03d11dcdaec973caa540b9ab9deed9472f0a22b 100644 (file)
@@ -11,8 +11,6 @@
 
 #include "mx6_common.h"
 
-#define CFG_MXC_UART_BASE             UART2_BASE
-
 /* MMC Configs */
 #define CFG_SYS_FSL_ESDHC_ADDR      0
 #define CFG_SYS_FSL_USDHC_NUM       2