iPXE
sis190.c File Reference
#include "sis190.h"

Go to the source code of this file.

Macros

#define ErrMask   (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)
#define TxErrMask   (WND | TABRT | FIFO | LINK)

Functions

 FILE_LICENCE (GPL_ANY)
static int sis190_isa_bridge_probe (struct pci_device *pdev __unused)
static void sis190_isa_bridge_remove (struct pci_device *pdev __unused)
static void __mdio_cmd (void *ioaddr, u32 ctl)
static void mdio_write (void *ioaddr, int phy_id, int reg, int val)
static int mdio_read (void *ioaddr, int phy_id, int reg)
static void __mdio_write (struct net_device *dev, int phy_id, int reg, int val)
static int __mdio_read (struct net_device *dev, int phy_id, int reg)
static u16 mdio_read_latched (void *ioaddr, int phy_id, int reg)
static u16 sis190_read_eeprom (void *ioaddr, u32 reg)
static void sis190_irq_mask_and_ack (void *ioaddr)
static void sis190_asic_down (void *ioaddr)
static void sis190_mark_as_last_descriptor (struct RxDesc *desc)
static void sis190_give_to_asic (struct RxDesc *desc)
static void sis190_map_to_asic (struct RxDesc *desc, u32 mapping)
static void sis190_make_unusable_by_asic (struct RxDesc *desc)
static struct io_buffersis190_alloc_rx_iob (struct RxDesc *desc)
static u32 sis190_rx_fill (struct sis190_private *tp, u32 start, u32 end)
static int sis190_rx_pkt_err (u32 status)
static int sis190_process_rx (struct sis190_private *tp)
static int sis190_tx_pkt_err (u32 status)
static void sis190_process_tx (struct sis190_private *tp)
static void sis190_poll (struct net_device *dev)
static void sis190_init_ring_indexes (struct sis190_private *tp)
static int sis190_init_ring (struct net_device *dev)
static void sis190_set_rx_mode (struct net_device *dev)
static void sis190_soft_reset (void *ioaddr)
static void sis190_hw_start (struct net_device *dev)
static void sis190_phy_task (struct sis190_private *tp)
static int sis190_open (struct net_device *dev)
static void sis190_down (struct net_device *dev)
static void sis190_free (struct net_device *dev)
static void sis190_close (struct net_device *dev)
static int sis190_transmit (struct net_device *dev, struct io_buffer *iob)
static void sis190_free_phy (struct list_head *first_phy)
static u16 sis190_default_phy (struct sis190_private *tp)
 sis190_default_phy - Select default PHY for sis190 mac.
static void sis190_init_phy (struct sis190_private *tp, struct sis190_phy *phy, unsigned int phy_id, u16 mii_status)
static void sis190_mii_probe_88e1111_fixup (struct sis190_private *tp)
static int sis190_mii_probe (struct net_device *dev)
 sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for
static void sis190_mii_remove (struct net_device *dev)
static int sis190_init_board (struct pci_device *pdev, struct net_device **netdev)
static void sis190_set_rgmii (struct sis190_private *tp, u8 reg)
static int sis190_get_mac_addr_from_eeprom (struct pci_device *pdev __unused, struct net_device *dev)
static int sis190_get_mac_addr_from_apc (struct pci_device *pdev, struct net_device *dev)
 sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network device to get address for
static void sis190_init_rxfilter (struct net_device *dev)
 sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize
static int sis190_get_mac_addr (struct pci_device *pdev, struct net_device *dev)
static void sis190_set_speed_auto (struct net_device *dev)
static void sis190_irq (struct net_device *dev, int enable)
static int sis190_probe (struct pci_device *pdev)
static void sis190_remove (struct pci_device *pdev)

Variables

static struct pci_device_id sis190_pci_tbl []
static struct pci_device_id sis190_isa_bridge_tbl []
struct pci_driver sis190_isa_bridge_driver __pci_driver
static const u32 sis190_intr_mask
static struct net_device_operations sis190_netdev_ops

Macro Definition Documentation

◆ ErrMask

#define ErrMask   (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)

Referenced by sis190_rx_pkt_err().

◆ TxErrMask

#define TxErrMask   (WND | TABRT | FIFO | LINK)

Referenced by sis190_tx_pkt_err().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL_ANY )

◆ sis190_isa_bridge_probe()

int sis190_isa_bridge_probe ( struct pci_device *pdev __unused)
static

Definition at line 50 of file sis190.c.

51{
52 return 0;
53}

References __unused.

◆ sis190_isa_bridge_remove()

void sis190_isa_bridge_remove ( struct pci_device *pdev __unused)
static

Definition at line 55 of file sis190.c.

56{
57 return;
58}

References __unused.

◆ __mdio_cmd()

void __mdio_cmd ( void * ioaddr,
u32 ctl )
static

Definition at line 75 of file sis190.c.

76{
77 unsigned int i;
78
79 SIS_W32(GMIIControl, ctl);
80
81 mdelay(1);
82
83 for (i = 0; i < 100; i++) {
85 break;
86 mdelay(1);
87 }
88
89 if (i > 99)
90 DBG("sis190: PHY command timed out !\n");
91}
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define EhnMIInotDone
Definition sis190.h:56
#define SIS_W32(reg, val)
Definition sis190.h:61
@ GMIIControl
Definition sis190.h:86
#define SIS_R32(reg)
Definition sis190.h:64
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79

References DBG, EhnMIInotDone, GMIIControl, ioaddr, mdelay(), SIS_R32, SIS_W32, and u32.

Referenced by mdio_read(), and mdio_write().

◆ mdio_write()

void mdio_write ( void * ioaddr,
int phy_id,
int reg,
int val )
static

Definition at line 93 of file sis190.c.

94{
96 (((u32) reg) << EhnMIIregShift) | (phy_id << EhnMIIpmdShift) |
97 (((u32) val) << EhnMIIdataShift));
98}
static unsigned long ioaddr
Definition davicom.c:129
void __asmcall int val
Definition setjmp.h:12
static unsigned int unsigned int reg
Definition myson.h:162
static void __mdio_cmd(void *ioaddr, u32 ctl)
Definition sis190.c:75
#define EhnMIIpmdShift
Definition sis190.h:53
#define EhnMIIreq
Definition sis190.h:55
#define EhnMIIregShift
Definition sis190.h:54
#define EhnMIIwrite
Definition sis190.h:51
#define EhnMIIdataShift
Definition sis190.h:52
#define u32
Definition vga.h:21

References __mdio_cmd(), EhnMIIdataShift, EhnMIIpmdShift, EhnMIIregShift, EhnMIIreq, EhnMIIwrite, ioaddr, reg, u32, and val.

Referenced by __mdio_write(), sis190_default_phy(), sis190_mii_probe_88e1111_fixup(), sis190_phy_task(), and sis190_set_speed_auto().

◆ mdio_read()

int mdio_read ( void * ioaddr,
int phy_id,
int reg )
static

◆ __mdio_write()

void __mdio_write ( struct net_device * dev,
int phy_id,
int reg,
int val )
static

Definition at line 108 of file sis190.c.

109{
110 struct sis190_private *tp = dev->priv;
111
112 mdio_write(tp->mmio_addr, phy_id, reg, val);
113}
static void mdio_write(void *ioaddr, int phy_id, int reg, int val)
Definition sis190.c:93
void * priv
Driver private data.
Definition netdevice.h:432
struct net_device * dev
Definition sis190.h:253
static struct tulip_private * tp
Definition tulip.c:442

References sis190_private::dev, mdio_write(), net_device::priv, reg, tp, and val.

Referenced by sis190_mii_probe().

◆ __mdio_read()

int __mdio_read ( struct net_device * dev,
int phy_id,
int reg )
static

Definition at line 115 of file sis190.c.

116{
117 struct sis190_private *tp = dev->priv;
118
119 return mdio_read(tp->mmio_addr, phy_id, reg);
120}
static int mdio_read(void *ioaddr, int phy_id, int reg)
Definition sis190.c:100

References sis190_private::dev, mdio_read(), net_device::priv, reg, and tp.

Referenced by sis190_mii_probe().

◆ mdio_read_latched()

u16 mdio_read_latched ( void * ioaddr,
int phy_id,
int reg )
static

Definition at line 122 of file sis190.c.

123{
124 mdio_read(ioaddr, phy_id, reg);
125 return mdio_read(ioaddr, phy_id, reg);
126}

References ioaddr, mdio_read(), reg, and u16.

Referenced by sis190_default_phy(), sis190_mii_probe(), and sis190_phy_task().

◆ sis190_read_eeprom()

u16 sis190_read_eeprom ( void * ioaddr,
u32 reg )
static

Definition at line 128 of file sis190.c.

