~ubuntu-branches/ubuntu/trusty/linux-keystone/trusty-updates

« back to all changes in this revision

Viewing changes to drivers/net/ethernet/apm/xgene/xgene_enet_main.c

  • Committer: Package Import Robot
  • Author(s): Ike Panhc, Ike Panhc, Upstream Kernel Changes, Ubuntu: 3.13.0-41.70
  • Date: 2014-11-23 12:42:10 UTC
  • Revision ID: package-import@ubuntu.com-20141123124210-ieh9igmkftwra4a4
Tags: 3.13.0-19.30
[ Ike Panhc ]

* Release Tracking Bug
  - LP: #1396375
* Rebase to Ubuntu-3.13.0-41.70

[ Upstream Kernel Changes ]

* ARM: dts: keystone: update for qmss/qpend/srio support
  - LP: #1395422
* rapidio: keystone: add SRIO SerDes support for 5Gbps baudrate
  - LP: #1395422
* rapidio: keystone: enhance SerDes management and port initialization
  - LP: #1395422

[ Ubuntu: 3.13.0-41.70 ]

* Release Tracking Bug
  - LP: #1396112
* [Config] CONFIG_SCOM_DEBUGFS=y for powerpc/powerpc64-smp
  ppc64el/generic
  - LP: #1395855
* Revert "KVM: x86: Handle errors when RIP is set during far jumps"
  - LP: #1393477
* Revert "net/macb: add pinctrl consumer support"
  - LP: #1393477
* Revert "iwlwifi: mvm: treat EAPOLs like mgmt frames wrt rate"
  - LP: #1393477
* Revert "ipmi: simplify locking"
  - LP: #1383921
* ACPI / blacklist: add Win8 OSI quirks for some Dell laptop models
  - LP: #1339456
* ACPI / battery: Accelerate battery resume callback
  - LP: #838543
* tools: cpu-hotplug fix unexpected operator error
* netlink: reset network header before passing to taps
  - LP: #1393477
* rtnetlink: fix VF info size
  - LP: #1393477
* myri10ge: check for DMA mapping errors
  - LP: #1393477
* tcp: don't use timestamp from repaired skb-s to calculate RTT (v2)
  - LP: #1393477
* sit: Fix ipip6_tunnel_lookup device matching criteria
  - LP: #1393477
* tcp: fix tcp_release_cb() to dispatch via address family for
  mtu_reduced()
  - LP: #1393477
* tcp: fix ssthresh and undo for consecutive short FRTO episodes
  - LP: #1393477
* packet: handle too big packets for PACKET_V3
  - LP: #1393477
* openvswitch: fix panic with multiple vlan headers
  - LP: #1393477
* vxlan: fix incorrect initializer in union vxlan_addr
  - LP: #1393477
* l2tp: fix race while getting PMTU on PPP pseudo-wire
  - LP: #1393477
* bonding: fix div by zero while enslaving and transmitting
  - LP: #1393477
* bridge: Check if vlan filtering is enabled only once.
  - LP: #1393477
* bridge: Fix br_should_learn to check vlan_enabled
  - LP: #1393477
* net: allow macvlans to move to net namespace
  - LP: #1393477
* tg3: Work around HW/FW limitations with vlan encapsulated frames
  - LP: #1393477
* tg3: Allow for recieve of full-size 8021AD frames
  - LP: #1393477
* xfrm: Generate blackhole routes only from route lookup functions
  - LP: #1393477
* xfrm: Generate queueing routes only from route lookup functions
  - LP: #1393477
* macvtap: Fix race between device delete and open.
  - LP: #1393477
* gro: fix aggregation for skb using frag_list
  - LP: #1393477
* hyperv: Fix a bug in netvsc_start_xmit()
  - LP: #1393477
* ip6_gre: fix flowi6_proto value in xmit path
  - LP: #1393477
* team: avoid race condition in scheduling delayed work
  - LP: #1393477
* sctp: handle association restarts when the socket is closed.
  - LP: #1393477
* tcp: fixing TLP's FIN recovery
  - LP: #1393477
