Lines Matching refs:card
165 static inline void pita_set_scl_highz(struct peak_pciec_card *card) in pita_set_scl_highz() argument
167 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SCL; in pita_set_scl_highz()
168 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_set_scl_highz()
171 static inline void pita_set_sda_highz(struct peak_pciec_card *card) in pita_set_sda_highz() argument
173 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SDA; in pita_set_sda_highz()
174 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_set_sda_highz()
177 static void peak_pciec_init_pita_gpio(struct peak_pciec_card *card) in peak_pciec_init_pita_gpio() argument
180 pita_set_scl_highz(card); in peak_pciec_init_pita_gpio()
181 pita_set_sda_highz(card); in peak_pciec_init_pita_gpio()
186 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_setsda() local
190 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SDA; in pita_setsda()
191 writeb(gp_out, card->cfg_base + PITA_GPOUT); in pita_setsda()
194 gp_outen = readb(card->cfg_base + PITA_GPOEN); in pita_setsda()
200 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_setsda()
205 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_setscl() local
209 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SCL; in pita_setscl()
210 writeb(gp_out, card->cfg_base + PITA_GPOUT); in pita_setscl()
213 gp_outen = readb(card->cfg_base + PITA_GPOEN); in pita_setscl()
219 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_setscl()
224 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_getsda() local
227 pita_set_sda_highz(card); in pita_getsda()
229 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SDA) ? 1 : 0; in pita_getsda()
234 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_getscl() local
237 pita_set_scl_highz(card); in pita_getscl()
239 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SCL) ? 1 : 0; in pita_getscl()
245 static int peak_pciec_write_pca9553(struct peak_pciec_card *card, in peak_pciec_write_pca9553() argument
260 if ((offset == 5) && (data == card->led_cache)) in peak_pciec_write_pca9553()
263 ret = i2c_transfer(&card->led_chip, &msg, 1); in peak_pciec_write_pca9553()
268 card->led_cache = data; in peak_pciec_write_pca9553()
278 struct peak_pciec_card *card = in peak_pciec_led_work() local
281 u8 new_led = card->led_cache; in peak_pciec_led_work()
285 for (i = 0; i < card->chan_count; i++) { in peak_pciec_led_work()
290 netdev = card->channel[i].netdev; in peak_pciec_led_work()
301 if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { in peak_pciec_led_work()
302 card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; in peak_pciec_led_work()
306 if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { in peak_pciec_led_work()
307 card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; in peak_pciec_led_work()
314 peak_pciec_write_pca9553(card, 5, new_led); in peak_pciec_led_work()
318 schedule_delayed_work(&card->led_work, HZ); in peak_pciec_led_work()
324 static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s) in peak_pciec_set_leds() argument
326 u8 new_led = card->led_cache; in peak_pciec_set_leds()
330 for (i = 0; i < card->chan_count; i++) in peak_pciec_set_leds()
337 peak_pciec_write_pca9553(card, 5, new_led); in peak_pciec_set_leds()
343 static void peak_pciec_start_led_work(struct peak_pciec_card *card) in peak_pciec_start_led_work() argument
345 schedule_delayed_work(&card->led_work, HZ); in peak_pciec_start_led_work()
351 static void peak_pciec_stop_led_work(struct peak_pciec_card *card) in peak_pciec_stop_led_work() argument
353 cancel_delayed_work_sync(&card->led_work); in peak_pciec_stop_led_work()
359 static int peak_pciec_init_leds(struct peak_pciec_card *card) in peak_pciec_init_leds() argument
364 err = peak_pciec_write_pca9553(card, 1, 44 / 1); in peak_pciec_init_leds()
369 err = peak_pciec_write_pca9553(card, 2, 0x80); in peak_pciec_init_leds()
374 err = peak_pciec_write_pca9553(card, 3, 44 / 5); in peak_pciec_init_leds()
379 err = peak_pciec_write_pca9553(card, 4, 0x80); in peak_pciec_init_leds()
384 return peak_pciec_write_pca9553(card, 5, PCA9553_LS0_INIT); in peak_pciec_init_leds()
390 static void peak_pciec_leds_exit(struct peak_pciec_card *card) in peak_pciec_leds_exit() argument
393 peak_pciec_write_pca9553(card, 5, PCA9553_LED_OFF_ALL); in peak_pciec_leds_exit()
404 struct peak_pciec_card *card = chan->pciec_card; in peak_pciec_write_reg() local
405 int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE; in peak_pciec_write_reg()
412 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_ON); in peak_pciec_write_reg()
416 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_SLOW); in peak_pciec_write_reg()
417 peak_pciec_start_led_work(card); in peak_pciec_write_reg()
440 struct peak_pciec_card *card; in peak_pciec_probe() local
448 card = prev_chan->pciec_card; in peak_pciec_probe()
449 if (!card) in peak_pciec_probe()
455 card = kzalloc(sizeof(struct peak_pciec_card), GFP_KERNEL); in peak_pciec_probe()
456 if (!card) in peak_pciec_probe()
459 card->cfg_base = chan->cfg_base; in peak_pciec_probe()
460 card->reg_base = priv->reg_base; in peak_pciec_probe()
462 card->led_chip.owner = THIS_MODULE; in peak_pciec_probe()
463 card->led_chip.dev.parent = &pdev->dev; in peak_pciec_probe()
464 card->led_chip.algo_data = &card->i2c_bit; in peak_pciec_probe()
465 strncpy(card->led_chip.name, "peak_i2c", in peak_pciec_probe()
466 sizeof(card->led_chip.name)); in peak_pciec_probe()
468 card->i2c_bit = peak_pciec_i2c_bit_ops; in peak_pciec_probe()
469 card->i2c_bit.udelay = 10; in peak_pciec_probe()
470 card->i2c_bit.timeout = HZ; in peak_pciec_probe()
471 card->i2c_bit.data = card; in peak_pciec_probe()
473 peak_pciec_init_pita_gpio(card); in peak_pciec_probe()
475 err = i2c_bit_add_bus(&card->led_chip); in peak_pciec_probe()
481 err = peak_pciec_init_leds(card); in peak_pciec_probe()
487 INIT_DELAYED_WORK(&card->led_work, peak_pciec_led_work); in peak_pciec_probe()
492 chan->pciec_card = card; in peak_pciec_probe()
493 card->channel[card->chan_count++].netdev = dev; in peak_pciec_probe()
498 i2c_del_adapter(&card->led_chip); in peak_pciec_probe()
501 peak_pciec_init_pita_gpio(card); in peak_pciec_probe()
502 kfree(card); in peak_pciec_probe()
507 static void peak_pciec_remove(struct peak_pciec_card *card) in peak_pciec_remove() argument
509 peak_pciec_stop_led_work(card); in peak_pciec_remove()
510 peak_pciec_leds_exit(card); in peak_pciec_remove()
511 i2c_del_adapter(&card->led_chip); in peak_pciec_remove()
512 peak_pciec_init_pita_gpio(card); in peak_pciec_remove()
513 kfree(card); in peak_pciec_remove()
526 static inline void peak_pciec_remove(struct peak_pciec_card *card) in peak_pciec_remove() argument