129{
130 u16 data = 0xffff;
131 unsigned int i;
132
133 if (!(SIS_R32(ROMControl) & 0x0002))
134 return 0;
135
136 SIS_W32(ROMInterface, EEREQ | EEROP | (reg << 10));
137
138 for (i = 0; i < 200; i++) {
139 if (!(SIS_R32(ROMInterface) & EEREQ)) {
140 data = (SIS_R32(ROMInterface) & 0xffff0000) >> 16;
141 break;
142 }
143 mdelay(1);
144 }
145
146 return data;
147}
uint8_t data[48]
Additional event data.
Definition ena.h:11
@ ROMInterface
Definition sis190.h:84
@ ROMControl
Definition sis190.h:83
@ EEREQ
Definition sis190.h:231
@ EEROP
Definition sis190.h:232

References data, EEREQ, EEROP, ioaddr, mdelay(), reg, ROMControl, ROMInterface, SIS_R32, SIS_W32, u16, and u32.

Referenced by sis190_get_mac_addr_from_eeprom().

◆ sis190_irq_mask_and_ack()

void sis190_irq_mask_and_ack ( void * ioaddr)
static

Definition at line 149 of file sis190.c.

150{
151 SIS_W32(IntrMask, 0x00);
152 SIS_W32(IntrStatus, 0xffffffff);
154}
@ IntrMask
Definition sis190.h:78
@ IntrStatus
Definition sis190.h:77
#define SIS_PCI_COMMIT()
Definition sis190.h:66

References IntrMask, IntrStatus, ioaddr, SIS_PCI_COMMIT, and SIS_W32.

Referenced by sis190_asic_down(), and sis190_init_board().

◆ sis190_asic_down()

void sis190_asic_down ( void * ioaddr)
static

Definition at line 156 of file sis190.c.

157{
158 /* Stop the chip's Tx and Rx DMA processes. */
159
160 SIS_W32(TxControl, 0x1a00);
161 SIS_W32(RxControl, 0x1a00);
162
164}
static void sis190_irq_mask_and_ack(void *ioaddr)
Definition sis190.c:149
@ RxControl
Definition sis190.h:73
@ TxControl
Definition sis190.h:69

References ioaddr, RxControl, sis190_irq_mask_and_ack(), SIS_W32, and TxControl.

Referenced by sis190_down(), and sis190_soft_reset().

◆ sis190_mark_as_last_descriptor()

void sis190_mark_as_last_descriptor ( struct RxDesc * desc)
inlinestatic

Definition at line 166 of file sis190.c.

167{
168 desc->size |= cpu_to_le32(RingEnd);
169}
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
#define cpu_to_le32(value)
Definition byteswap.h:108
@ RingEnd
Definition sis190.h:174

References cpu_to_le32, desc, and RingEnd.

Referenced by sis190_init_ring().

◆ sis190_give_to_asic()

void sis190_give_to_asic ( struct RxDesc * desc)
inlinestatic

Definition at line 171 of file sis190.c.

172{
173 u32 eor = le32_to_cpu(desc->size) & RingEnd;
174
175 desc->PSize = 0x0;
176 desc->size = cpu_to_le32((RX_BUF_SIZE & RX_BUF_MASK) | eor);
177 wmb();
178 desc->status = cpu_to_le32(OWNbit | INTbit);
179}
#define RX_BUF_SIZE
Definition 3c90x.h:269
#define le32_to_cpu(value)
Definition byteswap.h:114
#define wmb()
Definition io.h:546
@ OWNbit
Definition sis190.h:169
@ INTbit
Definition sis190.h:170
#define RX_BUF_MASK
Definition sis190.h:43

References cpu_to_le32, desc, INTbit, le32_to_cpu, OWNbit, RingEnd, RX_BUF_MASK, RX_BUF_SIZE, u32, and wmb.

Referenced by sis190_map_to_asic(), and sis190_process_rx().

◆ sis190_map_to_asic()

void sis190_map_to_asic ( struct RxDesc * desc,
u32 mapping )
inlinestatic

Definition at line 181 of file sis190.c.

182{
183 desc->addr = cpu_to_le32(mapping);
185}
static void sis190_give_to_asic(struct RxDesc *desc)
Definition sis190.c:171

References cpu_to_le32, desc, sis190_give_to_asic(), and u32.

Referenced by sis190_alloc_rx_iob().

◆ sis190_make_unusable_by_asic()

void sis190_make_unusable_by_asic ( struct RxDesc * desc)
inlinestatic

Definition at line 187 of file sis190.c.

188{
189 desc->PSize = 0x0;
190 desc->addr = cpu_to_le32(0xdeadbeef);
191 desc->size &= cpu_to_le32(RingEnd);
192 wmb();
193 desc->status = 0x0;
194}

References cpu_to_le32, desc, RingEnd, and wmb.

Referenced by sis190_alloc_rx_iob(), and sis190_process_rx().

◆ sis190_alloc_rx_iob()

struct io_buffer * sis190_alloc_rx_iob ( struct RxDesc * desc)
static

Definition at line 196 of file sis190.c.

197{
198 struct io_buffer *iob;
199
200 iob = alloc_iob(RX_BUF_SIZE);
201 if (iob) {
202 u32 mapping;
203
204 mapping = virt_to_bus(iob->data);
205 sis190_map_to_asic(desc, mapping);
206 } else {
207 DBG("sis190: alloc_iob failed\n");
209 }
210
211 return iob;
212}
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition iobuf.c:131
static void sis190_make_unusable_by_asic(struct RxDesc *desc)
Definition sis190.c:187
static void sis190_map_to_asic(struct RxDesc *desc, u32 mapping)
Definition sis190.c:181
A persistent I/O buffer.
Definition iobuf.h:38
void * data
Start of data.
Definition iobuf.h:53

References alloc_iob(), io_buffer::data, DBG, desc, RX_BUF_SIZE, sis190_make_unusable_by_asic(), sis190_map_to_asic(), u32, and virt_to_bus().

Referenced by sis190_rx_fill().

◆ sis190_rx_fill()

u32 sis190_rx_fill ( struct sis190_private * tp,
u32 start,
u32 end )
static

Definition at line 214 of file sis190.c.

215{
216 u32 cur;
217
218 for (cur = start; cur < end; cur++) {
219 unsigned int i = cur % NUM_RX_DESC;
220
221 if (tp->Rx_iobuf[i])
222 continue;
223
224 tp->Rx_iobuf[i] = sis190_alloc_rx_iob(tp->RxDescRing + i);
225
226 if (!tp->Rx_iobuf[i])
227 break;
228 }
229 return cur - start;
230}
uint32_t start
Starting offset.
Definition netvsc.h:1
#define NUM_RX_DESC
Definition igbvf.h:281
uint32_t end
Ending offset.
Definition netvsc.h:7
static struct io_buffer * sis190_alloc_rx_iob(struct RxDesc *desc)
Definition sis190.c:196

References end, NUM_RX_DESC, sis190_alloc_rx_iob(), start, tp, and u32.

Referenced by sis190_init_ring(), and sis190_process_rx().

◆ sis190_rx_pkt_err()

int sis190_rx_pkt_err ( u32 status)
inlinestatic

Definition at line 232 of file sis190.c.

233{
234#define ErrMask (OVRUN | SHORT | LIMIT | MIIER | NIBON | COLON | ABORT)
235
236 if ((status & CRCOK) && !(status & ErrMask))
237 return 0;
238
239 return -1;
240}
uint8_t status
Status.
Definition ena.h:5
#define ErrMask
@ CRCOK
Definition sis190.h:217

References CRCOK, ErrMask, status, and u32.

Referenced by sis190_process_rx().

◆ sis190_process_rx()

int sis190_process_rx ( struct sis190_private * tp)
static

Definition at line 242 of file sis190.c.

243{
244 u32 rx_left, cur_rx = tp->cur_rx;
245 u32 delta, count;
246
247 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx;
248
249 for (; rx_left > 0; rx_left--, cur_rx++) {
250 unsigned int entry = cur_rx % NUM_RX_DESC;
251 struct RxDesc *desc = tp->RxDescRing + entry;
252 u32 status;
253
254 if (le32_to_cpu(desc->status) & OWNbit)
255 break;
256
257 status = le32_to_cpu(desc->PSize);
258
259 if (sis190_rx_pkt_err(status) < 0) {
261 } else {
262 struct io_buffer *iob = tp->Rx_iobuf[entry];
263 unsigned int pkt_size = (status & RxSizeMask) - 4;
264
265 if (pkt_size > RX_BUF_SIZE) {
266 DBG("sis190: (frag) status = %08x.\n", status);
268 continue;
269 }
270
272
273 iob_put(iob, pkt_size);
274
275 DBG2("sis190: received packet. len: %d\n", pkt_size);
276 netdev_rx(tp->dev, iob);
277 DBGIO_HD(iob->data, 60);
278 tp->Rx_iobuf[entry] = NULL;
279 }
280 }
281 count = cur_rx - tp->cur_rx;
282 tp->cur_rx = cur_rx;
283
284 delta = sis190_rx_fill(tp, tp->dirty_rx, tp->cur_rx);
285 if (!delta && count)
286 DBG("sis190: no Rx buffer allocated.\n");
287 tp->dirty_rx += delta;
288
289 if (((tp->dirty_rx + NUM_RX_DESC) == tp->cur_rx))
290 DBG("sis190: Rx buffers exhausted.\n");
291
292 return count;
293}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
static unsigned int cur_rx
Definition epic100.c:84
#define DBG2(...)
Definition compiler.h:515
#define DBGIO_HD(...)
Definition compiler.h:551
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define iob_put(iobuf, len)
Definition iobuf.h:125
void netdev_rx(struct net_device *netdev, struct io_buffer *iobuf)
Add packet to receive queue.
Definition netdevice.c:549
static u32 sis190_rx_fill(struct sis190_private *tp, u32 start, u32 end)
Definition sis190.c:214
static int sis190_rx_pkt_err(u32 status)
Definition sis190.c:232
@ RxSizeMask
Definition sis190.h:218