* sparc64: Do not disable interrupts in nmi_cpu_busy()
  - LP: #1393477
* sparc64: Fix pcr_ops initialization and usage bugs.
  - LP: #1393477
* sparc32: dma_alloc_coherent must honour gfp flags
  - LP: #1393477
* sparc64: sun4v TLB error power off events
  - LP: #1393477
* sparc64: Fix corrupted thread fault code.
  - LP: #1393477
* sparc64: find_node adjustment
  - LP: #1393477
* sparc64: Move request_irq() from ldc_bind() to ldc_alloc()
  - LP: #1393477
* sparc: Let memset return the address argument
  - LP: #1393477
* sparc64: Fix reversed start/end in flush_tlb_kernel_range()
  - LP: #1393477
* sparc64: Fix lockdep warnings on reboot on Ultra-5
  - LP: #1393477
* sparc64: Fix FPU register corruption with AES crypto offload.
  - LP: #1393477
* sparc64: Do not define thread fpregs save area as zero-length array.
  - LP: #1393477
* sparc64: Fix hibernation code refrence to PAGE_OFFSET.
  - LP: #1393477
* sparc64: correctly recognise M6 and M7 cpu type
  - LP: #1393477
* sparc64: support M6 and M7 for building CPU distribution map
  - LP: #1393477
* sparc64: cpu hardware caps support for sparc M6 and M7
  - LP: #1393477
* sparc64: T5 PMU
  - LP: #1393477
* sparc64: Switch to 4-level page tables.
  - LP: #1393477
* sparc64: Define VA hole at run time, rather than at compile time.
  - LP: #1393477
* sparc64: Adjust KTSB assembler to support larger physical addresses.
  - LP: #1393477
* sparc64: Fix physical memory management regressions with large
  max_phys_bits.
  - LP: #1393477
* sparc64: Use kernel page tables for vmemmap.
  - LP: #1393477
* sparc64: Increase MAX_PHYS_ADDRESS_BITS to 53.
  - LP: #1393477
* sparc64: Adjust vmalloc region size based upon available virtual
  address bits.
  - LP: #1393477
* sparc64: sparse irq
  - LP: #1393477
* sparc64: Kill unnecessary tables and increase MAX_BANKS.
  - LP: #1393477
* sparc64: Increase size of boot string to 1024 bytes
  - LP: #1393477
* sparc64: Fix register corruption in top-most kernel stack frame during
  boot.
  - LP: #1393477
* sparc64: Implement __get_user_pages_fast().
  - LP: #1393477
* ext4: check EA value offset when loading
  - LP: #1393477
* jbd2: free bh when descriptor block checksum fails
  - LP: #1393477
* ext4: don't check quota format when there are no quota files
  - LP: #1393477
* target: Fix queue full status NULL pointer for SCF_TRANSPORT_TASK_SENSE
  - LP: #1393477
* vfs: fix data corruption when blocksize < pagesize for mmaped data
  - LP: #1393477
* ext4: fix mmap data corruption when blocksize < pagesize
  - LP: #1393477
* ext4: grab missed write_count for EXT4_IOC_SWAP_BOOT
  - LP: #1393477
* qla_target: don't delete changed nacls
  - LP: #1393477
* target: Fix APTPL metadata handling for dynamic MappedLUNs
  - LP: #1393477
* iser-target: Disable TX completion interrupt coalescing
  - LP: #1393477
* ext4: don't orphan or truncate the boot loader inode
  - LP: #1393477
* ext4: add ext4_iget_normal() which is to be used for dir tree lookups
  - LP: #1393477
* ext4: fix reservation overflow in ext4_da_write_begin
  - LP: #1393477
* ext4: Replace open coded mdata csum feature to helper function
  - LP: #1393477
* ext4: move error report out of atomic context in
  ext4_init_block_bitmap()
  - LP: #1393477
* ARC: [nsimosci] Allow "headless" models to boot
  - LP: #1393477
* ARC: Update order of registers in KGDB to match GDB 7.5
  - LP: #1393477
* ext4: check s_chksum_driver when looking for bg csum presence
  - LP: #1393477
