/* generic kernel variant of si_attach() */ si_t * si_kattach(osl_t *osh) { static bool ksii_attached = FALSE; if (!ksii_attached) { void *regs = REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE); if (si_doattach(&ksii, BCM4710_DEVICE_ID, osh, regs, SI_BUS, NULL, osh != SI_OSH ? &ksii.vars : NULL, osh != SI_OSH ? &ksii.varsz : NULL) == NULL) { if (NULL != ksii.common_info) MFREE(osh, ksii.common_info, sizeof(si_common_info_t)); SI_ERROR(("si_kattach: si_doattach failed\n")); REG_UNMAP(regs); return NULL; } REG_UNMAP(regs); /* save ticks normalized to ms for si_watchdog_ms() */ if (PMUCTL_ENAB(&ksii.pub)) { /* based on 32KHz ILP clock */ wd_msticks = 32; } else { wd_msticks = ALP_CLOCK / 1000; } ksii_attached = TRUE; SI_MSG(("si_kattach done. ccrev = %d, wd_msticks = %d\n", ksii.pub.ccrev, wd_msticks)); } return &ksii.pub; }
/* may be called with core in reset */ void si_detach(si_t *sih) { si_info_t *sii; uint idx; sii = SI_INFO(sih); if (sii == NULL) return; if (BUSTYPE(sih->bustype) == SI_BUS) for (idx = 0; idx < SI_MAXCORES; idx++) if (sii->common_info->regs[idx]) { REG_UNMAP(sii->common_info->regs[idx]); sii->common_info->regs[idx] = NULL; } if (1 == sii->common_info->attach_count--) { MFREE(sii->osh, sii->common_info, sizeof(si_common_info_t)); common_info_alloced = NULL; } #if !defined(BCMBUSTYPE) || (BCMBUSTYPE == SI_BUS) if (sii != &ksii) #endif /* !BCMBUSTYPE || (BCMBUSTYPE == SI_BUS) */ MFREE(sii->osh, sii, sizeof(si_info_t)); }
static int extpci_read_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) { uint32 addr, *reg = NULL, val; int ret = 0; if (pci_disabled || !(addr = config_cmd(sbh, bus, dev, func, off)) || !(reg = (uint32 *) REG_MAP(addr, len)) || BUSPROBE(val, reg)) val = 0xffffffff; val >>= 8 * (off & 3); if (len == 4) *((uint32 *) buf) = val; else if (len == 2) *((uint16 *) buf) = (uint16) val; else if (len == 1) *((uint8 *) buf) = (uint8) val; else ret = -1; if (reg) REG_UNMAP(reg); return ret; }
static int extpci_write_config(sb_t *sbh, uint bus, uint dev, uint func, uint off, void *buf, int len) { uint32 addr, *reg = NULL, val; int ret = 0; if (pci_disabled || !(addr = config_cmd(sbh, bus, dev, func, off)) || !(reg = (uint32 *) REG_MAP(addr, len)) || BUSPROBE(val, reg)) goto done; if (len == 4) val = *((uint32 *) buf); else if (len == 2) { val &= ~(0xffff << (8 * (off & 3))); val |= *((uint16 *) buf) << (8 * (off & 3)); } else if (len == 1) { val &= ~(0xff << (8 * (off & 3))); val |= *((uint8 *) buf) << (8 * (off & 3)); } else ret = -1; W_REG(reg, val); done: if (reg) REG_UNMAP(reg); return ret; }
/* Release access to the RoboSwitch */ void robo_detach(void *rinfo) { robo_info_t *robo = (robo_info_t *)rinfo; si_info_t *sii; sii = SI_INFO((si_t*)robo->sbh); if (robo->regs) { REG_UNMAP(robo->regs); robo->regs = NULL; } COMPILER_REFERENCE(sii); /* Free private state */ MFREE(sii->osh, robo, sizeof(robo_info_t)); }
void spi_reg_unmap(osl_t *osh, uintptr addr, int size) { REG_UNMAP((void*)(uintptr)addr); }
void sdstd_reg_unmap(osl_t *osh, int32 addr, int size) { REG_UNMAP((void*)(uintptr)addr); }