Lines Matching refs:card
28 void func(const struct fw_card *card, const char *fmt, ...) \
37 dev_name(card->device), &vaf); \
90 static void generate_config_rom(struct fw_card *card, __be32 *config_rom) in generate_config_rom() argument
108 BIB_LINK_SPEED(card->link_speed) | in generate_config_rom()
109 BIB_GENERATION(card->config_rom_generation++ % 14 + 2) | in generate_config_rom()
111 BIB_MAX_RECEIVE(card->max_receive) | in generate_config_rom()
113 config_rom[3] = cpu_to_be32(card->guid >> 32); in generate_config_rom()
114 config_rom[4] = cpu_to_be32(card->guid); in generate_config_rom()
152 struct fw_card *card; in update_config_roms() local
154 list_for_each_entry (card, &card_list, link) { in update_config_roms()
155 generate_config_rom(card, tmp_config_rom); in update_config_roms()
156 card->driver->set_config_rom(card, tmp_config_rom, in update_config_roms()
219 static int reset_bus(struct fw_card *card, bool short_reset) in reset_bus() argument
224 return card->driver->update_phy_reg(card, reg, 0, bit); in reset_bus()
227 void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset) in fw_schedule_bus_reset() argument
230 card->br_short = short_reset; in fw_schedule_bus_reset()
233 fw_card_get(card); in fw_schedule_bus_reset()
234 if (!queue_delayed_work(fw_workqueue, &card->br_work, in fw_schedule_bus_reset()
236 fw_card_put(card); in fw_schedule_bus_reset()
242 struct fw_card *card = container_of(work, struct fw_card, br_work.work); in br_work() local
245 if (card->reset_jiffies != 0 && in br_work()
246 time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) { in br_work()
247 if (!queue_delayed_work(fw_workqueue, &card->br_work, 2 * HZ)) in br_work()
248 fw_card_put(card); in br_work()
252 fw_send_phy_config(card, FW_PHY_CONFIG_NO_NODE_ID, card->generation, in br_work()
254 reset_bus(card, card->br_short); in br_work()
255 fw_card_put(card); in br_work()
258 static void allocate_broadcast_channel(struct fw_card *card, int generation) in allocate_broadcast_channel() argument
262 if (!card->broadcast_channel_allocated) { in allocate_broadcast_channel()
263 fw_iso_resource_manage(card, generation, 1ULL << 31, in allocate_broadcast_channel()
266 fw_notice(card, "failed to allocate broadcast channel\n"); in allocate_broadcast_channel()
269 card->broadcast_channel_allocated = true; in allocate_broadcast_channel()
272 device_for_each_child(card->device, (void *)(long)generation, in allocate_broadcast_channel()
280 void fw_schedule_bm_work(struct fw_card *card, unsigned long delay) in fw_schedule_bm_work() argument
282 fw_card_get(card); in fw_schedule_bm_work()
283 if (!schedule_delayed_work(&card->bm_work, delay)) in fw_schedule_bm_work()
284 fw_card_put(card); in fw_schedule_bm_work()
289 struct fw_card *card = container_of(work, struct fw_card, bm_work.work); in bm_work() local
301 spin_lock_irq(&card->lock); in bm_work()
303 if (card->local_node == NULL) { in bm_work()
304 spin_unlock_irq(&card->lock); in bm_work()
308 generation = card->generation; in bm_work()
310 root_node = card->root_node; in bm_work()
317 irm_device = card->irm_node->data; in bm_work()
326 irm_id = card->irm_node->node_id; in bm_work()
327 local_id = card->local_node->node_id; in bm_work()
330 card->reset_jiffies + DIV_ROUND_UP(HZ, 8)); in bm_work()
332 if ((is_next_generation(generation, card->bm_generation) && in bm_work()
333 !card->bm_abdicate) || in bm_work()
334 (card->bm_generation != generation && grace)) { in bm_work()
347 if (!card->irm_node->link_on) { in bm_work()
349 fw_notice(card, "%s, making local node (%02x) root\n", in bm_work()
356 fw_notice(card, "%s, making local node (%02x) root\n", in bm_work()
364 spin_unlock_irq(&card->lock); in bm_work()
366 rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, in bm_work()
377 spin_lock_irq(&card->lock); in bm_work()
378 if (rcode == RCODE_COMPLETE && generation == card->generation) in bm_work()
379 card->bm_node_id = in bm_work()
381 spin_unlock_irq(&card->lock); in bm_work()
386 allocate_broadcast_channel(card, generation); in bm_work()
397 fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); in bm_work()
401 spin_lock_irq(&card->lock); in bm_work()
411 fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", in bm_work()
415 } else if (card->bm_generation != generation) { in bm_work()
420 spin_unlock_irq(&card->lock); in bm_work()
421 fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); in bm_work()
430 card->bm_generation = generation; in bm_work()
443 spin_unlock_irq(&card->lock); in bm_work()
465 if (!card->beta_repeaters_present && in bm_work()
477 if (card->bm_retries++ < 5 && in bm_work()
478 (card->gap_count != gap_count || new_root_id != root_id)) in bm_work()
481 spin_unlock_irq(&card->lock); in bm_work()
484 fw_notice(card, "phy config: new root=%x, gap_count=%d\n", in bm_work()
486 fw_send_phy_config(card, new_root_id, generation, gap_count); in bm_work()
487 reset_bus(card, true); in bm_work()
497 rcode = fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, in bm_work()
506 allocate_broadcast_channel(card, generation); in bm_work()
511 fw_card_put(card); in bm_work()
514 void fw_card_initialize(struct fw_card *card, in fw_card_initialize() argument
520 card->index = atomic_inc_return(&index); in fw_card_initialize()
521 card->driver = driver; in fw_card_initialize()
522 card->device = device; in fw_card_initialize()
523 card->current_tlabel = 0; in fw_card_initialize()
524 card->tlabel_mask = 0; in fw_card_initialize()
525 card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000; in fw_card_initialize()
526 card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; in fw_card_initialize()
527 card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT; in fw_card_initialize()
528 card->split_timeout_jiffies = in fw_card_initialize()
530 card->color = 0; in fw_card_initialize()
531 card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; in fw_card_initialize()
533 kref_init(&card->kref); in fw_card_initialize()
534 init_completion(&card->done); in fw_card_initialize()
535 INIT_LIST_HEAD(&card->transaction_list); in fw_card_initialize()
536 INIT_LIST_HEAD(&card->phy_receiver_list); in fw_card_initialize()
537 spin_lock_init(&card->lock); in fw_card_initialize()
539 card->local_node = NULL; in fw_card_initialize()
541 INIT_DELAYED_WORK(&card->br_work, br_work); in fw_card_initialize()
542 INIT_DELAYED_WORK(&card->bm_work, bm_work); in fw_card_initialize()
546 int fw_card_add(struct fw_card *card, in fw_card_add() argument
551 card->max_receive = max_receive; in fw_card_add()
552 card->link_speed = link_speed; in fw_card_add()
553 card->guid = guid; in fw_card_add()
557 generate_config_rom(card, tmp_config_rom); in fw_card_add()
558 ret = card->driver->enable(card, tmp_config_rom, config_rom_length); in fw_card_add()
560 list_add_tail(&card->link, &card_list); in fw_card_add()
581 static int dummy_read_phy_reg(struct fw_card *card, int address) in dummy_read_phy_reg() argument
586 static int dummy_update_phy_reg(struct fw_card *card, int address, in dummy_update_phy_reg() argument
592 static void dummy_send_request(struct fw_card *card, struct fw_packet *packet) in dummy_send_request() argument
594 packet->callback(packet, card, RCODE_CANCELLED); in dummy_send_request()
597 static void dummy_send_response(struct fw_card *card, struct fw_packet *packet) in dummy_send_response() argument
599 packet->callback(packet, card, RCODE_CANCELLED); in dummy_send_response()
602 static int dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet) in dummy_cancel_packet() argument
607 static int dummy_enable_phys_dma(struct fw_card *card, in dummy_enable_phys_dma() argument
613 static struct fw_iso_context *dummy_allocate_iso_context(struct fw_card *card, in dummy_allocate_iso_context() argument
619 static u32 dummy_read_csr(struct fw_card *card, int csr_offset) in dummy_read_csr() argument
624 static void dummy_write_csr(struct fw_card *card, int csr_offset, u32 value) in dummy_write_csr() argument
673 struct fw_card *card = container_of(kref, struct fw_card, kref); in fw_card_release() local
675 complete(&card->done); in fw_card_release()
679 void fw_core_remove_card(struct fw_card *card) in fw_core_remove_card() argument
684 card->driver->update_phy_reg(card, 4, in fw_core_remove_card()
686 fw_schedule_bus_reset(card, false, true); in fw_core_remove_card()
689 list_del_init(&card->link); in fw_core_remove_card()
693 dummy_driver.free_iso_context = card->driver->free_iso_context; in fw_core_remove_card()
694 dummy_driver.stop_iso = card->driver->stop_iso; in fw_core_remove_card()
695 card->driver = &dummy_driver; in fw_core_remove_card()
697 spin_lock_irqsave(&card->lock, flags); in fw_core_remove_card()
698 fw_destroy_nodes(card); in fw_core_remove_card()
699 spin_unlock_irqrestore(&card->lock, flags); in fw_core_remove_card()
702 fw_card_put(card); in fw_core_remove_card()
703 wait_for_completion(&card->done); in fw_core_remove_card()
705 WARN_ON(!list_empty(&card->transaction_list)); in fw_core_remove_card()
725 int fw_card_read_cycle_time(struct fw_card *card, u32 *cycle_time) in fw_card_read_cycle_time() argument
727 if (card->driver->read_csr == dummy_read_csr) in fw_card_read_cycle_time()
732 *cycle_time = card->driver->read_csr(card, CSR_CYCLE_TIME); in fw_card_read_cycle_time()