References count, cur_rx, io_buffer::data, DBG, DBG2, DBGIO_HD, desc, iob_put, le32_to_cpu, netdev_rx(), NULL, NUM_RX_DESC, OWNbit, RX_BUF_SIZE, RxSizeMask, sis190_give_to_asic(), sis190_make_unusable_by_asic(), sis190_rx_fill(), sis190_rx_pkt_err(), status, tp, and u32.

Referenced by sis190_poll().

◆ sis190_tx_pkt_err()

int sis190_tx_pkt_err ( u32 status)
inlinestatic

Definition at line 295 of file sis190.c.

296{
297#define TxErrMask (WND | TABRT | FIFO | LINK)
298
299 if (!(status & TxErrMask))
300 return 0;
301
302 return -1;
303}
#define TxErrMask

References status, TxErrMask, and u32.

Referenced by sis190_process_tx().

◆ sis190_process_tx()

void sis190_process_tx ( struct sis190_private * tp)
static

Definition at line 305 of file sis190.c.

306{
307 u32 pending, dirty_tx = tp->dirty_tx;
308
309 pending = tp->cur_tx - dirty_tx;
310
311 for (; pending; pending--, dirty_tx++) {
312 unsigned int entry = dirty_tx % NUM_TX_DESC;
313 struct TxDesc *txd = tp->TxDescRing + entry;
314 u32 status = le32_to_cpu(txd->status);
315 struct io_buffer *iob;
316
317 if (status & OWNbit)
318 break;
319
320 iob = tp->Tx_iobuf[entry];
321
322 if (!iob)
323 break;
324
325 if (sis190_tx_pkt_err(status) == 0) {
326 DBG2("sis190: Transmitted packet: %#08x\n", status);
327 netdev_tx_complete(tp->dev, iob);
328 } else {
329 DBG("sis190: Transmit error: %#08x\n", status);
330 netdev_tx_complete_err(tp->dev, iob, -EINVAL);
331 }
332
333 tp->Tx_iobuf[entry] = NULL;
334 }
335
336 if (tp->dirty_tx != dirty_tx)
337 tp->dirty_tx = dirty_tx;
338}
#define txd
Definition davicom.c:144
#define EINVAL
Invalid argument.
Definition errno.h:429
#define NUM_TX_DESC
Definition igbvf.h:280
uint32_t pending
Pending events.
Definition hyperv.h:1
void netdev_tx_complete_err(struct net_device *netdev, struct io_buffer *iobuf, int rc)
Complete network transmission.
Definition netdevice.c:471
static void netdev_tx_complete(struct net_device *netdev, struct io_buffer *iobuf)
Complete network transmission.
Definition netdevice.h:767
static int sis190_tx_pkt_err(u32 status)
Definition sis190.c:295

References DBG, DBG2, EINVAL, le32_to_cpu, netdev_tx_complete(), netdev_tx_complete_err(), NULL, NUM_TX_DESC, OWNbit, pending, sis190_tx_pkt_err(), status, tp, txd, and u32.

Referenced by sis190_poll().

◆ sis190_poll()

void sis190_poll ( struct net_device * dev)
static

Definition at line 344 of file sis190.c.

345{
346 struct sis190_private *tp = dev->priv;
347 void *ioaddr = tp->mmio_addr;
348 u32 status;
349
351
352 if ((status == 0xffffffff) || !status)
353 return;
354
356
357 /* sis190_phy_task() needs to be called in event of a LinkChange and
358 * after auto-negotiation is finished. Finishing auto-neg won't generate
359 * any indication, hence we call it every time if the link is bad. */
360 if ((status & LinkChange) || !netdev_link_ok(dev))
362
363 if (status & RxQInt)
365
366 if (status & TxQ0Int)
368}
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition netdevice.h:640
static int sis190_process_rx(struct sis190_private *tp)
Definition sis190.c:242
static void sis190_process_tx(struct sis190_private *tp)
Definition sis190.c:305
static void sis190_phy_task(struct sis190_private *tp)
Definition sis190.c:448
@ RxQInt
Definition sis190.h:112
@ TxQ0Int
Definition sis190.h:116
@ LinkChange
Definition sis190.h:110

References sis190_private::dev, IntrStatus, ioaddr, LinkChange, netdev_link_ok(), net_device::priv, RxQInt, sis190_phy_task(), sis190_process_rx(), sis190_process_tx(), SIS_R32, SIS_W32, status, tp, TxQ0Int, and u32.

◆ sis190_init_ring_indexes()

void sis190_init_ring_indexes ( struct sis190_private * tp)
inlinestatic

Definition at line 370 of file sis190.c.

371{
372 tp->dirty_tx = tp->dirty_rx = tp->cur_tx = tp->cur_rx = 0;
373}

References tp.

Referenced by sis190_init_ring().

◆ sis190_init_ring()

int sis190_init_ring ( struct net_device * dev)
static

Definition at line 375 of file sis190.c.

376{
377 struct sis190_private *tp = dev->priv;
378
380
381 memset(tp->Tx_iobuf, 0, NUM_TX_DESC * sizeof(struct io_buffer *));
382 memset(tp->Rx_iobuf, 0, NUM_RX_DESC * sizeof(struct io_buffer *));
383
385 goto err;
386
388
389 return 0;
390
391err:
393 return -ENOMEM;
394}
#define ENOMEM
Not enough space.
Definition errno.h:535
void * memset(void *dest, int character, size_t len) __nonnull
static void sis190_free(struct net_device *dev)
Definition sis190.c:598
static void sis190_init_ring_indexes(struct sis190_private *tp)
Definition sis190.c:370
static void sis190_mark_as_last_descriptor(struct RxDesc *desc)
Definition sis190.c:166

References sis190_private::dev, ENOMEM, memset(), NUM_RX_DESC, NUM_TX_DESC, net_device::priv, sis190_free(), sis190_init_ring_indexes(), sis190_mark_as_last_descriptor(), sis190_rx_fill(), and tp.

Referenced by sis190_open().

◆ sis190_set_rx_mode()

void sis190_set_rx_mode ( struct net_device * dev)
static

Definition at line 396 of file sis190.c.

397{
398 struct sis190_private *tp = dev->priv;
399 void *ioaddr = tp->mmio_addr;
400 u32 mc_filter[2]; /* Multicast hash filter */
401 u16 rx_mode;
402
404 mc_filter[1] = mc_filter[0] = 0xffffffff;
405
406 SIS_W16(RxMacControl, rx_mode | 0x2);
407 SIS_W32(RxHashTable, mc_filter[0]);
408 SIS_W32(RxHashTable + 4, mc_filter[1]);
409
410}
#define SIS_W16(reg, val)
Definition sis190.h:60
@ RxMacControl
Definition sis190.h:93
@ RxHashTable
Definition sis190.h:95
@ AcceptMulticast
Definition sis190.h:134
@ AcceptMyPhys
Definition sis190.h:135
@ AcceptBroadcast
Definition sis190.h:133

References AcceptBroadcast, AcceptMulticast, AcceptMyPhys, sis190_private::dev, ioaddr, net_device::priv, RxHashTable, RxMacControl, SIS_W16, SIS_W32, tp, u16, and u32.

Referenced by sis190_hw_start().

◆ sis190_soft_reset()

void sis190_soft_reset ( void * ioaddr)
static

Definition at line 412 of file sis190.c.

413{
414 SIS_W32(IntrControl, 0x8000);
416 SIS_W32(IntrControl, 0x0);
418}
static void sis190_asic_down(void *ioaddr)
Definition sis190.c:156
@ IntrControl
Definition sis190.h:79

References IntrControl, ioaddr, sis190_asic_down(), SIS_PCI_COMMIT, and SIS_W32.

Referenced by sis190_hw_start(), sis190_init_board(), and sis190_remove().

◆ sis190_hw_start()

