aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-05-16 13:55:49 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-16 13:55:49 -0400
commit14d7e48751925b4d48f0fd2317b0570fd243f6fd (patch)
tree8175848962e7b2aa6887a6f1a89a9acc7a1460f4
parentb0456b24ff4c8f408feaf97ea465897672bb1ac1 (diff)
parentc3875ca7d9f9ad135debc78e211ea062ac48323c (diff)
Merge branch 'w5100-small-changes'
Akinobu Mita says: ==================== net: w5100: collection of small changes This patch series is the collection of relatively small changes for w5100 driver which includes a cleanup with no functional change, two fixes, and adding a functionality. * Changes from v1 - Remove the watchdong_timeo assignment to set default tx timeout, suggested by David Miller. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/wiznet/w5100-spi.c4
-rw-r--r--drivers/net/ethernet/wiznet/w5100.c28
-rw-r--r--drivers/net/ethernet/wiznet/w5100.h3
3 files changed, 21 insertions, 14 deletions
diff --git a/drivers/net/ethernet/wiznet/w5100-spi.c b/drivers/net/ethernet/wiznet/w5100-spi.c
index b868e458d0b5..93a2d3c07303 100644
--- a/drivers/net/ethernet/wiznet/w5100-spi.c
+++ b/drivers/net/ethernet/wiznet/w5100-spi.c
@@ -15,6 +15,7 @@
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/of_net.h>
18#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
19 20
20#include "w5100.h" 21#include "w5100.h"
@@ -414,6 +415,7 @@ static int w5100_spi_probe(struct spi_device *spi)
414 const struct spi_device_id *id = spi_get_device_id(spi); 415 const struct spi_device_id *id = spi_get_device_id(spi);
415 const struct w5100_ops *ops; 416 const struct w5100_ops *ops;
416 int priv_size; 417 int priv_size;
418 const void *mac = of_get_mac_address(spi->dev.of_node);
417 419
418 switch (id->driver_data) { 420 switch (id->driver_data) {
419 case W5100: 421 case W5100:
@@ -432,7 +434,7 @@ static int w5100_spi_probe(struct spi_device *spi)
432 return -EINVAL; 434 return -EINVAL;
433 } 435 }
434 436
435 return w5100_probe(&spi->dev, ops, priv_size, NULL, spi->irq, -EINVAL); 437 return w5100_probe(&spi->dev, ops, priv_size, mac, spi->irq, -EINVAL);
436} 438}
437 439
438static int w5100_spi_remove(struct spi_device *spi) 440static int w5100_spi_remove(struct spi_device *spi)
diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
index ec1889ce38a3..4f6255cf62ce 100644
--- a/drivers/net/ethernet/wiznet/w5100.c
+++ b/drivers/net/ethernet/wiznet/w5100.c
@@ -63,8 +63,9 @@ MODULE_LICENSE("GPL");
63#define S0_REGS(priv) ((priv)->s0_regs) 63#define S0_REGS(priv) ((priv)->s0_regs)
64 64
65#define W5100_S0_MR(priv) (S0_REGS(priv) + W5100_Sn_MR) 65#define W5100_S0_MR(priv) (S0_REGS(priv) + W5100_Sn_MR)
66#define S0_MR_MACRAW 0x04 /* MAC RAW mode (promiscuous) */ 66#define S0_MR_MACRAW 0x04 /* MAC RAW mode */
67#define S0_MR_MACRAW_MF 0x44 /* MAC RAW mode (filtered) */ 67#define S0_MR_MF 0x40 /* MAC Filter for W5100 and W5200 */
68#define W5500_S0_MR_MF 0x80 /* MAC Filter for W5500 */
68#define W5100_S0_CR(priv) (S0_REGS(priv) + W5100_Sn_CR) 69#define W5100_S0_CR(priv) (S0_REGS(priv) + W5100_Sn_CR)
69#define S0_CR_OPEN 0x01 /* OPEN command */ 70#define S0_CR_OPEN 0x01 /* OPEN command */
70#define S0_CR_CLOSE 0x10 /* CLOSE command */ 71#define S0_CR_CLOSE 0x10 /* CLOSE command */
@@ -173,11 +174,6 @@ struct w5100_priv {
173 struct work_struct restart_work; 174 struct work_struct restart_work;
174}; 175};
175 176
176static inline bool is_w5200(struct w5100_priv *priv)
177{
178 return priv->ops->chip_id == W5200;
179}
180
181/************************************************************************ 177/************************************************************************
182 * 178 *
183 * Lowlevel I/O functions 179 * Lowlevel I/O functions
@@ -707,8 +703,16 @@ static int w5100_hw_reset(struct w5100_priv *priv)
707 703
708static void w5100_hw_start(struct w5100_priv *priv) 704static void w5100_hw_start(struct w5100_priv *priv)
709{ 705{
710 w5100_write(priv, W5100_S0_MR(priv), priv->promisc ? 706 u8 mode = S0_MR_MACRAW;
711 S0_MR_MACRAW : S0_MR_MACRAW_MF); 707
708 if (!priv->promisc) {
709 if (priv->ops->chip_id == W5500)
710 mode |= W5500_S0_MR_MF;
711 else
712 mode |= S0_MR_MF;
713 }
714
715 w5100_write(priv, W5100_S0_MR(priv), mode);
712 w5100_command(priv, S0_CR_OPEN); 716 w5100_command(priv, S0_CR_OPEN);
713 w5100_enable_intr(priv); 717 w5100_enable_intr(priv);
714} 718}
@@ -1048,7 +1052,7 @@ static const struct net_device_ops w5100_netdev_ops = {
1048static int w5100_mmio_probe(struct platform_device *pdev) 1052static int w5100_mmio_probe(struct platform_device *pdev)
1049{ 1053{
1050 struct wiznet_platform_data *data = dev_get_platdata(&pdev->dev); 1054 struct wiznet_platform_data *data = dev_get_platdata(&pdev->dev);
1051 u8 *mac_addr = NULL; 1055 const void *mac_addr = NULL;
1052 struct resource *mem; 1056 struct resource *mem;
1053 const struct w5100_ops *ops; 1057 const struct w5100_ops *ops;
1054 int irq; 1058 int irq;
@@ -1083,7 +1087,8 @@ void *w5100_ops_priv(const struct net_device *ndev)
1083EXPORT_SYMBOL_GPL(w5100_ops_priv); 1087EXPORT_SYMBOL_GPL(w5100_ops_priv);
1084 1088
1085int w5100_probe(struct device *dev, const struct w5100_ops *ops, 1089int w5100_probe(struct device *dev, const struct w5100_ops *ops,
1086 int sizeof_ops_priv, u8 *mac_addr, int irq, int link_gpio) 1090 int sizeof_ops_priv, const void *mac_addr, int irq,
1091 int link_gpio)
1087{ 1092{
1088 struct w5100_priv *priv; 1093 struct w5100_priv *priv;
1089 struct net_device *ndev; 1094 struct net_device *ndev;
@@ -1138,7 +1143,6 @@ int w5100_probe(struct device *dev, const struct w5100_ops *ops,
1138 1143
1139 ndev->netdev_ops = &w5100_netdev_ops; 1144 ndev->netdev_ops = &w5100_netdev_ops;
1140 ndev->ethtool_ops = &w5100_ethtool_ops; 1145 ndev->ethtool_ops = &w5100_ethtool_ops;
1141 ndev->watchdog_timeo = HZ;
1142 netif_napi_add(ndev, &priv->napi, w5100_napi_poll, 16); 1146 netif_napi_add(ndev, &priv->napi, w5100_napi_poll, 16);
1143 1147
1144 /* This chip doesn't support VLAN packets with normal MTU, 1148 /* This chip doesn't support VLAN packets with normal MTU,
diff --git a/drivers/net/ethernet/wiznet/w5100.h b/drivers/net/ethernet/wiznet/w5100.h
index f8a16fad807b..17983a3b8d6c 100644
--- a/drivers/net/ethernet/wiznet/w5100.h
+++ b/drivers/net/ethernet/wiznet/w5100.h
@@ -30,7 +30,8 @@ struct w5100_ops {
30void *w5100_ops_priv(const struct net_device *ndev); 30void *w5100_ops_priv(const struct net_device *ndev);
31 31
32int w5100_probe(struct device *dev, const struct w5100_ops *ops, 32int w5100_probe(struct device *dev, const struct w5100_ops *ops,
33 int sizeof_ops_priv, u8 *mac_addr, int irq, int link_gpio); 33 int sizeof_ops_priv, const void *mac_addr, int irq,
34 int link_gpio);
34int w5100_remove(struct device *dev); 35int w5100_remove(struct device *dev);
35 36
36extern const struct dev_pm_ops w5100_pm_ops; 37extern const struct dev_pm_ops w5100_pm_ops;