Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * evm.c |
| 3 | * |
| 4 | * Board functions for TI814x EVM |
| 5 | * |
| 6 | * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/ |
| 7 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 12 | #include <cpsw.h> |
Alex Kiernan | 9925f1d | 2018-04-01 09:22:38 +0000 | [diff] [blame] | 13 | #include <environment.h> |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 14 | #include <errno.h> |
| 15 | #include <spl.h> |
| 16 | #include <asm/arch/cpu.h> |
| 17 | #include <asm/arch/hardware.h> |
| 18 | #include <asm/arch/omap.h> |
| 19 | #include <asm/arch/ddr_defs.h> |
| 20 | #include <asm/arch/clock.h> |
| 21 | #include <asm/arch/gpio.h> |
| 22 | #include <asm/arch/mmc_host_def.h> |
| 23 | #include <asm/arch/sys_proto.h> |
| 24 | #include <asm/io.h> |
| 25 | #include <asm/emif.h> |
| 26 | #include <asm/gpio.h> |
| 27 | #include "evm.h" |
| 28 | |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
| 30 | |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 31 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 32 | |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 33 | /* UART Defines */ |
| 34 | #ifdef CONFIG_SPL_BUILD |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 35 | static const struct cmd_control evm_ddr2_cctrl_data = { |
| 36 | .cmd0csratio = 0x80, |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 37 | .cmd0iclkout = 0x00, |
| 38 | |
| 39 | .cmd1csratio = 0x80, |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 40 | .cmd1iclkout = 0x00, |
| 41 | |
| 42 | .cmd2csratio = 0x80, |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 43 | .cmd2iclkout = 0x00, |
| 44 | }; |
| 45 | |
| 46 | static const struct emif_regs evm_ddr2_emif0_regs = { |
| 47 | .sdram_config = 0x40801ab2, |
| 48 | .ref_ctrl = 0x10000c30, |
| 49 | .sdram_tim1 = 0x0aaaf552, |
| 50 | .sdram_tim2 = 0x043631d2, |
| 51 | .sdram_tim3 = 0x00000327, |
| 52 | .emif_ddr_phy_ctlr_1 = 0x00000007 |
| 53 | }; |
| 54 | |
| 55 | static const struct emif_regs evm_ddr2_emif1_regs = { |
| 56 | .sdram_config = 0x40801ab2, |
| 57 | .ref_ctrl = 0x10000c30, |
| 58 | .sdram_tim1 = 0x0aaaf552, |
| 59 | .sdram_tim2 = 0x043631d2, |
| 60 | .sdram_tim3 = 0x00000327, |
| 61 | .emif_ddr_phy_ctlr_1 = 0x00000007 |
| 62 | }; |
| 63 | |
| 64 | const struct dmm_lisa_map_regs evm_lisa_map_regs = { |
| 65 | .dmm_lisa_map_0 = 0x00000000, |
| 66 | .dmm_lisa_map_1 = 0x00000000, |
| 67 | .dmm_lisa_map_2 = 0x806c0300, |
| 68 | .dmm_lisa_map_3 = 0x806c0300, |
| 69 | }; |
| 70 | |
| 71 | static const struct ddr_data evm_ddr2_data = { |
| 72 | .datardsratio0 = ((0x35<<10) | (0x35<<0)), |
| 73 | .datawdsratio0 = ((0x20<<10) | (0x20<<0)), |
| 74 | .datawiratio0 = ((0<<10) | (0<<0)), |
| 75 | .datagiratio0 = ((0<<10) | (0<<0)), |
| 76 | .datafwsratio0 = ((0x90<<10) | (0x90<<0)), |
| 77 | .datawrsratio0 = ((0x50<<10) | (0x50<<0)), |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 78 | }; |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 79 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 80 | void set_uart_mux_conf(void) |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 81 | { |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 82 | /* Set UART pins */ |
| 83 | enable_uart0_pin_mux(); |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 84 | } |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 85 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 86 | void set_mux_conf_regs(void) |
| 87 | { |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 88 | /* Set MMC pins */ |
| 89 | enable_mmc1_pin_mux(); |
| 90 | |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 91 | /* Set Ethernet pins */ |
| 92 | enable_enet_pin_mux(); |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 93 | } |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 94 | |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 95 | void sdram_init(void) |
| 96 | { |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 97 | config_dmm(&evm_lisa_map_regs); |
| 98 | |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 99 | config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data, |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 100 | &evm_ddr2_emif0_regs, 0); |
Lokesh Vutla | 965de8b | 2013-12-10 15:02:21 +0530 | [diff] [blame] | 101 | config_ddr(0, NULL, &evm_ddr2_data, &evm_ddr2_cctrl_data, |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 102 | &evm_ddr2_emif1_regs, 1); |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 103 | } |
Heiko Schocher | 0660481 | 2013-07-30 10:48:54 +0530 | [diff] [blame] | 104 | #endif |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 105 | |
| 106 | /* |
| 107 | * Basic board specific setup. Pinmux has been handled already. |
| 108 | */ |
| 109 | int board_init(void) |
| 110 | { |
Tom Rini | 73feefd | 2013-08-09 11:22:13 -0400 | [diff] [blame] | 111 | gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | |
Masahiro Yamada | 4aa2ba3 | 2017-05-09 20:31:39 +0900 | [diff] [blame] | 115 | #if defined(CONFIG_MMC) |
Matt Porter | ea7b96b | 2013-03-15 10:07:10 +0000 | [diff] [blame] | 116 | int board_mmc_init(bd_t *bis) |
| 117 | { |
| 118 | omap_mmc_init(1, 0, 0, -1, -1); |
| 119 | |
| 120 | return 0; |
| 121 | } |
| 122 | #endif |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 123 | |
| 124 | #ifdef CONFIG_DRIVER_TI_CPSW |
| 125 | static void cpsw_control(int enabled) |
| 126 | { |
| 127 | /* VTP can be added here */ |
| 128 | |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | static struct cpsw_slave_data cpsw_slaves[] = { |
| 133 | { |
| 134 | .slave_reg_ofs = 0x50, |
| 135 | .sliver_reg_ofs = 0x700, |
Mugunthan V N | 9c653aa | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 136 | .phy_addr = 1, |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 137 | }, |
| 138 | { |
| 139 | .slave_reg_ofs = 0x90, |
| 140 | .sliver_reg_ofs = 0x740, |
Mugunthan V N | 9c653aa | 2014-02-18 07:31:52 -0500 | [diff] [blame] | 141 | .phy_addr = 0, |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 142 | }, |
| 143 | }; |
| 144 | |
| 145 | static struct cpsw_platform_data cpsw_data = { |
| 146 | .mdio_base = CPSW_MDIO_BASE, |
| 147 | .cpsw_base = CPSW_BASE, |
| 148 | .mdio_div = 0xff, |
| 149 | .channels = 8, |
| 150 | .cpdma_reg_ofs = 0x100, |
| 151 | .slaves = 1, |
| 152 | .slave_data = cpsw_slaves, |
| 153 | .ale_reg_ofs = 0x600, |
| 154 | .ale_entries = 1024, |
| 155 | .host_port_reg_ofs = 0x28, |
| 156 | .hw_stats_reg_ofs = 0x400, |
Mugunthan V N | 2bf36ac | 2013-07-08 16:04:37 +0530 | [diff] [blame] | 157 | .bd_ram_ofs = 0x2000, |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 158 | .mac_control = (1 << 5), |
| 159 | .control = cpsw_control, |
| 160 | .host_port_num = 0, |
| 161 | .version = CPSW_CTRL_VERSION_1, |
| 162 | }; |
| 163 | #endif |
| 164 | |
| 165 | int board_eth_init(bd_t *bis) |
| 166 | { |
| 167 | uint8_t mac_addr[6]; |
| 168 | uint32_t mac_hi, mac_lo; |
| 169 | |
Simon Glass | 35affd7 | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 170 | if (!eth_env_get_enetaddr("ethaddr", mac_addr)) { |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 171 | printf("<ethaddr> not set. Reading from E-fuse\n"); |
| 172 | /* try reading mac address from efuse */ |
| 173 | mac_lo = readl(&cdev->macid0l); |
| 174 | mac_hi = readl(&cdev->macid0h); |
| 175 | mac_addr[0] = mac_hi & 0xFF; |
| 176 | mac_addr[1] = (mac_hi & 0xFF00) >> 8; |
| 177 | mac_addr[2] = (mac_hi & 0xFF0000) >> 16; |
| 178 | mac_addr[3] = (mac_hi & 0xFF000000) >> 24; |
| 179 | mac_addr[4] = mac_lo & 0xFF; |
| 180 | mac_addr[5] = (mac_lo & 0xFF00) >> 8; |
| 181 | |
Joe Hershberger | 0adb5b7 | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 182 | if (is_valid_ethaddr(mac_addr)) |
Simon Glass | fd1e959 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 183 | eth_env_set_enetaddr("ethaddr", mac_addr); |
Matt Porter | cd87464 | 2013-03-20 05:38:14 +0000 | [diff] [blame] | 184 | else |
| 185 | printf("Unable to read MAC address. Set <ethaddr>\n"); |
| 186 | } |
| 187 | |
| 188 | return cpsw_register(&cpsw_data); |
| 189 | } |