Lines Matching full:card

29 void func(const struct fw_card *card, const char *fmt, ...)	\
38 dev_name(card->device), &vaf); \
91 static void generate_config_rom(struct fw_card *card, __be32 *config_rom) in generate_config_rom() argument
109 BIB_LINK_SPEED(card->link_speed) | in generate_config_rom()
110 BIB_GENERATION(card->config_rom_generation++ % 14 + 2) | in generate_config_rom()
112 BIB_MAX_RECEIVE(card->max_receive) | in generate_config_rom()
114 config_rom[3] = cpu_to_be32(card->guid >> 32); in generate_config_rom()
115 config_rom[4] = cpu_to_be32(card->guid); in generate_config_rom()
153 struct fw_card *card; in update_config_roms() local
155 list_for_each_entry (card, &card_list, link) { in update_config_roms()
156 generate_config_rom(card, tmp_config_rom); in update_config_roms()
157 card->driver->set_config_rom(card, tmp_config_rom, in update_config_roms()
213 static int reset_bus(struct fw_card *card, bool short_reset) in reset_bus() argument
218 trace_bus_reset_initiate(card->index, card->generation, short_reset); in reset_bus()
220 return card->driver->update_phy_reg(card, reg, 0, bit); in reset_bus()
223 void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset) in fw_schedule_bus_reset() argument
225 trace_bus_reset_schedule(card->index, card->generation, short_reset); in fw_schedule_bus_reset()
228 card->br_short = short_reset; in fw_schedule_bus_reset()
231 fw_card_get(card); in fw_schedule_bus_reset()
232 if (!queue_delayed_work(fw_workqueue, &card->br_work, in fw_schedule_bus_reset()
234 fw_card_put(card); in fw_schedule_bus_reset()
240 struct fw_card *card = container_of(work, struct fw_card, br_work.work); in br_work() local
243 if (card->reset_jiffies != 0 && in br_work()
244 time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) { in br_work()
245 trace_bus_reset_postpone(card->index, card->generation, card->br_short); 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 scoped_guard(spinlock_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()
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()
432 if (card->gap_count == 0) { in bm_work()
447 card->bm_retries = 0; in bm_work()
459 spin_unlock_irq(&card->lock); in bm_work()
481 if (!card->beta_repeaters_present && in bm_work()
493 if (card->bm_retries++ < 5 && in bm_work()
494 (card->gap_count != gap_count || new_root_id != root_id)) in bm_work()
497 spin_unlock_irq(&card->lock); in bm_work()
500 fw_notice(card, "phy config: new root=%x, gap_count=%d\n", in bm_work()
502 fw_send_phy_config(card, new_root_id, generation, gap_count); in bm_work()
515 reset_bus(card, card->gap_count != 0); in bm_work()
525 rcode = fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, in bm_work()
534 allocate_broadcast_channel(card, generation); in bm_work()
539 fw_card_put(card); in bm_work()
542 void fw_card_initialize(struct fw_card *card, in fw_card_initialize() argument
548 card->index = atomic_inc_return(&index); in fw_card_initialize()
549 card->driver = driver; in fw_card_initialize()
550 card->device = device; in fw_card_initialize()
551 card->current_tlabel = 0; in fw_card_initialize()
552 card->tlabel_mask = 0; in fw_card_initialize()
553 card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000; in fw_card_initialize()
554 card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; in fw_card_initialize()
555 card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT; in fw_card_initialize()
556 card->split_timeout_jiffies = in fw_card_initialize()
558 card->color = 0; in fw_card_initialize()
559 card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; in fw_card_initialize()
561 kref_init(&card->kref); in fw_card_initialize()
562 init_completion(&card->done); in fw_card_initialize()
563 INIT_LIST_HEAD(&card->transaction_list); in fw_card_initialize()
564 INIT_LIST_HEAD(&card->phy_receiver_list); in fw_card_initialize()
565 spin_lock_init(&card->lock); in fw_card_initialize()
567 card->local_node = NULL; in fw_card_initialize()
569 INIT_DELAYED_WORK(&card->br_work, br_work); in fw_card_initialize()
570 INIT_DELAYED_WORK(&card->bm_work, bm_work); in fw_card_initialize()
574 int fw_card_add(struct fw_card *card, u32 max_receive, u32 link_speed, u64 guid, in fw_card_add() argument
592 isoc_wq = alloc_workqueue("firewire-isoc-card%u", in fw_card_add()
594 supported_isoc_contexts, card->index); in fw_card_add()
598 card->max_receive = max_receive; in fw_card_add()
599 card->link_speed = link_speed; in fw_card_add()
600 card->guid = guid; in fw_card_add()
604 generate_config_rom(card, tmp_config_rom); in fw_card_add()
605 ret = card->driver->enable(card, tmp_config_rom, config_rom_length); in fw_card_add()
611 card->isoc_wq = isoc_wq; in fw_card_add()
612 list_add_tail(&card->link, &card_list); in fw_card_add()
619 * The next few functions implement a dummy driver that is used once a card
621 * as all IO to the card will be handled (and failed) by the dummy driver
623 * shutdown still need to be provided by the card driver.
627 * .set_config_rom() is never called since the card is taken out of card_list
631 static int dummy_read_phy_reg(struct fw_card *card, int address) in dummy_read_phy_reg() argument
636 static int dummy_update_phy_reg(struct fw_card *card, int address, in dummy_update_phy_reg() argument
642 static void dummy_send_request(struct fw_card *card, struct fw_packet *packet) in dummy_send_request() argument
644 packet->callback(packet, card, RCODE_CANCELLED); in dummy_send_request()
647 static void dummy_send_response(struct fw_card *card, struct fw_packet *packet) in dummy_send_response() argument
649 packet->callback(packet, card, RCODE_CANCELLED); in dummy_send_response()
652 static int dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet) in dummy_cancel_packet() argument
657 static int dummy_enable_phys_dma(struct fw_card *card, in dummy_enable_phys_dma() argument
663 static struct fw_iso_context *dummy_allocate_iso_context(struct fw_card *card, in dummy_allocate_iso_context() argument
669 static u32 dummy_read_csr(struct fw_card *card, int csr_offset) in dummy_read_csr() argument
674 static void dummy_write_csr(struct fw_card *card, int csr_offset, u32 value) in dummy_write_csr() argument
723 struct fw_card *card = container_of(kref, struct fw_card, kref); in fw_card_release() local
725 complete(&card->done); in fw_card_release()
729 void fw_core_remove_card(struct fw_card *card) in fw_core_remove_card() argument
735 card->driver->update_phy_reg(card, 4, in fw_core_remove_card()
737 fw_schedule_bus_reset(card, false, true); in fw_core_remove_card()
740 list_del_init(&card->link); in fw_core_remove_card()
742 /* Switch off most of the card driver interface. */ in fw_core_remove_card()
743 dummy_driver.free_iso_context = card->driver->free_iso_context; in fw_core_remove_card()
744 dummy_driver.stop_iso = card->driver->stop_iso; in fw_core_remove_card()
745 card->driver = &dummy_driver; in fw_core_remove_card()
746 drain_workqueue(card->isoc_wq); in fw_core_remove_card()
748 scoped_guard(spinlock_irqsave, &card->lock) in fw_core_remove_card()
749 fw_destroy_nodes(card); in fw_core_remove_card()
752 fw_card_put(card); in fw_core_remove_card()
753 wait_for_completion(&card->done); in fw_core_remove_card()
755 destroy_workqueue(card->isoc_wq); in fw_core_remove_card()
757 WARN_ON(!list_empty(&card->transaction_list)); in fw_core_remove_card()
763 * for controller card.
764 * @card: The instance of card for 1394 OHCI controller.
768 * controller card. This function accesses the region without any lock primitives or IRQ mask.
777 int fw_card_read_cycle_time(struct fw_card *card, u32 *cycle_time) in fw_card_read_cycle_time() argument
779 if (card->driver->read_csr == dummy_read_csr) in fw_card_read_cycle_time()
784 *cycle_time = card->driver->read_csr(card, CSR_CYCLE_TIME); in fw_card_read_cycle_time()