27
27
#include <netdev.h>
29
#include <spi_flash.h>
28
30
#include <asm/arch/hardware.h>
29
31
#include <asm/arch/emif_defs.h>
30
32
#include <asm/arch/emac_defs.h>
31
33
#include <asm/arch/pinmux_defs.h>
32
34
#include <asm/io.h>
33
35
#include <asm/arch/davinci_misc.h>
36
#include <asm/errno.h>
34
37
#include <hwconfig.h>
36
39
DECLARE_GLOBAL_DATA_PTR;
44
47
#endif /* CONFIG_DRIVER_TI_EMAC */
49
#define CFG_MAC_ADDR_SPI_BUS 0
50
#define CFG_MAC_ADDR_SPI_CS 0
51
#define CFG_MAC_ADDR_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
52
#define CFG_MAC_ADDR_SPI_MODE SPI_MODE_3
54
#define CFG_MAC_ADDR_OFFSET (flash->size - SZ_64K)
56
#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
57
static int get_mac_addr(u8 *addr)
59
struct spi_flash *flash;
62
flash = spi_flash_probe(CFG_MAC_ADDR_SPI_BUS, CFG_MAC_ADDR_SPI_CS,
63
CFG_MAC_ADDR_SPI_MAX_HZ, CFG_MAC_ADDR_SPI_MODE);
65
printf("Error - unable to probe SPI flash.\n");
69
ret = spi_flash_read(flash, CFG_MAC_ADDR_OFFSET, 6, addr);
71
printf("Error - unable to read MAC address from SPI flash.\n");
46
79
void dsp_lpsc_on(unsigned domain, unsigned int id)
48
81
dv_reg_p mdstat, mdctl, ptstat, ptcmd;
98
131
int misc_init_r(void)
135
#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
137
uchar env_enetaddr[6];
140
enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
142
#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
146
spi_mac_read = get_mac_addr(buff);
149
* MAC address not present in the environment
150
* try and read the MAC address from SPI flash
153
if (!enetaddr_found) {
155
if (is_valid_ether_addr(buff)) {
156
if (eth_setenv_enetaddr("ethaddr", buff)) {
157
printf("Warning: Failed to "
158
"set MAC address from SPI flash\n");
161
printf("Warning: Invalid "
162
"MAC address read from SPI flash\n");
167
* MAC address present in environment compare it with
168
* the MAC address in SPI flash and warn on mismatch
170
if (!spi_mac_read && is_valid_ether_addr(buff) &&
171
memcmp(env_enetaddr, buff, 6))
172
printf("Warning: MAC address in SPI flash don't match "
173
"with the MAC address in the environment\n");
174
printf("Default using MAC address from environment\n");
180
/* Read Ethernet MAC address from EEPROM */
181
eeprom_mac_read = dvevm_read_mac_address(enetaddr);
184
* MAC address not present in the environment
185
* try and read the MAC address from EEPROM flash
188
if (!enetaddr_found) {
190
/* Set Ethernet MAC address from EEPROM */
191
davinci_sync_env_enetaddr(enetaddr);
194
* MAC address present in environment compare it with
195
* the MAC address in EEPROM and warn on mismatch
197
if (eeprom_mac_read && memcmp(enetaddr, env_enetaddr, 6))
198
printf("Warning: MAC address in EEPROM don't match "
199
"with the MAC address in the environment\n");
200
printf("Default using MAC address from environment\n");
111
static const struct pinmux_resource pinmuxes[] = {
214
const struct pinmux_resource pinmuxes[] = {
112
215
#ifdef CONFIG_DRIVER_TI_EMAC
113
216
PINMUX_ITEM(emac_pins_mdio),
114
217
#ifdef CONFIG_DRIVER_TI_EMAC_USE_RMII
135
238
PINMUX_ITEM(gpio_pins),
138
static const struct lpsc_resource lpsc[] = {
241
const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
243
const struct lpsc_resource lpsc[] = {
139
244
{ DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
140
245
{ DAVINCI_LPSC_SPI1 }, /* Serial Flash */
141
246
{ DAVINCI_LPSC_EMAC }, /* image download */