void sis190_hw_start ( struct net_device * dev)
static

Definition at line 420 of file sis190.c.

421{
422 struct sis190_private *tp = dev->priv;
423 void *ioaddr = tp->mmio_addr;
424
426
427 SIS_W32(TxDescStartAddr, tp->tx_dma);
428 SIS_W32(RxDescStartAddr, tp->rx_dma);
429
430 SIS_W32(IntrStatus, 0xffffffff);
431 SIS_W32(IntrMask, 0x0);
432 SIS_W32(GMIIControl, 0x0);
433 SIS_W32(TxMacControl, 0x60);
434 SIS_W16(RxMacControl, 0x02);
435 SIS_W32(RxHashTable, 0x0);
436 SIS_W32(0x6c, 0x0);
437 SIS_W32(RxWolCtrl, 0x0);
438 SIS_W32(RxWolData, 0x0);
439
441
443
444 SIS_W32(TxControl, 0x1a00 | CmdTxEnb);
445 SIS_W32(RxControl, 0x1a1d);
446}
static void sis190_soft_reset(void *ioaddr)
Definition sis190.c:412
static void sis190_set_rx_mode(struct net_device *dev)
Definition sis190.c:396
@ RxDescStartAddr
Definition sis190.h:74
@ RxWolCtrl
Definition sis190.h:97
@ RxWolData
Definition sis190.h:98
@ TxMacControl
Definition sis190.h:89
@ TxDescStartAddr
Definition sis190.h:70
@ CmdTxEnb
Definition sis190.h:123

References CmdTxEnb, sis190_private::dev, GMIIControl, IntrMask, IntrStatus, ioaddr, net_device::priv, RxControl, RxDescStartAddr, RxHashTable, RxMacControl, RxWolCtrl, RxWolData, sis190_set_rx_mode(), sis190_soft_reset(), SIS_PCI_COMMIT, SIS_W16, SIS_W32, tp, TxControl, TxDescStartAddr, and TxMacControl.

Referenced by sis190_open().

◆ sis190_phy_task()

void sis190_phy_task ( struct sis190_private * tp)
static

Definition at line 448 of file sis190.c.

449{
450 struct net_device *dev = tp->dev;
451 void *ioaddr = tp->mmio_addr;
452 int phy_id = tp->mii_if.phy_id;
453 int cnt = 0;
454 u16 val;
455
456 val = mdio_read(ioaddr, phy_id, MII_BMCR);
457
458 /* 100ms timeout is completely arbitrary. I have no datasheet to
459 * check whether that's a sensible value or not.
460 */
461 while ((val & BMCR_RESET) && (cnt < 100)) {
462 val = mdio_read(ioaddr, phy_id, MII_BMCR);
463 mdelay(1);
464 cnt++;
465 }
466
467 if (cnt > 99) {
468 DBG("sis190: BMCR_RESET timeout\n");
469 return;
470 }
471
472 if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) &
474 DBG("sis190: auto-negotiating...\n");
476 } else {
477 /* Rejoice ! */
478 struct {
479 int val;
480 u32 ctl;
481 const char *msg;
482 } reg31[] = {
483 { LPA_1000FULL, 0x07000c00 | 0x00001000,
484 "1000 Mbps Full Duplex" },
485 { LPA_1000HALF, 0x07000c00,
486 "1000 Mbps Half Duplex" },
487 { LPA_100FULL, 0x04000800 | 0x00001000,
488 "100 Mbps Full Duplex" },
489 { LPA_100HALF, 0x04000800,
490 "100 Mbps Half Duplex" },
491 { LPA_10FULL, 0x04000400 | 0x00001000,
492 "10 Mbps Full Duplex" },
493 { LPA_10HALF, 0x04000400,
494 "10 Mbps Half Duplex" },
495 { 0, 0x04000400, "unknown" }
496 }, *p = NULL;
497 u16 adv, autoexp, gigadv, gigrec;
498
499 val = mdio_read(ioaddr, phy_id, 0x1f);
500
501 val = mdio_read(ioaddr, phy_id, MII_LPA);
502 adv = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
503
504 autoexp = mdio_read(ioaddr, phy_id, MII_EXPANSION);
505
506 if (val & LPA_NPAGE && autoexp & EXPANSION_NWAY) {
507 /* check for gigabit speed */
508 gigadv = mdio_read(ioaddr, phy_id, MII_CTRL1000);
509 gigrec = mdio_read(ioaddr, phy_id, MII_STAT1000);
510 val = (gigadv & (gigrec >> 2));
512 p = reg31;
513 else if (val & ADVERTISE_1000HALF)
514 p = reg31 + 1;
515 }
516
517 if (!p) {
518 val &= adv;
519
520 for (p = reg31; p->val; p++) {
521 if ((val & p->val) == p->val)
522 break;
523 }
524 }
525
526 p->ctl |= SIS_R32(StationControl) & ~0x0f001c00;
527
528 if ((tp->features & F_HAS_RGMII) &&
529 (tp->features & F_PHY_BCM5461)) {
530 // Set Tx Delay in RGMII mode.
531 mdio_write(ioaddr, phy_id, 0x18, 0xf1c7);
532 udelay(200);
533 mdio_write(ioaddr, phy_id, 0x1c, 0x8c00);
534 p->ctl |= 0x03000000;
535 }
536
537 SIS_W32(StationControl, p->ctl);
538
539 if (tp->features & F_HAS_RGMII) {
540 SIS_W32(RGDelay, 0x0441);
541 SIS_W32(RGDelay, 0x0440);
542 }
543
544 DBG("sis190: link on %s mode.\n", p->msg);
545 netdev_link_up(dev);
546 }
547}
#define MII_ADVERTISE
Definition atl1e.h:875
#define MII_EXPANSION
Definition atl1e.h:877
#define MII_BMCR
Definition atl1e.h:871
#define MII_BMSR
Definition atl1e.h:872
#define MII_LPA
Definition atl1e.h:876
void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition message.c:62
#define LPA_NPAGE
Definition mii.h:112
#define ADVERTISE_1000HALF
Definition mii.h:135
#define LPA_100HALF
Definition mii.h:102
#define LPA_1000FULL
Definition mii.h:140
#define BMCR_RESET
Definition mii.h:53
#define MII_CTRL1000
Definition mii.h:25
#define LPA_10FULL
Definition mii.h:100
#define BMSR_ANEGCOMPLETE
Definition mii.h:61
#define ADVERTISE_1000FULL
Definition mii.h:134
#define MII_STAT1000
Definition mii.h:26
#define LPA_100FULL
Definition mii.h:104
#define LPA_10HALF
Definition mii.h:98
#define EXPANSION_NWAY
Definition mii.h:118
#define LPA_1000HALF
Definition mii.h:141
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition netdevice.c:231
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition netdevice.h:789
static u16 mdio_read_latched(void *ioaddr, int phy_id, int reg)
Definition sis190.c:122
@ F_HAS_RGMII
Definition sis190.h:245
@ F_PHY_BCM5461
Definition sis190.h:247
@ RGDelay
Definition sis190.h:91
@ StationControl
Definition sis190.h:85
A network device.
Definition netdevice.h:353
struct device * dev
Underlying hardware device.
Definition netdevice.h:365
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61

References ADVERTISE_1000FULL, ADVERTISE_1000HALF, BMCR_RESET, BMSR_ANEGCOMPLETE, DBG, net_device::dev, EXPANSION_NWAY, F_HAS_RGMII, F_PHY_BCM5461, ioaddr, LPA_1000FULL, LPA_1000HALF, LPA_100FULL, LPA_100HALF, LPA_10FULL, LPA_10HALF, LPA_NPAGE, mdelay(), mdio_read(), mdio_read_latched(), mdio_write(), MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CTRL1000, MII_EXPANSION, MII_LPA, MII_STAT1000, msg(), netdev_link_down(), netdev_link_up(), NULL, RGDelay, SIS_R32, SIS_W32, StationControl, tp, u16, u32, udelay(), and val.

Referenced by sis190_poll(), and sis190_probe().

◆ sis190_open()

int sis190_open ( struct net_device * dev)
static

Definition at line 549 of file sis190.c.

