Kconfig: USB: Migrate CONFIG_USB_EHCI to CONFIG_USB_EHCI_HCD
[platform/kernel/u-boot.git] / board / ti / beagle / beagle.c
index 3d9b6dd..c1365e2 100644 (file)
  *     Syed Mohammed Khasim <khasim@ti.com>
  *
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
-#ifdef CONFIG_STATUS_LED
+#include <dm.h>
+#include <ns16550.h>
+#ifdef CONFIG_LED_STATUS
 #include <status_led.h>
 #endif
 #include <twl4030.h>
 #include <asm/gpio.h>
 #include <asm/mach-types.h>
 #include <asm/omap_musb.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/musb.h>
 #include "beagle.h"
 #include <command.h>
 
-#ifdef CONFIG_USB_EHCI
+#ifdef CONFIG_USB_EHCI_HCD
 #include <usb.h>
 #include <asm/ehci-omap.h>
 #endif
@@ -86,6 +72,18 @@ static struct {
        char env_setting[64];
 } expansion_config;
 
+static const struct ns16550_platdata beagle_serial = {
+       .base = OMAP34XX_UART3,
+       .reg_shift = 2,
+       .clock = V_NS16550_CLK,
+       .fcr = UART_FCR_DEFVAL,
+};
+
+U_BOOT_DEVICE(beagle_uart) = {
+       "ns16550_serial",
+       &beagle_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -98,8 +96,8 @@ int board_init(void)
        /* boot param addr */
        gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
 
-#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
-       status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
+#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
+       status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
 #endif
 
        return 0;
@@ -108,32 +106,33 @@ int board_init(void)
 /*
  * Routine: get_board_revision
  * Description: Detect if we are running on a Beagle revision Ax/Bx,
- *             C1/2/3, C4 or xM. This can be done by reading
+ *             C1/2/3, C4, xM Ax/Bx or xM Cx. This can be done by reading
  *             the level of GPIO173, GPIO172 and GPIO171. This should
  *             result in
  *             GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  *             GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  *             GPIO173, GPIO172, GPIO171: 1 0 1 => C4
- *             GPIO173, GPIO172, GPIO171: 0 0 0 => xM
+ *             GPIO173, GPIO172, GPIO171: 0 1 0 => xM Cx
+ *             GPIO173, GPIO172, GPIO171: 0 0 0 => xM Ax/Bx
  */
 static int get_board_revision(void)
 {
-       int revision;
-
-       if (!gpio_request(171, "") &&
-           !gpio_request(172, "") &&
-           !gpio_request(173, "")) {
-
-               gpio_direction_input(171);
-               gpio_direction_input(172);
-               gpio_direction_input(173);
-
-               revision = gpio_get_value(173) << 2 |
-                          gpio_get_value(172) << 1 |
-                          gpio_get_value(171);
-       } else {
-               printf("Error: unable to acquire board revision GPIOs\n");
-               revision = -1;
+       static int revision = -1;
+
+       if (revision == -1) {
+               if (!gpio_request(171, "rev0") &&
+                   !gpio_request(172, "rev1") &&
+                   !gpio_request(173, "rev2")) {
+                       gpio_direction_input(171);
+                       gpio_direction_input(172);
+                       gpio_direction_input(173);
+
+                       revision = gpio_get_value(173) << 2 |
+                               gpio_get_value(172) << 1 |
+                               gpio_get_value(171);
+               } else {
+                       printf("Error: unable to acquire board revision GPIOs\n");
+               }
        }
 
        return revision;
@@ -181,8 +180,7 @@ void get_board_mem_timings(struct board_sdrc_timings *timings)
                        timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
                        break;
                }
-       case REVISION_XM_A:
-       case REVISION_XM_B:
+       case REVISION_XM_AB:
        case REVISION_XM_C:
                if (pop_mfr == 0) {
                        /* 256MB DDR */
@@ -255,8 +253,7 @@ static void beagle_display_init(void)
        case REVISION_C4:
                omap3_dss_panel_config(&dvid_cfg);
                break;
-       case REVISION_XM_A:
-       case REVISION_XM_B:
+       case REVISION_XM_AB:
        case REVISION_XM_C:
        default:
                omap3_dss_panel_config(&dvid_cfg_xm);
@@ -275,12 +272,11 @@ static void beagle_dvi_pup(void)
        case REVISION_AXBX:
        case REVISION_CX:
        case REVISION_C4:
-       case REVISION_XM_A:
-               gpio_request(170, "");
+               gpio_request(170, "dvi");
                gpio_direction_output(170, 0);
                gpio_set_value(170, 1);
                break;
-       case REVISION_XM_B:
+       case REVISION_XM_AB:
        case REVISION_XM_C:
        default:
                #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3)
@@ -311,12 +307,12 @@ static struct omap_musb_board_data musb_board_data = {
 };
 
 static struct musb_hdrc_platform_data musb_plat = {
-#if defined(CONFIG_MUSB_HOST)
+#if defined(CONFIG_USB_MUSB_HOST)
        .mode           = MUSB_HOST,
-#elif defined(CONFIG_MUSB_GADGET)
+#elif defined(CONFIG_USB_MUSB_GADGET)
        .mode           = MUSB_PERIPHERAL,
 #else
-#error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET"
+#error "Please define either CONFIG_USB_MUSB_HOST or CONFIG_USB_MUSB_GADGET"
 #endif
        .config         = &musb_config,
        .power          = 100,
@@ -334,9 +330,13 @@ int misc_init_r(void)
        struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
        struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
        struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
+       bool generate_fake_mac = false;
+       u32 value;
 
        /* Enable i2c2 pullup resisters */
-       writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
+       value = readl(&prog_io_base->io1);
+       value &= ~(PRG_I2C2_PULLUPRESX);
+       writel(value, &prog_io_base->io1);
 
        switch (get_board_revision()) {
        case REVISION_AXBX:
@@ -358,25 +358,16 @@ int misc_init_r(void)
                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
                break;
-       case REVISION_XM_A:
-               printf("Beagle xM Rev A\n");
-               setenv("beaglerev", "xMA");
-               MUX_BEAGLE_XM();
-               /* Set VAUX2 to 1.8V for EHCI PHY */
-               twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
-                                       TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
-                                       TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
-                                       TWL4030_PM_RECEIVER_DEV_GRP_P1);
-               break;
-       case REVISION_XM_B:
-               printf("Beagle xM Rev B\n");
-               setenv("beaglerev", "xMB");
+       case REVISION_XM_AB:
+               printf("Beagle xM Rev A/B\n");
+               setenv("beaglerev", "xMAB");
                MUX_BEAGLE_XM();
                /* Set VAUX2 to 1.8V for EHCI PHY */
                twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
                                        TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
+               generate_fake_mac = true;
                break;
        case REVISION_XM_C:
                printf("Beagle xM Rev C\n");
@@ -387,6 +378,7 @@ int misc_init_r(void)
                                        TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
+               generate_fake_mac = true;
                break;
        default:
                printf("Beagle unknown 0x%02x\n", get_board_revision());
@@ -396,6 +388,7 @@ int misc_init_r(void)
                                        TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
                                        TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
                                        TWL4030_PM_RECEIVER_DEV_GRP_P1);
+               generate_fake_mac = true;
        }
 
        switch (get_expansion_id()) {
@@ -483,8 +476,7 @@ int misc_init_r(void)
 
        twl4030_power_init();
        switch (get_board_revision()) {
-       case REVISION_XM_A:
-       case REVISION_XM_B:
+       case REVISION_XM_AB:
                twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
                break;
        default:
@@ -503,7 +495,7 @@ int misc_init_r(void)
        writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
                GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
 
-       dieid_num_r();
+       omap_die_id_display();
 
 #ifdef CONFIG_VIDEO_OMAP3
        beagle_dvi_pup();
@@ -515,6 +507,9 @@ int misc_init_r(void)
        musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE);
 #endif
 
+       if (generate_fake_mac)
+               omap_die_id_usbethaddr();
+
        return 0;
 }
 
@@ -529,14 +524,21 @@ void set_muxconf_regs(void)
        MUX_BEAGLE();
 }
 
-#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_GENERIC_MMC)
 int board_mmc_init(bd_t *bis)
 {
        return omap_mmc_init(0, 0, 0, -1, -1);
 }
 #endif
 
-#if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD)
+#if defined(CONFIG_GENERIC_MMC)
+void board_mmc_power_init(void)
+{
+       twl4030_power_mmc_init(0);
+}
+#endif
+
+#if defined(CONFIG_USB_EHCI_HCD) && !defined(CONFIG_SPL_BUILD)
 /* Call usb_stop() before starting the kernel */
 void show_boot_progress(int val)
 {
@@ -550,9 +552,10 @@ static struct omap_usbhs_board_data usbhs_bdata = {
        .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
 };
 
-int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+int ehci_hcd_init(int index, enum usb_init_type init,
+               struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
-       return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
+       return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
 }
 
 int ehci_hcd_stop(int index)
@@ -560,9 +563,9 @@ int ehci_hcd_stop(int index)
        return omap_ehci_hcd_stop();
 }
 
-#endif /* CONFIG_USB_EHCI */
+#endif /* CONFIG_USB_EHCI_HCD */
 
-#if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET)
+#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_MUSB_GADGET)
 int board_eth_init(bd_t *bis)
 {
        return usb_eth_initialize(bis);