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