Lines Matching refs:priv

118 static u32 dc2114x_inl(struct dc2114x_priv *priv, u32 addr)  in dc2114x_inl()  argument
120 return le32_to_cpu(readl(priv->iobase + addr)); in dc2114x_inl()
123 static void dc2114x_outl(struct dc2114x_priv *priv, u32 command, u32 addr) in dc2114x_outl() argument
125 writel(cpu_to_le32(command), priv->iobase + addr); in dc2114x_outl()
128 static void reset_de4x5(struct dc2114x_priv *priv) in reset_de4x5() argument
132 i = dc2114x_inl(priv, DE4X5_BMR); in reset_de4x5()
134 dc2114x_outl(priv, i | BMR_SWR, DE4X5_BMR); in reset_de4x5()
136 dc2114x_outl(priv, i, DE4X5_BMR); in reset_de4x5()
140 dc2114x_inl(priv, DE4X5_BMR); in reset_de4x5()
147 static void start_de4x5(struct dc2114x_priv *priv) in start_de4x5() argument
151 omr = dc2114x_inl(priv, DE4X5_OMR); in start_de4x5()
153 dc2114x_outl(priv, omr, DE4X5_OMR); /* Enable the TX and/or RX */ in start_de4x5()
156 static void stop_de4x5(struct dc2114x_priv *priv) in stop_de4x5() argument
160 omr = dc2114x_inl(priv, DE4X5_OMR); in stop_de4x5()
162 dc2114x_outl(priv, omr, DE4X5_OMR); /* Disable the TX and/or RX */ in stop_de4x5()
166 static void sendto_srom(struct dc2114x_priv *priv, u_int command, u_long addr) in sendto_srom() argument
168 dc2114x_outl(priv, command, addr); in sendto_srom()
172 static int getfrom_srom(struct dc2114x_priv *priv, u_long addr) in getfrom_srom() argument
174 u32 tmp = dc2114x_inl(priv, addr); in getfrom_srom()
181 static int do_read_eeprom(struct dc2114x_priv *priv, u_long ioaddr, int location, in do_read_eeprom() argument
188 sendto_srom(priv, SROM_RD | SROM_SR, ioaddr); in do_read_eeprom()
189 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
197 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS | dataval, in do_read_eeprom()
200 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS | dataval | DT_CLK, in do_read_eeprom()
204 getfrom_srom(priv, ioaddr) & 15); in do_read_eeprom()
206 !!(getfrom_srom(priv, ioaddr) & EE_DATA_READ); in do_read_eeprom()
209 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
211 debug_cond(SROM_DLEVEL >= 2, " :%X:", getfrom_srom(priv, ioaddr) & 15); in do_read_eeprom()
214 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS | DT_CLK, ioaddr); in do_read_eeprom()
217 getfrom_srom(priv, ioaddr) & 15); in do_read_eeprom()
219 !!(getfrom_srom(priv, ioaddr) & EE_DATA_READ); in do_read_eeprom()
220 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_read_eeprom()
225 sendto_srom(priv, SROM_RD | SROM_SR, ioaddr); in do_read_eeprom()
238 static int do_eeprom_cmd(struct dc2114x_priv *priv, u_long ioaddr, int cmd, in do_eeprom_cmd() argument
245 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS | DT_CLK, ioaddr); in do_eeprom_cmd()
251 sendto_srom(priv, dataval, ioaddr); in do_eeprom_cmd()
255 getfrom_srom(priv, ioaddr) & 15); in do_eeprom_cmd()
257 sendto_srom(priv, dataval | DT_CLK, ioaddr); in do_eeprom_cmd()
260 !!(getfrom_srom(priv, ioaddr) & EE_DATA_READ); in do_eeprom_cmd()
263 sendto_srom(priv, SROM_RD | SROM_SR | DT_CS, ioaddr); in do_eeprom_cmd()
266 sendto_srom(priv, SROM_RD | SROM_SR, ioaddr); in do_eeprom_cmd()
273 static int read_srom(struct dc2114x_priv *priv, u_long ioaddr, int index) in read_srom() argument
277 ee_addr_size = (do_read_eeprom(priv, ioaddr, 0xff, 8) & BIT(18)) ? 8 : 6; in read_srom()
279 return do_eeprom_cmd(priv, ioaddr, 0xffff | in read_srom()
284 static void send_setup_frame(struct dc2114x_priv *priv) in send_setup_frame() argument
293 *(pa + (i & 1)) = priv->enetaddr[i]; in send_setup_frame()
298 for (i = 0; priv->tx_ring[priv->tx_new].status & cpu_to_le32(T_OWN); i++) { in send_setup_frame()
302 printf("%s: tx error buffer not ready\n", priv->name); in send_setup_frame()
306 priv->tx_ring[priv->tx_new].buf = cpu_to_le32(phys_to_bus(priv->devno, in send_setup_frame()
308 priv->tx_ring[priv->tx_new].des1 = cpu_to_le32(TD_TER | TD_SET | SETUP_FRAME_LEN); in send_setup_frame()
309 priv->tx_ring[priv->tx_new].status = cpu_to_le32(T_OWN); in send_setup_frame()
311 dc2114x_outl(priv, POLL_DEMAND, DE4X5_TPD); in send_setup_frame()
313 for (i = 0; priv->tx_ring[priv->tx_new].status & cpu_to_le32(T_OWN); i++) { in send_setup_frame()
317 printf("%s: tx buffer not ready\n", priv->name); in send_setup_frame()
321 if (le32_to_cpu(priv->tx_ring[priv->tx_new].status) != 0x7FFFFFFF) { in send_setup_frame()
323 le32_to_cpu(priv->tx_ring[priv->tx_new].status)); in send_setup_frame()
326 priv->tx_new = (priv->tx_new + 1) % NUM_TX_DESC; in send_setup_frame()
329 static int dc21x4x_send_common(struct dc2114x_priv *priv, void *packet, int length) in dc21x4x_send_common() argument
335 printf("%s: bad packet size: %d\n", priv->name, length); in dc21x4x_send_common()
339 for (i = 0; priv->tx_ring[priv->tx_new].status & cpu_to_le32(T_OWN); i++) { in dc21x4x_send_common()
343 printf("%s: tx error buffer not ready\n", priv->name); in dc21x4x_send_common()
347 priv->tx_ring[priv->tx_new].buf = cpu_to_le32(phys_to_bus(priv->devno, in dc21x4x_send_common()
349 priv->tx_ring[priv->tx_new].des1 = cpu_to_le32(TD_TER | TD_LS | TD_FS | length); in dc21x4x_send_common()
350 priv->tx_ring[priv->tx_new].status = cpu_to_le32(T_OWN); in dc21x4x_send_common()
352 dc2114x_outl(priv, POLL_DEMAND, DE4X5_TPD); in dc21x4x_send_common()
354 for (i = 0; priv->tx_ring[priv->tx_new].status & cpu_to_le32(T_OWN); i++) { in dc21x4x_send_common()
358 printf(".%s: tx buffer not ready\n", priv->name); in dc21x4x_send_common()
362 if (le32_to_cpu(priv->tx_ring[priv->tx_new].status) & TD_ES) { in dc21x4x_send_common()
363 priv->tx_ring[priv->tx_new].status = 0x0; in dc21x4x_send_common()
370 priv->tx_new = (priv->tx_new + 1) % NUM_TX_DESC; in dc21x4x_send_common()
374 static int dc21x4x_recv_check(struct dc2114x_priv *priv) in dc21x4x_recv_check() argument
379 status = le32_to_cpu(priv->rx_ring[priv->rx_new].status); in dc21x4x_recv_check()
392 length = (le32_to_cpu(priv->rx_ring[priv->rx_new].status) in dc21x4x_recv_check()
402 static int dc21x4x_init_common(struct dc2114x_priv *priv) in dc21x4x_init_common() argument
406 reset_de4x5(priv); in dc21x4x_init_common()
408 if (dc2114x_inl(priv, DE4X5_STS) & (STS_TS | STS_RS)) { in dc21x4x_init_common()
413 dc2114x_outl(priv, OMR_SDP | OMR_PS | OMR_PM, DE4X5_OMR); in dc21x4x_init_common()
416 priv->rx_ring[i].status = cpu_to_le32(R_OWN); in dc21x4x_init_common()
417 priv->rx_ring[i].des1 = cpu_to_le32(RX_BUFF_SZ); in dc21x4x_init_common()
418 priv->rx_ring[i].buf = cpu_to_le32(phys_to_bus(priv->devno, in dc21x4x_init_common()
420 priv->rx_ring[i].next = 0; in dc21x4x_init_common()
424 priv->tx_ring[i].status = 0; in dc21x4x_init_common()
425 priv->tx_ring[i].des1 = 0; in dc21x4x_init_common()
426 priv->tx_ring[i].buf = 0; in dc21x4x_init_common()
427 priv->tx_ring[i].next = 0; in dc21x4x_init_common()
430 priv->rx_ring_size = NUM_RX_DESC; in dc21x4x_init_common()
431 priv->tx_ring_size = NUM_TX_DESC; in dc21x4x_init_common()
434 priv->rx_ring[priv->rx_ring_size - 1].des1 |= cpu_to_le32(RD_RER); in dc21x4x_init_common()
435 priv->tx_ring[priv->tx_ring_size - 1].des1 |= cpu_to_le32(TD_TER); in dc21x4x_init_common()
438 dc2114x_outl(priv, phys_to_bus(priv->devno, (u32)&priv->rx_ring), in dc21x4x_init_common()
440 dc2114x_outl(priv, phys_to_bus(priv->devno, (u32)&priv->tx_ring), in dc21x4x_init_common()
443 start_de4x5(priv); in dc21x4x_init_common()
445 priv->tx_new = 0; in dc21x4x_init_common()
446 priv->rx_new = 0; in dc21x4x_init_common()
448 send_setup_frame(priv); in dc21x4x_init_common()
453 static void dc21x4x_halt_common(struct dc2114x_priv *priv) in dc21x4x_halt_common() argument
455 stop_de4x5(priv); in dc21x4x_halt_common()
456 dc2114x_outl(priv, 0, DE4X5_SICR); in dc21x4x_halt_common()
459 static void read_hw_addr(struct dc2114x_priv *priv) in read_hw_addr() argument
461 u_short tmp, *p = (u_short *)(&priv->enetaddr[0]); in read_hw_addr()
465 tmp = read_srom(priv, DE4X5_APROM, (SROM_HWADD >> 1) + i); in read_hw_addr()
471 memset(priv->enetaddr, 0, ETH_ALEN); in read_hw_addr()
485 struct dc2114x_priv *priv = in dc21x4x_init() local
489 pci_write_config_byte(priv->devno, PCI_CFDA_PSM, WAKEUP); in dc21x4x_init()
491 return dc21x4x_init_common(priv); in dc21x4x_init()
496 struct dc2114x_priv *priv = in dc21x4x_halt() local
499 dc21x4x_halt_common(priv); in dc21x4x_halt()
501 pci_write_config_byte(priv->devno, PCI_CFDA_PSM, SLEEP); in dc21x4x_halt()
506 struct dc2114x_priv *priv = in dc21x4x_send() local
509 return dc21x4x_send_common(priv, packet, length); in dc21x4x_send()
514 struct dc2114x_priv *priv = in dc21x4x_recv() local
520 ret = dc21x4x_recv_check(priv); in dc21x4x_recv()
528 (net_rx_packets[priv->rx_new], length - 4); in dc21x4x_recv()
536 priv->rx_ring[priv->rx_new].status = cpu_to_le32(R_OWN); in dc21x4x_recv()
539 priv->rx_new = (priv->rx_new + 1) % priv->rx_ring_size; in dc21x4x_recv()
547 struct dc2114x_priv *priv; in dc21x4x_initialize() local
589 priv = memalign(32, sizeof(*priv)); in dc21x4x_initialize()
590 if (!priv) { in dc21x4x_initialize()
594 memset(priv, 0, sizeof(*priv)); in dc21x4x_initialize()
596 dev = &priv->dev; in dc21x4x_initialize()
599 priv->devno = devbusfn; in dc21x4x_initialize()
600 priv->name = dev->name; in dc21x4x_initialize()
601 priv->enetaddr = dev->enetaddr; in dc21x4x_initialize()
604 dev->priv = (void *)devbusfn; in dc21x4x_initialize()
615 read_hw_addr(priv); in dc21x4x_initialize()
629 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_start() local
631 memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr)); in dc2114x_start()
636 return dc21x4x_init_common(priv); in dc2114x_start()
641 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_stop() local
643 dc21x4x_halt_common(priv); in dc2114x_stop()
650 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_send() local
653 ret = dc21x4x_send_common(priv, packet, length); in dc2114x_send()
660 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_recv() local
663 ret = dc21x4x_recv_check(priv); in dc2114x_recv()
667 priv->rx_new = (priv->rx_new + 1) % priv->rx_ring_size; in dc2114x_recv()
674 *packetp = net_rx_packets[priv->rx_new]; in dc2114x_recv()
681 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_free_pkt() local
683 priv->rx_ring[priv->rx_new].status = cpu_to_le32(R_OWN); in dc2114x_free_pkt()
686 priv->rx_new = (priv->rx_new + 1) % priv->rx_ring_size; in dc2114x_free_pkt()
693 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_read_rom_hwaddr() local
695 read_hw_addr(priv); in dc2114x_read_rom_hwaddr()
713 struct dc2114x_priv *priv = dev_get_priv(dev); in dc2114x_probe() local
722 priv->devno = dev; in dc2114x_probe()
723 priv->enetaddr = plat->enetaddr; in dc2114x_probe()
724 priv->iobase = (void __iomem *)dm_pci_mem_to_phys(dev, iobase); in dc2114x_probe()