common: Move command functions out of common.h
[oweals/u-boot.git] / board / boundary / nitrogen6x / nitrogen6x.c
index 104d71fa5262d996efeb92aa94992046531ee3e7..33653b594957551769d10ffe387cf5f445e89e49 100644 (file)
@@ -1,11 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2010-2013 Freescale Semiconductor, Inc.
  * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <env.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/sys_proto.h>
 #include <malloc.h>
 #include <asm/arch/mx6-pins.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/gpio.h>
-#include <asm/imx-common/iomux-v3.h>
-#include <asm/imx-common/mxc_i2c.h>
-#include <asm/imx-common/sata.h>
-#include <asm/imx-common/spi.h>
-#include <asm/imx-common/boot_mode.h>
-#include <asm/imx-common/video.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>
+#include <asm/mach-imx/video.h>
 #include <mmc.h>
-#include <fsl_esdhc.h>
+#include <fsl_esdhc_imx.h>
 #include <micrel.h>
 #include <miiphy.h>
 #include <netdev.h>
@@ -31,7 +31,7 @@
 #include <i2c.h>
 #include <input.h>
 #include <netdev.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 #define GP_USB_OTG_PWR IMX_GPIO_NR(3, 22)
@@ -284,7 +284,7 @@ int board_ehci_power(int port, int on)
 
 #endif
 
-#ifdef CONFIG_FSL_ESDHC
+#ifdef CONFIG_FSL_ESDHC_IMX
 static struct fsl_esdhc_cfg usdhc_cfg[2] = {
        {USDHC3_BASE_ADDR},
        {USDHC4_BASE_ADDR},
@@ -382,6 +382,15 @@ int board_eth_init(bd_t *bis)
        struct phy_device *phydev = NULL;
        int ret;
 
+       gpio_request(WL12XX_WL_IRQ_GP, "wifi_irq");
+       gpio_request(IMX_GPIO_NR(6, 30), "rgmii_rxc");
+       gpio_request(IMX_GPIO_NR(6, 25), "rgmii_rd0");
+       gpio_request(IMX_GPIO_NR(6, 27), "rgmii_rd1");
+       gpio_request(IMX_GPIO_NR(6, 28), "rgmii_rd2");
+       gpio_request(IMX_GPIO_NR(6, 29), "rgmii_rd3");
+       gpio_request(IMX_GPIO_NR(6, 24), "rgmii_rx_ctl");
+       gpio_request(IMX_GPIO_NR(3, 23), "rgmii_reset_sabrelite");
+       gpio_request(IMX_GPIO_NR(1, 27), "rgmii_reset_nitrogen6x");
        setup_iomux_enet();
 
 #ifdef CONFIG_FEC_MXC
@@ -749,7 +758,7 @@ size_t display_count = ARRAY_SIZE(displays);
 
 int board_cfb_skip(void)
 {
-       return NULL != getenv("novideo");
+       return NULL != env_get("novideo");
 }
 
 static void setup_display(void)
@@ -903,7 +912,7 @@ int board_init(void)
        setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
        setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
 
-#ifdef CONFIG_CMD_SATA
+#ifdef CONFIG_SATA
        setup_sata();
 #endif
 
@@ -912,7 +921,16 @@ int board_init(void)
 
 int checkboard(void)
 {
-       if (gpio_get_value(WL12XX_WL_IRQ_GP))
+       int ret = gpio_get_value(WL12XX_WL_IRQ_GP);
+
+       if (ret < 0) {
+               /* The gpios have not been probed yet. Read it myself */
+               struct gpio_regs *regs = (struct gpio_regs *)GPIO6_BASE_ADDR;
+               int gpio = WL12XX_WL_IRQ_GP & 0x1f;
+
+               ret = (readl(&regs->gpio_psr) >> gpio) & 0x01;
+       }
+       if (ret)
                puts("Board: Nitrogen6X\n");
        else
                puts("Board: SABRE Lite\n");
@@ -954,7 +972,7 @@ static int do_kbd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        char envvalue[ARRAY_SIZE(buttons)+1];
        int numpressed = read_keys(envvalue);
-       setenv("keybd", envvalue);
+       env_set("keybd", envvalue);
        return numpressed == 0;
 }
 
@@ -974,7 +992,7 @@ static void preboot_keys(void)
        char keypress[ARRAY_SIZE(buttons)+1];
        numpressed = read_keys(keypress);
        if (numpressed) {
-               char *kbd_magic_keys = getenv("magic_keys");
+               char *kbd_magic_keys = env_get("magic_keys");
                char *suffix;
                /*
                 * loop over all magic keys
@@ -983,7 +1001,7 @@ static void preboot_keys(void)
                        char *keys;
                        char magic[sizeof(kbd_magic_prefix) + 1];
                        sprintf(magic, "%s%c", kbd_magic_prefix, *suffix);
-                       keys = getenv(magic);
+                       keys = env_get(magic);
                        if (keys) {
                                if (!strcmp(keys, keypress))
                                        break;
@@ -993,9 +1011,9 @@ static void preboot_keys(void)
                        char cmd_name[sizeof(kbd_command_prefix) + 1];
                        char *cmd;
                        sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix);
-                       cmd = getenv(cmd_name);
+                       cmd = env_get(cmd_name);
                        if (cmd) {
-                               setenv("preboot", cmd);
+                               env_set("preboot", cmd);
                                return;
                        }
                }
@@ -1014,6 +1032,16 @@ static const struct boot_mode board_boot_modes[] = {
 
 int misc_init_r(void)
 {
+       gpio_request(RGB_BACKLIGHT_GP, "lvds backlight");
+       gpio_request(LVDS_BACKLIGHT_GP, "lvds backlight");
+       gpio_request(GP_USB_OTG_PWR, "usbotg power");
+       gpio_request(IMX_GPIO_NR(7, 12), "usbh1 hub reset");
+       gpio_request(IMX_GPIO_NR(2, 2), "back");
+       gpio_request(IMX_GPIO_NR(2, 4), "home");
+       gpio_request(IMX_GPIO_NR(2, 1), "menu");
+       gpio_request(IMX_GPIO_NR(2, 3), "search");
+       gpio_request(IMX_GPIO_NR(7, 13), "volup");
+       gpio_request(IMX_GPIO_NR(4, 5), "voldown");
 #ifdef CONFIG_PREBOOT
        preboot_keys();
 #endif
@@ -1021,6 +1049,6 @@ int misc_init_r(void)
 #ifdef CONFIG_CMD_BMODE
        add_board_boot_modes(board_boot_modes);
 #endif
-       setenv_hex("reset_cause", get_imx_reset_cause());
+       env_set_hex("reset_cause", get_imx_reset_cause());
        return 0;
 }