aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/via
diff options
context:
space:
mode:
authorAlexey Charkov <alchark@gmail.com>2014-04-30 14:21:09 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-02 15:55:42 -0400
commitca8b6e04bc38891cbc0f2c7855bc7d0498dfff9b (patch)
treeadb76e1d823376b2ac445857356c7377004c96b9 /drivers/net/ethernet/via
parentc25aaf814a63f9d9c4e45416f13d70ef0aa0be2e (diff)
net: via-rhine: Drop revision property, use quirks instead
This adds two new flags to quirks and thus removes the need to carry revision in rhine_private. As a result, the init logic is simplified a bit. This also fixes a compiler warning in OF code on 64bit due to pointer casting: drivers/net/ethernet/via/via-rhine.c: In function ‘rhine_init_one_platform’: drivers/net/ethernet/via/via-rhine.c:1132:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] revision = (u32)match->data; ^ That code was added in commit 2d283862dc62daead9db0dc89cd0d0351e91f765 ("net: via-rhine: add OF bus binding"). Tested in platform configuration on a VIA WM8950 APC Rock board. Reported-by: Jan Moskyto Matejka <mq@suse.cz> Signed-off-by: Alexey Charkov <alchark@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/via')
-rw-r--r--drivers/net/ethernet/via/via-rhine.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 4fa92012ceac..13cfcced212e 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -264,6 +264,8 @@ enum rhine_quirks {
264 rq6patterns = 0x0040, /* 6 instead of 4 patterns for WOL */ 264 rq6patterns = 0x0040, /* 6 instead of 4 patterns for WOL */
265 rqStatusWBRace = 0x0080, /* Tx Status Writeback Error possible */ 265 rqStatusWBRace = 0x0080, /* Tx Status Writeback Error possible */
266 rqRhineI = 0x0100, /* See comment below */ 266 rqRhineI = 0x0100, /* See comment below */
267 rqIntPHY = 0x0200, /* Integrated PHY */
268 rqMgmt = 0x0400, /* Management adapter */
267}; 269};
268/* 270/*
269 * rqRhineI: VT86C100A (aka Rhine-I) uses different bits to enable 271 * rqRhineI: VT86C100A (aka Rhine-I) uses different bits to enable
@@ -284,11 +286,11 @@ static DEFINE_PCI_DEVICE_TABLE(rhine_pci_tbl) = {
284MODULE_DEVICE_TABLE(pci, rhine_pci_tbl); 286MODULE_DEVICE_TABLE(pci, rhine_pci_tbl);
285 287
286/* OpenFirmware identifiers for platform-bus devices 288/* OpenFirmware identifiers for platform-bus devices
287 * The .data field is currently only used to store chip revision 289 * The .data field is currently only used to store quirks
288 * (for quirks etc.)
289 */ 290 */
291static u32 vt8500_quirks = rqWOL | rqForceReset | rq6patterns;
290static struct of_device_id rhine_of_tbl[] = { 292static struct of_device_id rhine_of_tbl[] = {
291 { .compatible = "via,vt8500-rhine", .data = (void *)0x84 }, 293 { .compatible = "via,vt8500-rhine", .data = &vt8500_quirks },
292 { } /* terminate list */ 294 { } /* terminate list */
293}; 295};
294MODULE_DEVICE_TABLE(of, rhine_of_tbl); 296MODULE_DEVICE_TABLE(of, rhine_of_tbl);
@@ -459,7 +461,6 @@ struct rhine_private {
459 unsigned char *tx_bufs; 461 unsigned char *tx_bufs;
460 dma_addr_t tx_bufs_dma; 462 dma_addr_t tx_bufs_dma;
461 463
462 int revision;
463 int irq; 464 int irq;
464 long pioaddr; 465 long pioaddr;
465 struct net_device *dev; 466 struct net_device *dev;
@@ -882,7 +883,7 @@ static const struct net_device_ops rhine_netdev_ops = {
882#endif 883#endif
883}; 884};
884 885
885static int rhine_init_one_common(struct device *hwdev, int revision, 886static int rhine_init_one_common(struct device *hwdev, u32 quirks,
886 long pioaddr, void __iomem *ioaddr, int irq) 887 long pioaddr, void __iomem *ioaddr, int irq)
887{ 888{
888 struct net_device *dev; 889 struct net_device *dev;
@@ -906,31 +907,13 @@ static int rhine_init_one_common(struct device *hwdev, int revision,
906 907
907 rp = netdev_priv(dev); 908 rp = netdev_priv(dev);
908 rp->dev = dev; 909 rp->dev = dev;
909 rp->revision = revision; 910 rp->quirks = quirks;
910 rp->pioaddr = pioaddr; 911 rp->pioaddr = pioaddr;
911 rp->base = ioaddr; 912 rp->base = ioaddr;
912 rp->irq = irq; 913 rp->irq = irq;
913 rp->msg_enable = netif_msg_init(debug, RHINE_MSG_DEFAULT); 914 rp->msg_enable = netif_msg_init(debug, RHINE_MSG_DEFAULT);
914 915
915 phy_id = 0; 916 phy_id = rp->quirks & rqIntPHY ? 1 : 0;
916 name = "Rhine";
917 if (revision < VTunknown0) {
918 rp->quirks = rqRhineI;
919 } else if (revision >= VT6102) {
920 rp->quirks = rqWOL | rqForceReset;
921 if (revision < VT6105) {
922 name = "Rhine II";
923 rp->quirks |= rqStatusWBRace; /* Rhine-II exclusive */
924 } else {
925 phy_id = 1; /* Integrated PHY, phy_id fixed to 1 */
926 if (revision >= VT6105_B0)
927 rp->quirks |= rq6patterns;
928 if (revision < VT6105M)
929 name = "Rhine III";
930 else
931 name = "Rhine III (Management Adapter)";
932 }
933 }
934 917
935 u64_stats_init(&rp->tx_stats.syncp); 918 u64_stats_init(&rp->tx_stats.syncp);
936 u64_stats_init(&rp->rx_stats.syncp); 919 u64_stats_init(&rp->rx_stats.syncp);
@@ -975,7 +958,7 @@ static int rhine_init_one_common(struct device *hwdev, int revision,
975 if (rp->quirks & rqRhineI) 958 if (rp->quirks & rqRhineI)
976 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; 959 dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM;
977 960
978 if (rp->revision >= VT6105M) 961 if (rp->quirks & rqMgmt)
979 dev->features |= NETIF_F_HW_VLAN_CTAG_TX | 962 dev->features |= NETIF_F_HW_VLAN_CTAG_TX |
980 NETIF_F_HW_VLAN_CTAG_RX | 963 NETIF_F_HW_VLAN_CTAG_RX |
981 NETIF_F_HW_VLAN_CTAG_FILTER; 964 NETIF_F_HW_VLAN_CTAG_FILTER;
@@ -985,6 +968,15 @@ static int rhine_init_one_common(struct device *hwdev, int revision,
985 if (rc) 968 if (rc)
986 goto err_out_free_netdev; 969 goto err_out_free_netdev;
987 970
971 if (rp->quirks & rqRhineI)
972 name = "Rhine";
973 else if (rp->quirks & rqStatusWBRace)
974 name = "Rhine II";
975 else if (rp->quirks & rqMgmt)
976 name = "Rhine III (Management Adapter)";
977 else
978 name = "Rhine III";
979
988 netdev_info(dev, "VIA %s at 0x%lx, %pM, IRQ %d\n", 980 netdev_info(dev, "VIA %s at 0x%lx, %pM, IRQ %d\n",
989 name, (long)ioaddr, dev->dev_addr, rp->irq); 981 name, (long)ioaddr, dev->dev_addr, rp->irq);
990 982
@@ -1031,7 +1023,7 @@ static int rhine_init_one_pci(struct pci_dev *pdev,
1031 long pioaddr, memaddr; 1023 long pioaddr, memaddr;
1032 void __iomem *ioaddr; 1024 void __iomem *ioaddr;
1033 int io_size = pdev->revision < VTunknown0 ? 128 : 256; 1025 int io_size = pdev->revision < VTunknown0 ? 128 : 256;
1034 u32 quirks = pdev->revision < VTunknown0 ? rqRhineI : 0; 1026 u32 quirks;
1035#ifdef USE_MMIO 1027#ifdef USE_MMIO
1036 int bar = 1; 1028 int bar = 1;
1037#else 1029#else
@@ -1047,6 +1039,21 @@ static int rhine_init_one_pci(struct pci_dev *pdev,
1047 if (rc) 1039 if (rc)
1048 goto err_out; 1040 goto err_out;
1049 1041
1042 if (pdev->revision < VTunknown0) {
1043 quirks = rqRhineI;
1044 } else if (pdev->revision >= VT6102) {
1045 quirks = rqWOL | rqForceReset;
1046 if (pdev->revision < VT6105) {
1047 quirks |= rqStatusWBRace;
1048 } else {
1049 quirks |= rqIntPHY;
1050 if (pdev->revision >= VT6105_B0)
1051 quirks |= rq6patterns;
1052 if (pdev->revision >= VT6105M)
1053 quirks |= rqMgmt;
1054 }
1055 }
1056
1050 /* sanity check */ 1057 /* sanity check */
1051 if ((pci_resource_len(pdev, 0) < io_size) || 1058 if ((pci_resource_len(pdev, 0) < io_size) ||
1052 (pci_resource_len(pdev, 1) < io_size)) { 1059 (pci_resource_len(pdev, 1) < io_size)) {
@@ -1093,7 +1100,7 @@ static int rhine_init_one_pci(struct pci_dev *pdev,
1093 } 1100 }
1094#endif /* USE_MMIO */ 1101#endif /* USE_MMIO */
1095 1102
1096 rc = rhine_init_one_common(&pdev->dev, pdev->revision, 1103 rc = rhine_init_one_common(&pdev->dev, quirks,
1097 pioaddr, ioaddr, pdev->irq); 1104 pioaddr, ioaddr, pdev->irq);
1098 if (!rc) 1105 if (!rc)
1099 return 0; 1106 return 0;
@@ -1111,7 +1118,7 @@ err_out:
1111static int rhine_init_one_platform(struct platform_device *pdev) 1118static int rhine_init_one_platform(struct platform_device *pdev)
1112{ 1119{
1113 const struct of_device_id *match; 1120 const struct of_device_id *match;
1114 u32 revision; 1121 const u32 *quirks;
1115 int irq; 1122 int irq;
1116 struct resource *res; 1123 struct resource *res;
1117 void __iomem *ioaddr; 1124 void __iomem *ioaddr;
@@ -1129,11 +1136,11 @@ static int rhine_init_one_platform(struct platform_device *pdev)
1129 if (!irq) 1136 if (!irq)
1130 return -EINVAL; 1137 return -EINVAL;
1131 1138
1132 revision = (u32)match->data; 1139 quirks = match->data;
1133 if (!revision) 1140 if (!quirks)
1134 return -EINVAL; 1141 return -EINVAL;
1135 1142
1136 return rhine_init_one_common(&pdev->dev, revision, 1143 return rhine_init_one_common(&pdev->dev, *quirks,
1137 (long)ioaddr, ioaddr, irq); 1144 (long)ioaddr, ioaddr, irq);
1138} 1145}
1139 1146
@@ -1523,7 +1530,7 @@ static void init_registers(struct net_device *dev)
1523 1530
1524 rhine_set_rx_mode(dev); 1531 rhine_set_rx_mode(dev);
1525 1532
1526 if (rp->revision >= VT6105M) 1533 if (rp->quirks & rqMgmt)
1527 rhine_init_cam_filter(dev); 1534 rhine_init_cam_filter(dev);
1528 1535
1529 napi_enable(&rp->napi); 1536 napi_enable(&rp->napi);
@@ -2160,7 +2167,7 @@ static void rhine_set_rx_mode(struct net_device *dev)
2160 /* Too many to match, or accept all multicasts. */ 2167 /* Too many to match, or accept all multicasts. */
2161 iowrite32(0xffffffff, ioaddr + MulticastFilter0); 2168 iowrite32(0xffffffff, ioaddr + MulticastFilter0);
2162 iowrite32(0xffffffff, ioaddr + MulticastFilter1); 2169 iowrite32(0xffffffff, ioaddr + MulticastFilter1);
2163 } else if (rp->revision >= VT6105M) { 2170 } else if (rp->quirks & rqMgmt) {
2164 int i = 0; 2171 int i = 0;
2165 u32 mCAMmask = 0; /* 32 mCAMs (6105M and better) */ 2172 u32 mCAMmask = 0; /* 32 mCAMs (6105M and better) */
2166 netdev_for_each_mc_addr(ha, dev) { 2173 netdev_for_each_mc_addr(ha, dev) {
@@ -2182,7 +2189,7 @@ static void rhine_set_rx_mode(struct net_device *dev)
2182 iowrite32(mc_filter[1], ioaddr + MulticastFilter1); 2189 iowrite32(mc_filter[1], ioaddr + MulticastFilter1);
2183 } 2190 }
2184 /* enable/disable VLAN receive filtering */ 2191 /* enable/disable VLAN receive filtering */
2185 if (rp->revision >= VT6105M) { 2192 if (rp->quirks & rqMgmt) {
2186 if (dev->flags & IFF_PROMISC) 2193 if (dev->flags & IFF_PROMISC)
2187 BYTE_REG_BITS_OFF(BCR1_VIDFR, ioaddr + PCIBusConfig1); 2194 BYTE_REG_BITS_OFF(BCR1_VIDFR, ioaddr + PCIBusConfig1);
2188 else 2195 else