* drm/radeon: fix speaker allocation setup
  - LP: #1393477
* drm/radeon: use gart memory for DMA ring tests
  - LP: #1393477
* compiler: define OPTIMIZER_HIDE_VAR() macro
  - LP: #1393477
* random: add and use memzero_explicit() for clearing data
  - LP: #1393477
* ALSA: pcm: use the same dma mmap codepath both for arm and arm64
  - LP: #1393477
* ALSA: ALC283 codec - Avoid pop noise on headphones during
  suspend/resume
  - LP: #1393477
* ALSA: usb-audio: Add support for Steinberg UR22 USB interface
  - LP: #1393477
* ALSA: hda - hdmi: Fix missing ELD change event on plug/unplug
  - LP: #1393477
* arm64: compat: fix compat types affecting struct compat_elf_prpsinfo
  - LP: #1393477
* freezer: Do not freeze tasks killed by OOM killer
  - LP: #1393477
* OOM, PM: OOM killed task shouldn't escape PM suspend
  - LP: #1393477
* qxl: don't create too large primary surface
  - LP: #1393477
* MIPS: tlbex: Properly fix HUGE TLB Refill exception handler
  - LP: #1393477
* drm/cirrus: bind also to qemu-xen-traditional
  - LP: #1393477
* cpufreq: intel_pstate: Fix setting max_perf_pct in performance policy
  - LP: #1393477
* cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers
  - LP: #1393477
* cpufreq: intel_pstate: Reflect current no_turbo state correctly
  - LP: #1393477
* intel_pstate: Don't lose sysfs settings during cpu offline
  - LP: #1393477
* intel_pstate: Fix BYT frequency reporting
  - LP: #1393477
* intel_pstate: Correct BYT VID values.
  - LP: #1393477
* MIPS: ftrace: Fix a microMIPS build problem
  - LP: #1393477
* kvm: x86: don't kill guest on unknown exit reason
  - LP: #1393477
* kvm: fix excessive pages un-pinning in kvm_iommu_map error path.
  - LP: #1393477
* KVM: x86: use new CS.RPL as CPL during task switch
  - LP: #1393477
* KVM: x86: Handle errors when RIP is set during far jumps
  - LP: #1393477
* KVM: x86: Fix far-jump to non-canonical check
  - LP: #1393477
* staging:iio:ad5933: Fix NULL pointer deref when enabling buffer
  - LP: #1393477
* staging:iio:ad5933: Drop "raw" from channel names
  - LP: #1393477
* iio: st_sensors: Fix buffer copy
  - LP: #1393477
* iio: mxs-lradc: Propagate the real error code on platform_get_irq()
  failure
  - LP: #1393477
* iio: adc: mxs-lradc: Disable the clock on probe failure
  - LP: #1393477
* spi: pl022: Fix incorrect dma_unmap_sg
  - LP: #1393477
* mac80211: fix typo in starting baserate for rts_cts_rate_idx
  - LP: #1393477
* usb: dwc3: gadget: fix set_halt() bug with pending transfers
  - LP: #1393477
* usb: gadget: function: acm: make f_acm pass USB20CV Chapter9
  - LP: #1393477
* ext3: Don't check quota format when there are no quota files
  - LP: #1393477
* quota: Properly return errors from dquot_writeback_dquots()
  - LP: #1393477
* USB: serial: cp210x: add Silicon Labs 358x VID and PID
  - LP: #1393477
* usb: serial: ftdi_sio: add Awinda Station and Dongle products
  - LP: #1393477
* usb: option: add support for Telit LE910
  - LP: #1393477
* USB: option: add Haier CE81B CDMA modem
  - LP: #1393477
* x86, apic: Handle a bad TSC more gracefully
  - LP: #1393477
* i3200_edac: Report CE events properly
  - LP: #1393477
* i82860_edac: Report CE events properly
  - LP: #1393477
* cpc925_edac: Report UE events properly
  - LP: #1393477
* e7xxx_edac: Report CE events properly
  - LP: #1393477
* scsi: Fix error handling in SCSI_IOCTL_SEND_COMMAND
  - LP: #1393477
