Lines Matching +full:gain +full:- +full:offset

5  * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de>
16 #include <linux/dma-mapping.h>
22 * bcma_arch_register_fallback_sprom - Registers a method providing a
33 * This function is useful for weird architectures that have a half-assed
43 return -EEXIST; in bcma_arch_register_fallback_sprom()
55 err = -ENOENT; in bcma_fill_sprom_with_fallback()
64 bus->sprom.revision); in bcma_fill_sprom_with_fallback()
75 static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom, in bcma_sprom_read() argument
80 sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2)); in bcma_sprom_read()
132 for (word = 0; word < words - 1; word++) { in bcma_sprom_crc()
136 crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF); in bcma_sprom_crc()
149 tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC; in bcma_sprom_check_crc()
152 return -EPROTO; in bcma_sprom_check_crc()
167 revision = sprom[words - 1] & SSB_SPROM_REVISION_REV; in bcma_sprom_valid()
170 return -ENOENT; in bcma_sprom_valid()
173 bus->sprom.revision = revision; in bcma_sprom_valid()
183 #define SPOFF(offset) ((offset) / sizeof(u16)) argument
186 bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
189 bus->sprom._field = ((((u32)sprom[SPOFF((_offset)+2)] << 16 | \
204 static s8 sprom_extract_antgain(const u16 *in, u16 offset, u16 mask, u16 shift) in sprom_extract_antgain() argument
207 u8 gain; in sprom_extract_antgain() local
209 v = in[SPOFF(offset)]; in sprom_extract_antgain()
210 gain = (v & mask) >> shift; in sprom_extract_antgain()
211 if (gain == 0xFF) { in sprom_extract_antgain()
212 gain = 8; /* If unset use 2dBm */ in sprom_extract_antgain()
215 gain = ((gain & 0xC0) >> 6) | ((gain & 0x3F) << 2); in sprom_extract_antgain()
218 return (s8)gain; in sprom_extract_antgain()
230 ARRAY_SIZE(bus->sprom.core_pwr_info)); in bcma_sprom_extract_r8()
234 *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v); in bcma_sprom_extract_r8()
400 /* Extract the antenna gain values. */ in bcma_sprom_extract_r8()
401 bus->sprom.antenna_gain.a0 = sprom_extract_antgain(sprom, in bcma_sprom_extract_r8()
405 bus->sprom.antenna_gain.a1 = sprom_extract_antgain(sprom, in bcma_sprom_extract_r8()
409 bus->sprom.antenna_gain.a2 = sprom_extract_antgain(sprom, in bcma_sprom_extract_r8()
413 bus->sprom.antenna_gain.a3 = sprom_extract_antgain(sprom, in bcma_sprom_extract_r8()
486 if (bus->drv_cc.core->id.rev >= 31) { in bcma_sprom_ext_available()
487 if (!(bus->drv_cc.capabilities & BCMA_CC_CAP_SPROM)) in bcma_sprom_ext_available()
490 srom_control = bcma_read32(bus->drv_cc.core, in bcma_sprom_ext_available()
496 chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT); in bcma_sprom_ext_available()
497 switch (bus->chipinfo.id) { in bcma_sprom_ext_available()
514 * Indicates that on-chip OTP memory is present and enabled.
522 chip_status = bcma_read32(bus->drv_cc.core, BCMA_CC_CHIPSTAT); in bcma_sprom_onchip_available()
523 switch (bus->chipinfo.id) { in bcma_sprom_onchip_available()
550 otpsize = bus->drv_cc.capabilities & BCMA_CC_CAP_OTPS; in bcma_sprom_onchip_available()
559 * offset where SPROM data is located.
561 * On error, returns 0; byte offset otherwise.
565 struct bcma_device *cc = bus->drv_cc.core; in bcma_sprom_onchip_offset()
566 u32 offset; in bcma_sprom_onchip_offset() local
572 /* obtain bit offset from otplayout register */ in bcma_sprom_onchip_offset()
573 offset = (bcma_read32(cc, BCMA_CC_OTPL) & BCMA_CC_OTPL_GURGN_OFFSET); in bcma_sprom_onchip_offset()
574 return BCMA_CC_SPROM + (offset >> 3); in bcma_sprom_onchip_offset()
579 u16 offset = BCMA_CC_SPROM; in bcma_sprom_get() local
588 if (!bus->drv_cc.core) in bcma_sprom_get()
589 return -EOPNOTSUPP; in bcma_sprom_get()
596 * on-chip OTP only when no external SPROM in bcma_sprom_get()
601 /* determine offset */ in bcma_sprom_get()
602 offset = bcma_sprom_onchip_offset(bus); in bcma_sprom_get()
604 if (!offset || !sprom_onchip) { in bcma_sprom_get()
610 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); in bcma_sprom_get()
615 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || in bcma_sprom_get()
616 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) in bcma_sprom_get()
617 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false); in bcma_sprom_get()
619 bcma_debug(bus, "SPROM offset 0x%x\n", offset); in bcma_sprom_get()
625 return -ENOMEM; in bcma_sprom_get()
627 bcma_sprom_read(bus, offset, sprom, words); in bcma_sprom_get()
635 if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 || in bcma_sprom_get()
636 bus->chipinfo.id == BCMA_CHIP_ID_BCM43431) in bcma_sprom_get()
637 bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true); in bcma_sprom_get()
641 err = bcma_fill_sprom_with_fallback(bus, &bus->sprom); in bcma_sprom_get()