board: gateworks: gw_ventana: move GPIO config out of common
authorTim Harvey <tharvey@gateworks.com>
Tue, 8 Mar 2022 00:24:02 +0000 (16:24 -0800)
committerStefano Babic <sbabic@denx.de>
Tue, 12 Apr 2022 13:36:17 +0000 (15:36 +0200)
Move gpio configuration out of common and into u-boot code as it is
not used by the SPL.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
board/gateworks/gw_ventana/common.c
board/gateworks/gw_ventana/common.h
board/gateworks/gw_ventana/gw_ventana.c

index 6b8900e..725f948 100644 (file)
@@ -1209,92 +1209,6 @@ void setup_iomux_gpio(int board, struct ventana_board_info *info)
        }
 }
 
-/* setup GPIO pinmux and default configuration per baseboard and env */
-void setup_board_gpio(int board, struct ventana_board_info *info)
-{
-       const char *s;
-       char arg[10];
-       size_t len;
-       int i;
-       int quiet = simple_strtol(env_get("quiet"), NULL, 10);
-
-       if (board >= GW_UNKNOWN)
-               return;
-
-       /* RS232_EN# */
-       if (gpio_cfg[board].rs232_en) {
-               gpio_direction_output(gpio_cfg[board].rs232_en,
-                                     (hwconfig("rs232")) ? 0 : 1);
-       }
-
-       /* MSATA Enable */
-       if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
-               gpio_direction_output(GP_MSATA_SEL,
-                                     (hwconfig("msata")) ? 1 : 0);
-       }
-
-       /* USBOTG Select (PCISKT or FrontPanel) */
-       if (gpio_cfg[board].usb_sel) {
-               gpio_direction_output(gpio_cfg[board].usb_sel,
-                                     (hwconfig("usb_pcisel")) ? 1 : 0);
-       }
-
-       /*
-        * Configure DIO pinmux/padctl registers
-        * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
-        */
-       for (i = 0; i < gpio_cfg[board].dio_num; i++) {
-               struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
-               iomux_v3_cfg_t ctrl = DIO_PAD_CFG;
-               unsigned cputype = is_cpu_type(MXC_CPU_MX6Q) ? 0 : 1;
-
-               if (!cfg->gpio_padmux[0] && !cfg->gpio_padmux[1])
-                       continue;
-               sprintf(arg, "dio%d", i);
-               if (!hwconfig(arg))
-                       continue;
-               s = hwconfig_subarg(arg, "padctrl", &len);
-               if (s) {
-                       ctrl = MUX_PAD_CTRL(hextoul(s, NULL)
-                                           & 0x1ffff) | MUX_MODE_SION;
-               }
-               if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
-                       if (!quiet) {
-                               printf("DIO%d:  GPIO%d_IO%02d (gpio-%d)\n", i,
-                                      (cfg->gpio_param/32)+1,
-                                      cfg->gpio_param%32,
-                                      cfg->gpio_param);
-                       }
-                       imx_iomux_v3_setup_pad(cfg->gpio_padmux[cputype] |
-                                              ctrl);
-                       gpio_requestf(cfg->gpio_param, "dio%d", i);
-                       gpio_direction_input(cfg->gpio_param);
-               } else if (hwconfig_subarg_cmp(arg, "mode", "pwm") &&
-                          cfg->pwm_padmux) {
-                       if (!cfg->pwm_param) {
-                               printf("DIO%d:  Error: pwm config invalid\n",
-                                       i);
-                               continue;
-                       }
-                       if (!quiet)
-                               printf("DIO%d:  pwm%d\n", i, cfg->pwm_param);
-                       imx_iomux_v3_setup_pad(cfg->pwm_padmux[cputype] |
-                                              MUX_PAD_CTRL(ctrl));
-               }
-       }
-
-       if (!quiet) {
-               if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
-                       printf("MSATA: %s\n", (hwconfig("msata") ?
-                              "enabled" : "disabled"));
-               }
-               if (gpio_cfg[board].rs232_en) {
-                       printf("RS232: %s\n", (hwconfig("rs232")) ?
-                              "enabled" : "disabled");
-               }
-       }
-}
-
 #include <fdt_support.h>
 #define WDOG1_ADDR      0x20bc000
 #define WDOG2_ADDR      0x20c0000
