aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorMark Einon <mark.einon@gmail.com>2011-10-23 05:22:48 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-10-23 05:35:12 -0400
commit36f2771a70c44b3fbc1be34d5a82e8472437c7ca (patch)
tree978d3c516ae2a2836a01142d9464188fb40b5b72 /drivers/staging
parent44012dfe4e6113c5c51393e2cd6cd49d8108da96 (diff)
staging: et131x: Remove forward declaration of et131x_adapter_setup
Also associated function movements within et131x.c file Signed-off-by: Mark Einon <mark.einon@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/et131x/et131x.c445
1 files changed, 222 insertions, 223 deletions
diff --git a/drivers/staging/et131x/et131x.c b/drivers/staging/et131x/et131x.c
index 8048d676614c..29476350fca8 100644
--- a/drivers/staging/et131x/et131x.c
+++ b/drivers/staging/et131x/et131x.c
@@ -576,7 +576,6 @@ struct et131x_adapter {
576 struct net_device_stats net_stats; 576 struct net_device_stats net_stats;
577}; 577};
578 578
579void et131x_adapter_setup(struct et131x_adapter *adapter);
580void et131x_soft_reset(struct et131x_adapter *adapter); 579void et131x_soft_reset(struct et131x_adapter *adapter);
581void et131x_isr_handler(struct work_struct *work); 580void et131x_isr_handler(struct work_struct *work);
582void et1310_setup_device_for_multicast(struct et131x_adapter *adapter); 581void et1310_setup_device_for_multicast(struct et131x_adapter *adapter);
@@ -1731,6 +1730,53 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)
1731 } 1730 }
1732} 1731}
1733 1732
1733/**
1734 * et131x_configure_global_regs - configure JAGCore global regs
1735 * @adapter: pointer to our adapter structure
1736 *
1737 * Used to configure the global registers on the JAGCore
1738 */
1739void et131x_configure_global_regs(struct et131x_adapter *adapter)
1740{
1741 struct global_regs __iomem *regs = &adapter->regs->global;
1742
1743 writel(0, &regs->rxq_start_addr);
1744 writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
1745
1746 if (adapter->registry_jumbo_packet < 2048) {
1747 /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word
1748 * block of RAM that the driver can split between Tx
1749 * and Rx as it desires. Our default is to split it
1750 * 50/50:
1751 */
1752 writel(PARM_RX_MEM_END_DEF, &regs->rxq_end_addr);
1753 writel(PARM_RX_MEM_END_DEF + 1, &regs->txq_start_addr);
1754 } else if (adapter->registry_jumbo_packet < 8192) {
1755 /* For jumbo packets > 2k but < 8k, split 50-50. */
1756 writel(INTERNAL_MEM_RX_OFFSET, &regs->rxq_end_addr);
1757 writel(INTERNAL_MEM_RX_OFFSET + 1, &regs->txq_start_addr);
1758 } else {
1759 /* 9216 is the only packet size greater than 8k that
1760 * is available. The Tx buffer has to be big enough
1761 * for one whole packet on the Tx side. We'll make
1762 * the Tx 9408, and give the rest to Rx
1763 */
1764 writel(0x01b3, &regs->rxq_end_addr);
1765 writel(0x01b4, &regs->txq_start_addr);
1766 }
1767
1768 /* Initialize the loopback register. Disable all loopbacks. */
1769 writel(0, &regs->loopback);
1770
1771 /* MSI Register */
1772 writel(0, &regs->msi_config);
1773
1774 /* By default, disable the watchdog timer. It will be enabled when
1775 * a packet is queued.
1776 */
1777 writel(0, &regs->watchdog_timer);
1778}
1779
1734/* PM functions */ 1780/* PM functions */
1735 1781
1736/** 1782/**
@@ -1749,6 +1795,181 @@ int et1310_in_phy_coma(struct et131x_adapter *adapter)
1749} 1795}
1750 1796
1751/** 1797/**
1798 * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
1799 * @adapter: pointer to our adapter structure
1800 */
1801void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
1802{
1803 struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma;
1804 struct rx_ring *rx_local = &adapter->rx_ring;
1805 struct fbr_desc *fbr_entry;
1806 u32 entry;
1807 u32 psr_num_des;
1808 unsigned long flags;
1809
1810 /* Halt RXDMA to perform the reconfigure. */
1811 et131x_rx_dma_disable(adapter);
1812
1813 /* Load the completion writeback physical address
1814 *
1815 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
1816 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
1817 * are ever returned, make sure the high part is retrieved here
1818 * before storing the adjusted address.
1819 */
1820 writel((u32) ((u64)rx_local->rx_status_bus >> 32),
1821 &rx_dma->dma_wb_base_hi);
1822 writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo);
1823
1824 memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block));
1825
1826 /* Set the address and parameters of the packet status ring into the
1827 * 1310's registers
1828 */
1829 writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32),
1830 &rx_dma->psr_base_hi);
1831 writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo);
1832 writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des);
1833 writel(0, &rx_dma->psr_full_offset);
1834
1835 psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
1836 writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
1837 &rx_dma->psr_min_des);
1838
1839 spin_lock_irqsave(&adapter->rcv_lock, flags);
1840
1841 /* These local variables track the PSR in the adapter structure */
1842 rx_local->local_psr_full = 0;
1843
1844 /* Now's the best time to initialize FBR1 contents */
1845 fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr;
1846 for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) {
1847 fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry];
1848 fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry];
1849 fbr_entry->word2 = entry;
1850 fbr_entry++;
1851 }
1852
1853 /* Set the address and parameters of Free buffer ring 1 (and 0 if
1854 * required) into the 1310's registers
1855 */
1856 writel((u32) (rx_local->fbr[0]->real_physaddr >> 32),
1857 &rx_dma->fbr1_base_hi);
1858 writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo);
1859 writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des);
1860 writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset);
1861
1862 /* This variable tracks the free buffer ring 1 full position, so it
1863 * has to match the above.
1864 */
1865 rx_local->fbr[0]->local_full = ET_DMA10_WRAP;
1866 writel(
1867 ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
1868 &rx_dma->fbr1_min_des);
1869
1870#ifdef USE_FBR0
1871 /* Now's the best time to initialize FBR0 contents */
1872 fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr;
1873 for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) {
1874 fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry];
1875 fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry];
1876 fbr_entry->word2 = entry;
1877 fbr_entry++;
1878 }
1879
1880 writel((u32) (rx_local->fbr[1]->real_physaddr >> 32),
1881 &rx_dma->fbr0_base_hi);
1882 writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo);
1883 writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des);
1884 writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset);
1885
1886 /* This variable tracks the free buffer ring 0 full position, so it
1887 * has to match the above.
1888 */
1889 rx_local->fbr[1]->local_full = ET_DMA10_WRAP;
1890 writel(
1891 ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
1892 &rx_dma->fbr0_min_des);
1893#endif
1894
1895 /* Program the number of packets we will receive before generating an
1896 * interrupt.
1897 * For version B silicon, this value gets updated once autoneg is
1898 *complete.
1899 */
1900 writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done);
1901
1902 /* The "time_done" is not working correctly to coalesce interrupts
1903 * after a given time period, but rather is giving us an interrupt
1904 * regardless of whether we have received packets.
1905 * This value gets updated once autoneg is complete.
1906 */
1907 writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time);
1908
1909 spin_unlock_irqrestore(&adapter->rcv_lock, flags);
1910}
1911
1912/**
1913 * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
1914 * @adapter: pointer to our private adapter structure
1915 *
1916 * Configure the transmit engine with the ring buffers we have created
1917 * and prepare it for use.
1918 */
1919void et131x_config_tx_dma_regs(struct et131x_adapter *adapter)
1920{
1921 struct txdma_regs __iomem *txdma = &adapter->regs->txdma;
1922
1923 /* Load the hardware with the start of the transmit descriptor ring. */
1924 writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32),
1925 &txdma->pr_base_hi);
1926 writel((u32) adapter->tx_ring.tx_desc_ring_pa,
1927 &txdma->pr_base_lo);
1928
1929 /* Initialise the transmit DMA engine */
1930 writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des);
1931
1932 /* Load the completion writeback physical address */
1933 writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32),
1934 &txdma->dma_wb_base_hi);
1935 writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo);
1936
1937 *adapter->tx_ring.tx_status = 0;
1938
1939 writel(0, &txdma->service_request);
1940 adapter->tx_ring.send_idx = 0;
1941}
1942
1943/**
1944 * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
1945 * @adapter: pointer to our private adapter structure
1946 *
1947 * Returns 0 on success, errno on failure (as defined in errno.h)
1948 */
1949void et131x_adapter_setup(struct et131x_adapter *adapter)
1950{
1951 /* Configure the JAGCore */
1952 et131x_configure_global_regs(adapter);
1953
1954 et1310_config_mac_regs1(adapter);
1955
1956 /* Configure the MMC registers */
1957 /* All we need to do is initialize the Memory Control Register */
1958 writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl);
1959
1960 et1310_config_rxmac_regs(adapter);
1961 et1310_config_txmac_regs(adapter);
1962
1963 et131x_config_rx_dma_regs(adapter);
1964 et131x_config_tx_dma_regs(adapter);
1965
1966 et1310_config_macstat_regs(adapter);
1967
1968 et1310_phy_power_down(adapter, 0);
1969 et131x_xcvr_init(adapter);
1970}
1971
1972/**
1752 * et1310_enable_phy_coma - called when network cable is unplugged 1973 * et1310_enable_phy_coma - called when network cable is unplugged
1753 * @adapter: pointer to our adapter structure 1974 * @adapter: pointer to our adapter structure
1754 * 1975 *
@@ -2390,121 +2611,6 @@ int et131x_init_recv(struct et131x_adapter *adapter)
2390} 2611}
2391 2612
2392/** 2613/**
2393 * et131x_config_rx_dma_regs - Start of Rx_DMA init sequence
2394 * @adapter: pointer to our adapter structure
2395 */
2396void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
2397{
2398 struct rxdma_regs __iomem *rx_dma = &adapter->regs->rxdma;
2399 struct rx_ring *rx_local = &adapter->rx_ring;
2400 struct fbr_desc *fbr_entry;
2401 u32 entry;
2402 u32 psr_num_des;
2403 unsigned long flags;
2404
2405 /* Halt RXDMA to perform the reconfigure. */
2406 et131x_rx_dma_disable(adapter);
2407
2408 /* Load the completion writeback physical address
2409 *
2410 * NOTE : dma_alloc_coherent(), used above to alloc DMA regions,
2411 * ALWAYS returns SAC (32-bit) addresses. If DAC (64-bit) addresses
2412 * are ever returned, make sure the high part is retrieved here
2413 * before storing the adjusted address.
2414 */
2415 writel((u32) ((u64)rx_local->rx_status_bus >> 32),
2416 &rx_dma->dma_wb_base_hi);
2417 writel((u32) rx_local->rx_status_bus, &rx_dma->dma_wb_base_lo);
2418
2419 memset(rx_local->rx_status_block, 0, sizeof(struct rx_status_block));
2420
2421 /* Set the address and parameters of the packet status ring into the
2422 * 1310's registers
2423 */
2424 writel((u32) ((u64)rx_local->ps_ring_physaddr >> 32),
2425 &rx_dma->psr_base_hi);
2426 writel((u32) rx_local->ps_ring_physaddr, &rx_dma->psr_base_lo);
2427 writel(rx_local->psr_num_entries - 1, &rx_dma->psr_num_des);
2428 writel(0, &rx_dma->psr_full_offset);
2429
2430 psr_num_des = readl(&rx_dma->psr_num_des) & 0xFFF;
2431 writel((psr_num_des * LO_MARK_PERCENT_FOR_PSR) / 100,
2432 &rx_dma->psr_min_des);
2433
2434 spin_lock_irqsave(&adapter->rcv_lock, flags);
2435
2436 /* These local variables track the PSR in the adapter structure */
2437 rx_local->local_psr_full = 0;
2438
2439 /* Now's the best time to initialize FBR1 contents */
2440 fbr_entry = (struct fbr_desc *) rx_local->fbr[0]->ring_virtaddr;
2441 for (entry = 0; entry < rx_local->fbr[0]->num_entries; entry++) {
2442 fbr_entry->addr_hi = rx_local->fbr[0]->bus_high[entry];
2443 fbr_entry->addr_lo = rx_local->fbr[0]->bus_low[entry];
2444 fbr_entry->word2 = entry;
2445 fbr_entry++;
2446 }
2447
2448 /* Set the address and parameters of Free buffer ring 1 (and 0 if
2449 * required) into the 1310's registers
2450 */
2451 writel((u32) (rx_local->fbr[0]->real_physaddr >> 32),
2452 &rx_dma->fbr1_base_hi);
2453 writel((u32) rx_local->fbr[0]->real_physaddr, &rx_dma->fbr1_base_lo);
2454 writel(rx_local->fbr[0]->num_entries - 1, &rx_dma->fbr1_num_des);
2455 writel(ET_DMA10_WRAP, &rx_dma->fbr1_full_offset);
2456
2457 /* This variable tracks the free buffer ring 1 full position, so it
2458 * has to match the above.
2459 */
2460 rx_local->fbr[0]->local_full = ET_DMA10_WRAP;
2461 writel(
2462 ((rx_local->fbr[0]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
2463 &rx_dma->fbr1_min_des);
2464
2465#ifdef USE_FBR0
2466 /* Now's the best time to initialize FBR0 contents */
2467 fbr_entry = (struct fbr_desc *) rx_local->fbr[1]->ring_virtaddr;
2468 for (entry = 0; entry < rx_local->fbr[1]->num_entries; entry++) {
2469 fbr_entry->addr_hi = rx_local->fbr[1]->bus_high[entry];
2470 fbr_entry->addr_lo = rx_local->fbr[1]->bus_low[entry];
2471 fbr_entry->word2 = entry;
2472 fbr_entry++;
2473 }
2474
2475 writel((u32) (rx_local->fbr[1]->real_physaddr >> 32),
2476 &rx_dma->fbr0_base_hi);
2477 writel((u32) rx_local->fbr[1]->real_physaddr, &rx_dma->fbr0_base_lo);
2478 writel(rx_local->fbr[1]->num_entries - 1, &rx_dma->fbr0_num_des);
2479 writel(ET_DMA10_WRAP, &rx_dma->fbr0_full_offset);
2480
2481 /* This variable tracks the free buffer ring 0 full position, so it
2482 * has to match the above.
2483 */
2484 rx_local->fbr[1]->local_full = ET_DMA10_WRAP;
2485 writel(
2486 ((rx_local->fbr[1]->num_entries * LO_MARK_PERCENT_FOR_RX) / 100) - 1,
2487 &rx_dma->fbr0_min_des);
2488#endif
2489
2490 /* Program the number of packets we will receive before generating an
2491 * interrupt.
2492 * For version B silicon, this value gets updated once autoneg is
2493 *complete.
2494 */
2495 writel(PARM_RX_NUM_BUFS_DEF, &rx_dma->num_pkt_done);
2496
2497 /* The "time_done" is not working correctly to coalesce interrupts
2498 * after a given time period, but rather is giving us an interrupt
2499 * regardless of whether we have received packets.
2500 * This value gets updated once autoneg is complete.
2501 */
2502 writel(PARM_RX_TIME_INT_DEF, &rx_dma->max_pkt_time);
2503
2504 spin_unlock_irqrestore(&adapter->rcv_lock, flags);
2505}
2506
2507/**
2508 * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate. 2614 * et131x_set_rx_dma_timer - Set the heartbeat timer according to line rate.
2509 * @adapter: pointer to our adapter structure 2615 * @adapter: pointer to our adapter structure
2510 */ 2616 */
@@ -3046,37 +3152,6 @@ void et131x_tx_dma_memory_free(struct et131x_adapter *adapter)
3046} 3152}
3047 3153
3048/** 3154/**
3049 * et131x_config_tx_dma_regs - Set up the tx dma section of the JAGCore.
3050 * @adapter: pointer to our private adapter structure
3051 *
3052 * Configure the transmit engine with the ring buffers we have created
3053 * and prepare it for use.
3054 */
3055void et131x_config_tx_dma_regs(struct et131x_adapter *adapter)
3056{
3057 struct txdma_regs __iomem *txdma = &adapter->regs->txdma;
3058
3059 /* Load the hardware with the start of the transmit descriptor ring. */
3060 writel((u32) ((u64)adapter->tx_ring.tx_desc_ring_pa >> 32),
3061 &txdma->pr_base_hi);
3062 writel((u32) adapter->tx_ring.tx_desc_ring_pa,
3063 &txdma->pr_base_lo);
3064
3065 /* Initialise the transmit DMA engine */
3066 writel(NUM_DESC_PER_RING_TX - 1, &txdma->pr_num_des);
3067
3068 /* Load the completion writeback physical address */
3069 writel((u32)((u64)adapter->tx_ring.tx_status_pa >> 32),
3070 &txdma->dma_wb_base_hi);
3071 writel((u32)adapter->tx_ring.tx_status_pa, &txdma->dma_wb_base_lo);
3072
3073 *adapter->tx_ring.tx_status = 0;
3074
3075 writel(0, &txdma->service_request);
3076 adapter->tx_ring.send_idx = 0;
3077}
3078
3079/**
3080 * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310 3155 * et131x_tx_dma_disable - Stop of Tx_DMA on the ET1310
3081 * @adapter: pointer to our adapter structure 3156 * @adapter: pointer to our adapter structure
3082 */ 3157 */
@@ -4022,82 +4097,6 @@ void et131x_error_timer_handler(unsigned long data)
4022} 4097}
4023 4098
4024/** 4099/**
4025 * et131x_configure_global_regs - configure JAGCore global regs
4026 * @adapter: pointer to our adapter structure
4027 *
4028 * Used to configure the global registers on the JAGCore
4029 */
4030void et131x_configure_global_regs(struct et131x_adapter *adapter)
4031{
4032 struct global_regs __iomem *regs = &adapter->regs->global;
4033
4034 writel(0, &regs->rxq_start_addr);
4035 writel(INTERNAL_MEM_SIZE - 1, &regs->txq_end_addr);
4036
4037 if (adapter->registry_jumbo_packet < 2048) {
4038 /* Tx / RxDMA and Tx/Rx MAC interfaces have a 1k word
4039 * block of RAM that the driver can split between Tx
4040 * and Rx as it desires. Our default is to split it
4041 * 50/50:
4042 */
4043 writel(PARM_RX_MEM_END_DEF, &regs->rxq_end_addr);
4044 writel(PARM_RX_MEM_END_DEF + 1, &regs->txq_start_addr);
4045 } else if (adapter->registry_jumbo_packet < 8192) {
4046 /* For jumbo packets > 2k but < 8k, split 50-50. */
4047 writel(INTERNAL_MEM_RX_OFFSET, &regs->rxq_end_addr);
4048 writel(INTERNAL_MEM_RX_OFFSET + 1, &regs->txq_start_addr);
4049 } else {
4050 /* 9216 is the only packet size greater than 8k that
4051 * is available. The Tx buffer has to be big enough
4052 * for one whole packet on the Tx side. We'll make
4053 * the Tx 9408, and give the rest to Rx
4054 */
4055 writel(0x01b3, &regs->rxq_end_addr);
4056 writel(0x01b4, &regs->txq_start_addr);
4057 }
4058
4059 /* Initialize the loopback register. Disable all loopbacks. */
4060 writel(0, &regs->loopback);
4061
4062 /* MSI Register */
4063 writel(0, &regs->msi_config);
4064
4065 /* By default, disable the watchdog timer. It will be enabled when
4066 * a packet is queued.
4067 */
4068 writel(0, &regs->watchdog_timer);
4069}
4070
4071/**
4072 * et131x_adapter_setup - Set the adapter up as per cassini+ documentation
4073 * @adapter: pointer to our private adapter structure
4074 *
4075 * Returns 0 on success, errno on failure (as defined in errno.h)
4076 */
4077void et131x_adapter_setup(struct et131x_adapter *adapter)
4078{
4079 /* Configure the JAGCore */
4080 et131x_configure_global_regs(adapter);
4081
4082 et1310_config_mac_regs1(adapter);
4083
4084 /* Configure the MMC registers */
4085 /* All we need to do is initialize the Memory Control Register */
4086 writel(ET_MMC_ENABLE, &adapter->regs->mmc.mmc_ctrl);
4087
4088 et1310_config_rxmac_regs(adapter);
4089 et1310_config_txmac_regs(adapter);
4090
4091 et131x_config_rx_dma_regs(adapter);
4092 et131x_config_tx_dma_regs(adapter);
4093
4094 et1310_config_macstat_regs(adapter);
4095
4096 et1310_phy_power_down(adapter, 0);
4097 et131x_xcvr_init(adapter);
4098}
4099
4100/**
4101 * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310 4100 * et131x_soft_reset - Issue a soft reset to the hardware, complete for ET1310
4102 * @adapter: pointer to our private adapter structure 4101 * @adapter: pointer to our private adapter structure
4103 */ 4102 */