* usb: serial: ftdi_sio: add "bricked" FTDI device PID
  - LP: #1393477
* usb: musb: cppi41: restart hrtimer only if not yet done
  - LP: #1393477
* usb: gadget: udc: core: fix kernel oops with soft-connect
  - LP: #1393477
* nfsd4: fix crash on unknown operation number
  - LP: #1393477
* iwlwifi: configure the LTR
  - LP: #1393477
* mac80211: add vif to flush call
  - LP: #1393477
* iwlwifi: dvm: drop non VO frames when flushing
  - LP: #1393477
* usb: dwc3: gadget: Properly initialize LINK TRB
  - LP: #1393477
* Input: i8042 - quirks for Fujitsu Lifebook A544 and Lifebook AH544
  - LP: #1393477
* posix-timers: Fix stack info leak in timer_create()
  - LP: #1393477
* futex: Fix a race condition between REQUEUE_PI and task death
  - LP: #1393477
* PM / Sleep: fix recovery during resuming from hibernation
  - LP: #1393477
* ALSA: pcm: Zero-clear reserved fields of PCM status ioctl in compat
  mode
  - LP: #1393477
* ima: check xattr value length and type in the ima_inode_setxattr()
  - LP: #1393477
* evm: check xattr value length and type in evm_inode_setxattr()
  - LP: #1393477
* drm/radeon/dpm: disable ulv support on SI
  - LP: #1393477
* drm/radeon: dpm fixes for asrock systems
  - LP: #1393477
* drm/radeon: remove invalid pci id
  - LP: #1393477
* x86, pageattr: Prevent overflow in slow_virt_to_phys() for X86_PAE
  - LP: #1393477
* cgroup/kmemleak: add kmemleak_free() for cgroup deallocations.
  - LP: #1393477
* mm: free compound page with correct order
  - LP: #1393477
* mm, thp: fix collapsing of hugepages on madvise
  - LP: #1393477
* lib/bitmap.c: fix undefined shift in __bitmap_shift_{left|right}()
  - LP: #1393477
* ext4: fix overflow when updating superblock backups after resize
  - LP: #1393477
* ext4: fix oops when loading block bitmap failed
  - LP: #1393477
* ext4: enable journal checksum when metadata checksum feature enabled
  - LP: #1393477
* ext4: bail out from make_indexed_dir() on first error
  - LP: #1393477
* PCI: Rename sysfs 'enabled' file back to 'enable'
  - LP: #1393477
* wireless: rt2x00: add new rt2800usb device
  - LP: #1393477
* fs: allow open(dir, O_TMPFILE|..., 0) with mode 0
  - LP: #1393477
* tracing/syscalls: Ignore numbers outside NR_syscalls' range
  - LP: #1393477
* x86_64, entry: Fix out of bounds read on sysenter
  - LP: #1393477
* ACPI / EC: Add support to disallow QR_EC to be issued when SCI_EVT
  isn't set
  - LP: #1393477
* ACPI / EC: Fix regression due to conflicting firmware behavior between
  Samsung and Acer.
  - LP: #1393477
* net: sctp: fix skb_over_panic when receiving malformed ASCONF chunks
  - LP: #1393477
* net: sctp: fix panic on duplicate ASCONF chunks
  - LP: #1393477
* net: sctp: fix remote memory pressure from excessive queueing
  - LP: #1393477
* Linux 3.13.11.11
  - LP: #1393477
* MAINTAINERS: Update APM X-Gene section
  - LP: #1381084
* Documentation: dts: Update section header for APM X-Gene
  - LP: #1381084
* dtb: Add 10GbE node to APM X-Gene SoC device tree
  - LP: #1381084
* drivers: net: xgene: Preparing for adding 10GbE support
  - LP: #1381084
* drivers: net: xgene: Add 10GbE support
  - LP: #1381084
* drivers: net: xgene: Add 10GbE ethtool support
  - LP: #1381084
* dtb: Add SGMII based 1GbE node to APM X-Gene SoC device tree
  - LP: #1381216
* drivers: net: xgene: Preparing for adding SGMII based 1GbE
  - LP: #1381216
