]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.drivers/r8169-add-hw-start-helpers-for-the-8168-and-the-8101
Disable build of xen kernel.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.drivers / r8169-add-hw-start-helpers-for-the-8168-and-the-8101
1 Commit-Id: dacf815434a4d5f5b45687873df46927c64cfb19
2 From: Francois Romieu <romieu@fr.zoreil.com>
3 Date: Sat, 2 Aug 2008 20:44:13 +0200
4 Acked-by: Karsten Keil <kkeil@novell.com>
5 Reference: bnc#448168
6 Subject: [PATCH] r8169: add hw start helpers for the 8168 and the 8101
7
8 This commit triggers three 'defined but not used' warnings but
9 I prefer avoiding to tie these helpers to a specific change in
10 the hw start sequences of the 8168 or of the 8101.
11
12 Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
13 Cc: Edward Hsu <edward_hsu@realtek.com.tw>
14
15 ---
16 drivers/net/r8169.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++
17 1 file changed, 96 insertions(+)
18
19 --- a/drivers/net/r8169.c
20 +++ b/drivers/net/r8169.c
21 @@ -543,6 +543,11 @@ static int mdio_read(void __iomem *ioadd
22 return value;
23 }
24
25 +static void mdio_patch(void __iomem *ioaddr, int reg_addr, int value)
26 +{
27 + mdio_write(ioaddr, reg_addr, mdio_read(ioaddr, reg_addr) | value);
28 +}
29 +
30 static void rtl_mdio_write(struct net_device *dev, int phy_id, int location,
31 int val)
32 {
33 @@ -560,6 +565,72 @@ static int rtl_mdio_read(struct net_devi
34 return mdio_read(ioaddr, location);
35 }
36
37 +static void rtl_ephy_write(void __iomem *ioaddr, int reg_addr, int value)
38 +{
39 + unsigned int i;
40 +
41 + RTL_W32(EPHYAR, EPHYAR_WRITE_CMD | (value & EPHYAR_DATA_MASK) |
42 + (reg_addr & EPHYAR_REG_MASK) << EPHYAR_REG_SHIFT);
43 +
44 + for (i = 0; i < 100; i++) {
45 + if (!(RTL_R32(EPHYAR) & EPHYAR_FLAG))
46 + break;
47 + udelay(10);
48 + }
49 +}
50 +
51 +static u16 rtl_ephy_read(void __iomem *ioaddr, int reg_addr)
52 +{
53 + u16 value = 0xffff;
54 + unsigned int i;
55 +
56 + RTL_W32(EPHYAR, (reg_addr & EPHYAR_REG_MASK) << EPHYAR_REG_SHIFT);
57 +
58 + for (i = 0; i < 100; i++) {
59 + if (RTL_R32(EPHYAR) & EPHYAR_FLAG) {
60 + value = RTL_R32(EPHYAR) & EPHYAR_DATA_MASK;
61 + break;
62 + }
63 + udelay(10);
64 + }
65 +
66 + return value;
67 +}
68 +
69 +static void rtl_csi_write(void __iomem *ioaddr, int addr, int value)
70 +{
71 + unsigned int i;
72 +
73 + RTL_W32(CSIDR, value);
74 + RTL_W32(CSIAR, CSIAR_WRITE_CMD | (addr & CSIAR_ADDR_MASK) |
75 + CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
76 +
77 + for (i = 0; i < 100; i++) {
78 + if (!(RTL_R32(CSIAR) & CSIAR_FLAG))
79 + break;
80 + udelay(10);
81 + }
82 +}
83 +
84 +static u32 rtl_csi_read(void __iomem *ioaddr, int addr)
85 +{
86 + u32 value = ~0x00;
87 + unsigned int i;
88 +
89 + RTL_W32(CSIAR, (addr & CSIAR_ADDR_MASK) |
90 + CSIAR_BYTE_ENABLE << CSIAR_BYTE_ENABLE_SHIFT);
91 +
92 + for (i = 0; i < 100; i++) {
93 + if (RTL_R32(CSIAR) & CSIAR_FLAG) {
94 + value = RTL_R32(CSIDR);
95 + break;
96 + }
97 + udelay(10);
98 + }
99 +
100 + return value;
101 +}
102 +
103 static void rtl8169_irq_mask_and_ack(void __iomem *ioaddr)
104 {
105 RTL_W16(IntrMask, 0x0000);
106 @@ -2139,6 +2210,31 @@ static void rtl_tx_performance_tweak(str
107 }
108 }
109
110 +static void rtl_csi_access_enable(void __iomem *ioaddr)
111 +{
112 + u32 csi;
113 +
114 + csi = rtl_csi_read(ioaddr, 0x070c) & 0x00ffffff;
115 + rtl_csi_write(ioaddr, 0x070c, csi | 0x27000000);
116 +}
117 +
118 +struct ephy_info {
119 + unsigned int offset;
120 + u16 mask;
121 + u16 bits;
122 +};
123 +
124 +static void rtl_ephy_init(void __iomem *ioaddr, struct ephy_info *e, int len)
125 +{
126 + u16 w;
127 +
128 + while (len-- > 0) {
129 + w = (rtl_ephy_read(ioaddr, e->offset) & ~e->mask) | e->bits;
130 + rtl_ephy_write(ioaddr, e->offset, w);
131 + e++;
132 + }
133 +}
134 +
135 static void rtl_hw_start_8168(struct net_device *dev)
136 {
137 struct rtl8169_private *tp = netdev_priv(dev);