Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 |
| 3 | * Stefano Babic, DENX Software Engineering, sbabic@denx.de. |
| 4 | * |
| 5 | * Copyright (C) 2009 TechNexion Ltd. |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <netdev.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <asm/arch/mem.h> |
| 14 | #include <asm/arch/mux.h> |
| 15 | #include <asm/arch/sys_proto.h> |
| 16 | #include <asm/omap_gpio.h> |
| 17 | #include <asm/arch/mmc_host_def.h> |
| 18 | #include <i2c.h> |
Jeroen Hofstee | afa6756 | 2014-10-08 22:57:58 +0200 | [diff] [blame] | 19 | #include <spl.h> |
| 20 | #include <mmc.h> |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 21 | #include <asm/gpio.h> |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 22 | #ifdef CONFIG_USB_EHCI |
| 23 | #include <usb.h> |
| 24 | #include <asm/ehci-omap.h> |
| 25 | #endif |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 26 | #include "twister.h" |
| 27 | |
| 28 | DECLARE_GLOBAL_DATA_PTR; |
| 29 | |
| 30 | /* Timing definitions for Ethernet Controller */ |
| 31 | static const u32 gpmc_smc911[] = { |
| 32 | NET_GPMC_CONFIG1, |
| 33 | NET_GPMC_CONFIG2, |
| 34 | NET_GPMC_CONFIG3, |
| 35 | NET_GPMC_CONFIG4, |
| 36 | NET_GPMC_CONFIG5, |
| 37 | NET_GPMC_CONFIG6, |
| 38 | }; |
| 39 | |
| 40 | static const u32 gpmc_XR16L2751[] = { |
| 41 | XR16L2751_GPMC_CONFIG1, |
| 42 | XR16L2751_GPMC_CONFIG2, |
| 43 | XR16L2751_GPMC_CONFIG3, |
| 44 | XR16L2751_GPMC_CONFIG4, |
| 45 | XR16L2751_GPMC_CONFIG5, |
| 46 | XR16L2751_GPMC_CONFIG6, |
| 47 | }; |
| 48 | |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 49 | #ifdef CONFIG_USB_EHCI |
| 50 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 51 | .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, |
| 52 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 53 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 54 | }; |
| 55 | |
Troy Kisky | 7d6bbb9 | 2013-10-10 15:27:57 -0700 | [diff] [blame] | 56 | int ehci_hcd_init(int index, enum usb_init_type init, |
| 57 | struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 58 | { |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 59 | return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor); |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 62 | int ehci_hcd_stop(int index) |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 63 | { |
| 64 | return omap_ehci_hcd_stop(); |
| 65 | } |
| 66 | #endif |
| 67 | |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 68 | int board_init(void) |
| 69 | { |
| 70 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 71 | |
| 72 | /* boot param addr */ |
| 73 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 74 | |
| 75 | /* Chip select 1 and 3 are used for XR16L2751 UART controller */ |
| 76 | enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[1], |
| 77 | XR16L2751_UART1_BASE, GPMC_SIZE_16M); |
| 78 | |
| 79 | enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[3], |
| 80 | XR16L2751_UART2_BASE, GPMC_SIZE_16M); |
| 81 | |
| 82 | gpio_request(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, "USB_PHY1_RESET"); |
| 83 | gpio_direction_output(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, 1); |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 88 | #ifndef CONFIG_SPL_BUILD |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 89 | int misc_init_r(void) |
| 90 | { |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 91 | char *eth_addr; |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 92 | struct tam3517_module_info info; |
| 93 | int ret; |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 94 | |
Paul Kocialkowski | 6bc318e | 2015-08-27 19:37:13 +0200 | [diff] [blame] | 95 | omap_die_id_display(); |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 96 | |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 97 | eth_addr = getenv("ethaddr"); |
| 98 | if (eth_addr) |
| 99 | return 0; |
| 100 | |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 101 | TAM3517_READ_EEPROM(&info, ret); |
| 102 | if (!ret) |
| 103 | TAM3517_READ_MAC_FROM_EEPROM(&info); |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 104 | |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 105 | return 0; |
| 106 | } |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 107 | #endif |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 108 | |
| 109 | /* |
| 110 | * Routine: set_muxconf_regs |
| 111 | * Description: Setting up the configuration Mux registers specific to the |
| 112 | * hardware. Many pins need to be moved from protect to primary |
| 113 | * mode. |
| 114 | */ |
| 115 | void set_muxconf_regs(void) |
| 116 | { |
| 117 | MUX_TWISTER(); |
| 118 | } |
| 119 | |
| 120 | int board_eth_init(bd_t *bis) |
| 121 | { |
| 122 | davinci_emac_initialize(); |
| 123 | |
| 124 | /* init cs for extern lan */ |
| 125 | enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5], |
| 126 | CONFIG_SMC911X_BASE, GPMC_SIZE_16M); |
| 127 | if (smc911x_initialize(0, CONFIG_SMC911X_BASE) <= 0) |
| 128 | printf("\nError initializing SMC911x controlleri\n"); |
| 129 | |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | #if defined(CONFIG_OMAP_HSMMC) && \ |
| 134 | !defined(CONFIG_SPL_BUILD) |
| 135 | int board_mmc_init(bd_t *bis) |
| 136 | { |
Nikita Kiryanov | 4be9dbc | 2012-12-03 02:19:47 +0000 | [diff] [blame] | 137 | return omap_mmc_init(0, 0, 0, -1, -1); |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 138 | } |
| 139 | #endif |
Stefano Babic | 7f0461e | 2012-03-15 04:01:44 +0000 | [diff] [blame] | 140 | |
| 141 | #ifdef CONFIG_SPL_OS_BOOT |
| 142 | /* |
| 143 | * Do board specific preperation before SPL |
| 144 | * Linux boot |
| 145 | */ |
| 146 | void spl_board_prepare_for_linux(void) |
| 147 | { |
| 148 | /* init cs for extern lan */ |
| 149 | enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5], |
| 150 | CONFIG_SMC911X_BASE, GPMC_SIZE_16M); |
| 151 | } |
| 152 | int spl_start_uboot(void) |
| 153 | { |
| 154 | int val = 0; |
Stefano Babic | f51b4c7 | 2013-02-23 00:53:26 +0000 | [diff] [blame] | 155 | if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) { |
| 156 | gpio_direction_input(SPL_OS_BOOT_KEY); |
| 157 | val = gpio_get_value(SPL_OS_BOOT_KEY); |
| 158 | gpio_free(SPL_OS_BOOT_KEY); |
Stefano Babic | 7f0461e | 2012-03-15 04:01:44 +0000 | [diff] [blame] | 159 | } |
| 160 | return val; |
| 161 | } |
| 162 | #endif |