* drivers: net: xgene: Add SGMII based 1GbE support
  - LP: #1381216
* drivers: net: xgene: Add SGMII based 1GbE ethtool support
  - LP: #1381216
* drivers: net: xgene: Rewrite buggy loop in xgene_enet_ecc_init()
  - LP: #1381216
* dtb: xgene: fix: Backward compatibility with older firmware
  - LP: #1381084, #1381216
* drivers: net: xgene: Backward compatibility with older firmware
  - LP: #1381084, #1381216
* drivers: net: xgene: fix: Use separate resources
  - LP: #1381216
* HID: Add the transport-driver functions to the HIDP driver.
  - LP: #1393764
* ipc: fix compat msgrcv with negative msgtyp
  - LP: #1393355

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include "xgene_enet_main.h"
23
23
#include "xgene_enet_hw.h"
 
24
#include "xgene_enet_sgmac.h"
 
25
#include "xgene_enet_xgmac.h"
24
26
 
25
27
static void xgene_enet_init_bufpool(struct xgene_enet_desc_ring *buf_pool)
26
28
{
390
392
                }
391
393
        }
392
394
 
393
 
        return budget;
 
395
        return count;
394
396
}
395
397
 
396
398
static int xgene_enet_napi(struct napi_struct *napi, const int budget)
413
415
{
414
416
        struct xgene_enet_pdata *pdata = netdev_priv(ndev);
415
417
 
416
 
        xgene_gmac_reset(pdata);
 
418
        pdata->mac_ops->reset(pdata);
417
419
}
418
420
 
419
421
static int xgene_enet_register_irq(struct net_device *ndev)
445
447
static int xgene_enet_open(struct net_device *ndev)
446
448
{
447
449
        struct xgene_enet_pdata *pdata = netdev_priv(ndev);
 
450
        struct xgene_mac_ops *mac_ops = pdata->mac_ops;
448
451
        int ret;
449
452
 
450
 
        xgene_gmac_tx_enable(pdata);
451
 
        xgene_gmac_rx_enable(pdata);
 
453
        mac_ops->tx_enable(pdata);
 
454
        mac_ops->rx_enable(pdata);
452
455
 
453
456
        ret = xgene_enet_register_irq(ndev);
454
457
        if (ret)
455
458
                return ret;
456
459
        napi_enable(&pdata->rx_ring->napi);
457
460
 
458
 
        if (pdata->phy_dev)
 
461
        if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
459
462
                phy_start(pdata->phy_dev);
 
463
        else
 
464
                schedule_delayed_work(&pdata->link_work, PHY_POLL_LINK_OFF);
460
465
 
461
466
        netif_start_queue(ndev);
462
467
 
466
471
static int xgene_enet_close(struct net_device *ndev)
467
472
{
468
473
        struct xgene_enet_pdata *pdata = netdev_priv(ndev);
 
474
        struct xgene_mac_ops *mac_ops = pdata->mac_ops;
469
475
 
470
476
        netif_stop_queue(ndev);
471
477
 
472
 
        if (pdata->phy_dev)
 
478
        if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
473
479
                phy_stop(pdata->phy_dev);
 
480
        else
 
481
                cancel_delayed_work_sync(&pdata->link_work);
474
482
 
475
483
        napi_disable(&pdata->rx_ring->napi);
476
484
        xgene_enet_free_irq(ndev);
477
485
        xgene_enet_process_ring(pdata->rx_ring, -1);
478
486
 
479
 
        xgene_gmac_tx_disable(pdata);
480
 
        xgene_gmac_rx_disable(pdata);
 
487
        mac_ops->tx_disable(pdata);
 
488
        mac_ops->rx_disable(pdata);
481
489
 
482
490
        return 0;
483
491
}
604
612
 
605
613
        ring->cmd_base = pdata->ring_cmd_addr + (ring->num << 6);
606
614
        ring->cmd = ring->cmd_base + INC_DEC_CMD_ADDR;
607
 
        pdata->rm = RM3;
608
615
        ring = xgene_enet_setup_ring(ring);
609
616
        netdev_dbg(ndev, "ring info: num=%d  size=%d  id=%d  slots=%d\n",
610
617
                   ring->num, ring->size, ring->id, ring->slots);
623
630
        struct device *dev = ndev_to_dev(ndev);
624
631
        struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
625
632
        struct xgene_enet_desc_ring *buf_pool = NULL;
626
 
        u8 cpu_bufnum = 0, eth_bufnum = 0;
627
 
        u8 bp_bufnum = 0x20;
628
 
        u16 ring_id, ring_num = 0;
 
633
        u8 cpu_bufnum = 0, eth_bufnum = START_ETH_BUFNUM;
 
634
        u8 bp_bufnum = START_BP_BUFNUM;
 
635
        u16 ring_id, ring_num = START_RING_NUM;
629
636
        int ret;
630
637
 
631
638
        /* allocate rx descriptor ring */
715
722
        ret = eth_mac_addr(ndev, addr);
716
723
        if (ret)
717
724
                return ret;
718
 
        xgene_gmac_set_mac_addr(pdata);
 
725
        pdata->mac_ops->set_mac_addr(pdata);
719
726
 
720
727
        return ret;
721
728
}
794
801
 
