Lines Matching refs:dev

105 static u8 ks_rdreg8(struct eth_device *dev, u16 offset)  in ks_rdreg8()  argument
110 writew(offset | (BE0 << shift_bit), dev->iobase + 2); in ks_rdreg8()
112 return (u8)(readw(dev->iobase) >> shift_data); in ks_rdreg8()
115 static u16 ks_rdreg16(struct eth_device *dev, u16 offset) in ks_rdreg16() argument
117 writew(offset | ((BE1 | BE0) << (offset & 0x02)), dev->iobase + 2); in ks_rdreg16()
119 return readw(dev->iobase); in ks_rdreg16()
122 static void ks_wrreg8(struct eth_device *dev, u16 offset, u8 val) in ks_wrreg8() argument
127 writew(offset | (BE0 << shift_bit), dev->iobase + 2); in ks_wrreg8()
128 writew(value_write, dev->iobase); in ks_wrreg8()
131 static void ks_wrreg16(struct eth_device *dev, u16 offset, u16 val) in ks_wrreg16() argument
133 writew(offset | ((BE1 | BE0) << (offset & 0x02)), dev->iobase + 2); in ks_wrreg16()
134 writew(val, dev->iobase); in ks_wrreg16()
144 static inline void ks_inblk(struct eth_device *dev, u16 *wptr, u32 len) in ks_inblk() argument
149 *wptr++ = readw(dev->iobase); in ks_inblk()
158 static inline void ks_outblk(struct eth_device *dev, u16 *wptr, u32 len) in ks_outblk() argument
163 writew(*wptr++, dev->iobase); in ks_outblk()
166 static void ks_enable_int(struct eth_device *dev) in ks_enable_int() argument
168 ks_wrreg16(dev, KS_IER, ks->rc_ier); in ks_enable_int()
171 static void ks_set_powermode(struct eth_device *dev, unsigned pwrmode) in ks_set_powermode() argument
175 ks_rdreg16(dev, KS_GRR); in ks_set_powermode()
176 pmecr = ks_rdreg16(dev, KS_PMECR); in ks_set_powermode()
180 ks_wrreg16(dev, KS_PMECR, pmecr); in ks_set_powermode()
187 static void ks_read_config(struct eth_device *dev) in ks_read_config() argument
192 reg_data = ks_rdreg8(dev, KS_CCR) & 0x00FF; in ks_read_config()
193 reg_data |= ks_rdreg8(dev, KS_CCR + 1) << 8; in ks_read_config()
227 static void ks_soft_reset(struct eth_device *dev, unsigned op) in ks_soft_reset() argument
230 ks_wrreg16(dev, KS_IER, 0x0000); in ks_soft_reset()
231 ks_wrreg16(dev, KS_GRR, op); in ks_soft_reset()
233 ks_wrreg16(dev, KS_GRR, 0); in ks_soft_reset()
237 void ks_enable_qmu(struct eth_device *dev) in ks_enable_qmu() argument
241 w = ks_rdreg16(dev, KS_TXCR); in ks_enable_qmu()
244 ks_wrreg16(dev, KS_TXCR, w | TXCR_TXE); in ks_enable_qmu()
247 w = ks_rdreg16(dev, KS_RXQCR); in ks_enable_qmu()
248 ks_wrreg16(dev, KS_RXQCR, w | RXQCR_RXFCTE); in ks_enable_qmu()
251 w = ks_rdreg16(dev, KS_RXCR1); in ks_enable_qmu()
252 ks_wrreg16(dev, KS_RXCR1, w | RXCR1_RXE); in ks_enable_qmu()
255 static void ks_disable_qmu(struct eth_device *dev) in ks_disable_qmu() argument
259 w = ks_rdreg16(dev, KS_TXCR); in ks_disable_qmu()
263 ks_wrreg16(dev, KS_TXCR, w); in ks_disable_qmu()
266 w = ks_rdreg16(dev, KS_RXCR1); in ks_disable_qmu()
268 ks_wrreg16(dev, KS_RXCR1, w); in ks_disable_qmu()
271 static inline void ks_read_qmu(struct eth_device *dev, u16 *buf, u32 len) in ks_read_qmu() argument
277 ks_wrreg16(dev, KS_RXFDPR, RXFDPR_RXFPAI); in ks_read_qmu()
278 ks_wrreg8(dev, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff); in ks_read_qmu()
288 ks_rdreg8(dev, 0); in ks_read_qmu()
290 ks_inblk(dev, buf, w + 2 + 2); in ks_read_qmu()
293 ks_inblk(dev, buf, ALIGN(len, 4)); in ks_read_qmu()
296 ks_wrreg8(dev, KS_RXQCR, (ks->rc_rxqcr & ~RXQCR_SDA) & 0xff); in ks_read_qmu()
299 static void ks_rcv(struct eth_device *dev, uchar **pv_data) in ks_rcv() argument
304 ks->frame_cnt = ks_rdreg16(dev, KS_RXFCTR) >> 8; in ks_rcv()
309 frame_hdr->sts = ks_rdreg16(dev, KS_RXFHSR); in ks_rcv()
311 frame_hdr->len = ks_rdreg16(dev, KS_RXFHBCR); in ks_rcv()
321 ks_read_qmu(dev, (u16 *)(*pv_data), frame_hdr->len); in ks_rcv()
327 ks_wrreg16(dev, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); in ks_rcv()
340 static int ks_read_selftest(struct eth_device *dev) in ks_read_selftest() argument
346 mbir = ks_rdreg16(dev, KS_MBIR); in ks_read_selftest()
368 static void ks_setup(struct eth_device *dev) in ks_setup() argument
373 ks_wrreg16(dev, KS_TXFDPR, TXFDPR_TXFPAI); in ks_setup()
376 ks_wrreg16(dev, KS_RXFDPR, RXFDPR_RXFPAI); in ks_setup()
379 ks_wrreg16(dev, KS_RXFCTR, 1 & RXFCTR_THRESHOLD_MASK); in ks_setup()
383 ks_wrreg16(dev, KS_RXQCR, ks->rc_rxqcr); in ks_setup()
390 w = ks_rdreg16(dev, KS_P1MBCR); in ks_setup()
392 ks_wrreg16(dev, KS_P1MBCR, w); in ks_setup()
395 ks_wrreg16(dev, KS_TXCR, w); in ks_setup()
402 ks_wrreg16(dev, KS_RXCR1, w); in ks_setup()
405 static void ks_setup_int(struct eth_device *dev) in ks_setup_int() argument
410 ks_wrreg16(dev, KS_ISR, 0xffff); in ks_setup_int()
416 static int ks8851_mll_detect_chip(struct eth_device *dev) in ks8851_mll_detect_chip() argument
420 ks_read_config(dev); in ks8851_mll_detect_chip()
422 val = ks_rdreg16(dev, KS_CIDER); in ks8851_mll_detect_chip()
446 dev->priv = (void *)&chip_ids[i]; in ks8851_mll_detect_chip()
451 static void ks8851_mll_reset(struct eth_device *dev) in ks8851_mll_reset() argument
454 ks_set_powermode(dev, PMECR_PM_NORMAL); in ks8851_mll_reset()
458 ks_soft_reset(dev, GRR_GSR); in ks8851_mll_reset()
461 ks_wrreg16(dev, KS_IER, 0x0000); in ks8851_mll_reset()
462 ks_wrreg16(dev, KS_ISR, 0xffff); in ks8851_mll_reset()
465 ks_disable_qmu(dev); in ks8851_mll_reset()
468 static void ks8851_mll_phy_configure(struct eth_device *dev) in ks8851_mll_phy_configure() argument
472 ks_setup(dev); in ks8851_mll_phy_configure()
473 ks_setup_int(dev); in ks8851_mll_phy_configure()
476 data = ks_rdreg16(dev, KS_OBCR); in ks8851_mll_phy_configure()
477 ks_wrreg16(dev, KS_OBCR, data | OBCR_ODS_16MA); in ks8851_mll_phy_configure()
482 static void ks8851_mll_enable(struct eth_device *dev) in ks8851_mll_enable() argument
484 ks_wrreg16(dev, KS_ISR, 0xffff); in ks8851_mll_enable()
485 ks_enable_int(dev); in ks8851_mll_enable()
486 ks_enable_qmu(dev); in ks8851_mll_enable()
489 static int ks8851_mll_init(struct eth_device *dev, bd_t *bd) in ks8851_mll_init() argument
491 struct chip_id *id = dev->priv; in ks8851_mll_init()
495 if (ks_read_selftest(dev)) { in ks8851_mll_init()
500 ks8851_mll_reset(dev); in ks8851_mll_init()
503 ks8851_mll_phy_configure(dev); in ks8851_mll_init()
509 ks8851_mll_enable(dev); in ks8851_mll_init()
514 static void ks_write_qmu(struct eth_device *dev, u8 *pdata, u16 len) in ks_write_qmu() argument
521 ks_wrreg16(dev, KS_TXFDPR, TXFDPR_TXFPAI); in ks_write_qmu()
522 ks_wrreg8(dev, KS_RXQCR, (ks->rc_rxqcr | RXQCR_SDA) & 0xff); in ks_write_qmu()
524 ks_outblk(dev, ks->txh.txw, 4); in ks_write_qmu()
526 ks_outblk(dev, (u16 *)pdata, ALIGN(len, 4)); in ks_write_qmu()
528 ks_wrreg8(dev, KS_RXQCR, (ks->rc_rxqcr & ~RXQCR_SDA) & 0xff); in ks_write_qmu()
530 ks_wrreg16(dev, KS_TXQCR, TXQCR_METFE); in ks_write_qmu()
532 do { } while (ks_rdreg16(dev, KS_TXQCR) & TXQCR_METFE); in ks_write_qmu()
535 static int ks8851_mll_send(struct eth_device *dev, void *packet, int length) in ks8851_mll_send() argument
545 retv = ks_rdreg16(dev, KS_TXMIR) & 0x1fff; in ks8851_mll_send()
547 ks_write_qmu(dev, data, tmplen); in ks8851_mll_send()
555 static void ks8851_mll_halt(struct eth_device *dev) in ks8851_mll_halt() argument
557 ks8851_mll_reset(dev); in ks8851_mll_halt()
566 static int ks8851_mll_recv(struct eth_device *dev) in ks8851_mll_recv() argument
570 status = ks_rdreg16(dev, KS_ISR); in ks8851_mll_recv()
572 ks_wrreg16(dev, KS_ISR, status); in ks8851_mll_recv()
575 ks_rcv(dev, (uchar **)net_rx_packets); in ks8851_mll_recv()
578 u16 pmecr = ks_rdreg16(dev, KS_PMECR); in ks8851_mll_recv()
580 ks_wrreg16(dev, KS_PMECR, pmecr | PMECR_WKEVT_LINK); in ks8851_mll_recv()
586 static int ks8851_mll_write_hwaddr(struct eth_device *dev) in ks8851_mll_write_hwaddr() argument
590 addrh = (dev->enetaddr[0] << 8) | dev->enetaddr[1]; in ks8851_mll_write_hwaddr()
591 addrm = (dev->enetaddr[2] << 8) | dev->enetaddr[3]; in ks8851_mll_write_hwaddr()
592 addrl = (dev->enetaddr[4] << 8) | dev->enetaddr[5]; in ks8851_mll_write_hwaddr()
594 ks_wrreg16(dev, KS_MARH, addrh); in ks8851_mll_write_hwaddr()
595 ks_wrreg16(dev, KS_MARM, addrm); in ks8851_mll_write_hwaddr()
596 ks_wrreg16(dev, KS_MARL, addrl); in ks8851_mll_write_hwaddr()
603 struct eth_device *dev; in ks8851_mll_initialize() local
605 dev = malloc(sizeof(*dev)); in ks8851_mll_initialize()
606 if (!dev) { in ks8851_mll_initialize()
610 memset(dev, 0, sizeof(*dev)); in ks8851_mll_initialize()
612 dev->iobase = base_addr; in ks8851_mll_initialize()
617 if (ks8851_mll_detect_chip(dev)) { in ks8851_mll_initialize()
618 free(dev); in ks8851_mll_initialize()
622 dev->init = ks8851_mll_init; in ks8851_mll_initialize()
623 dev->halt = ks8851_mll_halt; in ks8851_mll_initialize()
624 dev->send = ks8851_mll_send; in ks8851_mll_initialize()
625 dev->recv = ks8851_mll_recv; in ks8851_mll_initialize()
626 dev->write_hwaddr = ks8851_mll_write_hwaddr; in ks8851_mll_initialize()
627 sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num); in ks8851_mll_initialize()
629 eth_register(dev); in ks8851_mll_initialize()