~ubuntu-branches/ubuntu/saucy/u-boot/saucy

« back to all changes in this revision

Viewing changes to board/davinci/da8xxevm/da850evm.c

  • Committer: Package Import Robot
  • Author(s): Clint Adams
  • Date: 2012-05-01 18:07:19 UTC
  • mfrom: (16.1.23 sid)
  • Revision ID: package-import@ubuntu.com-20120501180719-rjntk3287im4a0ns
Tags: 2012.04.01-1
* New upstream version.
  - Update mipsel-native-endianness.diff.
  - Update no-error-on-set-but-unused-variables.diff (partially merged).
  - Drop kirkwood_spi-irq_mask.diff (merged).
  - Drop kirkwood-disable-l2c.diff (merged).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <i2c.h>
26
26
#include <net.h>
27
27
#include <netdev.h>
 
28
#include <spi.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>
35
38
 
36
39
DECLARE_GLOBAL_DATA_PTR;
43
46
#endif
44
47
#endif /* CONFIG_DRIVER_TI_EMAC */
45
48
 
 
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
 
53
 
 
54
#define CFG_MAC_ADDR_OFFSET     (flash->size - SZ_64K)
 
55
 
 
56
#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 
57
static int get_mac_addr(u8 *addr)
 
58
{
 
59
        struct spi_flash *flash;
 
60
        int ret;
 
61
 
 
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);
 
64
        if (!flash) {
 
65
                printf("Error - unable to probe SPI flash.\n");
 
66
                return -1;
 
67
        }
 
68
 
 
69
        ret = spi_flash_read(flash, CFG_MAC_ADDR_OFFSET, 6, addr);
 
70
        if (ret) {
 
71
                printf("Error - unable to read MAC address from SPI flash.\n");
 
72
                return -1;
 
73
        }
 
74
 
 
75
        return ret;
 
76
}
 
77
#endif
 
78
 
46
79
void dsp_lpsc_on(unsigned domain, unsigned int id)
47
80
{
48
81
        dv_reg_p mdstat, mdctl, ptstat, ptcmd;
98
131
int misc_init_r(void)
99
132
{
100
133
        dspwake();
 
134
 
 
135
#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
 
136
 
 
137
        uchar env_enetaddr[6];
 
138
        int enetaddr_found;
 
139
 
 
140
        enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
 
141
 
 
142
#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 
143
        int spi_mac_read;
 
144
        uchar buff[6];
 
145
 
 
146
        spi_mac_read = get_mac_addr(buff);
 
147
 
 
148
        /*
 
149
         * MAC address not present in the environment
 
150
         * try and read the MAC address from SPI flash
 
151
         * and set it.
 
152
         */
 
153
        if (!enetaddr_found) {
 
154
                if (!spi_mac_read) {
 
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");
 
159
                                }
 
160
                        } else {
 
161
                                        printf("Warning: Invalid "
 
162
                                        "MAC address read from SPI flash\n");
 
163
                        }
 
164
                }
 
165
        } else {
 
166
                /*
 
167
                 * MAC address present in environment compare it with
 
168
                 * the MAC address in SPI flash and warn on mismatch
 
169
                 */
 
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");
 
175
        }
 
176
#endif
 
177
        uint8_t enetaddr[8];
 
178
        int eeprom_mac_read;
 
179
 
 
180
        /* Read Ethernet MAC address from EEPROM */
 
181
        eeprom_mac_read = dvevm_read_mac_address(enetaddr);
 
182
 
 
183
        /*
 
184
         * MAC address not present in the environment
 
185
         * try and read the MAC address from EEPROM flash
 
186
         * and set it.
 
187
         */
 
188
        if (!enetaddr_found) {
 
189
                if (eeprom_mac_read)
 
190
                        /* Set Ethernet MAC address from EEPROM */
 
191
                        davinci_sync_env_enetaddr(enetaddr);
 
192
        } else {
 
193
                /*
 
194
                 * MAC address present in environment compare it with
 
195
                 * the MAC address in EEPROM and warn on mismatch
 
196
                 */
 
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");
 
201
        }
 
202
 
 
203
#endif
101
204
        return 0;
102
205
}
103
206
 
108
211
#endif
109
212
};
110
213
 
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),
136
239
};
137
240
 
138
 
static const struct lpsc_resource lpsc[] = {
 
241
const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
 
242
 
 
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 */
143
248
        { DAVINCI_LPSC_GPIO },
144
249
};
145
250
 
 
251
const int lpsc_size = ARRAY_SIZE(lpsc);
 
252
 
146
253
#ifndef CONFIG_DA850_EVM_MAX_CPU_CLK
147
254
#define CONFIG_DA850_EVM_MAX_CPU_CLK    300000000
148
255
#endif