4 * CSR implementation, iso/bus manager implementation.
6 * Copyright (C) 1999 Andreas E. Bombe
7 * 2002 Manfred Weihs <weihs@ict.tuwien.ac.at>
9 * This code is licensed under the GPL. See the file COPYING in the root
10 * directory of the kernel sources for details.
15 * Manfred Weihs <weihs@ict.tuwien.ac.at>
16 * configuration ROM manipulation
20 #include <linux/jiffies.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/moduleparam.h>
24 #include <linux/param.h>
25 #include <linux/spinlock.h>
26 #include <linux/string.h>
29 #include "ieee1394_types.h"
32 #include "highlevel.h"
33 #include "ieee1394_core.h"
35 /* Module Parameters */
36 /* this module parameter can be used to disable mapping of the FCP registers */
39 module_param(fcp, int, 0444);
40 MODULE_PARM_DESC(fcp, "Map FCP registers (default = 1, disable = 0).");
42 static struct csr1212_keyval *node_cap = NULL;
44 static void add_host(struct hpsb_host *host);
45 static void remove_host(struct hpsb_host *host);
46 static void host_reset(struct hpsb_host *host);
47 static int read_maps(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
48 u64 addr, size_t length, u16 fl);
49 static int write_fcp(struct hpsb_host *host, int nodeid, int dest,
50 quadlet_t *data, u64 addr, size_t length, u16 flags);
51 static int read_regs(struct hpsb_host *host, int nodeid, quadlet_t *buf,
52 u64 addr, size_t length, u16 flags);
53 static int write_regs(struct hpsb_host *host, int nodeid, int destid,
54 quadlet_t *data, u64 addr, size_t length, u16 flags);
55 static int lock_regs(struct hpsb_host *host, int nodeid, quadlet_t *store,
56 u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 fl);
57 static int lock64_regs(struct hpsb_host *host, int nodeid, octlet_t * store,
58 u64 addr, octlet_t data, octlet_t arg, int extcode, u16 fl);
59 static int read_config_rom(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
60 u64 addr, size_t length, u16 fl);
61 static u64 allocate_addr_range(u64 size, u32 alignment, void *__host);
62 static void release_addr_range(u64 addr, void *__host);
64 static struct hpsb_highlevel csr_highlevel = {
65 .name = "standard registers",
67 .remove_host = remove_host,
68 .host_reset = host_reset,
71 static struct hpsb_address_ops map_ops = {
75 static struct hpsb_address_ops fcp_ops = {
79 static struct hpsb_address_ops reg_ops = {
83 .lock64 = lock64_regs,
86 static struct hpsb_address_ops config_rom_ops = {
87 .read = read_config_rom,
90 struct csr1212_bus_ops csr_bus_ops = {
91 .allocate_addr_range = allocate_addr_range,
92 .release_addr = release_addr_range,
96 static u16 csr_crc16(unsigned *data, int length)
99 int shift, sum, next=0;
101 for (i = length; i; i--) {
102 for (next = check, shift = 28; shift >= 0; shift -= 4 ) {
103 sum = ((next >> 12) ^ (be32_to_cpu(*data) >> shift)) & 0xf;
104 next = (next << 4) ^ (sum << 12) ^ (sum << 5) ^ (sum);
106 check = next & 0xffff;
113 static void host_reset(struct hpsb_host *host)
115 host->csr.state &= 0x300;
117 host->csr.bus_manager_id = 0x3f;
118 host->csr.bandwidth_available = 4915;
119 host->csr.channels_available_hi = 0xfffffffe; /* pre-alloc ch 31 per 1394a-2000 */
120 host->csr.channels_available_lo = ~0;
121 host->csr.broadcast_channel = 0x80000000 | 31;
124 if (host->driver->hw_csr_reg) {
125 host->driver->hw_csr_reg(host, 2, 0xfffffffe, ~0);
129 host->csr.node_ids = host->node_id << 16;
131 if (!host->is_root) {
132 /* clear cmstr bit */
133 host->csr.state &= ~0x100;
136 host->csr.topology_map[1] =
137 cpu_to_be32(be32_to_cpu(host->csr.topology_map[1]) + 1);
138 host->csr.topology_map[2] = cpu_to_be32(host->node_count << 16
139 | host->selfid_count);
140 host->csr.topology_map[0] =
141 cpu_to_be32((host->selfid_count + 2) << 16
142 | csr_crc16(host->csr.topology_map + 1,
143 host->selfid_count + 2));
145 host->csr.speed_map[1] =
146 cpu_to_be32(be32_to_cpu(host->csr.speed_map[1]) + 1);
147 host->csr.speed_map[0] = cpu_to_be32(0x3f1 << 16
148 | csr_crc16(host->csr.speed_map+1,
153 * HI == seconds (bits 0:2)
154 * LO == fractions of a second in units of 125usec (bits 19:31)
156 * Convert SPLIT_TIMEOUT to jiffies.
157 * The default and minimum as per 1394a-2000 clause 8.3.2.2.6 is 100ms.
159 static inline void calculate_expire(struct csr_control *csr)
161 unsigned long usecs =
162 (csr->split_timeout_hi & 0x07) * USEC_PER_SEC +
163 (csr->split_timeout_lo >> 19) * 125L;
165 csr->expire = usecs_to_jiffies(usecs > 100000L ? usecs : 100000L);
167 HPSB_VERBOSE("CSR: setting expire to %lu, HZ=%u", csr->expire, HZ);
171 static void add_host(struct hpsb_host *host)
173 struct csr1212_keyval *root;
174 quadlet_t bus_info[CSR_BUS_INFO_SIZE];
176 hpsb_register_addrspace(&csr_highlevel, host, ®_ops,
178 CSR_REGISTER_BASE + CSR_CONFIG_ROM);
179 hpsb_register_addrspace(&csr_highlevel, host, &config_rom_ops,
180 CSR_REGISTER_BASE + CSR_CONFIG_ROM,
181 CSR_REGISTER_BASE + CSR_CONFIG_ROM_END);
183 hpsb_register_addrspace(&csr_highlevel, host, &fcp_ops,
184 CSR_REGISTER_BASE + CSR_FCP_COMMAND,
185 CSR_REGISTER_BASE + CSR_FCP_END);
187 hpsb_register_addrspace(&csr_highlevel, host, &map_ops,
188 CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP,
189 CSR_REGISTER_BASE + CSR_TOPOLOGY_MAP_END);
190 hpsb_register_addrspace(&csr_highlevel, host, &map_ops,
191 CSR_REGISTER_BASE + CSR_SPEED_MAP,
192 CSR_REGISTER_BASE + CSR_SPEED_MAP_END);
194 spin_lock_init(&host->csr.lock);
197 host->csr.node_ids = 0;
198 host->csr.split_timeout_hi = 0;
199 host->csr.split_timeout_lo = 800 << 19;
200 calculate_expire(&host->csr);
201 host->csr.cycle_time = 0;
202 host->csr.bus_time = 0;
203 host->csr.bus_manager_id = 0x3f;
204 host->csr.bandwidth_available = 4915;
205 host->csr.channels_available_hi = 0xfffffffe; /* pre-alloc ch 31 per 1394a-2000 */
206 host->csr.channels_available_lo = ~0;
207 host->csr.broadcast_channel = 0x80000000 | 31;
210 if (host->driver->hw_csr_reg) {
211 host->driver->hw_csr_reg(host, 2, 0xfffffffe, ~0);
215 if (host->csr.max_rec >= 9)
216 host->csr.max_rom = 2;
217 else if (host->csr.max_rec >= 5)
218 host->csr.max_rom = 1;
220 host->csr.max_rom = 0;
222 host->csr.generation = 2;
224 bus_info[1] = __constant_cpu_to_be32(0x31333934);
225 bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) |
226 (1 << CSR_CMC_SHIFT) |
227 (1 << CSR_ISC_SHIFT) |
228 (0 << CSR_BMC_SHIFT) |
229 (0 << CSR_PMC_SHIFT) |
230 (host->csr.cyc_clk_acc << CSR_CYC_CLK_ACC_SHIFT) |
231 (host->csr.max_rec << CSR_MAX_REC_SHIFT) |
232 (host->csr.max_rom << CSR_MAX_ROM_SHIFT) |
233 (host->csr.generation << CSR_GENERATION_SHIFT) |
236 bus_info[3] = cpu_to_be32(host->csr.guid_hi);
237 bus_info[4] = cpu_to_be32(host->csr.guid_lo);
239 /* The hardware copy of the bus info block will be set later when a
240 * bus reset is issued. */
242 csr1212_init_local_csr(host->csr.rom, bus_info, host->csr.max_rom);
244 root = host->csr.rom->root_kv;
246 if(csr1212_attach_keyval_to_directory(root, node_cap) != CSR1212_SUCCESS) {
247 HPSB_ERR("Failed to attach Node Capabilities to root directory");
250 host->update_config_rom = 1;
253 static void remove_host(struct hpsb_host *host)
255 quadlet_t bus_info[CSR_BUS_INFO_SIZE];
257 bus_info[1] = __constant_cpu_to_be32(0x31333934);
258 bus_info[2] = cpu_to_be32((0 << CSR_IRMC_SHIFT) |
259 (0 << CSR_CMC_SHIFT) |
260 (0 << CSR_ISC_SHIFT) |
261 (0 << CSR_BMC_SHIFT) |
262 (0 << CSR_PMC_SHIFT) |
263 (host->csr.cyc_clk_acc << CSR_CYC_CLK_ACC_SHIFT) |
264 (host->csr.max_rec << CSR_MAX_REC_SHIFT) |
265 (0 << CSR_MAX_ROM_SHIFT) |
266 (0 << CSR_GENERATION_SHIFT) |
269 bus_info[3] = cpu_to_be32(host->csr.guid_hi);
270 bus_info[4] = cpu_to_be32(host->csr.guid_lo);
272 csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, node_cap);
274 csr1212_init_local_csr(host->csr.rom, bus_info, 0);
275 host->update_config_rom = 1;
279 int hpsb_update_config_rom(struct hpsb_host *host, const quadlet_t *new_rom,
280 size_t buffersize, unsigned char rom_version)
285 HPSB_NOTICE("hpsb_update_config_rom() is deprecated");
287 spin_lock_irqsave(&host->csr.lock, flags);
288 if (rom_version != host->csr.generation)
290 else if (buffersize > host->csr.rom->cache_head->size)
293 /* Just overwrite the generated ConfigROM image with new data,
294 * it can be regenerated later. */
295 memcpy(host->csr.rom->cache_head->data, new_rom, buffersize);
296 host->csr.rom->cache_head->len = buffersize;
298 if (host->driver->set_hw_config_rom)
299 host->driver->set_hw_config_rom(host, host->csr.rom->bus_info_data);
300 /* Increment the generation number to keep some sort of sync
301 * with the newer ConfigROM manipulation method. */
302 host->csr.generation++;
303 if (host->csr.generation > 0xf || host->csr.generation < 2)
304 host->csr.generation = 2;
307 spin_unlock_irqrestore(&host->csr.lock, flags);
312 /* Read topology / speed maps and configuration ROM */
313 static int read_maps(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
314 u64 addr, size_t length, u16 fl)
317 int csraddr = addr - CSR_REGISTER_BASE;
320 spin_lock_irqsave(&host->csr.lock, flags);
322 if (csraddr < CSR_SPEED_MAP) {
323 src = ((char *)host->csr.topology_map) + csraddr
326 src = ((char *)host->csr.speed_map) + csraddr - CSR_SPEED_MAP;
329 memcpy(buffer, src, length);
330 spin_unlock_irqrestore(&host->csr.lock, flags);
331 return RCODE_COMPLETE;
335 #define out if (--length == 0) break
337 static int read_regs(struct hpsb_host *host, int nodeid, quadlet_t *buf,
338 u64 addr, size_t length, u16 flags)
340 int csraddr = addr - CSR_REGISTER_BASE;
344 if ((csraddr | length) & 0x3)
345 return RCODE_TYPE_ERROR;
350 case CSR_STATE_CLEAR:
351 *(buf++) = cpu_to_be32(host->csr.state);
354 *(buf++) = cpu_to_be32(host->csr.state);
357 *(buf++) = cpu_to_be32(host->csr.node_ids);
360 case CSR_RESET_START:
361 return RCODE_TYPE_ERROR;
363 /* address gap - handled by default below */
365 case CSR_SPLIT_TIMEOUT_HI:
366 *(buf++) = cpu_to_be32(host->csr.split_timeout_hi);
368 case CSR_SPLIT_TIMEOUT_LO:
369 *(buf++) = cpu_to_be32(host->csr.split_timeout_lo);
373 return RCODE_ADDRESS_ERROR;
376 oldcycle = host->csr.cycle_time;
377 host->csr.cycle_time =
378 host->driver->devctl(host, GET_CYCLE_COUNTER, 0);
380 if (oldcycle > host->csr.cycle_time) {
381 /* cycle time wrapped around */
382 host->csr.bus_time += 1 << 7;
384 *(buf++) = cpu_to_be32(host->csr.cycle_time);
387 oldcycle = host->csr.cycle_time;
388 host->csr.cycle_time =
389 host->driver->devctl(host, GET_CYCLE_COUNTER, 0);
391 if (oldcycle > host->csr.cycle_time) {
392 /* cycle time wrapped around */
393 host->csr.bus_time += (1 << 7);
395 *(buf++) = cpu_to_be32(host->csr.bus_time
396 | (host->csr.cycle_time >> 25));
400 return RCODE_ADDRESS_ERROR;
402 case CSR_BUSY_TIMEOUT:
403 /* not yet implemented */
404 return RCODE_ADDRESS_ERROR;
406 case CSR_BUS_MANAGER_ID:
407 if (host->driver->hw_csr_reg)
408 ret = host->driver->hw_csr_reg(host, 0, 0, 0);
410 ret = host->csr.bus_manager_id;
412 *(buf++) = cpu_to_be32(ret);
414 case CSR_BANDWIDTH_AVAILABLE:
415 if (host->driver->hw_csr_reg)
416 ret = host->driver->hw_csr_reg(host, 1, 0, 0);
418 ret = host->csr.bandwidth_available;
420 *(buf++) = cpu_to_be32(ret);
422 case CSR_CHANNELS_AVAILABLE_HI:
423 if (host->driver->hw_csr_reg)
424 ret = host->driver->hw_csr_reg(host, 2, 0, 0);
426 ret = host->csr.channels_available_hi;
428 *(buf++) = cpu_to_be32(ret);
430 case CSR_CHANNELS_AVAILABLE_LO:
431 if (host->driver->hw_csr_reg)
432 ret = host->driver->hw_csr_reg(host, 3, 0, 0);
434 ret = host->csr.channels_available_lo;
436 *(buf++) = cpu_to_be32(ret);
439 case CSR_BROADCAST_CHANNEL:
440 *(buf++) = cpu_to_be32(host->csr.broadcast_channel);
443 /* address gap to end - fall through to default */
445 return RCODE_ADDRESS_ERROR;
448 return RCODE_COMPLETE;
451 static int write_regs(struct hpsb_host *host, int nodeid, int destid,
452 quadlet_t *data, u64 addr, size_t length, u16 flags)
454 int csraddr = addr - CSR_REGISTER_BASE;
456 if ((csraddr | length) & 0x3)
457 return RCODE_TYPE_ERROR;
462 case CSR_STATE_CLEAR:
463 /* FIXME FIXME FIXME */
464 printk("doh, someone wants to mess with state clear\n");
467 printk("doh, someone wants to mess with state set\n");
471 host->csr.node_ids &= NODE_MASK << 16;
472 host->csr.node_ids |= be32_to_cpu(*(data++)) & (BUS_MASK << 16);
473 host->node_id = host->csr.node_ids >> 16;
474 host->driver->devctl(host, SET_BUS_ID, host->node_id >> 6);
477 case CSR_RESET_START:
478 /* FIXME - perform command reset */
482 return RCODE_ADDRESS_ERROR;
484 case CSR_SPLIT_TIMEOUT_HI:
485 host->csr.split_timeout_hi =
486 be32_to_cpu(*(data++)) & 0x00000007;
487 calculate_expire(&host->csr);
489 case CSR_SPLIT_TIMEOUT_LO:
490 host->csr.split_timeout_lo =
491 be32_to_cpu(*(data++)) & 0xfff80000;
492 calculate_expire(&host->csr);
496 return RCODE_ADDRESS_ERROR;
499 /* should only be set by cycle start packet, automatically */
500 host->csr.cycle_time = be32_to_cpu(*data);
501 host->driver->devctl(host, SET_CYCLE_COUNTER,
502 be32_to_cpu(*(data++)));
505 host->csr.bus_time = be32_to_cpu(*(data++)) & 0xffffff80;
509 return RCODE_ADDRESS_ERROR;
511 case CSR_BUSY_TIMEOUT:
512 /* not yet implemented */
513 return RCODE_ADDRESS_ERROR;
515 case CSR_BUS_MANAGER_ID:
516 case CSR_BANDWIDTH_AVAILABLE:
517 case CSR_CHANNELS_AVAILABLE_HI:
518 case CSR_CHANNELS_AVAILABLE_LO:
519 /* these are not writable, only lockable */
520 return RCODE_TYPE_ERROR;
522 case CSR_BROADCAST_CHANNEL:
523 /* only the valid bit can be written */
524 host->csr.broadcast_channel = (host->csr.broadcast_channel & ~0x40000000)
525 | (be32_to_cpu(*data) & 0x40000000);
528 /* address gap to end - fall through */
530 return RCODE_ADDRESS_ERROR;
533 return RCODE_COMPLETE;
539 static int lock_regs(struct hpsb_host *host, int nodeid, quadlet_t *store,
540 u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 fl)
542 int csraddr = addr - CSR_REGISTER_BASE;
544 quadlet_t *regptr = NULL;
547 return RCODE_TYPE_ERROR;
549 if (csraddr < CSR_BUS_MANAGER_ID || csraddr > CSR_CHANNELS_AVAILABLE_LO
550 || extcode != EXTCODE_COMPARE_SWAP)
551 goto unsupported_lockreq;
553 data = be32_to_cpu(data);
554 arg = be32_to_cpu(arg);
556 /* Is somebody releasing the broadcast_channel on us? */
557 if (csraddr == CSR_CHANNELS_AVAILABLE_HI && (data & 0x1)) {
558 /* Note: this is may not be the right way to handle
559 * the problem, so we should look into the proper way
561 HPSB_WARN("Node [" NODE_BUS_FMT "] wants to release "
562 "broadcast channel 31. Ignoring.",
563 NODE_BUS_ARGS(host, nodeid));
565 data &= ~0x1; /* keep broadcast channel allocated */
568 if (host->driver->hw_csr_reg) {
572 hw_csr_reg(host, (csraddr - CSR_BUS_MANAGER_ID) >> 2,
575 *store = cpu_to_be32(old);
576 return RCODE_COMPLETE;
579 spin_lock_irqsave(&host->csr.lock, flags);
582 case CSR_BUS_MANAGER_ID:
583 regptr = &host->csr.bus_manager_id;
584 *store = cpu_to_be32(*regptr);
589 case CSR_BANDWIDTH_AVAILABLE:
595 regptr = &host->csr.bandwidth_available;
598 /* bandwidth available algorithm adapted from IEEE 1394a-2000 spec */
600 *store = cpu_to_be32(old); /* change nothing */
605 /* allocate bandwidth */
606 bandwidth = arg - data;
607 if (old >= bandwidth) {
608 new = old - bandwidth;
609 *store = cpu_to_be32(arg);
612 *store = cpu_to_be32(old);
615 /* deallocate bandwidth */
616 bandwidth = data - arg;
617 if (old + bandwidth < 0x2000) {
618 new = old + bandwidth;
619 *store = cpu_to_be32(arg);
622 *store = cpu_to_be32(old);
628 case CSR_CHANNELS_AVAILABLE_HI:
630 /* Lock algorithm for CHANNELS_AVAILABLE as recommended by 1394a-2000 */
631 quadlet_t affected_channels = arg ^ data;
633 regptr = &host->csr.channels_available_hi;
635 if ((arg & affected_channels) == (*regptr & affected_channels)) {
636 *regptr ^= affected_channels;
637 *store = cpu_to_be32(arg);
639 *store = cpu_to_be32(*regptr);
645 case CSR_CHANNELS_AVAILABLE_LO:
647 /* Lock algorithm for CHANNELS_AVAILABLE as recommended by 1394a-2000 */
648 quadlet_t affected_channels = arg ^ data;
650 regptr = &host->csr.channels_available_lo;
652 if ((arg & affected_channels) == (*regptr & affected_channels)) {
653 *regptr ^= affected_channels;
654 *store = cpu_to_be32(arg);
656 *store = cpu_to_be32(*regptr);
662 spin_unlock_irqrestore(&host->csr.lock, flags);
664 return RCODE_COMPLETE;
668 case CSR_STATE_CLEAR:
670 case CSR_RESET_START:
672 case CSR_SPLIT_TIMEOUT_HI:
673 case CSR_SPLIT_TIMEOUT_LO:
676 case CSR_BROADCAST_CHANNEL:
677 return RCODE_TYPE_ERROR;
679 case CSR_BUSY_TIMEOUT:
680 /* not yet implemented - fall through */
682 return RCODE_ADDRESS_ERROR;
686 static int lock64_regs(struct hpsb_host *host, int nodeid, octlet_t * store,
687 u64 addr, octlet_t data, octlet_t arg, int extcode, u16 fl)
689 int csraddr = addr - CSR_REGISTER_BASE;
692 data = be64_to_cpu(data);
693 arg = be64_to_cpu(arg);
696 return RCODE_TYPE_ERROR;
698 if (csraddr != CSR_CHANNELS_AVAILABLE
699 || extcode != EXTCODE_COMPARE_SWAP)
700 goto unsupported_lock64req;
702 /* Is somebody releasing the broadcast_channel on us? */
703 if (csraddr == CSR_CHANNELS_AVAILABLE_HI && (data & 0x100000000ULL)) {
704 /* Note: this is may not be the right way to handle
705 * the problem, so we should look into the proper way
707 HPSB_WARN("Node [" NODE_BUS_FMT "] wants to release "
708 "broadcast channel 31. Ignoring.",
709 NODE_BUS_ARGS(host, nodeid));
711 data &= ~0x100000000ULL; /* keep broadcast channel allocated */
714 if (host->driver->hw_csr_reg) {
715 quadlet_t data_hi, data_lo;
716 quadlet_t arg_hi, arg_lo;
717 quadlet_t old_hi, old_lo;
719 data_hi = data >> 32;
720 data_lo = data & 0xFFFFFFFF;
722 arg_lo = arg & 0xFFFFFFFF;
724 old_hi = host->driver->hw_csr_reg(host, (csraddr - CSR_BUS_MANAGER_ID) >> 2,
727 old_lo = host->driver->hw_csr_reg(host, ((csraddr + 4) - CSR_BUS_MANAGER_ID) >> 2,
730 *store = cpu_to_be64(((octlet_t)old_hi << 32) | old_lo);
733 octlet_t affected_channels = arg ^ data;
735 spin_lock_irqsave(&host->csr.lock, flags);
737 old = ((octlet_t)host->csr.channels_available_hi << 32) | host->csr.channels_available_lo;
739 if ((arg & affected_channels) == (old & affected_channels)) {
740 host->csr.channels_available_hi ^= (affected_channels >> 32);
741 host->csr.channels_available_lo ^= (affected_channels & 0xffffffff);
742 *store = cpu_to_be64(arg);
744 *store = cpu_to_be64(old);
747 spin_unlock_irqrestore(&host->csr.lock, flags);
750 /* Is somebody erroneously releasing the broadcast_channel on us? */
751 if (host->csr.channels_available_hi & 0x1)
752 host->csr.channels_available_hi &= ~0x1;
754 return RCODE_COMPLETE;
756 unsupported_lock64req:
758 case CSR_STATE_CLEAR:
760 case CSR_RESET_START:
762 case CSR_SPLIT_TIMEOUT_HI:
763 case CSR_SPLIT_TIMEOUT_LO:
766 case CSR_BUS_MANAGER_ID:
767 case CSR_BROADCAST_CHANNEL:
768 case CSR_BUSY_TIMEOUT:
769 case CSR_BANDWIDTH_AVAILABLE:
770 return RCODE_TYPE_ERROR;
773 return RCODE_ADDRESS_ERROR;
777 static int write_fcp(struct hpsb_host *host, int nodeid, int dest,
778 quadlet_t *data, u64 addr, size_t length, u16 flags)
780 int csraddr = addr - CSR_REGISTER_BASE;
783 return RCODE_TYPE_ERROR;
786 case CSR_FCP_COMMAND:
787 highlevel_fcp_request(host, nodeid, 0, (u8 *)data, length);
789 case CSR_FCP_RESPONSE:
790 highlevel_fcp_request(host, nodeid, 1, (u8 *)data, length);
793 return RCODE_TYPE_ERROR;
796 return RCODE_COMPLETE;
799 static int read_config_rom(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
800 u64 addr, size_t length, u16 fl)
802 u32 offset = addr - CSR1212_REGISTER_SPACE_BASE;
804 if (csr1212_read(host->csr.rom, offset, buffer, length) == CSR1212_SUCCESS)
805 return RCODE_COMPLETE;
807 return RCODE_ADDRESS_ERROR;
810 static u64 allocate_addr_range(u64 size, u32 alignment, void *__host)
812 struct hpsb_host *host = (struct hpsb_host*)__host;
814 return hpsb_allocate_and_register_addrspace(&csr_highlevel,
818 CSR1212_UNITS_SPACE_BASE,
819 CSR1212_UNITS_SPACE_END);
822 static void release_addr_range(u64 addr, void *__host)
824 struct hpsb_host *host = (struct hpsb_host*)__host;
825 hpsb_unregister_addrspace(&csr_highlevel, host, addr);
831 node_cap = csr1212_new_immediate(CSR1212_KV_ID_NODE_CAPABILITIES, 0x0083c0);
833 HPSB_ERR("Failed to allocate memory for Node Capabilties ConfigROM entry!");
837 hpsb_register_highlevel(&csr_highlevel);
842 void cleanup_csr(void)
845 csr1212_release_keyval(node_cap);
846 hpsb_unregister_highlevel(&csr_highlevel);