Lines Matching +full:offset +full:- +full:x

3  * SDIO-Hostbus related functions
9 * Copyright 2007-2008 Michael Buesch <m@bues.ch>
60 #define SBSDIO_FUNC1_SBADDRMID 0x1000b /* SB Address window Mid (b23-b16) */
61 #define SBSDIO_FUNC1_SBADDRHIGH 0x1000c /* SB Address window High (b24-b31) */
68 #define SBSDIO_SB_OFT_ADDR_MASK 0x7FFF /* sb offset addr is <= 15 bits, 32k */
71 #define SBSDIO_SB_ACCESS_2_4B_FLAG 0x8000 /* forces 32-bit SB access */
78 * ------- ------- ------------------------------------------
85 * In order to access the contents of a 32-bit Silicon Backplane address
93 * OOOOOOOOOOOOOOOO Offset within SB Address Window
94 * a 32-bit access flag
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",
156 bus->sdio_sbaddr = address; in ssb_sdio_set_sbaddr_window()
160 " to 0x%08x, error %d\n", address, error); in ssb_sdio_set_sbaddr_window()
167 u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset) in ssb_sdio_scan_read32() argument
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()
176 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %08x, error %d\n", 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()
229 static u8 ssb_sdio_read8(struct ssb_device *dev, u16 offset) in ssb_sdio_read8() argument
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()
239 offset &= SBSDIO_SB_OFT_ADDR_MASK; in ssb_sdio_read8()
240 val = sdio_readb(bus->host_sdio, offset, &error); in ssb_sdio_read8()
242 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %02x, error %d\n", 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()
251 static u16 ssb_sdio_read16(struct ssb_device *dev, u16 offset) in ssb_sdio_read16() argument
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()
261 offset &= SBSDIO_SB_OFT_ADDR_MASK; in ssb_sdio_read16()
262 val = sdio_readw(bus->host_sdio, offset, &error); in ssb_sdio_read16()
264 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %04x, error %d\n", 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()
273 static u32 ssb_sdio_read32(struct ssb_device *dev, u16 offset) in ssb_sdio_read32() argument
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()
283 offset &= SBSDIO_SB_OFT_ADDR_MASK; 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()
287 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X > %08x, error %d\n", 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()
298 size_t count, u16 offset, u8 reg_width) in ssb_sdio_block_read() argument
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()
311 offset &= SBSDIO_SB_OFT_ADDR_MASK; 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()
336 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n", 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()
343 static void ssb_sdio_write8(struct ssb_device *dev, u16 offset, u8 val) in ssb_sdio_write8() argument
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()
352 offset &= SBSDIO_SB_OFT_ADDR_MASK; in ssb_sdio_write8()
353 sdio_writeb(bus->host_sdio, val, offset, &error); in ssb_sdio_write8()
355 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %02x, error %d\n", 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()
362 static void ssb_sdio_write16(struct ssb_device *dev, u16 offset, u16 val) in ssb_sdio_write16() argument
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()
371 offset &= SBSDIO_SB_OFT_ADDR_MASK; in ssb_sdio_write16()
372 sdio_writew(bus->host_sdio, val, offset, &error); in ssb_sdio_write16()
374 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %04x, error %d\n", 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()
381 static void ssb_sdio_write32(struct ssb_device *dev, u16 offset, u32 val) in ssb_sdio_write32() argument
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()
390 offset &= SBSDIO_SB_OFT_ADDR_MASK; 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()
394 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X < %08x, error %d\n", 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()
405 size_t count, u16 offset, u8 reg_width) in ssb_sdio_block_write() argument
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()
417 offset |= bus->sdio_sbaddr & 0xffff; in ssb_sdio_block_write()
418 offset &= SBSDIO_SB_OFT_ADDR_MASK; in ssb_sdio_block_write()
422 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
427 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
432 offset |= SBSDIO_SB_ACCESS_2_4B_FLAG; /* 32 bit data access */ in ssb_sdio_block_write()
433 error = sdio_writesb(bus->host_sdio, offset, in ssb_sdio_block_write()
443 dev_dbg(ssb_sdio_dev(bus), "%04X:%04X (width=%u, len=%zu), error %d\n", in ssb_sdio_block_write()
444 bus->sdio_sbaddr >> 16, offset, reg_width, saved_count, error); in ssb_sdio_block_write()
446 sdio_release_host(bus->host_sdio); in ssb_sdio_block_write()
475 struct ssb_sprom *sprom = &iv->sprom; in ssb_sdio_get_invariants()
476 struct ssb_boardinfo *bi = &iv->boardinfo; in ssb_sdio_get_invariants()
482 sprom->boardflags_lo = 0; in ssb_sdio_get_invariants()
483 sprom->boardflags_hi = 0; in ssb_sdio_get_invariants()
485 tuple = bus->host_sdio->tuples; in ssb_sdio_get_invariants()
487 switch (tuple->code) { in ssb_sdio_get_invariants()
489 switch (tuple->data[0]) { in ssb_sdio_get_invariants()
491 GOTO_ERROR_ON((tuple->size != 7) && in ssb_sdio_get_invariants()
492 (tuple->data[1] != 6), in ssb_sdio_get_invariants()
495 mac = tuple->data + 2; in ssb_sdio_get_invariants()
496 memcpy(sprom->il0mac, mac, ETH_ALEN); in ssb_sdio_get_invariants()
497 memcpy(sprom->et1mac, mac, ETH_ALEN); in ssb_sdio_get_invariants()
504 switch (tuple->data[0]) { in ssb_sdio_get_invariants()
506 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
508 sprom->revision = tuple->data[1]; in ssb_sdio_get_invariants()
511 GOTO_ERROR_ON((tuple->size != 5) && in ssb_sdio_get_invariants()
512 (tuple->size != 7), in ssb_sdio_get_invariants()
514 bi->vendor = tuple->data[1] | in ssb_sdio_get_invariants()
515 (tuple->data[2]<<8); in ssb_sdio_get_invariants()
518 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
520 sprom->board_rev = tuple->data[1]; in ssb_sdio_get_invariants()
523 GOTO_ERROR_ON((tuple->size != 9) && in ssb_sdio_get_invariants()
524 (tuple->size != 10), in ssb_sdio_get_invariants()
526 sprom->pa0b0 = tuple->data[1] | in ssb_sdio_get_invariants()
527 ((u16)tuple->data[2] << 8); in ssb_sdio_get_invariants()
528 sprom->pa0b1 = tuple->data[3] | in ssb_sdio_get_invariants()
529 ((u16)tuple->data[4] << 8); in ssb_sdio_get_invariants()
530 sprom->pa0b2 = tuple->data[5] | in ssb_sdio_get_invariants()
531 ((u16)tuple->data[6] << 8); in ssb_sdio_get_invariants()
532 sprom->itssi_a = tuple->data[7]; in ssb_sdio_get_invariants()
533 sprom->itssi_bg = tuple->data[7]; in ssb_sdio_get_invariants()
534 sprom->maxpwr_a = tuple->data[8]; in ssb_sdio_get_invariants()
535 sprom->maxpwr_bg = tuple->data[8]; in ssb_sdio_get_invariants()
541 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
543 sprom->country_code = tuple->data[1]; in ssb_sdio_get_invariants()
546 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
548 sprom->ant_available_a = tuple->data[1]; in ssb_sdio_get_invariants()
549 sprom->ant_available_bg = tuple->data[1]; in ssb_sdio_get_invariants()
552 GOTO_ERROR_ON(tuple->size != 2, in ssb_sdio_get_invariants()
554 sprom->antenna_gain.a0 = tuple->data[1]; in ssb_sdio_get_invariants()
555 sprom->antenna_gain.a1 = tuple->data[1]; in ssb_sdio_get_invariants()
556 sprom->antenna_gain.a2 = tuple->data[1]; in ssb_sdio_get_invariants()
557 sprom->antenna_gain.a3 = tuple->data[1]; in ssb_sdio_get_invariants()
560 GOTO_ERROR_ON((tuple->size != 3) && in ssb_sdio_get_invariants()
561 (tuple->size != 5), in ssb_sdio_get_invariants()
563 sprom->boardflags_lo = tuple->data[1] | in ssb_sdio_get_invariants()
564 ((u16)tuple->data[2] << 8); in ssb_sdio_get_invariants()
567 GOTO_ERROR_ON(tuple->size != 5, in ssb_sdio_get_invariants()
569 sprom->gpio0 = tuple->data[1]; in ssb_sdio_get_invariants()
570 sprom->gpio1 = tuple->data[2]; in ssb_sdio_get_invariants()
571 sprom->gpio2 = tuple->data[3]; in ssb_sdio_get_invariants()
572 sprom->gpio3 = tuple->data[4]; in ssb_sdio_get_invariants()
581 tuple = tuple->next; in ssb_sdio_get_invariants()
588 return -ENODEV; in ssb_sdio_get_invariants()
593 if (bus->bustype != SSB_BUSTYPE_SDIO) in ssb_sdio_exit()
600 if (bus->bustype != SSB_BUSTYPE_SDIO) in ssb_sdio_init()
603 bus->sdio_sbaddr = ~0; in ssb_sdio_init()