550{
551 struct sis190_private *tp = dev->priv;
552 int rc;
553
554 /* Allocate TX ring */
556 if (!tp->TxDescRing) {
557 DBG("sis190: TX ring allocation failed\n");
558 rc = -ENOMEM;
559 goto out;
560 }
561 tp->tx_dma = cpu_to_le32(virt_to_bus(tp->TxDescRing));
562
563 /* Allocate RX ring */
565 if (!tp->RxDescRing) {
566 DBG("sis190: RX ring allocation failed\n");
567 rc = -ENOMEM;
568 goto error;
569 }
570 tp->rx_dma = cpu_to_le32(virt_to_bus(tp->RxDescRing));
571
573 if (rc < 0)
574 goto error;
575
576 /* init rx filter, also program MAC address to card */
578
580out:
581 return rc;
582
583error:
585 goto out;
586}
__be32 out[4]
Definition CIB_PRM.h:8
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
struct arbelprm_completion_with_error error
Definition arbel.h:1
#define RX_RING_BYTES
Definition eepro100.h:22
#define TX_RING_BYTES
Definition eepro100.h:23
void * malloc_phys(size_t size, size_t phys_align)
Allocate memory with specified physical alignment.
Definition malloc.c:707
static int sis190_init_ring(struct net_device *dev)
Definition sis190.c:375
static void sis190_init_rxfilter(struct net_device *dev)
sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize
Definition sis190.c:1019
static void sis190_hw_start(struct net_device *dev)
Definition sis190.c:420
#define RING_ALIGNMENT
Definition sis190.h:45

References cpu_to_le32, DBG, sis190_private::dev, ENOMEM, error, malloc_phys(), out, net_device::priv, rc, RING_ALIGNMENT, RX_RING_BYTES, sis190_free(), sis190_hw_start(), sis190_init_ring(), sis190_init_rxfilter(), tp, TX_RING_BYTES, and virt_to_bus().

◆ sis190_down()

void sis190_down ( struct net_device * dev)
static

Definition at line 588 of file sis190.c.

589{
590 struct sis190_private *tp = dev->priv;
591 void *ioaddr = tp->mmio_addr;
592
593 do {
595 } while (SIS_R32(IntrMask));
596}

References sis190_private::dev, IntrMask, ioaddr, net_device::priv, sis190_asic_down(), SIS_R32, and tp.

Referenced by sis190_close().

◆ sis190_free()

void sis190_free ( struct net_device * dev)
static

Definition at line 598 of file sis190.c.

599{
600 struct sis190_private *tp = dev->priv;
601 int i;
602
603 free_phys(tp->TxDescRing, TX_RING_BYTES);
604 free_phys(tp->RxDescRing, RX_RING_BYTES);
605
606 tp->TxDescRing = NULL;
607 tp->RxDescRing = NULL;
608
609 tp->tx_dma = 0;
610 tp->rx_dma = 0;
611
612 tp->cur_tx = tp->dirty_tx = 0;
613 tp->cur_rx = tp->dirty_rx = 0;
614
615 for (i = 0; i < NUM_RX_DESC; i++) {
616 free_iob(tp->Rx_iobuf[i]);
617 tp->Rx_iobuf[i] = NULL;
618 }
619
620 /* tx io_buffers aren't owned by the driver, so don't free them */
621 for(i = 0; i < NUM_TX_DESC; i++)
622 tp->Tx_iobuf[i] = NULL;
623}
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition iobuf.c:153
void free_phys(void *ptr, size_t size)
Free memory allocated with malloc_phys()
Definition malloc.c:723

References sis190_private::dev, free_iob(), free_phys(), NULL, NUM_RX_DESC, NUM_TX_DESC, net_device::priv, RX_RING_BYTES, tp, and TX_RING_BYTES.

Referenced by sis190_close(), sis190_init_ring(), and sis190_open().

◆ sis190_close()

void sis190_close ( struct net_device * dev)
static

Definition at line 625 of file sis190.c.

626{
627 sis190_down(dev);
628 sis190_free(dev);
629}
static void sis190_down(struct net_device *dev)
Definition sis190.c:588

References sis190_private::dev, sis190_down(), and sis190_free().

◆ sis190_transmit()

int sis190_transmit ( struct net_device * dev,
struct io_buffer * iob )
static

Definition at line 631 of file sis190.c.

632{
633 struct sis190_private *tp = dev->priv;
634 void *ioaddr = tp->mmio_addr;
635 u32 len, entry;
636 struct TxDesc *desc;
637
638 len = iob_len(iob);
639 if (len < ETH_ZLEN) {
640 iob_pad(iob, ETH_ZLEN);
641 len = ETH_ZLEN;
642 }
643
644 entry = tp->cur_tx % NUM_TX_DESC;
645 desc = tp->TxDescRing + entry;
646
647 if (le32_to_cpu(desc->status) & OWNbit) {
648 DBG("sis190: Tx Ring full\n");
649 return -EINVAL;
650 }
651
652 tp->Tx_iobuf[entry] = iob;
653
654 desc->PSize = cpu_to_le32(len);
655 desc->addr = cpu_to_le32(virt_to_bus(iob->data));
656
657 desc->size = cpu_to_le32(len);
658 if (entry == (NUM_TX_DESC - 1))
659 desc->size |= cpu_to_le32(RingEnd);
660
661 wmb();
662
663 desc->status = cpu_to_le32(OWNbit | INTbit | DEFbit | CRCbit | PADbit);
664
665 tp->cur_tx++;
666
667 SIS_W32(TxControl, 0x1a00 | CmdReset | CmdTxEnb);
668
669 return 0;
670}
ring len
Length.
Definition dwmac.h:226
#define ETH_ZLEN
Definition if_ether.h:11
void iob_pad(struct io_buffer *iobuf, size_t min_len)
Pad I/O buffer.
Definition iobpad.c:50
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition iobuf.h:160
@ DEFbit
Definition sis190.h:203
@ CRCbit
Definition sis190.h:171
@ PADbit
Definition sis190.h:172
@ CmdReset
Definition sis190.h:121

References CmdReset, CmdTxEnb, cpu_to_le32, CRCbit, io_buffer::data, DBG, DEFbit, desc, sis190_private::dev, EINVAL, ETH_ZLEN, INTbit, ioaddr, iob_len(), iob_pad(), le32_to_cpu, len, NUM_TX_DESC, OWNbit, PADbit, net_device::priv, RingEnd, SIS_W32, tp, TxControl, u32, virt_to_bus(), and wmb.

◆ sis190_free_phy()

void sis190_free_phy ( struct list_head * first_phy)
static

Definition at line 672 of file sis190.c.

673{
674 struct sis190_phy *cur, *next;
675
676 list_for_each_entry_safe(cur, next, first_phy, list) {
677 free(cur);
678 }
679}
uint32_t next
Next descriptor address.
Definition dwmac.h:11
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition list.h:459
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
struct list_head list
Definition sis190.h:270

References free, sis190_phy::list, list_for_each_entry_safe, and next.

Referenced by sis190_mii_probe(), and sis190_mii_remove().

◆ sis190_default_phy()

u16 sis190_default_phy ( struct sis190_private * tp)
static

sis190_default_phy - Select default PHY for sis190 mac.

@dev: the net device to probe for

Select first detected PHY with link as default. If no one is link on, select PHY whose types is HOME as default. If HOME doesn't exist, select LAN.

Definition at line 689 of file sis190.c.

690{
691 struct sis190_phy *phy, *phy_home, *phy_default, *phy_lan;
692 struct mii_if_info *mii_if = &tp->mii_if;
693 void *ioaddr = tp->mmio_addr;
694 u16 status;
695
696 phy_home = phy_default = phy_lan = NULL;
697
698 list_for_each_entry(phy, &tp->first_phy, list) {
700
701 // Link ON & Not select default PHY & not ghost PHY.
702 if ((status & BMSR_LSTATUS) &&
703 !phy_default &&
704 (phy->type != UNKNOWN)) {
705 phy_default = phy;
706 } else {
710 if (phy->type == HOME)
711 phy_home = phy;
712 else if (phy->type == LAN)
713 phy_lan = phy;
714 }
715 }
716
717 if (!phy_default) {
718 if (phy_home)
719 phy_default = phy_home;
720 else if (phy_lan)
721 phy_default = phy_lan;
722 else
723 phy_default = list_entry(&tp->first_phy,
724 struct sis190_phy, list);
725 }
726
727 if (mii_if->phy_id != phy_default->phy_id) {
728 mii_if->phy_id = phy_default->phy_id;
729 DBG("sis190: Using transceiver at address %d as default.\n",
730 mii_if->phy_id);
731 }
732
735
738
739 return status;
740}
#define list_entry(list, type, member)
Get the container of a list entry.
Definition list.h:322
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
#define BMCR_ANENABLE
Definition mii.h:50
#define BMCR_ISOLATE
Definition mii.h:48
#define BMSR_LSTATUS
Definition mii.h:58
@ UNKNOWN
Definition sis190.h:278
@ HOME
Definition sis190.h:279
@ LAN
Definition sis190.h:280
int phy_id
Definition mii.h:146
int phy_id
Definition sis190.h:271

References BMCR_ANENABLE, BMCR_ISOLATE, BMSR_LSTATUS, DBG, HOME, ioaddr, LAN, list_entry, list_for_each_entry, mdio_read(), mdio_read_latched(), mdio_write(), MII_BMCR, MII_BMSR, NULL, mii_if_info::phy_id, sis190_phy::phy_id, status, tp, sis190_phy::type, u16, and UNKNOWN.

