diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2007-06-11 17:04:41 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-08 22:16:43 -0400 |
commit | 7f796d83ffa58c6f752e53dbed8faebb74333e24 (patch) | |
tree | 88ea81bf2ac2e87f1808dec6e9789beb2e07df66 /drivers/net/r8169.c | |
parent | 07ce4064677806e330599ade772a914f500e74af (diff) |
r8169: add helpers for per-device hw_start handler
They aim to limit the amount of moved code when the hw_start
handler gets more specialized.
No functional change.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Edward Hsu <edward_hsu@realtek.com.tw>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r-- | drivers/net/r8169.c | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 5e24a0cf4d5f..f549f096dd01 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -1813,7 +1813,7 @@ static void rtl8169_hw_reset(void __iomem *ioaddr) | |||
1813 | RTL_R8(ChipCmd); | 1813 | RTL_R8(ChipCmd); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp) | 1816 | static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp) |
1817 | { | 1817 | { |
1818 | void __iomem *ioaddr = tp->mmio_addr; | 1818 | void __iomem *ioaddr = tp->mmio_addr; |
1819 | u32 cfg = rtl8169_rx_config; | 1819 | u32 cfg = rtl8169_rx_config; |
@@ -1851,6 +1851,35 @@ static void rtl_hw_start(struct net_device *dev) | |||
1851 | } | 1851 | } |
1852 | 1852 | ||
1853 | 1853 | ||
1854 | static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, | ||
1855 | void __iomem *ioaddr) | ||
1856 | { | ||
1857 | /* | ||
1858 | * Magic spell: some iop3xx ARM board needs the TxDescAddrHigh | ||
1859 | * register to be written before TxDescAddrLow to work. | ||
1860 | * Switching from MMIO to I/O access fixes the issue as well. | ||
1861 | */ | ||
1862 | RTL_W32(TxDescStartAddrHigh, ((u64) tp->TxPhyAddr) >> 32); | ||
1863 | RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr) & DMA_32BIT_MASK); | ||
1864 | RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr) >> 32); | ||
1865 | RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr) & DMA_32BIT_MASK); | ||
1866 | } | ||
1867 | |||
1868 | static u16 rtl_rw_cpluscmd(void __iomem *ioaddr) | ||
1869 | { | ||
1870 | u16 cmd; | ||
1871 | |||
1872 | cmd = RTL_R16(CPlusCmd); | ||
1873 | RTL_W16(CPlusCmd, cmd); | ||
1874 | return cmd; | ||
1875 | } | ||
1876 | |||
1877 | static void rtl_set_rx_max_size(void __iomem *ioaddr) | ||
1878 | { | ||
1879 | /* Low hurts. Let's disable the filtering. */ | ||
1880 | RTL_W16(RxMaxSize, 16383); | ||
1881 | } | ||
1882 | |||
1854 | static void rtl_hw_start_8169(struct net_device *dev) | 1883 | static void rtl_hw_start_8169(struct net_device *dev) |
1855 | { | 1884 | { |
1856 | struct rtl8169_private *tp = netdev_priv(dev); | 1885 | struct rtl8169_private *tp = netdev_priv(dev); |
@@ -1890,19 +1919,15 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
1890 | 1919 | ||
1891 | RTL_W8(EarlyTxThres, EarlyTxThld); | 1920 | RTL_W8(EarlyTxThres, EarlyTxThld); |
1892 | 1921 | ||
1893 | /* Low hurts. Let's disable the filtering. */ | 1922 | rtl_set_rx_max_size(ioaddr); |
1894 | RTL_W16(RxMaxSize, 16383); | ||
1895 | 1923 | ||
1896 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | 1924 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || |
1897 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | 1925 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || |
1898 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | 1926 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || |
1899 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | 1927 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) |
1900 | rtl8169_set_rx_tx_config_registers(tp); | 1928 | rtl_set_rx_tx_config_registers(tp); |
1901 | 1929 | ||
1902 | cmd = RTL_R16(CPlusCmd); | 1930 | tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; |
1903 | RTL_W16(CPlusCmd, cmd); | ||
1904 | |||
1905 | tp->cp_cmd |= cmd | PCIMulRW; | ||
1906 | 1931 | ||
1907 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 1932 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || |
1908 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 1933 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { |
@@ -1919,22 +1944,14 @@ static void rtl_hw_start_8169(struct net_device *dev) | |||
1919 | */ | 1944 | */ |
1920 | RTL_W16(IntrMitigate, 0x0000); | 1945 | RTL_W16(IntrMitigate, 0x0000); |
1921 | 1946 | ||
1922 | /* | 1947 | rtl_set_rx_tx_desc_registers(tp, ioaddr); |
1923 | * Magic spell: some iop3xx ARM board needs the TxDescAddrHigh | ||
1924 | * register to be written before TxDescAddrLow to work. | ||
1925 | * Switching from MMIO to I/O access fixes the issue as well. | ||
1926 | */ | ||
1927 | RTL_W32(TxDescStartAddrHigh, ((u64) tp->TxPhyAddr >> 32)); | ||
1928 | RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK)); | ||
1929 | RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32)); | ||
1930 | RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK)); | ||
1931 | 1948 | ||
1932 | if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && | 1949 | if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && |
1933 | (tp->mac_version != RTL_GIGA_MAC_VER_02) && | 1950 | (tp->mac_version != RTL_GIGA_MAC_VER_02) && |
1934 | (tp->mac_version != RTL_GIGA_MAC_VER_03) && | 1951 | (tp->mac_version != RTL_GIGA_MAC_VER_03) && |
1935 | (tp->mac_version != RTL_GIGA_MAC_VER_04)) { | 1952 | (tp->mac_version != RTL_GIGA_MAC_VER_04)) { |
1936 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 1953 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); |
1937 | rtl8169_set_rx_tx_config_registers(tp); | 1954 | rtl_set_rx_tx_config_registers(tp); |
1938 | } | 1955 | } |
1939 | 1956 | ||
1940 | RTL_W8(Cfg9346, Cfg9346_Lock); | 1957 | RTL_W8(Cfg9346, Cfg9346_Lock); |