aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-12-16 09:32:28 -0500
committerArnd Bergmann <arnd@arndb.de>2011-12-16 09:32:28 -0500
commit06d123e0984424505eedd09981f1bafc3c38de78 (patch)
tree4aa75853378becf583d9514f068045056f45c367
parent4966eba037bd0841cdb458907f27b71d4dcfd5d4 (diff)
parent2839038bb1a72ed7ef3c39521e0ca981c9cb1534 (diff)
Merge branch 'at91/macb' into next/drivers
-rw-r--r--Documentation/devicetree/bindings/net/macb.txt25
-rw-r--r--arch/arm/boot/dts/at91sam9g20.dtsi7
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi7
-rw-r--r--arch/arm/boot/dts/at91sam9m10g45ek.dts5
-rw-r--r--arch/arm/boot/dts/usb_a9g20.dts5
-rw-r--r--drivers/net/ethernet/cadence/at91_ether.c23
-rw-r--r--drivers/net/ethernet/cadence/macb.c73
-rw-r--r--drivers/net/ethernet/cadence/macb.h2
8 files changed, 129 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
new file mode 100644
index 000000000000..44afa0e5057d
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -0,0 +1,25 @@
1* Cadence MACB/GEM Ethernet controller
2
3Required properties:
4- compatible: Should be "cdns,[<chip>-]{macb|gem}"
5 Use "cdns,at91sam9260-macb" Atmel at91sam9260 and at91sam9263 SoCs.
6 Use "cdns,at32ap7000-macb" for other 10/100 usage or use the generic form: "cdns,macb".
7 Use "cnds,pc302-gem" for Picochip picoXcell pc302 and later devices based on
8 the Cadence GEM, or the generic form: "cdns,gem".
9- reg: Address and length of the register set for the device
10- interrupts: Should contain macb interrupt
11- phy-mode: String, operation mode of the PHY interface.
12 Supported values are: "mii", "rmii", "gmii", "rgmii".
13
14Optional properties:
15- local-mac-address: 6 bytes, mac address
16
17Examples:
18
19 macb0: ethernet@fffc4000 {
20 compatible = "cdns,at32ap7000-macb";
21 reg = <0xfffc4000 0x4000>;
22 interrupts = <21>;
23 phy-mode = "rmii";
24 local-mac-address = [3a 0e 03 04 05 06];
25 };
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index aeef04269cf8..07603b8c9503 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -114,6 +114,13 @@
114 atmel,use-dma-tx; 114 atmel,use-dma-tx;
115 status = "disabled"; 115 status = "disabled";
116 }; 116 };
117
118 macb0: ethernet@fffc4000 {
119 compatible = "cdns,at32ap7000-macb", "cdns,macb";
120 reg = <0xfffc4000 0x100>;
121 interrupts = <21>;
122 status = "disabled";
123 };
117 }; 124 };
118 }; 125 };
119}; 126};
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index db6a45202f26..fffa005300a4 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -101,6 +101,13 @@
101 atmel,use-dma-tx; 101 atmel,use-dma-tx;
102 status = "disabled"; 102 status = "disabled";
103 }; 103 };
104
105 macb0: ethernet@fffbc000 {
106 compatible = "cdns,at32ap7000-macb", "cdns,macb";
107 reg = <0xfffbc000 0x100>;
108 interrupts = <25>;
109 status = "disabled";
110 };
104 }; 111 };
105 }; 112 };
106}; 113};
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index 85b34f59cd82..a387e7704ce1 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -30,6 +30,11 @@
30 usart1: serial@fff90000 { 30 usart1: serial@fff90000 {
31 status = "okay"; 31 status = "okay";
32 }; 32 };
33
34 macb0: ethernet@fffbc000 {
35 phy-mode = "rmii";
36 status = "okay";
37 };
33 }; 38 };
34 }; 39 };
35}; 40};
diff --git a/arch/arm/boot/dts/usb_a9g20.dts b/arch/arm/boot/dts/usb_a9g20.dts
index d66e2c00ac35..f04b535477f5 100644
--- a/arch/arm/boot/dts/usb_a9g20.dts
+++ b/arch/arm/boot/dts/usb_a9g20.dts
@@ -25,6 +25,11 @@
25 dbgu: serial@fffff200 { 25 dbgu: serial@fffff200 {
26 status = "okay"; 26 status = "okay";
27 }; 27 };
28
29 macb0: ethernet@fffc4000 {
30 phy-mode = "rmii";
31 status = "okay";
32 };
28 }; 33 };
29 }; 34 };
30}; 35};
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index dfeb46cb3f74..1a5b6efa0120 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -256,8 +256,7 @@ static void enable_phyirq(struct net_device *dev)
256 unsigned int dsintr, irq_number; 256 unsigned int dsintr, irq_number;
257 int status; 257 int status;
258 258
259 irq_number = lp->board_data.phy_irq_pin; 259 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
260 if (!irq_number) {
261 /* 260 /*
262 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), 261 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
263 * or board does not have it connected. 262 * or board does not have it connected.
@@ -266,6 +265,7 @@ static void enable_phyirq(struct net_device *dev)
266 return; 265 return;
267 } 266 }
268 267
268 irq_number = lp->board_data.phy_irq_pin;
269 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev); 269 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
270 if (status) { 270 if (status) {
271 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status); 271 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
@@ -320,8 +320,7 @@ static void disable_phyirq(struct net_device *dev)
320 unsigned int dsintr; 320 unsigned int dsintr;
321 unsigned int irq_number; 321 unsigned int irq_number;
322 322
323 irq_number = lp->board_data.phy_irq_pin; 323 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
324 if (!irq_number) {
325 del_timer_sync(&lp->check_timer); 324 del_timer_sync(&lp->check_timer);
326 return; 325 return;
327 } 326 }
@@ -366,6 +365,7 @@ static void disable_phyirq(struct net_device *dev)
366 disable_mdi(); 365 disable_mdi();
367 spin_unlock_irq(&lp->lock); 366 spin_unlock_irq(&lp->lock);
368 367
368 irq_number = lp->board_data.phy_irq_pin;
369 free_irq(irq_number, dev); /* Free interrupt handler */ 369 free_irq(irq_number, dev); /* Free interrupt handler */
370} 370}
371 371
@@ -1078,7 +1078,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1078 netif_carrier_off(dev); /* will be enabled in open() */ 1078 netif_carrier_off(dev); /* will be enabled in open() */
1079 1079
1080 /* If board has no PHY IRQ, use a timer to poll the PHY */ 1080 /* If board has no PHY IRQ, use a timer to poll the PHY */
1081 if (!lp->board_data.phy_irq_pin) { 1081 if (!gpio_is_valid(lp->board_data.phy_irq_pin)) {
1082 init_timer(&lp->check_timer); 1082 init_timer(&lp->check_timer);
1083 lp->check_timer.data = (unsigned long)dev; 1083 lp->check_timer.data = (unsigned long)dev;
1084 lp->check_timer.function = at91ether_check_link; 1084 lp->check_timer.function = at91ether_check_link;
@@ -1170,7 +1170,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1170 struct net_device *dev = platform_get_drvdata(pdev); 1170 struct net_device *dev = platform_get_drvdata(pdev);
1171 struct at91_private *lp = netdev_priv(dev); 1171 struct at91_private *lp = netdev_priv(dev);
1172 1172
1173 if (lp->board_data.phy_irq_pin >= 32) 1173 if (gpio_is_valid(lp->board_data.phy_irq_pin) &&
1174 lp->board_data.phy_irq_pin >= 32)
1174 gpio_free(lp->board_data.phy_irq_pin); 1175 gpio_free(lp->board_data.phy_irq_pin);
1175 1176
1176 unregister_netdev(dev); 1177 unregister_netdev(dev);
@@ -1189,11 +1190,12 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1189{ 1190{
1190 struct net_device *net_dev = platform_get_drvdata(pdev); 1191 struct net_device *net_dev = platform_get_drvdata(pdev);
1191 struct at91_private *lp = netdev_priv(net_dev); 1192 struct at91_private *lp = netdev_priv(net_dev);
1192 int phy_irq = lp->board_data.phy_irq_pin;
1193 1193
1194 if (netif_running(net_dev)) { 1194 if (netif_running(net_dev)) {
1195 if (phy_irq) 1195 if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
1196 int phy_irq = lp->board_data.phy_irq_pin;
1196 disable_irq(phy_irq); 1197 disable_irq(phy_irq);
1198 }
1197 1199
1198 netif_stop_queue(net_dev); 1200 netif_stop_queue(net_dev);
1199 netif_device_detach(net_dev); 1201 netif_device_detach(net_dev);
@@ -1207,7 +1209,6 @@ static int at91ether_resume(struct platform_device *pdev)
1207{ 1209{
1208 struct net_device *net_dev = platform_get_drvdata(pdev); 1210 struct net_device *net_dev = platform_get_drvdata(pdev);
1209 struct at91_private *lp = netdev_priv(net_dev); 1211 struct at91_private *lp = netdev_priv(net_dev);
1210 int phy_irq = lp->board_data.phy_irq_pin;
1211 1212
1212 if (netif_running(net_dev)) { 1213 if (netif_running(net_dev)) {
1213 clk_enable(lp->ether_clk); 1214 clk_enable(lp->ether_clk);
@@ -1215,8 +1216,10 @@ static int at91ether_resume(struct platform_device *pdev)
1215 netif_device_attach(net_dev); 1216 netif_device_attach(net_dev);
1216 netif_start_queue(net_dev); 1217 netif_start_queue(net_dev);
1217 1218
1218 if (phy_irq) 1219 if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
1220 int phy_irq = lp->board_data.phy_irq_pin;
1219 enable_irq(phy_irq); 1221 enable_irq(phy_irq);
1222 }
1220 } 1223 }
1221 return 0; 1224 return 0;
1222} 1225}
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 64d61461bdc7..baf1a0d88d8a 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -23,6 +23,8 @@
23#include <linux/platform_data/macb.h> 23#include <linux/platform_data/macb.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/phy.h> 25#include <linux/phy.h>
26#include <linux/of_device.h>
27#include <linux/of_net.h>
26 28
27#include "macb.h" 29#include "macb.h"
28 30
@@ -191,7 +193,6 @@ static int macb_mii_probe(struct net_device *dev)
191{ 193{
192 struct macb *bp = netdev_priv(dev); 194 struct macb *bp = netdev_priv(dev);
193 struct phy_device *phydev; 195 struct phy_device *phydev;
194 struct macb_platform_data *pdata;
195 int ret; 196 int ret;
196 197
197 phydev = phy_find_first(bp->mii_bus); 198 phydev = phy_find_first(bp->mii_bus);
@@ -200,14 +201,11 @@ static int macb_mii_probe(struct net_device *dev)
200 return -1; 201 return -1;
201 } 202 }
202 203
203 pdata = bp->pdev->dev.platform_data;
204 /* TODO : add pin_irq */ 204 /* TODO : add pin_irq */
205 205
206 /* attach the mac to the phy */ 206 /* attach the mac to the phy */
207 ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0, 207 ret = phy_connect_direct(dev, phydev, &macb_handle_link_change, 0,
208 pdata && pdata->is_rmii ? 208 bp->phy_interface);
209 PHY_INTERFACE_MODE_RMII :
210 PHY_INTERFACE_MODE_MII);
211 if (ret) { 209 if (ret) {
212 netdev_err(dev, "Could not attach to PHY\n"); 210 netdev_err(dev, "Could not attach to PHY\n");
213 return ret; 211 return ret;
@@ -1244,6 +1242,52 @@ static const struct net_device_ops macb_netdev_ops = {
1244#endif 1242#endif
1245}; 1243};
1246 1244
1245#if defined(CONFIG_OF)
1246static const struct of_device_id macb_dt_ids[] = {
1247 { .compatible = "cdns,at32ap7000-macb" },
1248 { .compatible = "cdns,at91sam9260-macb" },
1249 { .compatible = "cdns,macb" },
1250 { .compatible = "cdns,pc302-gem" },
1251 { .compatible = "cdns,gem" },
1252 { /* sentinel */ }
1253};
1254
1255MODULE_DEVICE_TABLE(of, macb_dt_ids);
1256
1257static int __devinit macb_get_phy_mode_dt(struct platform_device *pdev)
1258{
1259 struct device_node *np = pdev->dev.of_node;
1260
1261 if (np)
1262 return of_get_phy_mode(np);
1263
1264 return -ENODEV;
1265}
1266
1267static int __devinit macb_get_hwaddr_dt(struct macb *bp)
1268{
1269 struct device_node *np = bp->pdev->dev.of_node;
1270 if (np) {
1271 const char *mac = of_get_mac_address(np);
1272 if (mac) {
1273 memcpy(bp->dev->dev_addr, mac, ETH_ALEN);
1274 return 0;
1275 }
1276 }
1277
1278 return -ENODEV;
1279}
1280#else
1281static int __devinit macb_get_phy_mode_dt(struct platform_device *pdev)
1282{
1283 return -ENODEV;
1284}
1285static int __devinit macb_get_hwaddr_dt(struct macb *bp)
1286{
1287 return -ENODEV;
1288}
1289#endif
1290
1247static int __init macb_probe(struct platform_device *pdev) 1291static int __init macb_probe(struct platform_device *pdev)
1248{ 1292{
1249 struct macb_platform_data *pdata; 1293 struct macb_platform_data *pdata;
@@ -1318,10 +1362,22 @@ static int __init macb_probe(struct platform_device *pdev)
1318 config |= macb_dbw(bp); 1362 config |= macb_dbw(bp);
1319 macb_writel(bp, NCFGR, config); 1363 macb_writel(bp, NCFGR, config);
1320 1364
1321 macb_get_hwaddr(bp); 1365 err = macb_get_hwaddr_dt(bp);
1322 pdata = pdev->dev.platform_data; 1366 if (err < 0)
1367 macb_get_hwaddr(bp);
1368
1369 err = macb_get_phy_mode_dt(pdev);
1370 if (err < 0) {
1371 pdata = pdev->dev.platform_data;
1372 if (pdata && pdata->is_rmii)
1373 bp->phy_interface = PHY_INTERFACE_MODE_RMII;
1374 else
1375 bp->phy_interface = PHY_INTERFACE_MODE_MII;
1376 } else {
1377 bp->phy_interface = err;
1378 }
1323 1379
1324 if (pdata && pdata->is_rmii) 1380 if (bp->phy_interface == PHY_INTERFACE_MODE_RMII)
1325#if defined(CONFIG_ARCH_AT91) 1381#if defined(CONFIG_ARCH_AT91)
1326 macb_or_gem_writel(bp, USRIO, (MACB_BIT(RMII) | 1382 macb_or_gem_writel(bp, USRIO, (MACB_BIT(RMII) |
1327 MACB_BIT(CLKEN))); 1383 MACB_BIT(CLKEN)));
@@ -1444,6 +1500,7 @@ static struct platform_driver macb_driver = {
1444 .driver = { 1500 .driver = {
1445 .name = "macb", 1501 .name = "macb",
1446 .owner = THIS_MODULE, 1502 .owner = THIS_MODULE,
1503 .of_match_table = of_match_ptr(macb_dt_ids),
1447 }, 1504 },
1448}; 1505};
1449 1506
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 193107884a5a..335e288f5314 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -532,6 +532,8 @@ struct macb {
532 unsigned int link; 532 unsigned int link;
533 unsigned int speed; 533 unsigned int speed;
534 unsigned int duplex; 534 unsigned int duplex;
535
536 phy_interface_t phy_interface;
535}; 537};
536 538
537static inline bool macb_is_gem(struct macb *bp) 539static inline bool macb_is_gem(struct macb *bp)