Referenced by sis190_mii_probe().

◆ sis190_init_phy()

void sis190_init_phy ( struct sis190_private * tp,
struct sis190_phy * phy,
unsigned int phy_id,
u16 mii_status )
static

Definition at line 742 of file sis190.c.

745{
746 void *ioaddr = tp->mmio_addr;
747 struct mii_chip_info *p;
748
749 INIT_LIST_HEAD(&phy->list);
750 phy->status = mii_status;
751 phy->phy_id = phy_id;
752
753 phy->id[0] = mdio_read(ioaddr, phy_id, MII_PHYSID1);
754 phy->id[1] = mdio_read(ioaddr, phy_id, MII_PHYSID2);
755
756 for (p = mii_chip_table; p->type; p++) {
757 if ((p->id[0] == phy->id[0]) &&
758 (p->id[1] == (phy->id[1] & 0xfff0))) {
759 break;
760 }
761 }
762
763 if (p->id[1]) {
764 phy->type = (p->type == MIX) ?
765 ((mii_status & (BMSR_100FULL | BMSR_100HALF)) ?
766 LAN : HOME) : p->type;
767 tp->features |= p->feature;
768
769 DBG("sis190: %s transceiver at address %d.\n", p->name, phy_id);
770 } else {
771 phy->type = UNKNOWN;
772
773 DBG("sis190: unknown PHY 0x%x:0x%x transceiver at address %d\n",
774 phy->id[0], (phy->id[1] & 0xfff0), phy_id);
775 }
776}
#define MII_PHYSID2
Definition atl1e.h:874
#define MII_PHYSID1
Definition atl1e.h:873
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition list.h:46
#define BMSR_100HALF
Definition mii.h:68
#define BMSR_100FULL
Definition mii.h:69
static struct mii_chip_info mii_chip_table[]
@ MIX
Definition sis190.h:281
u16 id[2]
Definition sis190.h:286
const char * name
Definition sis190.h:285
unsigned int type
Definition sis190.h:287
u16 status
Definition sis190.h:273
u16 id[2]
Definition sis190.h:272

References BMSR_100FULL, BMSR_100HALF, DBG, mii_chip_info::feature, HOME, mii_chip_info::id, sis190_phy::id, INIT_LIST_HEAD, ioaddr, LAN, sis190_phy::list, mdio_read(), mii_chip_table, MII_PHYSID1, MII_PHYSID2, MIX, mii_chip_info::name, sis190_phy::phy_id, sis190_phy::status, tp, mii_chip_info::type, sis190_phy::type, u16, and UNKNOWN.

Referenced by sis190_mii_probe().

◆ sis190_mii_probe_88e1111_fixup()

void sis190_mii_probe_88e1111_fixup ( struct sis190_private * tp)
static

Definition at line 778 of file sis190.c.

779{
780 if (tp->features & F_PHY_88E1111) {
781 void *ioaddr = tp->mmio_addr;
782 int phy_id = tp->mii_if.phy_id;
783 u16 reg[2][2] = {
784 { 0x808b, 0x0ce1 },
785 { 0x808f, 0x0c60 }
786 }, *p;
787
788 p = (tp->features & F_HAS_RGMII) ? reg[0] : reg[1];
789
790 mdio_write(ioaddr, phy_id, 0x1b, p[0]);
791 udelay(200);
792 mdio_write(ioaddr, phy_id, 0x14, p[1]);
793 udelay(200);
794 }
795}
@ F_PHY_88E1111
Definition sis190.h:246

References F_HAS_RGMII, F_PHY_88E1111, ioaddr, mdio_write(), reg, tp, u16, and udelay().

Referenced by sis190_mii_probe().

◆ sis190_mii_probe()

int sis190_mii_probe ( struct net_device * dev)
static

sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for

Search for total of 32 possible mii phy addresses. Identify and set current phy if found one, return error if it failed to found.

Definition at line 805 of file sis190.c.

806{
807 struct sis190_private *tp = dev->priv;
808 struct mii_if_info *mii_if = &tp->mii_if;
809 void *ioaddr = tp->mmio_addr;
810 int phy_id;
811 int rc = 0;
812
813 INIT_LIST_HEAD(&tp->first_phy);
814
815 for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
816 struct sis190_phy *phy;
817 u16 status;
818
820
821 // Try next mii if the current one is not accessible.
822 if (status == 0xffff || status == 0x0000)
823 continue;
824
825 phy = zalloc(sizeof(*phy));
826 if (!phy) {
827 sis190_free_phy(&tp->first_phy);
828 rc = -ENOMEM;
829 goto out;
830 }
831
832 DBG("sis190: found PHY\n");
833
835
836 list_add(&tp->first_phy, &phy->list);
837 }
838
839 if (list_empty(&tp->first_phy)) {
840 DBG("sis190: No MII transceivers found!\n");
841 rc = -EIO;
842 goto out;
843 }
844
845 /* Select default PHY for mac */
847
849
850 mii_if->dev = dev;
851 mii_if->mdio_read = __mdio_read;
852 mii_if->mdio_write = __mdio_write;
853 mii_if->phy_id_mask = PHY_ID_ANY;
854 mii_if->reg_num_mask = MII_REG_ANY;
855out:
856 return rc;
857}
#define EIO
Input/output error.
Definition errno.h:434
#define list_empty(list)
Test whether a list is empty.
Definition list.h:137
#define list_add(new, head)
Add a new entry to the head of a list.
Definition list.h:70
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static void sis190_mii_probe_88e1111_fixup(struct sis190_private *tp)
Definition sis190.c:778
static void __mdio_write(struct net_device *dev, int phy_id, int reg, int val)
Definition sis190.c:108
static void sis190_init_phy(struct sis190_private *tp, struct sis190_phy *phy, unsigned int phy_id, u16 mii_status)
Definition sis190.c:742
static int __mdio_read(struct net_device *dev, int phy_id, int reg)
Definition sis190.c:115
static void sis190_free_phy(struct list_head *first_phy)
Definition sis190.c:672
static u16 sis190_default_phy(struct sis190_private *tp)
sis190_default_phy - Select default PHY for sis190 mac.
Definition sis190.c:689
#define PHY_MAX_ADDR
Definition sis190.h:27
#define MII_REG_ANY
Definition sis190.h:29
#define PHY_ID_ANY
Definition sis190.h:28
int reg_num_mask
Definition mii.h:149
int phy_id_mask
Definition mii.h:148
int(* mdio_read)(struct net_device *dev, int phy_id, int location)
Definition mii.h:156
struct net_device * dev
Definition mii.h:155
void(* mdio_write)(struct net_device *dev, int phy_id, int location, int val)
Definition mii.h:157

References __mdio_read(), __mdio_write(), DBG, mii_if_info::dev, sis190_private::dev, EIO, ENOMEM, INIT_LIST_HEAD, ioaddr, sis190_phy::list, list_add, list_empty, mii_if_info::mdio_read, mdio_read_latched(), mii_if_info::mdio_write, MII_BMSR, MII_REG_ANY, out, mii_if_info::phy_id, sis190_phy::phy_id, PHY_ID_ANY, mii_if_info::phy_id_mask, PHY_MAX_ADDR, net_device::priv, rc, mii_if_info::reg_num_mask, sis190_default_phy(), sis190_free_phy(), sis190_init_phy(), sis190_mii_probe_88e1111_fixup(), status, tp, u16, and zalloc().

Referenced by sis190_probe().

◆ sis190_mii_remove()

void sis190_mii_remove ( struct net_device * dev)
static

Definition at line 859 of file sis190.c.

860{
861 struct sis190_private *tp = dev->priv;
862
863 sis190_free_phy(&tp->first_phy);
864}

References sis190_private::dev, net_device::priv, sis190_free_phy(), and tp.

Referenced by sis190_probe(), and sis190_remove().

◆ sis190_init_board()

int sis190_init_board ( struct pci_device * pdev,
struct net_device ** netdev )
static

Definition at line 866 of file sis190.c.

867{
868 struct sis190_private *tp;
869 struct net_device *dev;
870 void *ioaddr;
871 int rc;
872
873 dev = alloc_etherdev(sizeof(*tp));
874 if (!dev) {
875 DBG("sis190: unable to alloc new etherdev\n");
876 rc = -ENOMEM;
877 goto err;
878 }
879
880 dev->dev = &pdev->dev;
881
882 tp = dev->priv;
883 memset(tp, 0, sizeof(*tp));
884
885 tp->dev = dev;
886
887 adjust_pci_device(pdev);
888
890 if (!ioaddr) {
891 DBG("sis190: cannot remap MMIO, aborting\n");
892 rc = -EIO;
893 goto err;
894 }
895
896 tp->pci_device = pdev;
897 tp->mmio_addr = ioaddr;
898
900
902
903 *netdev = dev;
904
905 return 0;
906
907err:
908 return rc;
909}
struct net_device * alloc_etherdev(size_t priv_size)
Allocate Ethernet device.
Definition ethernet.c:265
static struct net_device * netdev
Definition gdbudp.c:53
void * pci_ioremap(struct pci_device *pci, unsigned long bus_addr, size_t len)
Map PCI bus address as an I/O address.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
#define SIS190_REGS_SIZE
Definition sis190.h:47
unsigned long membase
Memory base.
Definition pci.h:220
struct device dev
Generic device.
Definition pci.h:213

