ace44df15fa0f361534adabe29ea71dc9208afe2
[openwrt/openwrt.git] / target / linux / pxa / patches-3.10 / 004-smsc911x_verdex_pro_support.patch
1 From 7645a459feb02f7aae4c3a5724b7800495d1b659 Mon Sep 17 00:00:00 2001
2 From: Bobby Powers <bobbypowers@gmail.com>
3 Date: Wed, 28 Oct 2009 22:41:31 -0400
4 Subject: [PATCH] [ARM] smsc911x: Verdex Pro support
5
6 Basically Joseph Kortje's patch, cleaned up to apply to Linus's
7 tree. Some of the smsc911x.c had been applied already
8
9 Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
10 ---
11 drivers/net/smsc911x.c | 50 +++++++++++++++++++++++++++++++++++++--------
12 drivers/net/smsc911x.h | 2 +-
13 include/linux/smsc911x.h | 11 ++++++++++
14 3 files changed, 53 insertions(+), 10 deletions(-)
15
16 --- a/drivers/net/ethernet/smsc/smsc911x.c
17 +++ b/drivers/net/ethernet/smsc/smsc911x.c
18 @@ -60,6 +60,7 @@
19 #include <linux/of_device.h>
20 #include <linux/of_gpio.h>
21 #include <linux/of_net.h>
22 +#include <asm/system_info.h>
23 #include "smsc911x.h"
24
25 #define SMSC_CHIPNAME "smsc911x"
26 @@ -1514,7 +1515,7 @@ static int smsc911x_open(struct net_devi
27 SMSC_WARN(pdata, ifup,
28 "Timed out waiting for EEPROM busy bit to clear");
29
30 - smsc911x_reg_write(pdata, GPIO_CFG, 0x70070000);
31 + smsc911x_reg_write(pdata, GPIO_CFG, GPIO_CFG_LED1_EN_ | GPIO_CFG_LED2_EN_ | (1 << 20));
32
33 /* The soft reset above cleared the device's MAC address,
34 * restore it from local copy (set in probe) */
35 @@ -1525,8 +1526,8 @@ static int smsc911x_open(struct net_devi
36 /* Initialise irqs, but leave all sources disabled */
37 smsc911x_disable_irq_chip(dev);
38
39 - /* Set interrupt deassertion to 100uS */
40 - intcfg = ((10 << 24) | INT_CFG_IRQ_EN_);
41 + /* Set interrupt deassertion to 22*10uS */
42 + intcfg = ((22 << 24) | INT_CFG_IRQ_EN_);
43
44 if (pdata->config.irq_polarity) {
45 SMSC_TRACE(pdata, ifup, "irq polarity: active high");
46 @@ -1552,7 +1553,7 @@ static int smsc911x_open(struct net_devi
47 temp |= INT_EN_SW_INT_EN_;
48 smsc911x_reg_write(pdata, INT_EN, temp);
49
50 - timeout = 1000;
51 + timeout = 2000;
52 while (timeout--) {
53 if (pdata->software_irq_signal)
54 break;
55 @@ -2370,6 +2371,38 @@ static inline int smsc911x_probe_config_
56 }
57 #endif /* CONFIG_OF */
58
59 +static inline unsigned int is_gumstix_oui(u8 *addr)
60 +{
61 + return (addr[0] == 0x00 && addr[1] == 0x15 && addr[2] == 0xC9);
62 +}
63 +
64 +/**
65 + * gen_serial_ether_addr - Generate software assigned Ethernet address
66 + * based on the system_serial number
67 + * @addr: Pointer to a six-byte array containing the Ethernet address
68 + *
69 + * Generate an Ethernet address (MAC) that is not multicast
70 + * and has the local assigned bit set, keyed on the system_serial
71 + */
72 +static inline void gen_serial_ether_addr(u8 *addr)
73 +{
74 + static u8 ether_serial_digit = 0;
75 + addr [0] = system_serial_high >> 8;
76 + addr [1] = system_serial_high;
77 + addr [2] = system_serial_low >> 24;
78 + addr [3] = system_serial_low >> 16;
79 + addr [4] = system_serial_low >> 8;
80 + addr [5] = (system_serial_low & 0xc0) | /* top bits are from system serial */
81 + (1 << 4) | /* 2 bits identify interface type 1=ether, 2=usb, 3&4 undef */
82 + ((ether_serial_digit++) & 0x0f); /* 15 possible interfaces of each type */
83 +
84 + if(!is_gumstix_oui(addr))
85 + {
86 + addr [0] &= 0xfe; /* clear multicast bit */
87 + addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
88 + }
89 +}
90 +
91 static int smsc911x_drv_probe(struct platform_device *pdev)
92 {
93 struct device_node *np = pdev->dev.of_node;
94 @@ -2516,11 +2549,11 @@ static int smsc911x_drv_probe(struct pla
95 SMSC_TRACE(pdata, probe,
96 "Mac Address is read from LAN911x EEPROM");
97 } else {
98 - /* eeprom values are invalid, generate random MAC */
99 - eth_hw_addr_random(dev);
100 + /* eeprom values are invalid, generate MAC from serial number */
101 + gen_serial_ether_addr(dev->dev_addr);
102 smsc911x_set_hw_mac_address(pdata, dev->dev_addr);
103 SMSC_TRACE(pdata, probe,
104 - "MAC Address is set to eth_random_addr");
105 + "MAC Address is derived from system serial number");
106 }
107 }
108