static void obio_attach_critical(struct obio_softc *sc) { struct obio_attach_args oa; cfdata_t cf; size_t i; for (i = 0; i < __arraycount(critical_devs); i++) { oa.obio_iot = sc->sc_iot; oa.obio_dmat = sc->sc_dmat; oa.obio_addr = critical_devs[i].addr; oa.obio_size = OBIOCF_SIZE_DEFAULT; oa.obio_intr = OBIOCF_INTR_DEFAULT; oa.obio_intrbase = OBIOCF_INTRBASE_DEFAULT; #if 0 if (oa.obio_addr != OBIOCF_ADDR_DEFAULT && (oa.obio_addr < sc->sc_base || oa.obio_addr >= sc->sc_base + sc->sc_size)) continue; #endif cf = config_search_ia(obio_find, sc->sc_dev, "obio", &oa); if (cf == NULL && critical_devs[i].required) panic("obio_attach_critical: failed to find %s!", critical_devs[i].name); oa.obio_addr = cf->cf_loc[OBIOCF_ADDR]; oa.obio_size = cf->cf_loc[OBIOCF_SIZE]; oa.obio_intr = cf->cf_loc[OBIOCF_INTR]; oa.obio_intrbase = cf->cf_loc[OBIOCF_INTRBASE]; config_attach(sc->sc_dev, cf, &oa, obio_print); } }
void mainbus_attach(device_t parent, device_t self, void *aux) { static const char * const devnames[] = { /* ATTACH ORDER */ "cpu", /* 1. CPU */ "vrip", "vr4102ip", "vr4122ip", "vr4181ip", /* 2. System BUS */ "txsim", "bivideo", "btnmgr", /* 3. misc */ }; struct mainbus_attach_args ma; int i; __mainbus_attached = 1; printf("\n"); /* system bus_space */ ma.ma_iot = hpcmips_system_bus_space(); hpcmips_init_bus_space((struct bus_space_tag_hpcmips *)ma.ma_iot, NULL, "main bus", 0, 0xffffffff); /* search and attach devices in order */ for (i = 0; i < sizeof(devnames) / sizeof(devnames[0]); i++) { ma.ma_name = devnames[i]; config_search_ia(mainbus_search, self, "mainbus", &ma); } /* APM */ config_found_ia(self, "hpcapmif", NULL, mainbus_print); }
static void uda1341_attach(device_t parent, device_t self, void *aux) { struct uda1341_softc *sc = device_private(self); struct ipaq_softc *psc = device_private(parent); aprint_normal("\n"); aprint_normal_dev(self, "UDA1341 CODEC\n"); sc->sc_dev = self; sc->sc_iot = psc->sc_iot; sc->sc_ioh = psc->sc_ioh; sc->sc_parent = psc; uda1341_L3_init(sc); uda1341_init(sc); uda1341_reset(sc); uda1341_reginit(sc); /* * Attach each devices */ config_search_ia(uda1341_search, self, "udaif", NULL); }
/* * use config_search_ia to find appropriate device, then call that device * directly with NULL device variable storage. A device can then * always tell the difference between the real and console init * by checking for NULL. */ int atari_config_found(cfdata_t pcfp, device_t parent, void *aux, cfprint_t pfn) { struct device temp; cfdata_t cf; const struct cfattach *ca; if (atari_realconfig) return config_found(parent, aux, pfn) != NULL; memset(&temp, 0, sizeof(temp)); if (parent == NULL) parent = &temp; parent->dv_cfdata = pcfp; parent->dv_cfdriver = config_cfdriver_lookup(pcfp->cf_name); parent->dv_unit = pcfp->cf_unit; if ((cf = config_search_ia(NULL, parent, NULL, aux)) != NULL) { ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname); if (ca != NULL) { (*ca->ca_attach)(parent, NULL, aux); parent->dv_cfdata = NULL; return 1; } } parent->dv_cfdata = NULL; return 0; }
void obio_cfattach(struct device *parent, struct device *self, void *aux) { struct gt_softc * const gt = device_private(parent); struct obio_softc *sc = device_private(self); struct gt_attach_args *ga = aux; uint32_t datal, datah; GT_OBIOFOUND(gt, ga); datal = bus_space_read_4(ga->ga_memt, ga->ga_memh, obio_info[ga->ga_unit].low_decode); datah = bus_space_read_4(ga->ga_memt, ga->ga_memh, obio_info[ga->ga_unit].high_decode); if (GT_LowAddr_GET(datal) > GT_HighAddr_GET(datah)) { aprint_normal(": disabled\n"); return; } sc->sc_memt = obio_bs_tags[ga->ga_unit]; if (sc->sc_memt == NULL) { aprint_normal(": unused\n"); return; } aprint_normal(": addr %#x-%#x, %s-endian\n", GT_LowAddr_GET(datal), GT_HighAddr_GET(datah), GT_PCISwap_GET(datal) == 1 ? "little" : "big"); config_search_ia(obio_cfsearch, &sc->sc_dev, "obio", NULL); }
static void L3i_attach(device_t parent, device_t self, void *aux) { struct L3i_softc *sc = device_private(self); sc->sc_dev = self; sc->sc_iot = &omap_bs_tag; aprint_normal(": L3i Interconnect\n"); sc->sc_ioh = 0; #ifdef NOTYET sc->sc_dmac = &omap_bus_dma_tag; #endif L3i_attached = 1; #ifdef L3I_DEBUG L3i_target_agent_check(sc, (bus_addr_t)OMAP2_TA_L4_CORE, "L4 core"); L3i_target_agent_check(sc, (bus_addr_t)OMAP2_TA_GPMC, "GPMC"); #endif #ifdef NOTYET /* * Attach all our devices */ config_search_ia(L3i_search, self, "L3i", NULL); #endif }
/* * API for device drivers. * * We provide wrapper routines to decouple the ABI for the SPI * device drivers from the ABI for the SPI bus drivers. */ static void spi_attach(device_t parent, device_t self, void *aux) { struct spi_softc *sc = device_private(self); struct spibus_attach_args *sba = aux; int i; aprint_naive(": SPI bus\n"); aprint_normal(": SPI bus\n"); sc->sc_controller = *sba->sba_controller; /* allocate slave structures */ sc->sc_slaves = malloc(sizeof (struct spi_handle) * sc->sc_nslaves, M_DEVBUF, M_WAITOK | M_ZERO); sc->sc_speed = 0; sc->sc_mode = -1; /* * Initialize slave handles */ sc->sc_nslaves = sba->sba_controller->sct_nslaves; for (i = 0; i < sc->sc_nslaves; i++) { sc->sc_slaves[i].sh_slave = i; sc->sc_slaves[i].sh_sc = sc; sc->sc_slaves[i].sh_controller = &sc->sc_controller; } /* * Locate and attach child devices */ config_search_ia(spi_search, self, "spi", NULL); }
static void vme_attach(device_t parent, device_t self, void *args) { struct confargs *ca = aux; struct vme_softc *sc = device_private(self); struct confargs vmea; int unit; sc->sc_dev = self; unit = device_unit(self); aprint_normal(": (%s)\n", vme_info[unit].name); sc->sc_bustag = ca->ca_bustag; sc->sc_dmatag = ca->ca_dmatag; sc->sc_bustype = unit; vme_space_tag.cookie = sc; vme_space_tag.parent = sc->sc_bustag; vme_dma_tag = *sc->sc_dmatag; vme_dma_tag._cookie = sc; vme_dma_tag._dmamap_load = vme_dmamap_load; vmea = *ca; vmea.ca_bustag = &vme_space_tag; vmea.ca_dmatag = &vme_dma_tag; /* We know ca_bustype == BUS_VMExx */ config_search_ia(bus_scan, self, "vme", args); }
static void obio_attach1(device_t self) { /* * Attach the rest of our devices */ config_search_ia(obio_search, self, "obio", NULL); }
static void nor_attach(device_t parent, device_t self, void *aux) { struct nor_softc * const sc = device_private(self); struct nor_attach_args * const naa = aux; struct nor_chip * const chip = &sc->sc_chip; sc->sc_dev = self; sc->sc_controller_dev = parent; sc->sc_nor_if = naa->naa_nor_if; aprint_naive("\n"); aprint_normal("\n"); if (nor_scan_media(self, chip)) return; sc->sc_flash_if = nor_flash_if; sc->sc_flash_if.erasesize = chip->nc_block_size; sc->sc_flash_if.page_size = chip->nc_page_size; sc->sc_flash_if.writesize = chip->nc_page_size; /* allocate cache */ #ifdef NOTYET chip->nc_oob_cache = kmem_alloc(chip->nc_spare_size, KM_SLEEP); #endif chip->nc_page_cache = kmem_alloc(chip->nc_page_size, KM_SLEEP); mutex_init(&sc->sc_device_lock, MUTEX_DEFAULT, IPL_NONE); if (flash_sync_thread_init(&sc->sc_flash_io, self, &sc->sc_flash_if)) { goto error; } if (!pmf_device_register1(sc->sc_dev, NULL, NULL, nor_shutdown)) aprint_error_dev(sc->sc_dev, "couldn't establish power handler\n"); #ifdef NOR_BBT nor_bbt_init(self); nor_bbt_scan(self); #endif /* * Attach all our devices */ config_search_ia(nor_search, self, NULL, NULL); return; error: #ifdef NOTET kmem_free(chip->nc_oob_cache, chip->nc_spare_size); #endif kmem_free(chip->nc_page_cache, chip->nc_page_size); mutex_destroy(&sc->sc_device_lock); }
static void mainbusattach(device_t parent, device_t self, void *aux) { aprint_normal("\n"); /* Search for and attach children. */ config_search_ia(mainbussearch, self, "mainbus", NULL); }
static void obmem_attach(device_t parent, device_t self, void *aux) { struct mainbus_attach_args *ma = aux; struct obmem_softc *sc = device_private(self); struct obmem_attach_args obma; const char *const *cpp; static const char *const special[] = { /* find these first */ NULL }; obmem_attached = 1; sc->sc_dev = self; aprint_normal("\n"); sc->sc_bustag = ma->ma_bustag; sc->sc_dmatag = ma->ma_dmatag; obmem_space_tag.cookie = sc; obmem_space_tag.parent = sc->sc_bustag; /* * Prepare the skeleton attach arguments for our devices. * The values we give in the locators are indications to * sun68k_bus_search about which locators must and must not * be defined. */ obma = *ma; obma.obma_bustag = &obmem_space_tag; obma.obma_paddr = LOCATOR_REQUIRED; obma.obma_pri = LOCATOR_OPTIONAL; /* Find all `early' obmem devices */ for (cpp = special; *cpp != NULL; cpp++) { obma.obma_name = *cpp; config_search_ia(sun68k_bus_search, self, "obmem", &obma); } /* Find all other obmem devices */ obma.obma_name = NULL; config_search_ia(sun68k_bus_search, self, "obmem", &obma); }
void tx39uart_attach(struct device *parent, struct device *self, void *aux) { struct txsim_attach_args *ta = aux; struct tx39uart_softc *sc = (void *)self; tx_chipset_tag_t tc; printf("\n"); sc->sc_tc = tc = ta->ta_tc; config_search_ia(tx39uart_search, self, "txcomif", tx39uart_print); }
static void apbh_attach(device_t parent, device_t self, void *aux) { struct apb_attach_args aa; static int apbh_attached = 0; if (apbh_attached) return; aa.aa_iot = &imx23_bus_space; aa.aa_dmat = &imx23_bus_dma_tag; aprint_normal("\n"); config_search_ia(apbh_search_crit_cb, self, "apbh", &aa); config_search_ia(apbh_search_cb, self, "apbh", &aa); apbh_attached = 1; return; }
void ixpsip_attach(struct device *parent, struct device *self, void *aux) { struct ixpsip_softc *sc = (void *) self; sc->sc_iot = &ixp12x0_bs_tag; printf("\n"); /* * Attach each devices */ config_search_ia(ixpsip_search, self, "ixpsip", NULL); }
void ixpsip_attach(device_t parent, device_t self, void *aux) { struct ixpsip_softc *sc = device_private(self); sc->sc_iot = &ixp12x0_bs_tag; printf("\n"); /* * Attach each devices */ config_search_ia(ixpsip_search, self, "ixpsip", NULL); }
static void rsbus_attach(device_t parent, device_t self, void *aux) { struct rsbus_softc *sc = device_private(self); sc->sc_iot = &rsbus_bs_tag; printf("\n"); /* * Attach each devices */ config_search_ia(rsbus_search, self, "rsbus", NULL); }
static void tipb_attach(struct device *parent, struct device *self, void *aux) { struct tipb_softc *sc = (struct tipb_softc *)self; tipb_attached = 1; #if NOMAPDMAC > 0 #error DMA not implemented sc->sc_dmac = &omap_bus_dma_tag; #else sc->sc_dmac = NULL; #endif aprint_normal(": Texas Instruments Peripheral Bus\n"); aprint_naive("\n"); /* * There are some devices that need to be set up before all the * others. The earlies array contains their names. Find them and * attach them in the order they appear in the array. */ const char *const *earlyp; for (earlyp = earlies; *earlyp != NULL; earlyp++) /* * The bus search function is passed an aux argument that * "describes the device that has been found". The type of it * is void *. However, I want to pass a constant string, so * use __UNCONST to convince the compiler that this is ok. */ config_search_ia(tipb_search, self, "tipb", __UNCONST(*earlyp)); /* * Attach all other devices */ config_search_ia(tipb_search, self, "tipb", NULL); }
static void mainbus_attach(struct device *parent, struct device *self, void *aux) { struct mainbus_attach_args mba; printf("\n"); mba.mba_dmat = &next68k_bus_dma_tag; /* Search for and attach children. */ config_search_ia(mainbus_search, self, "mainbus", &mba); mainbus_attached = 1; }
void s3c2440_i2s_attach(device_t parent, device_t self, void *aux) { struct s3c2440_i2s_softc *sc = device_private(self); DPRINTF(("%s\n", __func__)); sc->sc_dev = self; s3c2440_i2s_init(sc); printf("\n"); config_search_ia(s3c2440_i2s_search, self, "ssiis", NULL); }
void g2busattach(device_t parent, device_t self, void *aux) { struct g2bus_softc *sc = device_private(self); struct g2bus_attach_args ga; sc->sc_dev = self; printf("\n"); TAILQ_INIT(&sc->sc_subdevs); g2bus_bus_mem_init(sc); ga.ga_memt = &sc->sc_memt; config_search_ia(g2bussearch, self, "g2bus", &ga); }
int imxusbc_attach_common(device_t parent, device_t self, bus_space_tag_t iot) { struct imxusbc_softc *sc = device_private(self); sc->sc_iot = iot; /* Map entire USBOH3 registers. Host controller drivers * re-use subregions of this. */ if (bus_space_map(iot, USBOH3_BASE, USBOH3_SIZE, 0, &sc->sc_ioh)) return -1; /* attach OTG/EHCI host controllers */ config_search_ia(imxusbc_search, self, "imxusbc", NULL); return 0; }
static void bcmccb_mainbus_attach(device_t parent, device_t self, void *aux) { struct bcmccb_softc * const sc = &bcmccb_sc; sc->sc_dev = self; self->dv_private = sc; sc->sc_bst = bcm53xx_ioreg_bst; bus_space_subregion (sc->sc_bst, bcm53xx_ioreg_bsh, CCB_BASE, CCB_SIZE, &sc->sc_bsh); aprint_naive("\n"); aprint_normal("\n"); for (size_t i = 0; i < __arraycount(bcmccb_locators); i++) { const struct bcm_locators *loc = &bcmccb_locators[i]; #ifdef BCM5301X if (strcmp(loc->loc_name, "bcmsw") == 0) { bcm53xx_srab_init(); // need this for ethernet. } #endif struct bcmccb_attach_args ccbaa = { .ccbaa_ccb_bst = sc->sc_bst, .ccbaa_ccb_bsh = sc->sc_bsh, .ccbaa_dmat = &bcm53xx_dma_tag, .ccbaa_loc = *loc, }; /* * If the device might be in reset, let's try to take it * out of it. If it fails or is unavailable, skip it. */ if (!bcm53xx_idm_device_init(loc, sc->sc_bst, sc->sc_bsh)) continue; cfdata_t cf = config_search_ia(bcmccb_find, self, "bcmccb", &ccbaa); if (cf != NULL) config_attach(self, cf, &ccbaa, bcmccb_print); } }
static void ixme_attach(device_t parent, device_t self, void *arg) { struct ixme_softc *sc = device_private(self); extern paddr_t physical_start, physical_end; aprint_naive("\n"); aprint_normal(": IXP4xx MicroEngine Support\n"); sc->sc_qmgr = ixpqmgr_init(&ixp425_bs_tag); if (sc->sc_qmgr == NULL) { panic("%s: ixme_attach: Failed to init Queue Manager", device_xname(self)); } sc->sc_dr.dr_sysbase = physical_start; sc->sc_dr.dr_busbase = 0; sc->sc_dr.dr_len = physical_end - physical_start; sc->sc_dt._ranges = &sc->sc_dr; sc->sc_dt._nranges = 1; sc->sc_dt._dmamap_create = _bus_dmamap_create; sc->sc_dt._dmamap_destroy = _bus_dmamap_destroy; sc->sc_dt._dmamap_load = _bus_dmamap_load; sc->sc_dt._dmamap_load_mbuf = _bus_dmamap_load_mbuf; sc->sc_dt._dmamap_load_uio = _bus_dmamap_load_uio; sc->sc_dt._dmamap_load_raw = _bus_dmamap_load_raw; sc->sc_dt._dmamap_unload = _bus_dmamap_unload; sc->sc_dt._dmamap_sync_pre = _bus_dmamap_sync; sc->sc_dt._dmamap_sync_post = NULL; sc->sc_dt._dmamem_alloc = _bus_dmamem_alloc; sc->sc_dt._dmamem_free = _bus_dmamem_free; sc->sc_dt._dmamem_map = _bus_dmamem_map; sc->sc_dt._dmamem_unmap = _bus_dmamem_unmap; sc->sc_dt._dmamem_mmap = _bus_dmamem_mmap; sc->sc_dt._dmatag_subregion = _bus_dmatag_subregion; sc->sc_dt._dmatag_destroy = _bus_dmatag_destroy; config_search_ia(ixme_search, self, "ixme", NULL); }
static void tegraio_scan(device_t self, bus_space_handle_t bsh, const struct tegra_locators *locators, u_int count) { const struct tegra_locators * const eloc = locators + count; for (const struct tegra_locators *loc = locators; loc < eloc; loc++) { struct tegraio_attach_args tio = { .tio_loc = *loc, .tio_bst = &armv7_generic_bs_tag, .tio_a4x_bst = &armv7_generic_a4x_bs_tag, .tio_bsh = bsh, .tio_dmat = &tegra_dma_tag, .tio_coherent_dmat = &tegra_coherent_dma_tag, }; cfdata_t cf = config_search_ia(tegraio_find, self, "tegraio", &tio); if (cf != NULL) config_attach(self, cf, &tio, tegraio_print); } }
static void ocp_attach(struct device *parent, struct device *self, void *aux) { struct ocp_softc *sc = (struct ocp_softc *)self; ocp_attached = 1; #if NOMAPDMAC > 0 #error DMA not implemented sc->sc_dmac = &omap_bus_dma_tag; #else sc->sc_dmac = NULL; #endif aprint_normal(": OCP Bus\n"); aprint_naive("\n"); /* * Attach all our devices */ config_search_ia(ocp_search, self, "ocp", NULL); }
static void j720ssp_attach(device_t parent, device_t self, void *aux) { struct j720ssp_softc *sc = device_private(self); struct sa11x0_softc *psc = device_private(parent); struct sa11x0_attach_args *sa = aux; sc->sc_dev = self; sc->sc_iot = psc->sc_iot; sc->sc_gpioh = psc->sc_gpioh; sc->sc_parent = psc; if (bus_space_map(sc->sc_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ssph)) { aprint_normal(": unable to map SSP registers\n"); return; } aprint_normal("\n"); config_search_ia(j720ssp_search, self, "j720ssp", NULL); }
static void mfp_attach(device_t parent, device_t self, void *aux) { struct mfp_softc *sc = device_private(self); struct intio_attach_args *ia = aux; int r; aprint_normal("\n"); mfp_attached = 1; /* mfp_init() is already called via early config_console() */ sc->sc_bst = ia->ia_bst; sc->sc_intr = ia->ia_intr; ia->ia_size = 0x30; r = intio_map_allocate_region(parent, ia, INTIO_MAP_ALLOCATE); #ifdef DIAGNOSTIC if (r) panic("IO map for MFP corruption??"); #endif bus_space_map(ia->ia_bst, ia->ia_addr, 0x2000, 0, &sc->sc_bht); config_search_ia(mfp_search, self, "mfp", NULL); }
void ixpsip_attach(device_t parent, device_t self, void *aux) { struct ixpsip_softc *sc = device_private(self); sc->sc_iot = &ixp425_bs_tag; ixpsip_softc = sc; printf("\n"); if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE, 0, &sc->sc_ioh)) { printf("%s: Can't map expansion bus control registers!\n", device_xname(self)); return; } /* * Attach each devices */ config_search_ia(ixpsip_search, self, "ixpsip", NULL); }
void cs80busattach(device_t parent, device_t self, void *aux) { struct cs80bus_softc *sc = device_private(self); struct gpib_attach_args *ga = aux; struct cs80bus_attach_args ca; int slave; u_int16_t id; printf("\n"); sc->sc_dev = self; sc->sc_ic = ga->ga_ic; for (slave = 0; slave < 8; slave++) { if (gpib_isalloc(device_private(device_parent(sc->sc_dev)), slave)) continue; if (gpibrecv(sc->sc_ic, GPIB_BROADCAST_ADDR, slave, &id, 2) != 2) continue; BE16TOH(id); DPRINTF(DBG_STATUS, ("cs80busattach: found id 0x%x\n", id)); if ((id & 0x200) == 0) continue; ca.ca_ic = sc->sc_ic; ca.ca_slave = slave; ca.ca_id = id; (void)config_search_ia(cs80bussearch, sc->sc_dev, "cs80bus", &ca); } }