1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <common.h>
28#include <i2c.h>
29#include <net.h>
30#include <asm/arch/hardware.h>
31#include <asm/io.h>
32#include <asm/arch/davinci_misc.h>
33
34DECLARE_GLOBAL_DATA_PTR;
35
36#ifndef CONFIG_PRELOADER
37int dram_init(void)
38{
39
40 gd->ram_size = get_ram_size(
41 (void *)CONFIG_SYS_SDRAM_BASE,
42 CONFIG_MAX_RAM_BANK_SIZE);
43 return 0;
44}
45
46void dram_init_banksize(void)
47{
48 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
49 gd->bd->bi_dram[0].size = gd->ram_size;
50}
51#endif
52
53#ifdef CONFIG_DRIVER_TI_EMAC
54
55
56
57
58int dvevm_read_mac_address(uint8_t *buf)
59{
60#ifdef CONFIG_SYS_I2C_EEPROM_ADDR
61
62 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x7F00, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
63 (uint8_t *) &buf[0], 6))
64 goto i2cerr;
65
66
67 if (!is_valid_ether_addr(buf))
68 goto err;
69
70 return 1;
71
72i2cerr:
73 printf("Read from EEPROM @ 0x%02x failed\n", CONFIG_SYS_I2C_EEPROM_ADDR);
74err:
75#endif
76
77 return 0;
78}
79
80
81
82
83#if defined(CONFIG_SOC_DA8XX)
84void davinci_emac_mii_mode_sel(int mode_sel)
85{
86 int val;
87
88 val = readl(&davinci_syscfg_regs->cfgchip3);
89 if (mode_sel == 0)
90 val &= ~(1 << 8);
91 else
92 val |= (1 << 8);
93 writel(val, &davinci_syscfg_regs->cfgchip3);
94}
95#endif
96
97
98
99
100void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
101{
102 uint8_t env_enetaddr[6];
103
104 eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
105 if (!memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) {
106
107
108 debug("### Setting environment from EEPROM MAC address = "
109 "\"%pM\"\n",
110 env_enetaddr);
111 eth_setenv_enetaddr("ethaddr", rom_enetaddr);
112 }
113}
114
115#endif
116
117#if defined(CONFIG_SOC_DA8XX)
118#ifndef CONFIG_USE_IRQ
119void irq_init(void)
120{
121
122
123
124
125
126 writel(0, &davinci_aintc_regs->ger);
127
128 writel(0, &davinci_aintc_regs->hier);
129
130 writel(0xffffffff, &davinci_aintc_regs->ecr1);
131 writel(0xffffffff, &davinci_aintc_regs->ecr2);
132 writel(0xffffffff, &davinci_aintc_regs->ecr3);
133}
134#endif
135
136
137
138
139int da8xx_configure_lpsc_items(const struct lpsc_resource *item,
140 const int n_items)
141{
142 int i;
143
144 for (i = 0; i < n_items; i++)
145 lpsc_on(item[i].lpsc_no);
146
147 return 0;
148}
149#endif
150