795
802
        pdata->phy_mode = of_get_phy_mode(pdev->dev.of_node);
796
803
        if (pdata->phy_mode < 0) {
797
 
                dev_err(dev, "Incorrect phy-connection-type in DTS\n");
798
 
                return -EINVAL;
 
804
                dev_err(dev, "Unable to get phy-connection-type\n");
 
805
                return pdata->phy_mode;
 
806
        }
 
807
        if (pdata->phy_mode != PHY_INTERFACE_MODE_RGMII &&
 
808
            pdata->phy_mode != PHY_INTERFACE_MODE_SGMII &&
 
809
            pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) {
 
810
                dev_err(dev, "Incorrect phy-connection-type specified\n");
 
811
                return -ENODEV;
799
812
        }
800
813
 
801
814
        pdata->clk = devm_clk_get(&pdev->dev, NULL);
810
823
        pdata->eth_csr_addr = base_addr + BLOCK_ETH_CSR_OFFSET;
811
824
        pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET;
812
825
        pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET;
813
 
        pdata->mcx_mac_addr = base_addr + BLOCK_ETH_MAC_OFFSET;
814
 
        pdata->mcx_stats_addr = base_addr + BLOCK_ETH_STATS_OFFSET;
815
 
        pdata->mcx_mac_csr_addr = base_addr + BLOCK_ETH_MAC_CSR_OFFSET;
 
826
        if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII ||
 
827
            pdata->phy_mode == PHY_INTERFACE_MODE_SGMII) {
 
828
                pdata->mcx_mac_addr = base_addr + BLOCK_ETH_MAC_OFFSET;
 
829
                pdata->mcx_mac_csr_addr = base_addr + BLOCK_ETH_MAC_CSR_OFFSET;
 
830
        } else {
 
831
                pdata->mcx_mac_addr = base_addr + BLOCK_AXG_MAC_OFFSET;
 
832
                pdata->mcx_mac_csr_addr = base_addr + BLOCK_AXG_MAC_CSR_OFFSET;
 
833
        }
816
834
        pdata->rx_buff_cnt = NUM_PKT_BUF;
817
835
 
818
 
        return ret;
 
836
        return 0;
819
837
}
820
838
 
821
839
static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata)
825
843
        u16 dst_ring_num;
826
844
        int ret;
827
845
 
828
 
        xgene_gmac_tx_disable(pdata);
829
 
        xgene_gmac_rx_disable(pdata);
 
846
        ret = pdata->port_ops->reset(pdata);
 
847
        if (ret)
 
848
                return ret;
830
849
 
831
850
        ret = xgene_enet_create_desc_rings(ndev);
832
851
        if (ret) {
844
863
        }
845
864
 
846
865
        dst_ring_num = xgene_enet_dst_ring_num(pdata->rx_ring);
847
 
        xgene_enet_cle_bypass(pdata, dst_ring_num, buf_pool->id);
 
