Lines Matching +full:address +full:- +full:address +full:- +full:data
3 * SDIO-Hostbus related functions
9 * Copyright 2007-2008 Michael Buesch <m@bues.ch>
59 #define SBSDIO_FUNC1_SBADDRLOW 0x1000a /* SB Address window Low (b15) */
60 #define SBSDIO_FUNC1_SBADDRMID 0x1000b /* SB Address window Mid (b23-b16) */
61 #define SBSDIO_FUNC1_SBADDRHIGH 0x1000c /* SB Address window High (b24-b31) */
64 #define SBSDIO_SBADDRLOW_MASK 0x80 /* Valid address bits in SBADDRLOW */
65 #define SBSDIO_SBADDRMID_MASK 0xff /* Valid address bits in SBADDRMID */
66 #define SBSDIO_SBADDRHIGH_MASK 0xff /* Valid address bits in SBADDRHIGH */
71 #define SBSDIO_SB_ACCESS_2_4B_FLAG 0x8000 /* forces 32-bit SB access */
75 * Address map within the SDIO function address space (128K).
78 * ------- ------- ------------------------------------------
79 * 0x00000 0x0ffff selected backplane address window (64K)
82 * The current address window is configured by writing to registers
85 * In order to access the contents of a 32-bit Silicon Backplane address
86 * the backplane address window must be first loaded with the highest
87 * 16 bits of the target address. Then, an access must be done to the
88 * SDIO function address space using the lower 15 bits of the address.
89 * Bit 15 of the address must be set when doing 32 bit accesses.
92 * WWWWWWWWWWWWWWWWW SB Address Window
93 * OOOOOOOOOOOOOOOO Offset within SB Address Window
94 * a 32-bit access flag
101 * NOTE: SDIO address @addr is 17 bits long (SDIO address space is 128K).
106 return &bus->host_sdio->dev; in ssb_sdio_dev()
114 sdio_writeb(bus->host_sdio, val, addr, &error); in ssb_sdio_writeb()
116 dev_dbg(ssb_sdio_dev(bus), "%08X <- %02x, error %d\n", in ssb_sdio_writeb()
129 val = sdio_readb(bus->host_sdio, addr, &error);
131 dev_dbg(ssb_sdio_dev(bus), "%08X -> %02x, error %d\n",
140 static int ssb_sdio_set_sbaddr_window(struct ssb_bus *bus, u32 address) in ssb_sdio_set_sbaddr_window() argument
145 (address >> 8) & SBSDIO_SBADDRLOW_MASK); in ssb_sdio_set_sbaddr_window()
149 (address >> 16) & SBSDIO_SBADDRMID_MASK); in ssb_sdio_set_sbaddr_window()
153 (address >> 24) & SBSDIO_SBADDRHIGH_MASK); in ssb_sdio_set_sbaddr_window()
156 bus->sdio_sbaddr = address; in ssb_sdio_set_sbaddr_window()
159 dev_dbg(ssb_sdio_dev(bus), "failed to set address window" in ssb_sdio_set_sbaddr_window()
160 " to 0x%08x, error %d\n", address, error); in ssb_sdio_set_sbaddr_window()
172 sdio_claim_host(bus->host_sdio); in ssb_sdio_scan_read32()
173 val = sdio_readl(bus->host_sdio, offset, &error); in ssb_sdio_scan_read32()
174 sdio_release_host(bus->host_sdio); in ssb_sdio_scan_read32()
177 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_scan_read32()
190 sdio_claim_host(bus->host_sdio); in ssb_sdio_scan_switch_coreidx()
192 sdio_release_host(bus->host_sdio); in ssb_sdio_scan_switch_coreidx()
205 u8 coreidx = dev->core_index; in ssb_sdio_switch_core()
210 if (unlikely(bus->sdio_sbaddr != sbaddr)) { in ssb_sdio_switch_core()
214 ssb_core_name(dev->id.coreid), coreidx); in ssb_sdio_switch_core()
222 bus->mapped_device = dev; in ssb_sdio_switch_core()
231 struct ssb_bus *bus = dev->bus; in ssb_sdio_read8()
235 sdio_claim_host(bus->host_sdio); in ssb_sdio_read8()
238 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_read8()
240 val = sdio_readb(bus->host_sdio, offset, &error); in ssb_sdio_read8()
243 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_read8()
246 sdio_release_host(bus->host_sdio); in ssb_sdio_read8()
253 struct ssb_bus *bus = dev->bus; in ssb_sdio_read16()
257 sdio_claim_host(bus->host_sdio); in ssb_sdio_read16()
260 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_read16()
262 val = sdio_readw(bus->host_sdio, offset, &error); in ssb_sdio_read16()
265 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_read16()
268 sdio_release_host(bus->host_sdio); in ssb_sdio_read16()
275 struct ssb_bus *bus = dev->bus; in ssb_sdio_read32()
279 sdio_claim_host(bus->host_sdio); in ssb_sdio_read32()
282 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_read32()
284 offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */ in ssb_sdio_read32()
285 val = sdio_readl(bus->host_sdio, offset, &error); in ssb_sdio_read32()
288 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_read32()
291 sdio_release_host(bus->host_sdio); in ssb_sdio_read32()
301 struct ssb_bus *bus = dev->bus; in ssb_sdio_block_read()
304 sdio_claim_host(bus->host_sdio); in ssb_sdio_block_read()
306 error = -EIO; in ssb_sdio_block_read()
310 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_block_read()
315 error = sdio_readsb(bus->host_sdio, buffer, offset, count); in ssb_sdio_block_read()
320 error = sdio_readsb(bus->host_sdio, buffer, offset, count); in ssb_sdio_block_read()
325 offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */ in ssb_sdio_block_read()
326 error = sdio_readsb(bus->host_sdio, buffer, offset, count); in ssb_sdio_block_read()
337 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error); in ssb_sdio_block_read()
339 sdio_release_host(bus->host_sdio); in ssb_sdio_block_read()
345 struct ssb_bus *bus = dev->bus; in ssb_sdio_write8()
348 sdio_claim_host(bus->host_sdio); in ssb_sdio_write8()
351 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_write8()
353 sdio_writeb(bus->host_sdio, val, offset, &error); in ssb_sdio_write8()
356 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_write8()
359 sdio_release_host(bus->host_sdio); in ssb_sdio_write8()
364 struct ssb_bus *bus = dev->bus; in ssb_sdio_write16()
367 sdio_claim_host(bus->host_sdio); in ssb_sdio_write16()
370 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_write16()
372 sdio_writew(bus->host_sdio, val, offset, &error); in ssb_sdio_write16()
375 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_write16()
378 sdio_release_host(bus->host_sdio); in ssb_sdio_write16()
383 struct ssb_bus *bus = dev->bus; in ssb_sdio_write32()
386 sdio_claim_host(bus->host_sdio); in ssb_sdio_write32()
389 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_write32()
391 offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */ in ssb_sdio_write32()
392 sdio_writel(bus->host_sdio, val, offset, &error); in ssb_sdio_write32()
395 bus->sdio_sbaddr >> 16, offset, val, error); in ssb_sdio_write32()
397 if (bus->quirks & SSB_QUIRK_SDIO_READ_AFTER_WRITE32) in ssb_sdio_write32()
398 sdio_readl(bus->host_sdio, 0, &error); in ssb_sdio_write32()
400 sdio_release_host(bus->host_sdio); in ssb_sdio_write32()
408 struct ssb_bus *bus = dev->bus; in ssb_sdio_block_write()
411 sdio_claim_host(bus->host_sdio); in ssb_sdio_block_write()
413 error = -EIO; in ssb_sdio_block_write()
416 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_block_write()
421 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
426 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
431 offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */ in ssb_sdio_block_write()
432 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
443 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error); in ssb_sdio_block_write()
445 sdio_release_host(bus->host_sdio); in ssb_sdio_block_write()
474 struct ssb_sprom *sprom = &iv->sprom; in ssb_sdio_get_invariants()
475 struct ssb_boardinfo *bi = &iv->boardinfo; in ssb_sdio_get_invariants()
481 sprom->boardflags_lo = 0; in ssb_sdio_get_invariants()
482 sprom->boardflags_hi = 0; in ssb_sdio_get_invariants()
484 tuple = bus->host_sdio->tuples; in ssb_sdio_get_invariants()
486 switch (tuple->code) { in ssb_sdio_get_invariants()
488 switch (tuple->data[0]) { in ssb_sdio_get_invariants()
490 GOTO_ERROR_ON((tuple->size != 7) && in ssb_sdio_get_invariants()
491 (tuple->data[1] != 6), in ssb_sdio_get_invariants()
493 /* fetch the MAC address. */ in ssb_sdio_get_invariants()
494 mac = tuple->data + 2; in ssb_sdio_get_invariants()
495 memcpy(sprom->il0mac, mac, ETH_ALEN); in ssb_sdio_get_invariants()
496 memcpy(sprom->et1mac, mac, ETH_ALEN); in ssb_sdio_get_invariants()
503 switch (tuple->data[0]) { in ssb_sdio_get_invariants()
505 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
507 sprom->revision = tuple->data[1]; in ssb_sdio_get_invariants()
510 GOTO_ERROR_ON((tuple->size != 5) && in ssb_sdio_get_invariants()
511 (tuple->size != 7), in ssb_sdio_get_invariants()
513 bi->vendor = tuple->data[1] | in ssb_sdio_get_invariants()
514 (tuple->data[2]<<8); in ssb_sdio_get_invariants()
517 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
519 sprom->board_rev = tuple->data[1]; in ssb_sdio_get_invariants()
522 GOTO_ERROR_ON((tuple->size != 9) && in ssb_sdio_get_invariants()
523 (tuple->size != 10), in ssb_sdio_get_invariants()
525 sprom->pa0b0 = tuple->data[1] | in ssb_sdio_get_invariants()
526 ((u16)tuple->data[2] << 8); in ssb_sdio_get_invariants()
527 sprom->pa0b1 = tuple->data[3] | in ssb_sdio_get_invariants()
528 ((u16)tuple->data[4] << 8); in ssb_sdio_get_invariants()
529 sprom->pa0b2 = tuple->data[5] | in ssb_sdio_get_invariants()
530 ((u16)tuple->data[6] << 8); in ssb_sdio_get_invariants()
531 sprom->itssi_a = tuple->data[7]; in ssb_sdio_get_invariants()
532 sprom->itssi_bg = tuple->data[7]; in ssb_sdio_get_invariants()
533 sprom->maxpwr_a = tuple->data[8]; in ssb_sdio_get_invariants()
534 sprom->maxpwr_bg = tuple->data[8]; in ssb_sdio_get_invariants()
540 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
542 sprom->country_code = tuple->data[1]; in ssb_sdio_get_invariants()
545 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
547 sprom->ant_available_a = tuple->data[1]; in ssb_sdio_get_invariants()
548 sprom->ant_available_bg = tuple->data[1]; in ssb_sdio_get_invariants()
551 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
553 sprom->antenna_gain.a0 = tuple->data[1]; in ssb_sdio_get_invariants()
554 sprom->antenna_gain.a1 = tuple->data[1]; in ssb_sdio_get_invariants()
555 sprom->antenna_gain.a2 = tuple->data[1]; in ssb_sdio_get_invariants()
556 sprom->antenna_gain.a3 = tuple->data[1]; in ssb_sdio_get_invariants()
559 GOTO_ERROR_ON((tuple->size != 3) && in ssb_sdio_get_invariants()
560 (tuple->size != 5), in ssb_sdio_get_invariants()
562 sprom->boardflags_lo = tuple->data[1] | in ssb_sdio_get_invariants()
563 ((u16)tuple->data[2] << 8); in ssb_sdio_get_invariants()
566 GOTO_ERROR_ON(tuple->size != 5, in ssb_sdio_get_invariants()
568 sprom->gpio0 = tuple->data[1]; in ssb_sdio_get_invariants()
569 sprom->gpio1 = tuple->data[2]; in ssb_sdio_get_invariants()
570 sprom->gpio2 = tuple->data[3]; in ssb_sdio_get_invariants()
571 sprom->gpio3 = tuple->data[4]; in ssb_sdio_get_invariants()
580 tuple = tuple->next; in ssb_sdio_get_invariants()
587 return -ENODEV; in ssb_sdio_get_invariants()
592 if (bus->bustype != SSB_BUSTYPE_SDIO) in ssb_sdio_exit()
599 if (bus->bustype != SSB_BUSTYPE_SDIO) in ssb_sdio_init()
602 bus->sdio_sbaddr = ~0; in ssb_sdio_init()