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 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <netdev.h> |
| 28 | #include <asm/io.h> |
| 29 | #include <asm/arch/mem.h> |
| 30 | #include <asm/arch/mux.h> |
| 31 | #include <asm/arch/sys_proto.h> |
| 32 | #include <asm/omap_gpio.h> |
| 33 | #include <asm/arch/mmc_host_def.h> |
| 34 | #include <i2c.h> |
| 35 | #include <asm/gpio.h> |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 36 | #ifdef CONFIG_USB_EHCI |
| 37 | #include <usb.h> |
| 38 | #include <asm/ehci-omap.h> |
| 39 | #endif |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 40 | #include "twister.h" |
| 41 | |
| 42 | DECLARE_GLOBAL_DATA_PTR; |
| 43 | |
| 44 | /* Timing definitions for Ethernet Controller */ |
| 45 | static const u32 gpmc_smc911[] = { |
| 46 | NET_GPMC_CONFIG1, |
| 47 | NET_GPMC_CONFIG2, |
| 48 | NET_GPMC_CONFIG3, |
| 49 | NET_GPMC_CONFIG4, |
| 50 | NET_GPMC_CONFIG5, |
| 51 | NET_GPMC_CONFIG6, |
| 52 | }; |
| 53 | |
| 54 | static const u32 gpmc_XR16L2751[] = { |
| 55 | XR16L2751_GPMC_CONFIG1, |
| 56 | XR16L2751_GPMC_CONFIG2, |
| 57 | XR16L2751_GPMC_CONFIG3, |
| 58 | XR16L2751_GPMC_CONFIG4, |
| 59 | XR16L2751_GPMC_CONFIG5, |
| 60 | XR16L2751_GPMC_CONFIG6, |
| 61 | }; |
| 62 | |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 63 | #ifdef CONFIG_USB_EHCI |
| 64 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 65 | .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, |
| 66 | .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, |
| 67 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 68 | }; |
| 69 | |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 70 | int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 71 | { |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 72 | return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Lucas Stach | 3494a4c | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 75 | int ehci_hcd_stop(int index) |
Stefano Babic | b149226 | 2012-02-07 23:28:58 +0000 | [diff] [blame] | 76 | { |
| 77 | return omap_ehci_hcd_stop(); |
| 78 | } |
| 79 | #endif |
| 80 | |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 81 | int board_init(void) |
| 82 | { |
| 83 | gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ |
| 84 | |
| 85 | /* boot param addr */ |
| 86 | gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); |
| 87 | |
| 88 | /* Chip select 1 and 3 are used for XR16L2751 UART controller */ |
| 89 | enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[1], |
| 90 | XR16L2751_UART1_BASE, GPMC_SIZE_16M); |
| 91 | |
| 92 | enable_gpmc_cs_config(gpmc_XR16L2751, &gpmc_cfg->cs[3], |
| 93 | XR16L2751_UART2_BASE, GPMC_SIZE_16M); |
| 94 | |
| 95 | gpio_request(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, "USB_PHY1_RESET"); |
| 96 | gpio_direction_output(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, 1); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 101 | #ifndef CONFIG_SPL_BUILD |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 102 | int misc_init_r(void) |
| 103 | { |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 104 | char *eth_addr; |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 105 | struct tam3517_module_info info; |
| 106 | int ret; |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 107 | |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 108 | dieid_num_r(); |
| 109 | |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 110 | eth_addr = getenv("ethaddr"); |
| 111 | if (eth_addr) |
| 112 | return 0; |
| 113 | |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 114 | TAM3517_READ_EEPROM(&info, ret); |
| 115 | if (!ret) |
| 116 | TAM3517_READ_MAC_FROM_EEPROM(&info); |
Stefano Babic | 95123d1 | 2012-08-29 01:22:00 +0000 | [diff] [blame] | 117 | |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 118 | return 0; |
| 119 | } |
Stefano Babic | 0a152e6 | 2012-11-23 05:19:25 +0000 | [diff] [blame] | 120 | #endif |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Routine: set_muxconf_regs |
| 124 | * Description: Setting up the configuration Mux registers specific to the |
| 125 | * hardware. Many pins need to be moved from protect to primary |
| 126 | * mode. |
| 127 | */ |
| 128 | void set_muxconf_regs(void) |
| 129 | { |
| 130 | MUX_TWISTER(); |
| 131 | } |
| 132 | |
| 133 | int board_eth_init(bd_t *bis) |
| 134 | { |
| 135 | davinci_emac_initialize(); |
| 136 | |
| 137 | /* init cs for extern lan */ |
| 138 | enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5], |
| 139 | CONFIG_SMC911X_BASE, GPMC_SIZE_16M); |
| 140 | if (smc911x_initialize(0, CONFIG_SMC911X_BASE) <= 0) |
| 141 | printf("\nError initializing SMC911x controlleri\n"); |
| 142 | |
| 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | #if defined(CONFIG_OMAP_HSMMC) && \ |
| 147 | !defined(CONFIG_SPL_BUILD) |
| 148 | int board_mmc_init(bd_t *bis) |
| 149 | { |
Jonathan Solnit | a9b0556 | 2012-02-24 11:30:18 +0000 | [diff] [blame] | 150 | return omap_mmc_init(0, 0, 0); |
Stefano Babic | 1047c0c | 2011-11-30 23:56:53 +0000 | [diff] [blame] | 151 | } |
| 152 | #endif |
Stefano Babic | 7f0461e | 2012-03-15 04:01:44 +0000 | [diff] [blame] | 153 | |
| 154 | #ifdef CONFIG_SPL_OS_BOOT |
| 155 | /* |
| 156 | * Do board specific preperation before SPL |
| 157 | * Linux boot |
| 158 | */ |
| 159 | void spl_board_prepare_for_linux(void) |
| 160 | { |
| 161 | /* init cs for extern lan */ |
| 162 | enable_gpmc_cs_config(gpmc_smc911, &gpmc_cfg->cs[5], |
| 163 | CONFIG_SMC911X_BASE, GPMC_SIZE_16M); |
| 164 | } |
| 165 | int spl_start_uboot(void) |
| 166 | { |
| 167 | int val = 0; |
Stefano Babic | f51b4c7 | 2013-02-23 00:53:26 +0000 | [diff] [blame^] | 168 | if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) { |
| 169 | gpio_direction_input(SPL_OS_BOOT_KEY); |
| 170 | val = gpio_get_value(SPL_OS_BOOT_KEY); |
| 171 | gpio_free(SPL_OS_BOOT_KEY); |
Stefano Babic | 7f0461e | 2012-03-15 04:01:44 +0000 | [diff] [blame] | 172 | } |
| 173 | return val; |
| 174 | } |
| 175 | #endif |