References adjust_pci_device(), alloc_etherdev(), DBG, net_device::dev, pci_device::dev, EIO, ENOMEM, ioaddr, pci_device::membase, memset(), netdev, pci_ioremap(), rc, sis190_irq_mask_and_ack(), SIS190_REGS_SIZE, sis190_soft_reset(), and tp.

Referenced by sis190_probe().

◆ sis190_set_rgmii()

void sis190_set_rgmii ( struct sis190_private * tp,
u8 reg )
static

Definition at line 911 of file sis190.c.

912{
913 tp->features |= (reg & 0x80) ? F_HAS_RGMII : 0;
914}

References F_HAS_RGMII, reg, tp, and u8.

Referenced by sis190_get_mac_addr_from_apc(), and sis190_get_mac_addr_from_eeprom().

◆ sis190_get_mac_addr_from_eeprom()

int sis190_get_mac_addr_from_eeprom ( struct pci_device *pdev __unused,
struct net_device * dev )
static

Definition at line 916 of file sis190.c.

918{
919 struct sis190_private *tp = dev->priv;
920 void *ioaddr = tp->mmio_addr;
921 u16 sig;
922 int i;
923
924 DBG("sis190: Read MAC address from EEPROM\n");
925
926 /* Check to see if there is a sane EEPROM */
928
929 if ((sig == 0xffff) || (sig == 0x0000)) {
930 DBG("sis190: Error EEPROM read.\n");
931 return -EIO;
932 }
933
934 /* Get MAC address from EEPROM */
935 for (i = 0; i < ETH_ALEN / 2; i++) {
937
938 ((u16 *)dev->hw_addr)[i] = cpu_to_le16(w);
939 }
940
942
943 return 0;
944}
u8 sig
Definition CIB_PRM.h:15
#define ETH_ALEN
Definition if_ether.h:9
#define cpu_to_le16(value)
Definition byteswap.h:107
static u16 sis190_read_eeprom(void *ioaddr, u32 reg)
Definition sis190.c:128
static void sis190_set_rgmii(struct sis190_private *tp, u8 reg)
Definition sis190.c:911
@ EEPROMInfo
Definition sis190.h:240
@ EEPROMMACAddr
Definition sis190.h:241
@ EEPROMSignature
Definition sis190.h:238
uint8_t hw_addr[MAX_HW_ADDR_LEN]
Hardware address.
Definition netdevice.h:382

References __unused, cpu_to_le16, DBG, sis190_private::dev, EEPROMInfo, EEPROMMACAddr, EEPROMSignature, EIO, ETH_ALEN, net_device::hw_addr, ioaddr, net_device::priv, sig, sis190_read_eeprom(), sis190_set_rgmii(), tp, and u16.

Referenced by sis190_get_mac_addr().

◆ sis190_get_mac_addr_from_apc()

int sis190_get_mac_addr_from_apc ( struct pci_device * pdev,
struct net_device * dev )
static

sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network device to get address for

SiS96x model, use APC CMOS RAM to store MAC address. APC CMOS RAM is accessed through ISA bridge. MAC address is read into @net_dev->dev_addr.

Definition at line 955 of file sis190.c.

957{
958 struct sis190_private *tp = dev->priv;
959 struct pci_device *isa_bridge = NULL;
960 struct device *d;
961 u8 reg, tmp8;
962 unsigned int i;
963
964 DBG("sis190: Read MAC address from APC.\n");
965
967 unsigned int i;
968 for(i = 0; i < sis190_isa_bridge_driver.id_count; i++) {
969 isa_bridge = container_of(d, struct pci_device, dev);
970 if(isa_bridge->vendor ==
971 sis190_isa_bridge_driver.ids[i].vendor
972 && isa_bridge->device ==
973 sis190_isa_bridge_driver.ids[i].device) {
974 DBG("sis190: ISA bridge found\n");
975 break;
976 } else {
977 isa_bridge = NULL;
978 }
979 }
980 if(isa_bridge)
981 break;
982 }
983
984 if (!isa_bridge) {
985 DBG("sis190: Can not find ISA bridge.\n");
986 return -EIO;
987 }
988
989 /* Enable port 78h & 79h to access APC Registers. */
990 pci_read_config_byte(isa_bridge, 0x48, &tmp8);
991 reg = (tmp8 & ~0x02);
992 pci_write_config_byte(isa_bridge, 0x48, reg);
993 udelay(50);
994 pci_read_config_byte(isa_bridge, 0x48, &reg);
995
996 for (i = 0; i < ETH_ALEN; i++) {
997 outb(0x9 + i, 0x78);
998 dev->hw_addr[i] = inb(0x79);
999 }
1000
1001 outb(0x12, 0x78);
1002 reg = inb(0x79);
1003
1005
1006 /* Restore the value to ISA Bridge */
1007 pci_write_config_byte(isa_bridge, 0x48, tmp8);
1008
1009 return 0;
1010}
#define u8
Definition igbvf_osdep.h:40
#define outb(data, io_addr)
Definition io.h:310
#define inb(io_addr)
Definition io.h:283
int pci_write_config_byte(struct pci_device *pci, unsigned int where, uint8_t value)
Write byte to PCI configuration space.
int pci_read_config_byte(struct pci_device *pci, unsigned int where, uint8_t *value)
Read byte from PCI configuration space.
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
A hardware device.
Definition device.h:77
struct list_head siblings
Devices on the same bus.
Definition device.h:85
A PCI device.
Definition pci.h:211
uint16_t vendor
Vendor ID.
Definition pci.h:228
uint16_t device
Device ID.
Definition pci.h:230

References container_of, DBG, pci_device::dev, sis190_private::dev, pci_device::device, EIO, ETH_ALEN, net_device::hw_addr, inb, list_for_each_entry, NULL, outb, pci_read_config_byte(), pci_write_config_byte(), net_device::priv, reg, device::siblings, sis190_set_rgmii(), tp, u8, udelay(), and pci_device::vendor.

Referenced by sis190_get_mac_addr().

◆ sis190_init_rxfilter()

void sis190_init_rxfilter ( struct net_device * dev)
inlinestatic

sis190_init_rxfilter - Initialize the Rx filter @dev: network device to initialize

Set receive filter address to our MAC address and enable packet filtering.

Definition at line 1019 of file sis190.c.

1020{
1021 struct sis190_private *tp = dev->priv;
1022 void *ioaddr = tp->mmio_addr;
1023 u16 ctl;
1024 int i;
1025
1026 ctl = SIS_R16(RxMacControl);
1027 /*
1028 * Disable packet filtering before setting filter.
1029 * Note: SiS's driver writes 32 bits but RxMacControl is 16 bits
1030 * only and followed by RxMacAddr (6 bytes). Strange. -- FR
1031 */
1032 SIS_W16(RxMacControl, ctl & ~0x0f00);
1033
1034 for (i = 0; i < ETH_ALEN; i++)
1035 SIS_W8(RxMacAddr + i, dev->ll_addr[i]);
1036
1037 SIS_W16(RxMacControl, ctl);
1039}
#define SIS_W8(reg, val)
Definition sis190.h:59
@ RxMacAddr
Definition sis190.h:94
#define SIS_R16(reg)
Definition sis190.h:63
uint8_t ll_addr[MAX_LL_ADDR_LEN]
Link-layer address.
Definition netdevice.h:388

References sis190_private::dev, ETH_ALEN, ioaddr, net_device::ll_addr, net_device::priv, RxMacAddr, RxMacControl, SIS_PCI_COMMIT, SIS_R16, SIS_W16, SIS_W8, tp, and u16.

Referenced by sis190_open().

◆ sis190_get_mac_addr()

int sis190_get_mac_addr ( struct pci_device * pdev,
struct net_device * dev )
static

Definition at line 1041 of file sis190.c.

1043{
1044 int rc;
1045
1047 if (rc < 0) {
1048 u8 reg;
1049
1050 pci_read_config_byte(pdev, 0x73, &reg);
1051
1052 if (reg & 0x00000001)
1053 rc = sis190_get_mac_addr_from_apc(pdev, dev);
1054 }
1055 return rc;
1056}
static int sis190_get_mac_addr_from_eeprom(struct pci_device *pdev __unused, struct net_device *dev)
Definition sis190.c:916
static int sis190_get_mac_addr_from_apc(struct pci_device *pdev, struct net_device *dev)
sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model @pdev: PCI device @dev: network devic...
Definition sis190.c:955

