Lines Matching +full:reg +full:- +full:names
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net>
13 #include <linux/firewire-constants.h>
67 if (t->is_split_transaction) in try_cancel_split_timeout()
68 return del_timer(&t->split_timeout_timer); in try_cancel_split_timeout()
79 spin_lock_irqsave(&card->lock, flags); in close_transaction()
80 list_for_each_entry(t, &card->transaction_list, link) { in close_transaction()
83 spin_unlock_irqrestore(&card->lock, flags); in close_transaction()
86 list_del_init(&t->link); in close_transaction()
87 card->tlabel_mask &= ~(1ULL << t->tlabel); in close_transaction()
91 spin_unlock_irqrestore(&card->lock, flags); in close_transaction()
93 if (&t->link != &card->transaction_list) { in close_transaction()
94 t->callback(card, rcode, NULL, 0, t->callback_data); in close_transaction()
99 return -ENOENT; in close_transaction()
115 if (card->driver->cancel_packet(card, &transaction->packet) == 0) in fw_cancel_transaction()
130 struct fw_card *card = t->card; in split_transaction_timeout_callback()
133 spin_lock_irqsave(&card->lock, flags); in split_transaction_timeout_callback()
134 if (list_empty(&t->link)) { in split_transaction_timeout_callback()
135 spin_unlock_irqrestore(&card->lock, flags); in split_transaction_timeout_callback()
138 list_del(&t->link); in split_transaction_timeout_callback()
139 card->tlabel_mask &= ~(1ULL << t->tlabel); in split_transaction_timeout_callback()
140 spin_unlock_irqrestore(&card->lock, flags); in split_transaction_timeout_callback()
142 t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data); in split_transaction_timeout_callback()
150 spin_lock_irqsave(&card->lock, flags); in start_split_transaction_timeout()
152 if (list_empty(&t->link) || WARN_ON(t->is_split_transaction)) { in start_split_transaction_timeout()
153 spin_unlock_irqrestore(&card->lock, flags); in start_split_transaction_timeout()
157 t->is_split_transaction = true; in start_split_transaction_timeout()
158 mod_timer(&t->split_timeout_timer, in start_split_transaction_timeout()
159 jiffies + card->split_timeout_jiffies); in start_split_transaction_timeout()
161 spin_unlock_irqrestore(&card->lock, flags); in start_split_transaction_timeout()
205 packet->header[0] = in fw_fill_request()
209 packet->header_length = 4; in fw_fill_request()
210 packet->payload = payload; in fw_fill_request()
211 packet->payload_length = length; in fw_fill_request()
222 packet->header[0] = in fw_fill_request()
227 packet->header[1] = in fw_fill_request()
229 packet->header[2] = in fw_fill_request()
234 packet->header[3] = *(u32 *)payload; in fw_fill_request()
235 packet->header_length = 16; in fw_fill_request()
236 packet->payload_length = 0; in fw_fill_request()
241 packet->header[3] = in fw_fill_request()
244 packet->header_length = 16; in fw_fill_request()
245 packet->payload = payload; in fw_fill_request()
246 packet->payload_length = length; in fw_fill_request()
250 packet->header_length = 12; in fw_fill_request()
251 packet->payload_length = 0; in fw_fill_request()
255 packet->header[3] = in fw_fill_request()
258 packet->header_length = 16; in fw_fill_request()
259 packet->payload_length = 0; in fw_fill_request()
266 packet->speed = speed; in fw_fill_request()
267 packet->generation = generation; in fw_fill_request()
268 packet->ack = 0; in fw_fill_request()
269 packet->payload_mapped = false; in fw_fill_request()
276 tlabel = card->current_tlabel; in allocate_tlabel()
277 while (card->tlabel_mask & (1ULL << tlabel)) { in allocate_tlabel()
279 if (tlabel == card->current_tlabel) in allocate_tlabel()
280 return -EBUSY; in allocate_tlabel()
283 card->current_tlabel = (tlabel + 1) & 0x3f; in allocate_tlabel()
284 card->tlabel_mask |= 1ULL << tlabel; in allocate_tlabel()
290 * fw_send_request() - submit a request packet for transmission
307 * In case of lock requests, specify one of the firewire-core specific %TCODE_
317 * The payload buffer at @data is going to be DMA-mapped except in case of
327 * the firewire-core specific %RCODE_SEND_ERROR. The other firewire-core
350 spin_lock_irqsave(&card->lock, flags); in fw_send_request()
354 spin_unlock_irqrestore(&card->lock, flags); in fw_send_request()
359 t->node_id = destination_id; in fw_send_request()
360 t->tlabel = tlabel; in fw_send_request()
361 t->card = card; in fw_send_request()
362 t->is_split_transaction = false; in fw_send_request()
363 timer_setup(&t->split_timeout_timer, in fw_send_request()
365 t->callback = callback; in fw_send_request()
366 t->callback_data = callback_data; in fw_send_request()
368 fw_fill_request(&t->packet, tcode, t->tlabel, in fw_send_request()
369 destination_id, card->node_id, generation, in fw_send_request()
371 t->packet.callback = transmit_complete_callback; in fw_send_request()
373 list_add_tail(&t->link, &card->transaction_list); in fw_send_request()
375 spin_unlock_irqrestore(&card->lock, flags); in fw_send_request()
377 card->driver->send_request(card, &t->packet); in fw_send_request()
393 memcpy(d->payload, payload, length); in transaction_callback()
394 d->rcode = rcode; in transaction_callback()
395 complete(&d->done); in transaction_callback()
399 * fw_run_transaction() - send request and sleep until transaction is completed
460 gap_count = card->driver->read_phy_reg(card, 1); in fw_send_phy_config()
477 card->driver->send_request(card, &phy_config_packet); in fw_send_phy_config()
489 if (handler->offset < offset + length && in lookup_overlapping_address_handler()
490 offset < handler->offset + handler->length) in lookup_overlapping_address_handler()
500 return handler->offset <= offset && in is_enclosing_handler()
501 offset + length <= handler->offset + handler->length; in is_enclosing_handler()
544 * fw_core_add_address_handler() - register for incoming requests
548 * region->start, ->end, and handler->length have to be quadlet-aligned.
555 * Return value: 0 on success, non-zero otherwise.
558 * fw_core_add_address_handler() and is returned in handler->offset.
566 int ret = -EBUSY; in fw_core_add_address_handler()
568 if (region->start & 0xffff000000000003ULL || in fw_core_add_address_handler()
569 region->start >= region->end || in fw_core_add_address_handler()
570 region->end > 0x0001000000000000ULL || in fw_core_add_address_handler()
571 handler->length & 3 || in fw_core_add_address_handler()
572 handler->length == 0) in fw_core_add_address_handler()
573 return -EINVAL; in fw_core_add_address_handler()
577 handler->offset = region->start; in fw_core_add_address_handler()
578 while (handler->offset + handler->length <= region->end) { in fw_core_add_address_handler()
579 if (is_in_fcp_region(handler->offset, handler->length)) in fw_core_add_address_handler()
584 handler->offset, handler->length); in fw_core_add_address_handler()
586 handler->offset += other->length; in fw_core_add_address_handler()
588 list_add_tail_rcu(&handler->link, &address_handler_list); in fw_core_add_address_handler()
601 * fw_core_remove_address_handler() - unregister an address handler
606 * When fw_core_remove_address_handler() returns, @handler->callback() is
612 list_del_rcu(&handler->link); in fw_core_remove_address_handler()
639 tcode = HEADER_GET_TCODE(r->request_header[0]); in fw_get_response_length()
650 data_length = HEADER_GET_DATA_LENGTH(r->request_header[3]); in fw_get_response_length()
654 ext_tcode = HEADER_GET_EXTENDED_TCODE(r->request_header[3]); in fw_get_response_length()
655 data_length = HEADER_GET_DATA_LENGTH(r->request_header[3]); in fw_get_response_length()
681 response->header[0] = in fw_fill_response()
685 response->header[1] = in fw_fill_response()
688 response->header[2] = 0; in fw_fill_response()
693 response->header[0] |= HEADER_TCODE(TCODE_WRITE_RESPONSE); in fw_fill_response()
694 response->header_length = 12; in fw_fill_response()
695 response->payload_length = 0; in fw_fill_response()
699 response->header[0] |= in fw_fill_response()
702 response->header[3] = *(u32 *)payload; in fw_fill_response()
704 response->header[3] = 0; in fw_fill_response()
705 response->header_length = 16; in fw_fill_response()
706 response->payload_length = 0; in fw_fill_response()
711 response->header[0] |= HEADER_TCODE(tcode + 2); in fw_fill_response()
712 response->header[3] = in fw_fill_response()
715 response->header_length = 16; in fw_fill_response()
716 response->payload = payload; in fw_fill_response()
717 response->payload_length = length; in fw_fill_response()
724 response->payload_mapped = false; in fw_fill_response()
734 cycles = card->split_timeout_cycles; in compute_split_timeout_timestamp()
751 request_tcode = HEADER_GET_TCODE(p->header[0]); in allocate_request()
754 data = &p->header[3]; in allocate_request()
760 data = p->payload; in allocate_request()
761 length = HEADER_GET_DATA_LENGTH(p->header[3]); in allocate_request()
771 length = HEADER_GET_DATA_LENGTH(p->header[3]); in allocate_request()
775 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", in allocate_request()
776 p->header[0], p->header[1], p->header[2]); in allocate_request()
784 request->response.speed = p->speed; in allocate_request()
785 request->response.timestamp = in allocate_request()
786 compute_split_timeout_timestamp(card, p->timestamp); in allocate_request()
787 request->response.generation = p->generation; in allocate_request()
788 request->response.ack = 0; in allocate_request()
789 request->response.callback = free_response_callback; in allocate_request()
790 request->ack = p->ack; in allocate_request()
791 request->length = length; in allocate_request()
793 memcpy(request->data, data, length); in allocate_request()
795 memcpy(request->request_header, p->header, sizeof(p->header)); in allocate_request()
807 if (request->ack != ACK_PENDING || in fw_send_response()
808 HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) { in fw_send_response()
814 fw_fill_response(&request->response, request->request_header, in fw_send_response()
815 rcode, request->data, in fw_send_response()
818 fw_fill_response(&request->response, request->request_header, in fw_send_response()
821 card->driver->send_response(card, &request->response); in fw_send_response()
826 * fw_get_request_speed() - returns speed at which the @request was received
831 return request->response.speed; in fw_get_request_speed()
843 destination = HEADER_GET_DESTINATION(p->header[0]); in handle_exclusive_region_request()
844 source = HEADER_GET_SOURCE(p->header[1]); in handle_exclusive_region_request()
845 tcode = HEADER_GET_TCODE(p->header[0]); in handle_exclusive_region_request()
847 tcode = 0x10 + HEADER_GET_EXTENDED_TCODE(p->header[3]); in handle_exclusive_region_request()
851 offset, request->length); in handle_exclusive_region_request()
853 handler->address_callback(card, request, in handle_exclusive_region_request()
855 p->generation, offset, in handle_exclusive_region_request()
856 request->data, request->length, in handle_exclusive_region_request()
857 handler->callback_data); in handle_exclusive_region_request()
874 request->length > 0x200) { in handle_fcp_region_request()
880 tcode = HEADER_GET_TCODE(p->header[0]); in handle_fcp_region_request()
881 destination = HEADER_GET_DESTINATION(p->header[0]); in handle_fcp_region_request()
882 source = HEADER_GET_SOURCE(p->header[1]); in handle_fcp_region_request()
893 if (is_enclosing_handler(handler, offset, request->length)) in handle_fcp_region_request()
894 handler->address_callback(card, NULL, tcode, in handle_fcp_region_request()
896 p->generation, offset, in handle_fcp_region_request()
897 request->data, in handle_fcp_region_request()
898 request->length, in handle_fcp_region_request()
899 handler->callback_data); in handle_fcp_region_request()
911 if (p->ack != ACK_PENDING && p->ack != ACK_COMPLETE) in fw_core_handle_request()
914 if (TCODE_IS_LINK_INTERNAL(HEADER_GET_TCODE(p->header[0]))) { in fw_core_handle_request()
925 offset = ((u64)HEADER_GET_OFFSET_HIGH(p->header[1]) << 32) | in fw_core_handle_request()
926 p->header[2]; in fw_core_handle_request()
928 if (!is_in_fcp_region(offset, request->length)) in fw_core_handle_request()
944 tcode = HEADER_GET_TCODE(p->header[0]); in fw_core_handle_response()
945 tlabel = HEADER_GET_TLABEL(p->header[0]); in fw_core_handle_response()
946 source = HEADER_GET_SOURCE(p->header[1]); in fw_core_handle_response()
947 rcode = HEADER_GET_RCODE(p->header[1]); in fw_core_handle_response()
949 spin_lock_irqsave(&card->lock, flags); in fw_core_handle_response()
950 list_for_each_entry(t, &card->transaction_list, link) { in fw_core_handle_response()
951 if (t->node_id == source && t->tlabel == tlabel) { in fw_core_handle_response()
953 spin_unlock_irqrestore(&card->lock, flags); in fw_core_handle_response()
956 list_del_init(&t->link); in fw_core_handle_response()
957 card->tlabel_mask &= ~(1ULL << t->tlabel); in fw_core_handle_response()
961 spin_unlock_irqrestore(&card->lock, flags); in fw_core_handle_response()
963 if (&t->link == &card->transaction_list) { in fw_core_handle_response()
977 data = (u32 *) &p->header[3]; in fw_core_handle_response()
988 data = p->payload; in fw_core_handle_response()
989 data_length = HEADER_GET_DATA_LENGTH(p->header[3]); in fw_core_handle_response()
1003 card->driver->cancel_packet(card, &t->packet); in fw_core_handle_response()
1005 t->callback(card, rcode, data, data_length, t->callback_data); in fw_core_handle_response()
1010 * fw_rcode_string - convert a firewire result code to an error description
1015 static const char *const names[] = { in fw_rcode_string() local
1028 if ((unsigned int)rcode < ARRAY_SIZE(names) && names[rcode]) in fw_rcode_string()
1029 return names[rcode]; in fw_rcode_string()
1056 start = (offset - topology_map_region.start) / 4; in handle_topology_map()
1057 memcpy(payload, &card->topology_map[start], length); in handle_topology_map()
1075 cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); in update_split_timeout()
1080 card->split_timeout_cycles = cycles; in update_split_timeout()
1081 card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); in update_split_timeout()
1089 int reg = offset & ~CSR_REGISTER_BASE; in handle_registers() local
1094 switch (reg) { in handle_registers()
1096 if (!card->priority_budget_implemented) { in handle_registers()
1104 * per IEEE 1394-2008 8.3.22.3, not IEEE 1394.1-2004 3.2.8 in handle_registers()
1105 * and 9.6, but interoperable with IEEE 1394.1-2004 bridges in handle_registers()
1115 *data = cpu_to_be32(card->driver->read_csr(card, reg)); in handle_registers()
1117 card->driver->write_csr(card, reg, be32_to_cpu(*data)); in handle_registers()
1124 card->driver->write_csr(card, CSR_STATE_CLEAR, in handle_registers()
1132 *data = cpu_to_be32(card->split_timeout_hi); in handle_registers()
1134 spin_lock_irqsave(&card->lock, flags); in handle_registers()
1135 card->split_timeout_hi = be32_to_cpu(*data) & 7; in handle_registers()
1137 spin_unlock_irqrestore(&card->lock, flags); in handle_registers()
1145 *data = cpu_to_be32(card->split_timeout_lo); in handle_registers()
1147 spin_lock_irqsave(&card->lock, flags); in handle_registers()
1148 card->split_timeout_lo = in handle_registers()
1151 spin_unlock_irqrestore(&card->lock, flags); in handle_registers()
1159 *data = card->maint_utility_register; in handle_registers()
1161 card->maint_utility_register = *data; in handle_registers()
1168 *data = cpu_to_be32(card->broadcast_channel); in handle_registers()
1170 card->broadcast_channel = in handle_registers()
1264 return -ENOMEM; in fw_core_init()