Make use of U-Boot's GPIO DM and device tree to control the I2C IO
expander. While at it, also enable the native GPIO.

Signed-off-by: Aditya Prayoga <adi...@kobol.io>
---
 board/kobol/helios4/helios4.c | 32 --------------------------------
 configs/helios4_defconfig     |  4 ++++
 2 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/board/kobol/helios4/helios4.c b/board/kobol/helios4/helios4.c
index 3416783..37c46a5 100644
--- a/board/kobol/helios4/helios4.c
+++ b/board/kobol/helios4/helios4.c
@@ -33,18 +33,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define BOARD_GPP_POL_LOW      0x0
 #define BOARD_GPP_POL_MID      0x0
 
-/* IO expander on Marvell GP board includes e.g. fan enabling */
-struct marvell_io_exp {
-       u8 addr;
-       u8 val;
-};
-
-static struct marvell_io_exp io_exp[] = {
-       {6, 0xf9},
-       {2, 0x46}, /* Assert reset signals and enable USB3 current limiter */
-       {6, 0xb9}
-};
-
 static struct serdes_map board_serdes_map[] = {
        {SATA0, SERDES_SPEED_6_GBPS, SERDES_DEFAULT_MODE, 0, 0},
        {USB3_HOST0, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
@@ -123,29 +111,9 @@ int board_early_init_f(void)
 
 int board_init(void)
 {
-       int i;
-
        /* Address of boot parameters */
        gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
 
-       /* Init I2C IO expanders */
-       for (i = 0; i < ARRAY_SIZE(io_exp); i++) {
-               struct udevice *dev;
-               int ret;
-
-               ret = i2c_get_chip_for_busnum(0, io_exp[i].addr, 1, &dev);
-               if (ret) {
-                       printf("Cannot find I2C: %d\n", ret);
-                       return 0;
-               }
-
-               ret = dm_i2c_write(dev, io_exp[i].val, &io_exp[i].val, 1);
-               if (ret) {
-                       printf("Failed to set IO expander via I2C\n");
-                       return -EIO;
-               }
-       }
-
        return 0;
 }
 
diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig
index 8ac8978..69dd774 100644
--- a/configs/helios4_defconfig
+++ b/configs/helios4_defconfig
@@ -22,6 +22,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141
 CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PCI=y
@@ -38,6 +39,9 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_SCSI_AHCI=y
+CONFIG_DM_GPIO=y
+CONFIG_MVEBU_GPIO=y
+CONFIG_DM_PCA953X=y
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_I2C_SET_DEFAULT_BUS_NUM=y
-- 
2.7.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to