Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: velocity: Add platform device support to VIA velocity driver

Add support for the VIA Velocity network driver to be bound to a
OF created platform device.

Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tony Prisk and committed by
David S. Miller
6dffbe53 e2c41f14

+305 -129
+20
Documentation/devicetree/bindings/net/via-velocity.txt
··· 1 + * VIA Velocity 10/100/1000 Network Controller 2 + 3 + Required properties: 4 + - compatible : Should be "via,velocity-vt6110" 5 + - reg : Address and length of the io space 6 + - interrupts : Should contain the controller interrupt line 7 + 8 + Optional properties: 9 + - no-eeprom : PCI network cards use an external EEPROM to store data. Embedded 10 + devices quite often set this data in uboot and do not provide an eeprom. 11 + Specify this option if you have no external eeprom. 12 + 13 + Examples: 14 + 15 + eth0@d8004000 { 16 + compatible = "via,velocity-vt6110"; 17 + reg = <0xd8004000 0x400>; 18 + interrupts = <10>; 19 + no-eeprom; 20 + };
+1 -2
drivers/net/ethernet/via/Kconfig
··· 5 5 config NET_VENDOR_VIA 6 6 bool "VIA devices" 7 7 default y 8 - depends on PCI 9 8 ---help--- 10 9 If you have a network (Ethernet) card belonging to this class, say Y 11 10 and read the Ethernet-HOWTO, available from ··· 44 45 45 46 config VIA_VELOCITY 46 47 tristate "VIA Velocity support" 47 - depends on PCI 48 + depends on (PCI || USE_OF) 48 49 select CRC32 49 50 select CRC_CCITT 50 51 select NET_CORE
+282 -126
drivers/net/ethernet/via/via-velocity.c
··· 65 65 #include <linux/if.h> 66 66 #include <linux/uaccess.h> 67 67 #include <linux/proc_fs.h> 68 + #include <linux/of_address.h> 69 + #include <linux/of_device.h> 70 + #include <linux/of_irq.h> 68 71 #include <linux/inetdevice.h> 72 + #include <linux/platform_device.h> 69 73 #include <linux/reboot.h> 70 74 #include <linux/ethtool.h> 71 75 #include <linux/mii.h> ··· 84 80 85 81 #include "via-velocity.h" 86 82 83 + enum velocity_bus_type { 84 + BUS_PCI, 85 + BUS_PLATFORM, 86 + }; 87 87 88 88 static int velocity_nics; 89 89 static int msglevel = MSG_LEVEL_INFO; 90 + 91 + static void velocity_set_power_state(struct velocity_info *vptr, char state) 92 + { 93 + void *addr = vptr->mac_regs; 94 + 95 + if (vptr->pdev) 96 + pci_set_power_state(vptr->pdev, state); 97 + else 98 + writeb(state, addr + 0x154); 99 + } 90 100 91 101 /** 92 102 * mac_get_cam_mask - Read a CAM mask ··· 380 362 * Describe the PCI device identifiers that we support in this 381 363 * device driver. Used for hotplug autoloading. 382 364 */ 383 - static DEFINE_PCI_DEVICE_TABLE(velocity_id_table) = { 365 + 366 + static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = { 384 367 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) }, 385 368 { } 386 369 }; 387 370 388 - MODULE_DEVICE_TABLE(pci, velocity_id_table); 371 + MODULE_DEVICE_TABLE(pci, velocity_pci_id_table); 372 + 373 + /** 374 + * Describe the OF device identifiers that we support in this 375 + * device driver. Used for devicetree nodes. 376 + */ 377 + static struct of_device_id velocity_of_ids[] = { 378 + { .compatible = "via,velocity-vt6110", .data = &chip_info_table[0] }, 379 + { /* Sentinel */ }, 380 + }; 381 + MODULE_DEVICE_TABLE(of, velocity_of_ids); 389 382 390 383 /** 391 384 * get_chip_name - identifier to name ··· 412 383 if (chip_info_table[i].chip_id == chip_id) 413 384 break; 414 385 return chip_info_table[i].name; 415 - } 416 - 417 - /** 418 - * velocity_remove1 - device unplug 419 - * @pdev: PCI device being removed 420 - * 421 - * Device unload callback. Called on an unplug or on module 422 - * unload for each active device that is present. Disconnects 423 - * the device from the network layer and frees all the resources 424 - */ 425 - static void velocity_remove1(struct pci_dev *pdev) 426 - { 427 - struct net_device *dev = pci_get_drvdata(pdev); 428 - struct velocity_info *vptr = netdev_priv(dev); 429 - 430 - unregister_netdev(dev); 431 - iounmap(vptr->mac_regs); 432 - pci_release_regions(pdev); 433 - pci_disable_device(pdev); 434 - pci_set_drvdata(pdev, NULL); 435 - free_netdev(dev); 436 - 437 - velocity_nics--; 438 386 } 439 387 440 388 /** ··· 1187 1181 u16 BMCR; 1188 1182 1189 1183 switch (PHYID_GET_PHY_ID(vptr->phy_id)) { 1184 + case PHYID_ICPLUS_IP101A: 1185 + MII_REG_BITS_ON((ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP), 1186 + MII_ADVERTISE, vptr->mac_regs); 1187 + if (vptr->mii_status & VELOCITY_DUPLEX_FULL) 1188 + MII_REG_BITS_ON(TCSR_ECHODIS, MII_SREVISION, 1189 + vptr->mac_regs); 1190 + else 1191 + MII_REG_BITS_OFF(TCSR_ECHODIS, MII_SREVISION, 1192 + vptr->mac_regs); 1193 + MII_REG_BITS_ON(PLED_LALBE, MII_TPISTATUS, vptr->mac_regs); 1194 + break; 1190 1195 case PHYID_CICADA_CS8201: 1191 1196 /* 1192 1197 * Reset to hardware default ··· 1329 1312 enum velocity_init_type type) 1330 1313 { 1331 1314 struct mac_regs __iomem *regs = vptr->mac_regs; 1315 + struct net_device *netdev = vptr->netdev; 1332 1316 int i, mii_status; 1333 1317 1334 1318 mac_wol_reset(regs); ··· 1338 1320 case VELOCITY_INIT_RESET: 1339 1321 case VELOCITY_INIT_WOL: 1340 1322 1341 - netif_stop_queue(vptr->netdev); 1323 + netif_stop_queue(netdev); 1342 1324 1343 1325 /* 1344 1326 * Reset RX to prevent RX pointer not on the 4X location ··· 1351 1333 if (velocity_set_media_mode(vptr, mii_status) != VELOCITY_LINK_CHANGE) { 1352 1334 velocity_print_link_status(vptr); 1353 1335 if (!(vptr->mii_status & VELOCITY_LINK_FAIL)) 1354 - netif_wake_queue(vptr->netdev); 1336 + netif_wake_queue(netdev); 1355 1337 } 1356 1338 1357 1339 enable_flow_control_ability(vptr); ··· 1371 1353 velocity_soft_reset(vptr); 1372 1354 mdelay(5); 1373 1355 1374 - mac_eeprom_reload(regs); 1375 - for (i = 0; i < 6; i++) 1376 - writeb(vptr->netdev->dev_addr[i], &(regs->PAR[i])); 1356 + if (!vptr->no_eeprom) { 1357 + mac_eeprom_reload(regs); 1358 + for (i = 0; i < 6; i++) 1359 + writeb(netdev->dev_addr[i], regs->PAR + i); 1360 + } 1377 1361 1378 1362 /* 1379 1363 * clear Pre_ACPI bit. ··· 1398 1378 /* 1399 1379 * Set packet filter: Receive directed and broadcast address 1400 1380 */ 1401 - velocity_set_multi(vptr->netdev); 1381 + velocity_set_multi(netdev); 1402 1382 1403 1383 /* 1404 1384 * Enable MII auto-polling ··· 1425 1405 writel((CR0_DPOLL | CR0_TXON | CR0_RXON | CR0_STRT), &regs->CR0Set); 1426 1406 1427 1407 mii_status = velocity_get_opt_media_mode(vptr); 1428 - netif_stop_queue(vptr->netdev); 1408 + netif_stop_queue(netdev); 1429 1409 1430 1410 mii_init(vptr, mii_status); 1431 1411 1432 1412 if (velocity_set_media_mode(vptr, mii_status) != VELOCITY_LINK_CHANGE) { 1433 1413 velocity_print_link_status(vptr); 1434 1414 if (!(vptr->mii_status & VELOCITY_LINK_FAIL)) 1435 - netif_wake_queue(vptr->netdev); 1415 + netif_wake_queue(netdev); 1436 1416 } 1437 1417 1438 1418 enable_flow_control_ability(vptr); ··· 2253 2233 goto out; 2254 2234 2255 2235 /* Ensure chip is running */ 2256 - pci_set_power_state(vptr->pdev, PCI_D0); 2236 + velocity_set_power_state(vptr, PCI_D0); 2257 2237 2258 2238 velocity_init_registers(vptr, VELOCITY_INIT_COLD); 2259 2239 2260 - ret = request_irq(vptr->pdev->irq, velocity_intr, IRQF_SHARED, 2240 + ret = request_irq(dev->irq, velocity_intr, IRQF_SHARED, 2261 2241 dev->name, dev); 2262 2242 if (ret < 0) { 2263 2243 /* Power down the chip */ 2264 - pci_set_power_state(vptr->pdev, PCI_D3hot); 2244 + velocity_set_power_state(vptr, PCI_D3hot); 2265 2245 velocity_free_rings(vptr); 2266 2246 goto out; 2267 2247 } ··· 2334 2314 2335 2315 tmp_vptr->netdev = dev; 2336 2316 tmp_vptr->pdev = vptr->pdev; 2317 + tmp_vptr->dev = vptr->dev; 2337 2318 tmp_vptr->options = vptr->options; 2338 2319 tmp_vptr->tx.numq = vptr->tx.numq; 2339 2320 ··· 2434 2413 saving then we need to bring the device back up to talk to it */ 2435 2414 2436 2415 if (!netif_running(dev)) 2437 - pci_set_power_state(vptr->pdev, PCI_D0); 2416 + velocity_set_power_state(vptr, PCI_D0); 2438 2417 2439 2418 switch (cmd) { 2440 2419 case SIOCGMIIPHY: /* Get address of MII PHY in use. */ ··· 2447 2426 ret = -EOPNOTSUPP; 2448 2427 } 2449 2428 if (!netif_running(dev)) 2450 - pci_set_power_state(vptr->pdev, PCI_D3hot); 2429 + velocity_set_power_state(vptr, PCI_D3hot); 2451 2430 2452 2431 2453 2432 return ret; ··· 2513 2492 if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) 2514 2493 velocity_get_ip(vptr); 2515 2494 2516 - free_irq(vptr->pdev->irq, dev); 2495 + free_irq(dev->irq, dev); 2517 2496 2518 2497 velocity_free_rings(vptr); 2519 2498 ··· 2652 2631 * Set up the initial velocity_info struct for the device that has been 2653 2632 * discovered. 2654 2633 */ 2655 - static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, 2656 - const struct velocity_info_tbl *info) 2634 + static void velocity_init_info(struct velocity_info *vptr, 2635 + const struct velocity_info_tbl *info) 2657 2636 { 2658 - memset(vptr, 0, sizeof(struct velocity_info)); 2659 - 2660 - vptr->dev = &pdev->dev; 2661 - vptr->pdev = pdev; 2662 2637 vptr->chip_id = info->chip_id; 2663 2638 vptr->tx.numq = info->txqueue; 2664 2639 vptr->multicast_limit = MCAM_SIZE; ··· 2669 2652 * Retrieve the PCI configuration space data that interests us from 2670 2653 * the kernel PCI layer 2671 2654 */ 2672 - static int velocity_get_pci_info(struct velocity_info *vptr, 2673 - struct pci_dev *pdev) 2655 + static int velocity_get_pci_info(struct velocity_info *vptr) 2674 2656 { 2675 - vptr->rev_id = pdev->revision; 2657 + struct pci_dev *pdev = vptr->pdev; 2676 2658 2677 2659 pci_set_master(pdev); 2678 2660 ··· 2694 2678 dev_err(&pdev->dev, "region #1 is too small.\n"); 2695 2679 return -EINVAL; 2696 2680 } 2697 - vptr->pdev = pdev; 2681 + 2682 + return 0; 2683 + } 2684 + 2685 + /** 2686 + * velocity_get_platform_info - retrieve platform info for device 2687 + * @vptr: velocity device 2688 + * @pdev: platform device it matches 2689 + * 2690 + * Retrieve the Platform configuration data that interests us 2691 + */ 2692 + static int velocity_get_platform_info(struct velocity_info *vptr) 2693 + { 2694 + struct resource res; 2695 + int ret; 2696 + 2697 + if (of_get_property(vptr->dev->of_node, "no-eeprom", NULL)) 2698 + vptr->no_eeprom = 1; 2699 + 2700 + ret = of_address_to_resource(vptr->dev->of_node, 0, &res); 2701 + if (ret) { 2702 + dev_err(vptr->dev, "unable to find memory address\n"); 2703 + return ret; 2704 + } 2705 + 2706 + vptr->memaddr = res.start; 2707 + 2708 + if (resource_size(&res) < VELOCITY_IO_SIZE) { 2709 + dev_err(vptr->dev, "memory region is too small.\n"); 2710 + return -EINVAL; 2711 + } 2698 2712 2699 2713 return 0; 2700 2714 } ··· 2753 2707 } 2754 2708 2755 2709 /** 2756 - * velocity_found1 - set up discovered velocity card 2710 + * velocity_probe - set up discovered velocity device 2757 2711 * @pdev: PCI device 2758 2712 * @ent: PCI device table entry that matched 2713 + * @bustype: bus that device is connected to 2759 2714 * 2760 2715 * Configure a discovered adapter from scratch. Return a negative 2761 2716 * errno error code on failure paths. 2762 2717 */ 2763 - static int velocity_found1(struct pci_dev *pdev, 2764 - const struct pci_device_id *ent) 2718 + static int velocity_probe(struct device *dev, int irq, 2719 + const struct velocity_info_tbl *info, 2720 + enum velocity_bus_type bustype) 2765 2721 { 2766 2722 static int first = 1; 2767 - struct net_device *dev; 2723 + struct net_device *netdev; 2768 2724 int i; 2769 2725 const char *drv_string; 2770 - const struct velocity_info_tbl *info = &chip_info_table[ent->driver_data]; 2771 2726 struct velocity_info *vptr; 2772 2727 struct mac_regs __iomem *regs; 2773 2728 int ret = -ENOMEM; ··· 2777 2730 * can support more than MAX_UNITS. 2778 2731 */ 2779 2732 if (velocity_nics >= MAX_UNITS) { 2780 - dev_notice(&pdev->dev, "already found %d NICs.\n", 2781 - velocity_nics); 2733 + dev_notice(dev, "already found %d NICs.\n", velocity_nics); 2782 2734 return -ENODEV; 2783 2735 } 2784 2736 2785 - dev = alloc_etherdev(sizeof(struct velocity_info)); 2786 - if (!dev) 2737 + netdev = alloc_etherdev(sizeof(struct velocity_info)); 2738 + if (!netdev) 2787 2739 goto out; 2788 2740 2789 2741 /* Chain it all together */ 2790 2742 2791 - SET_NETDEV_DEV(dev, &pdev->dev); 2792 - vptr = netdev_priv(dev); 2743 + SET_NETDEV_DEV(netdev, dev); 2744 + vptr = netdev_priv(netdev); 2793 2745 2794 2746 if (first) { 2795 2747 printk(KERN_INFO "%s Ver. %s\n", ··· 2798 2752 first = 0; 2799 2753 } 2800 2754 2801 - velocity_init_info(pdev, vptr, info); 2755 + netdev->irq = irq; 2756 + vptr->netdev = netdev; 2757 + vptr->dev = dev; 2802 2758 2803 - vptr->netdev = dev; 2759 + velocity_init_info(vptr, info); 2804 2760 2805 - ret = pci_enable_device(pdev); 2806 - if (ret < 0) 2807 - goto err_free_dev; 2761 + if (bustype == BUS_PCI) { 2762 + vptr->pdev = to_pci_dev(dev); 2808 2763 2809 - ret = velocity_get_pci_info(vptr, pdev); 2810 - if (ret < 0) { 2811 - /* error message already printed */ 2812 - goto err_disable; 2813 - } 2814 - 2815 - ret = pci_request_regions(pdev, VELOCITY_NAME); 2816 - if (ret < 0) { 2817 - dev_err(&pdev->dev, "No PCI resources.\n"); 2818 - goto err_disable; 2764 + ret = velocity_get_pci_info(vptr); 2765 + if (ret < 0) 2766 + goto err_free_dev; 2767 + } else { 2768 + vptr->pdev = NULL; 2769 + ret = velocity_get_platform_info(vptr); 2770 + if (ret < 0) 2771 + goto err_free_dev; 2819 2772 } 2820 2773 2821 2774 regs = ioremap(vptr->memaddr, VELOCITY_IO_SIZE); 2822 2775 if (regs == NULL) { 2823 2776 ret = -EIO; 2824 - goto err_release_res; 2777 + goto err_free_dev; 2825 2778 } 2826 2779 2827 2780 vptr->mac_regs = regs; 2781 + vptr->rev_id = readb(&regs->rev_id); 2828 2782 2829 2783 mac_wol_reset(regs); 2830 2784 2831 2785 for (i = 0; i < 6; i++) 2832 - dev->dev_addr[i] = readb(&regs->PAR[i]); 2786 + netdev->dev_addr[i] = readb(&regs->PAR[i]); 2833 2787 2834 2788 2835 - drv_string = dev_driver_string(&pdev->dev); 2789 + drv_string = dev_driver_string(dev); 2836 2790 2837 2791 velocity_get_options(&vptr->options, velocity_nics, drv_string); 2838 2792 ··· 2853 2807 2854 2808 vptr->phy_id = MII_GET_PHY_ID(vptr->mac_regs); 2855 2809 2856 - dev->netdev_ops = &velocity_netdev_ops; 2857 - dev->ethtool_ops = &velocity_ethtool_ops; 2858 - netif_napi_add(dev, &vptr->napi, velocity_poll, VELOCITY_NAPI_WEIGHT); 2810 + netdev->netdev_ops = &velocity_netdev_ops; 2811 + netdev->ethtool_ops = &velocity_ethtool_ops; 2812 + netif_napi_add(netdev, &vptr->napi, velocity_poll, 2813 + VELOCITY_NAPI_WEIGHT); 2859 2814 2860 - dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | 2815 + netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | 2861 2816 NETIF_F_HW_VLAN_CTAG_TX; 2862 - dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_FILTER | 2863 - NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_IP_CSUM; 2817 + netdev->features |= NETIF_F_HW_VLAN_CTAG_TX | 2818 + NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_RX | 2819 + NETIF_F_IP_CSUM; 2864 2820 2865 - ret = register_netdev(dev); 2821 + ret = register_netdev(netdev); 2866 2822 if (ret < 0) 2867 2823 goto err_iounmap; 2868 2824 2869 - if (!velocity_get_link(dev)) { 2870 - netif_carrier_off(dev); 2825 + if (!velocity_get_link(netdev)) { 2826 + netif_carrier_off(netdev); 2871 2827 vptr->mii_status |= VELOCITY_LINK_FAIL; 2872 2828 } 2873 2829 2874 2830 velocity_print_info(vptr); 2875 - pci_set_drvdata(pdev, dev); 2831 + dev_set_drvdata(vptr->dev, netdev); 2876 2832 2877 2833 /* and leave the chip powered down */ 2878 2834 2879 - pci_set_power_state(pdev, PCI_D3hot); 2835 + velocity_set_power_state(vptr, PCI_D3hot); 2880 2836 velocity_nics++; 2881 2837 out: 2882 2838 return ret; 2883 2839 2884 2840 err_iounmap: 2885 2841 iounmap(regs); 2886 - err_release_res: 2887 - pci_release_regions(pdev); 2888 - err_disable: 2889 - pci_disable_device(pdev); 2890 2842 err_free_dev: 2891 - free_netdev(dev); 2843 + free_netdev(netdev); 2892 2844 goto out; 2893 2845 } 2894 2846 2895 - #ifdef CONFIG_PM 2847 + /** 2848 + * velocity_remove - device unplug 2849 + * @dev: device being removed 2850 + * 2851 + * Device unload callback. Called on an unplug or on module 2852 + * unload for each active device that is present. Disconnects 2853 + * the device from the network layer and frees all the resources 2854 + */ 2855 + static int velocity_remove(struct device *dev) 2856 + { 2857 + struct net_device *netdev = dev_get_drvdata(dev); 2858 + struct velocity_info *vptr = netdev_priv(netdev); 2859 + 2860 + unregister_netdev(netdev); 2861 + iounmap(vptr->mac_regs); 2862 + free_netdev(netdev); 2863 + velocity_nics--; 2864 + 2865 + return 0; 2866 + } 2867 + 2868 + static int velocity_pci_probe(struct pci_dev *pdev, 2869 + const struct pci_device_id *ent) 2870 + { 2871 + const struct velocity_info_tbl *info = 2872 + &chip_info_table[ent->driver_data]; 2873 + int ret; 2874 + 2875 + ret = pci_enable_device(pdev); 2876 + if (ret < 0) 2877 + return ret; 2878 + 2879 + ret = pci_request_regions(pdev, VELOCITY_NAME); 2880 + if (ret < 0) { 2881 + dev_err(&pdev->dev, "No PCI resources.\n"); 2882 + goto fail1; 2883 + } 2884 + 2885 + ret = velocity_probe(&pdev->dev, pdev->irq, info, BUS_PCI); 2886 + if (ret == 0) 2887 + return 0; 2888 + 2889 + pci_release_regions(pdev); 2890 + fail1: 2891 + pci_disable_device(pdev); 2892 + return ret; 2893 + } 2894 + 2895 + static void velocity_pci_remove(struct pci_dev *pdev) 2896 + { 2897 + velocity_remove(&pdev->dev); 2898 + 2899 + pci_release_regions(pdev); 2900 + pci_disable_device(pdev); 2901 + } 2902 + 2903 + static int velocity_platform_probe(struct platform_device *pdev) 2904 + { 2905 + const struct of_device_id *of_id; 2906 + const struct velocity_info_tbl *info; 2907 + int irq; 2908 + 2909 + of_id = of_match_device(velocity_of_ids, &pdev->dev); 2910 + if (!of_id) 2911 + return -EINVAL; 2912 + info = of_id->data; 2913 + 2914 + irq = irq_of_parse_and_map(pdev->dev.of_node, 0); 2915 + if (!irq) 2916 + return -EINVAL; 2917 + 2918 + return velocity_probe(&pdev->dev, irq, info, BUS_PLATFORM); 2919 + } 2920 + 2921 + static int velocity_platform_remove(struct platform_device *pdev) 2922 + { 2923 + velocity_remove(&pdev->dev); 2924 + 2925 + return 0; 2926 + } 2927 + 2928 + #ifdef CONFIG_PM_SLEEP 2896 2929 /** 2897 2930 * wol_calc_crc - WOL CRC 2898 2931 * @pattern: data pattern ··· 3128 3003 3129 3004 } 3130 3005 3131 - static int velocity_suspend(struct pci_dev *pdev, pm_message_t state) 3006 + static int velocity_suspend(struct device *dev) 3132 3007 { 3133 - struct net_device *dev = pci_get_drvdata(pdev); 3134 - struct velocity_info *vptr = netdev_priv(dev); 3008 + struct net_device *netdev = dev_get_drvdata(dev); 3009 + struct velocity_info *vptr = netdev_priv(netdev); 3135 3010 unsigned long flags; 3136 3011 3137 3012 if (!netif_running(vptr->netdev)) ··· 3140 3015 netif_device_detach(vptr->netdev); 3141 3016 3142 3017 spin_lock_irqsave(&vptr->lock, flags); 3143 - pci_save_state(pdev); 3018 + if (vptr->pdev) 3019 + pci_save_state(vptr->pdev); 3144 3020 3145 3021 if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) { 3146 3022 velocity_get_ip(vptr); 3147 3023 velocity_save_context(vptr, &vptr->context); 3148 3024 velocity_shutdown(vptr); 3149 3025 velocity_set_wol(vptr); 3150 - pci_enable_wake(pdev, PCI_D3hot, 1); 3151 - pci_set_power_state(pdev, PCI_D3hot); 3026 + if (vptr->pdev) 3027 + pci_enable_wake(vptr->pdev, PCI_D3hot, 1); 3028 + velocity_set_power_state(vptr, PCI_D3hot); 3152 3029 } else { 3153 3030 velocity_save_context(vptr, &vptr->context); 3154 3031 velocity_shutdown(vptr); 3155 - pci_disable_device(pdev); 3156 - pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3032 + if (vptr->pdev) 3033 + pci_disable_device(vptr->pdev); 3034 + velocity_set_power_state(vptr, PCI_D3hot); 3157 3035 } 3158 3036 3159 3037 spin_unlock_irqrestore(&vptr->lock, flags); ··· 3198 3070 writeb(*((u8 *) (context->mac_reg + i)), ptr + i); 3199 3071 } 3200 3072 3201 - static int velocity_resume(struct pci_dev *pdev) 3073 + static int velocity_resume(struct device *dev) 3202 3074 { 3203 - struct net_device *dev = pci_get_drvdata(pdev); 3204 - struct velocity_info *vptr = netdev_priv(dev); 3075 + struct net_device *netdev = dev_get_drvdata(dev); 3076 + struct velocity_info *vptr = netdev_priv(netdev); 3205 3077 unsigned long flags; 3206 3078 int i; 3207 3079 3208 3080 if (!netif_running(vptr->netdev)) 3209 3081 return 0; 3210 3082 3211 - pci_set_power_state(pdev, PCI_D0); 3212 - pci_enable_wake(pdev, 0, 0); 3213 - pci_restore_state(pdev); 3083 + velocity_set_power_state(vptr, PCI_D0); 3084 + 3085 + if (vptr->pdev) { 3086 + pci_enable_wake(vptr->pdev, 0, 0); 3087 + pci_restore_state(vptr->pdev); 3088 + } 3214 3089 3215 3090 mac_wol_reset(vptr->mac_regs); 3216 3091 ··· 3235 3104 3236 3105 return 0; 3237 3106 } 3238 - #endif 3107 + #endif /* CONFIG_PM_SLEEP */ 3108 + 3109 + static SIMPLE_DEV_PM_OPS(velocity_pm_ops, velocity_suspend, velocity_resume); 3239 3110 3240 3111 /* 3241 3112 * Definition for our device driver. The PCI layer interface 3242 3113 * uses this to handle all our card discover and plugging 3243 3114 */ 3244 - static struct pci_driver velocity_driver = { 3115 + static struct pci_driver velocity_pci_driver = { 3245 3116 .name = VELOCITY_NAME, 3246 - .id_table = velocity_id_table, 3247 - .probe = velocity_found1, 3248 - .remove = velocity_remove1, 3249 - #ifdef CONFIG_PM 3250 - .suspend = velocity_suspend, 3251 - .resume = velocity_resume, 3252 - #endif 3117 + .id_table = velocity_pci_id_table, 3118 + .probe = velocity_pci_probe, 3119 + .remove = velocity_pci_remove, 3120 + .driver = { 3121 + .pm = &velocity_pm_ops, 3122 + }, 3253 3123 }; 3254 3124 3125 + static struct platform_driver velocity_platform_driver = { 3126 + .probe = velocity_platform_probe, 3127 + .remove = velocity_platform_remove, 3128 + .driver = { 3129 + .name = "via-velocity", 3130 + .owner = THIS_MODULE, 3131 + .of_match_table = velocity_of_ids, 3132 + .pm = &velocity_pm_ops, 3133 + }, 3134 + }; 3255 3135 3256 3136 /** 3257 3137 * velocity_ethtool_up - pre hook for ethtool ··· 3275 3133 { 3276 3134 struct velocity_info *vptr = netdev_priv(dev); 3277 3135 if (!netif_running(dev)) 3278 - pci_set_power_state(vptr->pdev, PCI_D0); 3136 + velocity_set_power_state(vptr, PCI_D0); 3279 3137 return 0; 3280 3138 } 3281 3139 ··· 3290 3148 { 3291 3149 struct velocity_info *vptr = netdev_priv(dev); 3292 3150 if (!netif_running(dev)) 3293 - pci_set_power_state(vptr->pdev, PCI_D3hot); 3151 + velocity_set_power_state(vptr, PCI_D3hot); 3294 3152 } 3295 3153 3296 3154 static int velocity_get_settings(struct net_device *dev, ··· 3410 3268 static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 3411 3269 { 3412 3270 struct velocity_info *vptr = netdev_priv(dev); 3271 + 3413 3272 strlcpy(info->driver, VELOCITY_NAME, sizeof(info->driver)); 3414 3273 strlcpy(info->version, VELOCITY_VERSION, sizeof(info->version)); 3415 - strlcpy(info->bus_info, pci_name(vptr->pdev), sizeof(info->bus_info)); 3274 + if (vptr->pdev) 3275 + strlcpy(info->bus_info, pci_name(vptr->pdev), 3276 + sizeof(info->bus_info)); 3277 + else 3278 + strlcpy(info->bus_info, "platform", sizeof(info->bus_info)); 3416 3279 } 3417 3280 3418 3281 static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) ··· 3707 3560 */ 3708 3561 static int __init velocity_init_module(void) 3709 3562 { 3710 - int ret; 3563 + int ret_pci, ret_platform; 3711 3564 3712 3565 velocity_register_notifier(); 3713 - ret = pci_register_driver(&velocity_driver); 3714 - if (ret < 0) 3566 + 3567 + ret_pci = pci_register_driver(&velocity_pci_driver); 3568 + ret_platform = platform_driver_register(&velocity_platform_driver); 3569 + 3570 + /* if both_registers failed, remove the notifier */ 3571 + if ((ret_pci < 0) && (ret_platform < 0)) { 3715 3572 velocity_unregister_notifier(); 3716 - return ret; 3573 + return ret_pci; 3574 + } 3575 + 3576 + return 0; 3717 3577 } 3718 3578 3719 3579 /** ··· 3734 3580 static void __exit velocity_cleanup_module(void) 3735 3581 { 3736 3582 velocity_unregister_notifier(); 3737 - pci_unregister_driver(&velocity_driver); 3583 + 3584 + pci_unregister_driver(&velocity_pci_driver); 3585 + platform_driver_unregister(&velocity_platform_driver); 3738 3586 } 3739 3587 3740 3588 module_init(velocity_init_module);
+2 -1
drivers/net/ethernet/via/via-velocity.h
··· 1265 1265 #define PHYID_VT3216_64BIT 0x000FC600UL 1266 1266 #define PHYID_MARVELL_1000 0x01410C50UL 1267 1267 #define PHYID_MARVELL_1000S 0x01410C40UL 1268 - 1268 + #define PHYID_ICPLUS_IP101A 0x02430C54UL 1269 1269 #define PHYID_REV_ID_MASK 0x0000000FUL 1270 1270 1271 1271 #define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK) ··· 1437 1437 struct device *dev; 1438 1438 struct pci_dev *pdev; 1439 1439 struct net_device *netdev; 1440 + int no_eeprom; 1440 1441 1441 1442 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 1442 1443 u8 ip_addr[4];