Lines Matching refs:card

166 static inline void pita_set_scl_highz(struct peak_pciec_card *card)  in pita_set_scl_highz()  argument
168 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SCL; in pita_set_scl_highz()
169 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_set_scl_highz()
172 static inline void pita_set_sda_highz(struct peak_pciec_card *card) in pita_set_sda_highz() argument
174 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SDA; in pita_set_sda_highz()
175 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_set_sda_highz()
178 static void peak_pciec_init_pita_gpio(struct peak_pciec_card *card) in peak_pciec_init_pita_gpio() argument
181 pita_set_scl_highz(card); in peak_pciec_init_pita_gpio()
182 pita_set_sda_highz(card); in peak_pciec_init_pita_gpio()
187 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_setsda() local
191 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SDA; in pita_setsda()
192 writeb(gp_out, card->cfg_base + PITA_GPOUT); in pita_setsda()
195 gp_outen = readb(card->cfg_base + PITA_GPOEN); in pita_setsda()
201 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_setsda()
206 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_setscl() local
210 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SCL; in pita_setscl()
211 writeb(gp_out, card->cfg_base + PITA_GPOUT); in pita_setscl()
214 gp_outen = readb(card->cfg_base + PITA_GPOEN); in pita_setscl()
220 writeb(gp_outen, card->cfg_base + PITA_GPOEN); in pita_setscl()
225 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_getsda() local
228 pita_set_sda_highz(card); in pita_getsda()
230 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SDA) ? 1 : 0; in pita_getsda()
235 struct peak_pciec_card *card = (struct peak_pciec_card *)data; in pita_getscl() local
238 pita_set_scl_highz(card); in pita_getscl()
240 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SCL) ? 1 : 0; in pita_getscl()
246 static int peak_pciec_write_pca9553(struct peak_pciec_card *card, in peak_pciec_write_pca9553() argument
261 if ((offset == 5) && (data == card->led_cache)) in peak_pciec_write_pca9553()
264 ret = i2c_transfer(&card->led_chip, &msg, 1); in peak_pciec_write_pca9553()
269 card->led_cache = data; in peak_pciec_write_pca9553()
279 struct peak_pciec_card *card = in peak_pciec_led_work() local
282 u8 new_led = card->led_cache; in peak_pciec_led_work()
286 for (i = 0; i < card->chan_count; i++) { in peak_pciec_led_work()
291 netdev = card->channel[i].netdev; in peak_pciec_led_work()
302 if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { in peak_pciec_led_work()
303 card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; in peak_pciec_led_work()
307 if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { in peak_pciec_led_work()
308 card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; in peak_pciec_led_work()
315 peak_pciec_write_pca9553(card, 5, new_led); in peak_pciec_led_work()
319 schedule_delayed_work(&card->led_work, HZ); in peak_pciec_led_work()
325 static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s) in peak_pciec_set_leds() argument
327 u8 new_led = card->led_cache; in peak_pciec_set_leds()
331 for (i = 0; i < card->chan_count; i++) in peak_pciec_set_leds()
338 peak_pciec_write_pca9553(card, 5, new_led); in peak_pciec_set_leds()
344 static void peak_pciec_start_led_work(struct peak_pciec_card *card) in peak_pciec_start_led_work() argument
346 schedule_delayed_work(&card->led_work, HZ); in peak_pciec_start_led_work()
352 static void peak_pciec_stop_led_work(struct peak_pciec_card *card) in peak_pciec_stop_led_work() argument
354 cancel_delayed_work_sync(&card->led_work); in peak_pciec_stop_led_work()
360 static int peak_pciec_init_leds(struct peak_pciec_card *card) in peak_pciec_init_leds() argument
365 err = peak_pciec_write_pca9553(card, 1, 44 / 1); in peak_pciec_init_leds()
370 err = peak_pciec_write_pca9553(card, 2, 0x80); in peak_pciec_init_leds()
375 err = peak_pciec_write_pca9553(card, 3, 44 / 5); in peak_pciec_init_leds()
380 err = peak_pciec_write_pca9553(card, 4, 0x80); in peak_pciec_init_leds()
385 return peak_pciec_write_pca9553(card, 5, PCA9553_LS0_INIT); in peak_pciec_init_leds()
391 static void peak_pciec_leds_exit(struct peak_pciec_card *card) in peak_pciec_leds_exit() argument
394 peak_pciec_write_pca9553(card, 5, PCA9553_LED_OFF_ALL); in peak_pciec_leds_exit()
405 struct peak_pciec_card *card = chan->pciec_card; in peak_pciec_write_reg() local
406 int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE; in peak_pciec_write_reg()
413 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_ON); in peak_pciec_write_reg()
417 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_SLOW); in peak_pciec_write_reg()
418 peak_pciec_start_led_work(card); in peak_pciec_write_reg()
441 struct peak_pciec_card *card; in peak_pciec_probe() local
449 card = prev_chan->pciec_card; in peak_pciec_probe()
450 if (!card) in peak_pciec_probe()
456 card = kzalloc(sizeof(struct peak_pciec_card), GFP_KERNEL); in peak_pciec_probe()
457 if (!card) in peak_pciec_probe()
460 card->cfg_base = chan->cfg_base; in peak_pciec_probe()
461 card->reg_base = priv->reg_base; in peak_pciec_probe()
463 card->led_chip.owner = THIS_MODULE; in peak_pciec_probe()
464 card->led_chip.dev.parent = &pdev->dev; in peak_pciec_probe()
465 card->led_chip.algo_data = &card->i2c_bit; in peak_pciec_probe()
466 strncpy(card->led_chip.name, "peak_i2c", in peak_pciec_probe()
467 sizeof(card->led_chip.name)); in peak_pciec_probe()
469 card->i2c_bit = peak_pciec_i2c_bit_ops; in peak_pciec_probe()
470 card->i2c_bit.udelay = 10; in peak_pciec_probe()
471 card->i2c_bit.timeout = HZ; in peak_pciec_probe()
472 card->i2c_bit.data = card; in peak_pciec_probe()
474 peak_pciec_init_pita_gpio(card); in peak_pciec_probe()
476 err = i2c_bit_add_bus(&card->led_chip); in peak_pciec_probe()
482 err = peak_pciec_init_leds(card); in peak_pciec_probe()
488 INIT_DELAYED_WORK(&card->led_work, peak_pciec_led_work); in peak_pciec_probe()
493 chan->pciec_card = card; in peak_pciec_probe()
494 card->channel[card->chan_count++].netdev = dev; in peak_pciec_probe()
499 i2c_del_adapter(&card->led_chip); in peak_pciec_probe()
502 peak_pciec_init_pita_gpio(card); in peak_pciec_probe()
503 kfree(card); in peak_pciec_probe()
508 static void peak_pciec_remove(struct peak_pciec_card *card) in peak_pciec_remove() argument
510 peak_pciec_stop_led_work(card); in peak_pciec_remove()
511 peak_pciec_leds_exit(card); in peak_pciec_remove()
512 i2c_del_adapter(&card->led_chip); in peak_pciec_remove()
513 peak_pciec_init_pita_gpio(card); in peak_pciec_remove()
514 kfree(card); in peak_pciec_remove()
527 static inline void peak_pciec_remove(struct peak_pciec_card *card) in peak_pciec_remove() argument