Commit 7194ab80 authored by Ben Warren's avatar Ben Warren

Convert SMC91111 Ethernet driver to CONFIG_NET_MULTI API

All in-tree boards that use this controller have CONFIG_NET_MULTI
added
Also:
  - changed CONFIG_DRIVER_SMC91111 to CONFIG_SMC91111
  - cleaned up line lengths
  - modified all boards that override weak function in this driver
  - modified all eeprom standalone apps to work with new driver
  - updated blackfin standalone EEPROM app after testing
Signed-off-by: default avatarBen Warren <biggerbadderben@gmail.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
parent 32e7f239
......@@ -22,6 +22,7 @@
*/
#include <common.h>
#include <netdev.h>
int board_early_init_f (void)
{
......@@ -38,3 +39,14 @@ phys_size_t initdram (int board_type)
{
return (0);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -22,6 +22,7 @@
*/
#include <common.h>
#include <netdev.h>
int board_early_init_f (void)
{
......@@ -38,3 +39,14 @@ phys_size_t initdram (int board_type)
{
return (0);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -22,6 +22,7 @@
*/
#include <common.h>
#include <netdev.h>
int checkboard (void)
{
......@@ -33,3 +34,14 @@ phys_size_t initdram (int board_type)
{
return (0);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -34,9 +34,7 @@
*/
#include <common.h>
#ifdef CONFIG_PCI
#include <netdev.h>
#endif
DECLARE_GLOBAL_DATA_PTR;
......@@ -127,9 +125,16 @@ extern void dram_query(void);
return 0;
}
#ifdef CONFIG_PCI
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
return pci_eth_init(bis);
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
#ifdef CONFIG_PCI
rc += pci_eth_init(bis);
#endif
return rc;
}
#endif
......@@ -34,6 +34,7 @@
*/
#include <common.h>
#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -89,3 +90,14 @@ int dram_init (void)
{
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
#include "psd4256.h"
#include "flash-defines.h"
......@@ -57,3 +58,10 @@ int misc_init_r(void)
return 0;
}
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
#include "bf533-stamp.h"
......@@ -283,3 +284,10 @@ void __led_toggle(led_id_t mask)
}
#endif
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -7,6 +7,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <config.h>
#include <asm/blackfin.h>
......@@ -25,3 +26,10 @@ phys_size_t initdram(int board_type)
gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
return gd->bd->bi_memsize;
}
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -43,3 +44,10 @@ phys_size_t initdram(int board_type)
gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
return gd->bd->bi_memsize;
}
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -12,6 +12,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -44,3 +45,10 @@ void swap_to(int device_id)
SSYNC();
}
#endif
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -71,3 +72,14 @@ int dram_init (void)
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -7,6 +7,7 @@
*/
#include <common.h>
#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -23,3 +24,10 @@ phys_size_t initdram(int board_type)
gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
return gd->bd->bi_memsize;
}
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -7,6 +7,7 @@
*/
#include <common.h>
#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -23,3 +24,10 @@ phys_size_t initdram(int board_type)
gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
return gd->bd->bi_memsize;
}
#ifdef CONFIG_SMC91111
int board_eth_init(bd_t *bis)
{
return smc91111_initialize(0, CONFIG_SMC91111_BASE);
}
#endif
......@@ -27,6 +27,7 @@
#include <asm/arch/pxa-regs.h>
#include <common.h>
#include <netdev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -223,3 +224,14 @@ dram_init (void)
PHYS_SDRAM_3_SIZE +
PHYS_SDRAM_4_SIZE );
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -22,6 +22,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <i2c.h>
#include <da9030.h>
#include <malloc.h>
......@@ -363,3 +364,14 @@ void hw_watchdog_reset(void)
i2c_reg_write(addr, SYS_CONTROL_A, val);
}
#endif
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -23,6 +23,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <SA-1100.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -53,3 +54,14 @@ int dram_init (void)
return (0);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -19,6 +19,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <config.h>
#include <asm/leon.h>
......@@ -37,3 +38,14 @@ int misc_init_r(void)
{
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -19,6 +19,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <config.h>
#include <asm/leon.h>
......@@ -37,3 +38,14 @@ int misc_init_r(void)
{
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -24,6 +24,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/arch/pxa-regs.h>
#include <asm/mach-types.h>
......@@ -182,3 +183,14 @@ void show_boot_progress (int status)
return;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -23,6 +23,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/arch/pxa-regs.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -120,3 +121,14 @@ void show_boot_progress (int status)
return;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
#if defined(CONFIG_LH7A400)
#include <lh7a400.h>
#elif defined(CONFIG_LH7A404)
......@@ -79,3 +80,14 @@ int dram_init (void)
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -24,6 +24,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
#include <asm/processor.h>
......@@ -57,3 +58,14 @@ void led_set_state(unsigned short value)
{
writew(value & 0xFF, LED_BASE);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -27,43 +27,42 @@
#include <common.h>
#include <exports.h>
#include <timestamp.h>
#include <net.h>
#include "../drivers/net/smc91111.h"
#define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
static u16 read_eeprom_reg(u16 reg)
static u16 read_eeprom_reg(struct eth_device *dev, u16 reg)
{
int timeout;
SMC_SELECT_BANK(2);
SMC_outw(reg, PTR_REG);
SMC_SELECT_BANK(dev, 2);
SMC_outw(dev, reg, PTR_REG);
SMC_SELECT_BANK(1);
SMC_outw(SMC_inw (CTL_REG) | CTL_EEPROM_SELECT | CTL_RELOAD,
SMC_SELECT_BANK(dev, 1);
SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_RELOAD,
CTL_REG);
timeout = 100;
while((SMC_inw (CTL_REG) & CTL_RELOAD) && --timeout)
while((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --timeout)
udelay(100);
if (timeout == 0) {
printf("Timeout Reading EEPROM register %02x\n", reg);
return 0;
}
return SMC_inw (GP_REG);
return SMC_inw (dev, GP_REG);
}
static int write_eeprom_reg(u16 value, u16 reg)
static int write_eeprom_reg(struct eth_device *dev, u16 value, u16 reg)
{
int timeout;
SMC_SELECT_BANK(2);
SMC_outw(reg, PTR_REG);
SMC_SELECT_BANK(dev, 2);
SMC_outw(dev, reg, PTR_REG);
SMC_SELECT_BANK(1);
SMC_outw(value, GP_REG);
SMC_outw(SMC_inw (CTL_REG) | CTL_EEPROM_SELECT | CTL_STORE, CTL_REG);
SMC_SELECT_BANK(dev, 1);
SMC_outw(dev, value, GP_REG);
SMC_outw(dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | CTL_STORE, CTL_REG);
timeout = 100;
while ((SMC_inw(CTL_REG) & CTL_STORE) && --timeout)
while ((SMC_inw(dev, CTL_REG) & CTL_STORE) && --timeout)
udelay (100);
if (timeout == 0) {
printf("Timeout Writing EEPROM register %02x\n", reg);
......@@ -73,17 +72,17 @@ static int write_eeprom_reg(u16 value, u16 reg)
return 1;
}
static int write_data(u16 *buf, int len)
static int write_data(struct eth_device *dev, u16 *buf, int len)
{
u16 reg = 0x23;
while (len--)
write_eeprom_reg(*buf++, reg++);
write_eeprom_reg(dev, *buf++, reg++);
return 0;
}
static int verify_macaddr(char *s)
static int verify_macaddr(struct eth_device *dev, char *s)
{
u16 reg;
int i, err = 0;
......@@ -91,7 +90,7 @@ static int verify_macaddr(char *s)
printf("MAC Address: ");
err = i = 0;
for (i = 0; i < 3; i++) {
reg = read_eeprom_reg(0x20 + i);
reg = read_eeprom_reg(dev, 0x20 + i);
printf("%02x:%02x%c", reg & 0xff, reg >> 8, i != 2 ? ':' : '\n');
if (s)
err |= reg != ((u16 *)s)[i];
......@@ -100,7 +99,7 @@ static int verify_macaddr(char *s)
return err ? 0 : 1;
}
static int set_mac(char *s)
static int set_mac(struct eth_device *dev, char *s)
{
int i;
char *e, eaddr[6];
......@@ -112,7 +111,7 @@ static int set_mac(char *s)
}
for (i = 0; i < 3; i++)
write_eeprom_reg(*(((u16 *)eaddr) + i), 0x20 + i);
write_eeprom_reg(dev, *(((u16 *)eaddr) + i), 0x20 + i);
return 0;
}
......@@ -150,6 +149,10 @@ int eeprom(int argc, char *argv[])
int i, len, ret;
unsigned char buf[58], *p;
struct eth_device dev = {
.iobase = CONFIG_SMC91111_BASE
};
app_startup(argv);
if (get_version() != XF_VERSION) {
printf("Wrong XF_VERSION.\n");
......@@ -160,14 +163,14 @@ int eeprom(int argc, char *argv[])
return crcek();
if ((SMC_inw (BANK_SELECT) & 0xFF00) != 0x3300) {
if ((SMC_inw (&dev, BANK_SELECT) & 0xFF00) != 0x3300) {
printf("SMSC91111 not found.\n");
return 2;
}
/* Called without parameters - print MAC address */
if (argc < 2) {
verify_macaddr(NULL);
verify_macaddr(&dev, NULL);
return 0;
}
......@@ -201,8 +204,8 @@ int eeprom(int argc, char *argv[])
}
/* First argument (MAC) is mandatory */
set_mac(argv[1]);
if (verify_macaddr(argv[1])) {
set_mac(&dev, argv[1]);
if (verify_macaddr(&dev, argv[1])) {
printf("*** MAC address does not match! ***\n");
return 4;
}
......@@ -210,7 +213,7 @@ int eeprom(int argc, char *argv[])
while (len--)
*p++ = 0;
write_data((u16 *)buf, sizeof(buf) >> 1);
write_data(&dev, (u16 *)buf, sizeof(buf) >> 1);
return 0;
}
......@@ -21,6 +21,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <i2c.h>
#include <flash.h>
#include <nand.h>
......@@ -115,3 +116,14 @@ int board_nand_init(struct nand_chip *nand)
return 0;
}
#endif
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -22,6 +22,7 @@
*/
#include <common.h>
#include <netdev.h>
int board_early_init_f (void)
{
......@@ -38,3 +39,14 @@ phys_size_t initdram (int board_type)
{
return (0);
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -31,6 +31,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <command.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -133,3 +134,14 @@ U_BOOT_CMD(idpcmd, CONFIG_SYS_MAXARGS, 0, do_idpcmd,
);
#endif
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -24,6 +24,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
#include <asm/processor.h>
......@@ -51,3 +52,14 @@ int dram_init (void)
void led_set_state (unsigned short value)
{
}
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_SMC91111
rc = smc91111_initialize(0, CONFIG_SMC91111_BASE);
#endif
return rc;
}
#endif
......@@ -26,6 +26,7 @@
*/
#include <common.h>
#include <netdev.h>
#include <asm/io.h>
#include <asm/arch/gpio.h>
......@@ -89,3 +90,14 @@ int dram_init(void)
gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
return 0;
}
#ifdef CONFIG_CMD_NET
int board_eth_init(</