index d7f60a0..a036634 100644 (file)
@@ -81,8 +81,6 @@ extern struct ventana gpio_cfg[GW_UNKNOWN];
 
 /* configure gpio iomux/defaults */
 void setup_iomux_gpio(int board, struct ventana_board_info *);
-/* late setup of GPIO (configuration per baseboard and env) */
-void setup_board_gpio(int board, struct ventana_board_info *);
 /* early model/revision ft fixups */
 void ft_early_fixup(void *fdt, int board_type);
 
index a76f0ea..9b8f7b5 100644 (file)
@@ -576,6 +576,91 @@ static const struct boot_mode board_boot_modes[] = {
 };
 #endif
 
+/* setup GPIO pinmux and default configuration per baseboard and env */
+void setup_board_gpio(int board, struct ventana_board_info *info)
+{
+       const char *s;
+       char arg[10];
+       size_t len;
+       int i;
+       int quiet = simple_strtol(env_get("quiet"), NULL, 10);
+
+       if (board >= GW_UNKNOWN)
+               return;
+
+       /* RS232_EN# */
+       if (gpio_cfg[board].rs232_en) {
+               gpio_direction_output(gpio_cfg[board].rs232_en,
+                                     (hwconfig("rs232")) ? 0 : 1);
+       }
+
+       /* MSATA Enable */
+       if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
+               gpio_direction_output(GP_MSATA_SEL,
+                                     (hwconfig("msata")) ? 1 : 0);
+       }
+
+       /* USBOTG Select (PCISKT or FrontPanel) */
+       if (gpio_cfg[board].usb_sel) {
+               gpio_direction_output(gpio_cfg[board].usb_sel,
+                                     (hwconfig("usb_pcisel")) ? 1 : 0);
+       }
+
+       /*
+        * Configure DIO pinmux/padctl registers
+        * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
+        */
+       for (i = 0; i < gpio_cfg[board].dio_num; i++) {
+               struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
+               iomux_v3_cfg_t ctrl = DIO_PAD_CFG;
+               unsigned int cputype = is_cpu_type(MXC_CPU_MX6Q) ? 0 : 1;
+
+               if (!cfg->gpio_padmux[0] && !cfg->gpio_padmux[1])
+                       continue;
+               sprintf(arg, "dio%d", i);
+               if (!hwconfig(arg))
+                       continue;
+               s = hwconfig_subarg(arg, "padctrl", &len);
+               if (s) {
+                       ctrl = MUX_PAD_CTRL(hextoul(s, NULL)
+                                           & 0x1ffff) | MUX_MODE_SION;
+               }
+               if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
+                       if (!quiet) {
+                               printf("DIO%d:  GPIO%d_IO%02d (gpio-%d)\n", i,
+                                      (cfg->gpio_param / 32) + 1,
+                                      cfg->gpio_param % 32,
+                                      cfg->gpio_param);
+                       }
+                       imx_iomux_v3_setup_pad(cfg->gpio_padmux[cputype] |
+                                              ctrl);
+                       gpio_requestf(cfg->gpio_param, "dio%d", i);
+                       gpio_direction_input(cfg->gpio_param);
+               } else if (hwconfig_subarg_cmp(arg, "mode", "pwm") &&
+                          cfg->pwm_padmux) {
+                       if (!cfg->pwm_param) {
+                               printf("DIO%d:  Error: pwm config invalid\n",
+                                      i);
+                               continue;
+                       }
+                       if (!quiet)
+                               printf("DIO%d:  pwm%d\n", i, cfg->pwm_param);
+                       imx_iomux_v3_setup_pad(cfg->pwm_padmux[cputype] |
+                                              MUX_PAD_CTRL(ctrl));
+               }
+       }
+
+       if (!quiet) {
+               if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
+                       printf("MSATA: %s\n", (hwconfig("msata") ?
+                              "enabled" : "disabled"));
+               }
+               if (gpio_cfg[board].rs232_en) {
+                       printf("RS232: %s\n", (hwconfig("rs232")) ?
+                              "enabled" : "disabled");
+               }
+       }
+}
 /* late init */
 int misc_init_r(void)
 {