References sis190_private::dev, pci_read_config_byte(), rc, reg, sis190_get_mac_addr_from_apc(), sis190_get_mac_addr_from_eeprom(), and u8.

Referenced by sis190_probe().

◆ sis190_set_speed_auto()

void sis190_set_speed_auto ( struct net_device * dev)
static

Definition at line 1058 of file sis190.c.

1059{
1060 struct sis190_private *tp = dev->priv;
1061 void *ioaddr = tp->mmio_addr;
1062 int phy_id = tp->mii_if.phy_id;
1063 int val;
1064
1065 DBG("sis190: Enabling Auto-negotiation.\n");
1066
1067 val = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
1068
1069 // Enable 10/100 Full/Half Mode, leave MII_ADVERTISE bit4:0
1070 // unchanged.
1074
1075 // Enable 1000 Full Mode.
1077
1078 // Enable auto-negotiation and restart auto-negotiation.
1079 mdio_write(ioaddr, phy_id, MII_BMCR,
1081}
#define ADVERTISE_10HALF
Definition mii.h:75
#define ADVERTISE_100FULL
Definition mii.h:81
#define ADVERTISE_SLCT
Definition mii.h:73
#define BMCR_ANRESTART
Definition mii.h:47
#define ADVERTISE_10FULL
Definition mii.h:77
#define ADVERTISE_100HALF
Definition mii.h:79

References ADVERTISE_1000FULL, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISE_SLCT, BMCR_ANENABLE, BMCR_ANRESTART, BMCR_RESET, DBG, sis190_private::dev, ioaddr, mdio_read(), mdio_write(), MII_ADVERTISE, MII_BMCR, MII_CTRL1000, net_device::priv, tp, and val.

Referenced by sis190_probe().

◆ sis190_irq()

void sis190_irq ( struct net_device * dev,
int enable )
static

Definition at line 1083 of file sis190.c.

1084{
1085 struct sis190_private *tp = dev->priv;
1086 void *ioaddr = tp->mmio_addr;
1087
1088 SIS_W32(IntrStatus, 0xffffffff);
1089
1090 if (enable == 0)
1091 SIS_W32(IntrMask, 0x00);
1092 else
1094
1096}
static const u32 sis190_intr_mask
Definition sis190.c:72

References sis190_private::dev, IntrMask, IntrStatus, ioaddr, net_device::priv, sis190_intr_mask, SIS_PCI_COMMIT, SIS_W32, and tp.

◆ sis190_probe()

int sis190_probe ( struct pci_device * pdev)
static

Definition at line 1106 of file sis190.c.

1107{
1108 struct sis190_private *tp;
1109 struct net_device *dev;
1110 int rc;
1111
1112 rc = sis190_init_board(pdev, &dev);
1113 if (rc < 0)
1114 goto out;
1116
1117 pci_set_drvdata(pdev, dev);
1118
1119 tp = dev->priv;
1120
1121 rc = sis190_get_mac_addr(pdev, dev);
1122 if (rc < 0)
1123 goto err;
1124
1126 if (rc < 0)
1127 goto err;
1128
1130 if (rc < 0)
1131 goto err;
1132
1135
1136out:
1137 return rc;
1138
1139err:
1141 iounmap(tp->mmio_addr);
1142 goto out;
1143}
void iounmap(volatile const void *io_addr)
Unmap I/O address.
int register_netdev(struct net_device *netdev)
Register network device.
Definition netdevice.c:760
static void netdev_init(struct net_device *netdev, struct net_device_operations *op)
Initialise a network device.
Definition netdevice.h:519
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
Definition pci.h:366
static int sis190_init_board(struct pci_device *pdev, struct net_device **netdev)
Definition sis190.c:866
static int sis190_mii_probe(struct net_device *dev)
sis190_mii_probe - Probe MII PHY for sis190 @dev: the net device to probe for
Definition sis190.c:805
static int sis190_get_mac_addr(struct pci_device *pdev, struct net_device *dev)
Definition sis190.c:1041
static void sis190_set_speed_auto(struct net_device *dev)
Definition sis190.c:1058
static struct net_device_operations sis190_netdev_ops
Definition sis190.c:1098
static void sis190_mii_remove(struct net_device *dev)
Definition sis190.c:859

References net_device::dev, iounmap(), netdev_init(), out, pci_set_drvdata(), rc, register_netdev(), sis190_get_mac_addr(), sis190_init_board(), sis190_mii_probe(), sis190_mii_remove(), sis190_netdev_ops, sis190_phy_task(), sis190_set_speed_auto(), and tp.

◆ sis190_remove()

void sis190_remove ( struct pci_device * pdev)
static

Definition at line 1145 of file sis190.c.

1146{
1147 struct net_device *dev = pci_get_drvdata(pdev);
1148 struct sis190_private *tp = dev->priv;
1149 void *ioaddr = tp->mmio_addr;
1150
1152
1153 /* shutdown chip, disable interrupts, etc */
1155
1156 iounmap(tp->mmio_addr);
1157
1160 netdev_put(dev);
1161}
void unregister_netdev(struct net_device *netdev)
Unregister network device.
Definition netdevice.c:942
static void netdev_nullify(struct net_device *netdev)
Stop using a network device.
Definition netdevice.h:532
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
Definition pci.h:376

References net_device::dev, sis190_private::dev, ioaddr, iounmap(), netdev_nullify(), netdev_put(), pci_get_drvdata(), net_device::priv, sis190_mii_remove(), sis190_soft_reset(), tp, and unregister_netdev().

Variable Documentation

◆ sis190_pci_tbl

struct pci_device_id sis190_pci_tbl[]
static
Initial value:
= {
PCI_ROM (0x1039, 0x0190, "sis190", "sis190", 0),
PCI_ROM (0x1039, 0x0191, "sis191", "sis191", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

Definition at line 28 of file sis190.c.

28 {
29 PCI_ROM (0x1039, 0x0190, "sis190", "sis190", 0),
30 PCI_ROM (0x1039, 0x0191, "sis191", "sis191", 0),
31};

◆ sis190_isa_bridge_tbl

struct pci_device_id sis190_isa_bridge_tbl[]
static
Initial value:
= {
PCI_ID (0x1039, 0x0965, "", "", 0),
PCI_ID (0x1039, 0x0966, "", "", 0),
PCI_ID (0x1039, 0x0968, "", "", 0),
}
#define PCI_ID(_vendor, _device, _name, _description, _data)
Definition pci.h:302

Definition at line 44 of file sis190.c.

44 {
45 PCI_ID (0x1039, 0x0965, "", "", 0),
46 PCI_ID (0x1039, 0x0966, "", "", 0),
47 PCI_ID (0x1039, 0x0968, "", "", 0),
48};

◆ __pci_driver

struct pci_driver sis190_pci_driver __pci_driver
Initial value:
= {
.id_count = (sizeof(sis190_isa_bridge_tbl) /
sizeof(sis190_isa_bridge_tbl[0])),
}
static void sis190_isa_bridge_remove(struct pci_device *pdev __unused)
Definition sis190.c:55
static struct pci_device_id sis190_isa_bridge_tbl[]
Definition sis190.c:44
static int sis190_isa_bridge_probe(struct pci_device *pdev __unused)
Definition sis190.c:50
static struct xen_remove_from_physmap * remove
Definition xenmem.h:39

Definition at line 60 of file sis190.c.

60 {
62 .id_count = (sizeof(sis190_isa_bridge_tbl) /
63 sizeof(sis190_isa_bridge_tbl[0])),
66};

◆ sis190_intr_mask

const u32 sis190_intr_mask
static
Initial value:
=
@ RxHalt
Definition sis190.h:117
@ TxHalt
Definition sis190.h:118
@ TxQ1Int
Definition sis190.h:114
@ RxQEmpty
Definition sis190.h:111

Definition at line 72 of file sis190.c.

Referenced by sis190_irq().

◆ sis190_netdev_ops

struct net_device_operations sis190_netdev_ops
static
Initial value:
= {
.open = sis190_open,
.close = sis190_close,
.poll = sis190_poll,
.transmit = sis190_transmit,
.irq = sis190_irq,
}
static int sis190_transmit(struct net_device *dev, struct io_buffer *iob)
Definition sis190.c:631
static void sis190_poll(struct net_device *dev)
Definition sis190.c:344
static void sis190_close(struct net_device *dev)
Definition sis190.c:625
static void sis190_irq(struct net_device *dev, int enable)
Definition sis190.c:1083
static int sis190_open(struct net_device *dev)
Definition sis190.c:549

Definition at line 1098 of file sis190.c.

1098 {
1099 .open = sis190_open,
1100 .close = sis190_close,
1101 .poll = sis190_poll,
1102 .transmit = sis190_transmit,
1103 .irq = sis190_irq,
1104};

Referenced by sis190_probe().