866
        pdata->port_ops->cle_bypass(pdata, dst_ring_num, buf_pool->id);
 
867
        pdata->mac_ops->init(pdata);
848
868
 
849
869
        return ret;
850
870
}
851
871
 
 
872
static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata)
 
873
{
 
874
        switch (pdata->phy_mode) {
 
875
        case PHY_INTERFACE_MODE_RGMII:
 
876
                pdata->mac_ops = &xgene_gmac_ops;
 
877
                pdata->port_ops = &xgene_gport_ops;
 
878
                pdata->rm = RM3;
 
879
                break;
 
880
        case PHY_INTERFACE_MODE_SGMII:
 
881
                pdata->mac_ops = &xgene_sgmac_ops;
 
882
                pdata->port_ops = &xgene_sgport_ops;
 
883
                pdata->rm = RM1;
 
884
                break;
 
885
        default:
 
886
                pdata->mac_ops = &xgene_xgmac_ops;
 
887
                pdata->port_ops = &xgene_xgport_ops;
 
888
                pdata->rm = RM0;
 
889
                break;
 
890
        }
 
891
}
 
892
 
852
893
static int xgene_enet_probe(struct platform_device *pdev)
853
894
{
854
895
        struct net_device *ndev;
855
896
        struct xgene_enet_pdata *pdata;
856
897
        struct device *dev = &pdev->dev;
857
898
        struct napi_struct *napi;
 
899
        struct xgene_mac_ops *mac_ops;
858
900
        int ret;
859
901
 
860
902
        ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata));
877
919
        if (ret)
878
920
                goto err;
879
921
 
880
 
        xgene_enet_reset(pdata);
881
 
        xgene_gmac_init(pdata, SPEED_1000);
 
922
        xgene_enet_setup_ops(pdata);
882
923
 
883
924
        ret = register_netdev(ndev);
884
925
        if (ret) {
898
939
 
899
940
        napi = &pdata->rx_ring->napi;
900
941
        netif_napi_add(ndev, napi, xgene_enet_napi, NAPI_POLL_WEIGHT);
901
 
        ret = xgene_enet_mdio_config(pdata);
 
942
        mac_ops = pdata->mac_ops;
 
943
        if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
 
944
                ret = xgene_enet_mdio_config(pdata);
 
945
        else
 
946
                INIT_DELAYED_WORK(&pdata->link_work, mac_ops->link_state);
902
947
 
903
948
        return ret;
904
949
err:
 
950
        unregister_netdev(ndev);
905
951
        free_netdev(ndev);
906
952
        return ret;
907
953
}
909
955
static int xgene_enet_remove(struct platform_device *pdev)
910
956
{
911
957
        struct xgene_enet_pdata *pdata;
 
958
        struct xgene_mac_ops *mac_ops;
912
959
        struct net_device *ndev;
913
960
 
914
961
        pdata = platform_get_drvdata(pdev);
 
962
        mac_ops = pdata->mac_ops;
915
963
        ndev = pdata->ndev;
916
964
 
917
 
        xgene_gmac_rx_disable(pdata);
918
 
        xgene_gmac_tx_disable(pdata);
 
965
        mac_ops->rx_disable(pdata);
 
966
        mac_ops->tx_disable(pdata);
919
967
 
920
968
        netif_napi_del(&pdata->rx_ring->napi);
921
969
        xgene_enet_mdio_remove(pdata);
922
970
        xgene_enet_delete_desc_rings(pdata);
923
971
        unregister_netdev(ndev);
924
 
        xgene_gport_shutdown(pdata);
 
972
        pdata->port_ops->shutdown(pdata);
925
973
        free_netdev(ndev);
926
974
 
927
975
        return 0;
947
995
 
948
996
MODULE_DESCRIPTION("APM X-Gene SoC Ethernet driver");
949
997
MODULE_VERSION(XGENE_DRV_VERSION);
 
998
MODULE_AUTHOR("Iyappan Subramanian <isubramanian@apm.com>");
950
999
MODULE_AUTHOR("Keyur Chudgar <kchudgar@apm.com>");
951
1000
MODULE_LICENSE("GPL");