void vexpress_device_register(device_t self, void *aux) { prop_dictionary_t dict = device_properties(self); if (device_is_a(self, "armperiph") && device_is_a(device_parent(self), "mainbus")) { /* * XXX KLUDGE ALERT XXX * The iot mainbus supplies is completely wrong since it scales * addresses by 2. The simpliest remedy is to replace with our * bus space used for the armcore regisers (which armperiph uses). */ struct mainbus_attach_args *const mb = aux; mb->mb_iot = &vexpress_bs_tag; return; } #if defined(CPU_CORTEXA7) || defined(CPU_CORTEXA15) if (device_is_a(self, "armgtmr")) { /* * The frequency of the generic timer is the reference * frequency. */ prop_dictionary_set_uint32(dict, "frequency", VEXPRESS_REF_FREQ); return; } #endif }
static void cpsw_attach(device_t parent, device_t self, void *aux) { struct obio_attach_args * const oa = aux; struct cpsw_softc * const sc = device_private(self); prop_dictionary_t dict = device_properties(self); struct ethercom * const ec = &sc->sc_ec; struct ifnet * const ifp = &ec->ec_if; int error; u_int i; KERNHIST_INIT(cpswhist, 4096); sc->sc_dev = self; aprint_normal(": TI CPSW Ethernet\n"); aprint_naive("\n"); callout_init(&sc->sc_tick_ch, 0); callout_setfunc(&sc->sc_tick_ch, cpsw_tick, sc); prop_data_t eaprop = prop_dictionary_get(dict, "mac-address"); if (eaprop == NULL) { /* grab mac_id0 from AM335x control module */ uint32_t reg_lo, reg_hi; if (sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_LO, ®_lo) == 0 && sitara_cm_reg_read_4(OMAP2SCM_MAC_ID0_HI, ®_hi) == 0) { sc->sc_enaddr[0] = (reg_hi >> 0) & 0xff; sc->sc_enaddr[1] = (reg_hi >> 8) & 0xff; sc->sc_enaddr[2] = (reg_hi >> 16) & 0xff; sc->sc_enaddr[3] = (reg_hi >> 24) & 0xff; sc->sc_enaddr[4] = (reg_lo >> 0) & 0xff; sc->sc_enaddr[5] = (reg_lo >> 8) & 0xff; } else {
void ibm4xx_device_register(struct device *dev, void *aux) { struct device *parent = device_parent(dev); if (device_is_a(dev, "emac") && device_is_a(parent, "opb")) { /* Set the mac-addr of the on-chip Ethernet. */ struct opb_attach_args *oaa = aux; if (oaa->opb_instance < 10) { prop_data_t pd; unsigned char prop_name[15]; snprintf(prop_name, sizeof(prop_name), "emac%d-mac-addr", oaa->opb_instance); pd = prop_dictionary_get(board_properties, prop_name); if (pd == NULL) { printf("WARNING: unable to get mac-addr " "property from board properties\n"); return; } if (prop_dictionary_set(device_properties(dev), "mac-addr", pd) == false) { printf("WARNING: unable to set mac-addr " "property for %s\n", dev->dv_xname); } } return; } }
static void via_mapchan(const struct pci_attach_args *pa, struct pciide_channel *cp, pcireg_t interface, int (*pci_intr)(void *)) { struct ata_channel *wdc_cp; struct pciide_softc *sc; prop_bool_t compat_nat_enable; wdc_cp = &cp->ata_channel; sc = CHAN_TO_PCIIDE(&cp->ata_channel); compat_nat_enable = prop_dictionary_get( device_properties(sc->sc_wdcdev.sc_atac.atac_dev), "use-compat-native-irq"); if (interface & PCIIDE_INTERFACE_PCI(wdc_cp->ch_channel)) { /* native mode with irq 14/15 requested? */ if (compat_nat_enable != NULL && prop_bool_true(compat_nat_enable)) via_mapregs_compat_native(pa, cp); else pciide_mapregs_native(pa, cp, pci_intr); } else { pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel); if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0) pciide_map_compat_intr(pa, cp, wdc_cp->ch_channel); } wdcattach(wdc_cp); }
static void fd_set_properties(struct fd_softc *fd) { prop_dictionary_t disk_info, odisk_info, geom; const struct fd_type *fdt; int secsize; fdt = fd->sc_type; if (fdt == NULL) { fdt = fd->sc_deftype; if (fdt == NULL) return; } disk_info = prop_dictionary_create(); geom = prop_dictionary_create(); prop_dictionary_set_uint64(geom, "sectors-per-unit", fdt->size); switch (fdt->secsize) { case 2: secsize = 512; break; case 3: secsize = 1024; break; default: secsize = 0; } prop_dictionary_set_uint32(geom, "sector-size", secsize); prop_dictionary_set_uint16(geom, "sectors-per-track", fdt->sectrac); prop_dictionary_set_uint16(geom, "tracks-per-cylinder", fdt->heads); prop_dictionary_set_uint64(geom, "cylinders-per-unit", fdt->cyls); prop_dictionary_set(disk_info, "geometry", geom); prop_object_release(geom); prop_dictionary_set(device_properties(fd->sc_dev), "disk-info", disk_info); /* * Don't release disk_info here; we keep a reference to it. * disk_detach() will release it when we go away. */ odisk_info = fd->sc_dk.dk_info; fd->sc_dk.dk_info = disk_info; if (odisk_info) prop_object_release(odisk_info); }
static void epe_attach(device_t parent, device_t self, void *aux) { struct epe_softc *sc = device_private(self); struct epsoc_attach_args *sa; prop_data_t enaddr; aprint_normal("\n"); sa = aux; sc->sc_dev = self; sc->sc_iot = sa->sa_iot; sc->sc_intr = sa->sa_intr; sc->sc_dmat = sa->sa_dmat; if (bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", device_xname(self)); /* Fetch the Ethernet address from property if set. */ enaddr = prop_dictionary_get(device_properties(self), "mac-address"); if (enaddr != NULL) { KASSERT(prop_object_type(enaddr) == PROP_TYPE_DATA); KASSERT(prop_data_size(enaddr) == ETHER_ADDR_LEN); memcpy(sc->sc_enaddr, prop_data_data_nocopy(enaddr), ETHER_ADDR_LEN); bus_space_write_4(sc->sc_iot, sc->sc_ioh, EPE_AFP, 0); bus_space_write_region_1(sc->sc_iot, sc->sc_ioh, EPE_IndAd, sc->sc_enaddr, ETHER_ADDR_LEN); } ep93xx_intr_establish(sc->sc_intr, IPL_NET, epe_intr, sc); epe_init(sc); }
static void awin_tve_attach(device_t parent, device_t self, void *aux) { struct awin_tve_softc *sc = device_private(self); struct awinio_attach_args * const aio = aux; const struct awin_locators * const loc = &aio->aio_loc; prop_dictionary_t cfg = device_properties(self); int8_t tcon_unit = -1; sc->sc_dev = self; sc->sc_bst = aio->aio_core_bst; bus_space_subregion(sc->sc_bst, aio->aio_core_bsh, loc->loc_offset, loc->loc_size, &sc->sc_bsh); if (prop_dictionary_get_int8(cfg, "tcon_unit", &tcon_unit)) { sc->sc_tcon_unit = tcon_unit; } else { sc->sc_tcon_unit = 0; /* default value */ } sc->sc_tcon_pll = awin_tcon_get_clk_pll(sc->sc_tcon_unit); switch (sc->sc_tcon_pll) { case 3: awin_pll3_enable(); break; case 7: awin_pll7_enable(); break; default: panic("awin_tve pll"); } /* for now assume we're always at 0 */ awin_reg_set_clear(aio->aio_core_bst, aio->aio_ccm_bsh, AWIN_AHB_GATING1_REG, AWIN_AHB_GATING1_TVE0, 0); aprint_naive("\n"); aprint_normal(": TV Encoder / VGA output\n"); if (tcon_unit >= 0) { aprint_verbose_dev(self, ": using TCON%d, pll%d\n", sc->sc_tcon_unit, sc->sc_tcon_pll); } sc->sc_i2c_blklen = 16; #if 0 sc->sc_ih = intr_establish(loc->loc_intr, IPL_SCHED, IST_LEVEL, awin_tve_intr, sc); if (sc->sc_ih == NULL) { aprint_error_dev(self, "couldn't establish interrupt %d\n", loc->loc_intr); return; } aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr); #endif awin_tve_i2c_init(sc); awin_tve_enable(sc); awin_tve_read_edid(sc); }
static void exynos_wdt_attach(device_t parent, device_t self, void *aux) { struct exynos_wdt_softc * const sc = device_private(self); struct exyo_attach_args * const exyo = aux; prop_dictionary_t dict = device_properties(self); sc->sc_dev = self; sc->sc_bst = exyo->exyo_core_bst; if (bus_space_subregion(sc->sc_bst, exyo->exyo_core_bsh, exyo->exyo_loc.loc_offset, exyo->exyo_loc.loc_size, &sc->sc_wdog_bsh)) { aprint_error(": failed to map registers\n"); return; } /* * This runs at the Exynos Pclk. */ prop_dictionary_get_uint32(dict, "frequency", &sc->sc_freq); sc->sc_wdog_wtcon = exynos_wdt_wdog_read(sc, EXYNOS_WDT_WTCON); sc->sc_wdog_armed = (sc->sc_wdog_wtcon & WTCON_ENABLE) && (sc->sc_wdog_wtcon & WTCON_RESET_ENABLE); if (sc->sc_wdog_armed) { sc->sc_wdog_prescaler = __SHIFTOUT(sc->sc_wdog_wtcon, WTCON_PRESCALER) + 1; sc->sc_wdog_clock_select = __SHIFTOUT(sc->sc_wdog_wtcon, WTCON_CLOCK_SELECT); sc->sc_freq /= sc->sc_wdog_prescaler; sc->sc_freq >>= 4 + sc->sc_wdog_clock_select; sc->sc_wdog_wtdat = exynos_wdt_wdog_read(sc, EXYNOS_WDT_WTDAT); sc->sc_wdog_period = (sc->sc_wdog_wtdat + 1) / sc->sc_freq; } else {
void zynq7000_device_register(device_t self, void *aux) { prop_dictionary_t dict = device_properties(self); if (device_is_a(self, "armperiph") && device_is_a(device_parent(self), "mainbus")) { /* * XXX KLUDGE ALERT XXX * The iot mainbus supplies is completely wrong since it scales * addresses by 2. The simpliest remedy is to replace with our * bus space used for the armcore registers (which armperiph uses). */ struct mainbus_attach_args * const mb = aux; mb->mb_iot = zynq7000_armcore_bst; return; } /* * We need to tell the A9 Global/Watchdog Timer * what frequency it runs at. */ if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) { prop_dictionary_set_uint32(dict, "frequency", 666666666 / PERIPHCLK_N); return; } }
static void usbd_serialnumber(device_t dv, struct usbd_device *dev) { if (dev->ud_serial) { prop_dictionary_set_cstring(device_properties(dv), "serialnumber", dev->ud_serial); } }
static void bcm_dmac_attach(device_t parent, device_t self, void *aux) { struct bcm_dmac_softc *sc = device_private(self); const prop_dictionary_t cfg = device_properties(self); struct bcm_dmac_channel *ch; struct amba_attach_args *aaa = aux; uint32_t val; int index; sc->sc_dev = self; sc->sc_iot = aaa->aaa_iot; if (bus_space_map(aaa->aaa_iot, aaa->aaa_addr, aaa->aaa_size, 0, &sc->sc_ioh)) { aprint_error(": unable to map device\n"); return; } prop_dictionary_get_uint32(cfg, "chanmask", &sc->sc_channelmask); sc->sc_channelmask &= BCM_DMAC_CHANNELMASK; mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SCHED); sc->sc_nchannels = 31 - __builtin_clz(sc->sc_channelmask); sc->sc_channels = kmem_alloc( sizeof(*sc->sc_channels) * sc->sc_nchannels, KM_SLEEP); if (sc->sc_channels == NULL) { aprint_error(": couldn't allocate channels\n"); return; } aprint_normal(":"); for (index = 0; index < sc->sc_nchannels; index++) { ch = &sc->sc_channels[index]; ch->ch_sc = sc; ch->ch_index = index; ch->ch_callback = NULL; ch->ch_callbackarg = NULL; ch->ch_ih = NULL; if ((__BIT(index) & sc->sc_channelmask) == 0) continue; aprint_normal(" DMA%d", index); ch->ch_debug = DMAC_READ(sc, DMAC_DEBUG(index)); val = DMAC_READ(sc, DMAC_CS(index)); val |= DMAC_CS_RESET; DMAC_WRITE(sc, DMAC_CS(index), val); } aprint_normal("\n"); aprint_naive("\n"); }
static void bcmpwm_attach(device_t parent, device_t self, void *aux) { struct bcm2835pwm_softc *sc = device_private(self); struct amba_attach_args *aaa = aux; const prop_dictionary_t cfg = device_properties(self); aprint_naive("\n"); aprint_normal(": PWM\n"); sc->sc_dev = self; sc->sc_iot = aaa->aaa_iot; sc->sc_iob = aaa->aaa_addr; if (bus_space_map(aaa->aaa_iot, aaa->aaa_addr, BCM2835_PWM_SIZE, 0, &sc->sc_ioh)) { aprint_error_dev(sc->sc_dev, "unable to map device\n"); goto fail0; } prop_dictionary_get_uint32(cfg, "pwmclockrate", &sc->sc_clockrate); sc->sc_channels[0].sc = sc; sc->sc_channels[0].ctlmask = PWM_CTL_MSEN1 | PWM_CTL_USEF1 | PWM_CTL_POLA1 | PWM_CTL_SBIT1 | PWM_CTL_RPTL1 | PWM_CTL_MODE1 | PWM_CTL_PWEN1; sc->sc_channels[0].stamask = PWM_STA_STA1; sc->sc_channels[0].gapomask = PWM_STA_GAPO1; sc->sc_channels[0].rng = PWM_RNG1; sc->sc_channels[0].dat = PWM_DAT1; sc->sc_channels[1].sc = sc; sc->sc_channels[1].ctlmask = PWM_CTL_MSEN2 | PWM_CTL_USEF2 | PWM_CTL_POLA2 | PWM_CTL_SBIT2 | PWM_CTL_RPTL2 | PWM_CTL_MODE2 | PWM_CTL_PWEN2; sc->sc_channels[1].stamask = PWM_STA_STA2; sc->sc_channels[1].gapomask = PWM_STA_GAPO2; sc->sc_channels[1].rng = PWM_RNG2; sc->sc_channels[1].dat = PWM_DAT2; /* The PWM hardware can be used by vcaudio if the * analog output is selected */ sc->sc_channels[0].inuse = false; sc->sc_channels[1].inuse = false; mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); /* Success! */ fail0: return; }
static void addprop_integer(struct device *dev, const char *name, uint32_t val) { prop_number_t pn; pn = prop_number_create_integer(val); KASSERT(pn != NULL); if (prop_dictionary_set(device_properties(dev), name, pn) == false) { printf("WARNING: unable to set %s property for %s", name, device_xname(dev)); } prop_object_release(pn); }
static void addprop_data(device_t dev, const char *name, const uint8_t *data, int len) { prop_data_t pd; pd = prop_data_create_data(data, len); KASSERT(pd != NULL); if (prop_dictionary_set(device_properties(dev), name, pd) == false) { printf("WARNING: unable to set %s property for %s\n", name, device_xname(dev)); } prop_object_release(pd); }
static void emac_attach(device_t parent, device_t self, void *aux) { struct emac_softc *sc = device_private(self); struct at91bus_attach_args *sa = aux; prop_data_t enaddr; uint32_t u; printf("\n"); sc->sc_dev = self; sc->sc_iot = sa->sa_iot; sc->sc_pid = sa->sa_pid; sc->sc_dmat = sa->sa_dmat; if (bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", device_xname(self)); /* enable peripheral clock */ at91_peripheral_clock(sc->sc_pid, 1); /* configure emac: */ EMAC_WRITE(ETH_CTL, 0); // disable everything EMAC_WRITE(ETH_IDR, -1); // disable interrupts EMAC_WRITE(ETH_RBQP, 0); // clear receive EMAC_WRITE(ETH_CFG, ETH_CFG_CLK_32 | ETH_CFG_SPD | ETH_CFG_FD | ETH_CFG_BIG); EMAC_WRITE(ETH_TCR, 0); // send nothing //(void)EMAC_READ(ETH_ISR); u = EMAC_READ(ETH_TSR); EMAC_WRITE(ETH_TSR, (u & (ETH_TSR_UND | ETH_TSR_COMP | ETH_TSR_BNQ | ETH_TSR_IDLE | ETH_TSR_RLE | ETH_TSR_COL|ETH_TSR_OVR))); u = EMAC_READ(ETH_RSR); EMAC_WRITE(ETH_RSR, (u & (ETH_RSR_OVR|ETH_RSR_REC|ETH_RSR_BNA))); /* Fetch the Ethernet address from property if set. */ enaddr = prop_dictionary_get(device_properties(self), "mac-addr"); if (enaddr != NULL) { KASSERT(prop_object_type(enaddr) == PROP_TYPE_DATA); KASSERT(prop_data_size(enaddr) == ETHER_ADDR_LEN); memcpy(sc->sc_enaddr, prop_data_data_nocopy(enaddr), ETHER_ADDR_LEN); } else { static const uint8_t hardcoded[ETHER_ADDR_LEN] = { 0x00, 0x0d, 0x10, 0x81, 0x0c, 0x94 }; memcpy(sc->sc_enaddr, hardcoded, ETHER_ADDR_LEN); } at91_intr_establish(sc->sc_pid, IPL_NET, INTR_HIGH_LEVEL, emac_intr, sc); emac_init(sc); }
static void awin_fb_attach(device_t parent, device_t self, void *aux) { struct awin_fb_softc *sc = device_private(self); struct awinfb_attach_args * const afb = aux; prop_dictionary_t cfg = device_properties(self); struct genfb_ops ops; if (awin_fb_consoledev == NULL) awin_fb_consoledev = self; sc->sc_gen.sc_dev = self; sc->sc_debedev = parent; sc->sc_dmat = afb->afb_dmat; sc->sc_dmasegs = afb->afb_dmasegs; sc->sc_ndmasegs = afb->afb_ndmasegs; sc->sc_mpdev = device_find_by_driver_unit("awinmp", 0); prop_dictionary_set_uint32(cfg, "width", afb->afb_width); prop_dictionary_set_uint32(cfg, "height", afb->afb_height); prop_dictionary_set_uint8(cfg, "depth", 32); prop_dictionary_set_uint16(cfg, "linebytes", afb->afb_width * 4); prop_dictionary_set_uint32(cfg, "address", 0); prop_dictionary_set_uint32(cfg, "virtual_address", (uintptr_t)afb->afb_fb); genfb_init(&sc->sc_gen); if (sc->sc_gen.sc_width == 0 || sc->sc_gen.sc_fbsize == 0) { aprint_normal(": disabled\n"); return; } pmf_device_register1(self, NULL, NULL, awin_fb_shutdown); memset(&ops, 0, sizeof(ops)); ops.genfb_ioctl = awin_fb_ioctl; ops.genfb_mmap = awin_fb_mmap; aprint_naive("\n"); bool is_console = false; prop_dictionary_get_bool(cfg, "is_console", &is_console); if (is_console) aprint_normal(": switching to framebuffer console\n"); else aprint_normal("\n"); genfb_attach(&sc->sc_gen, &ops); }
static void tegra_genfb_attach(device_t parent, device_t self, void *aux) { struct tegra_genfb_softc * const sc = device_private(self); struct tegrafb_attach_args * const tfb = aux; prop_dictionary_t prop = device_properties(self); const bool is_console = tfb->tfb_console; struct genfb_ops ops; sc->sc_gen.sc_dev = self; sc->sc_dmat = tfb->tfb_dmat; sc->sc_dmamap = tfb->tfb_dmamap; prop_dictionary_set_bool(prop, "is_console", is_console); prop_dictionary_set_uint32(prop, "width", tfb->tfb_width); prop_dictionary_set_uint32(prop, "height", tfb->tfb_height); prop_dictionary_set_uint8(prop, "depth", tfb->tfb_depth); prop_dictionary_set_uint32(prop, "linebytes", tfb->tfb_stride); prop_dictionary_set_uint64(prop, "address", 0); prop_dictionary_set_uint64(prop, "virtual_address", (uintptr_t)tfb->tfb_dmap); genfb_init(&sc->sc_gen); if (sc->sc_gen.sc_width == 0 || sc->sc_gen.sc_fbsize == 0) { aprint_error(": disabled\n"); return; } pmf_device_register1(self, NULL, NULL, tegra_genfb_shutdown); aprint_naive("\n"); if (is_console) { aprint_normal(": switching to framebuffer console\n"); } else { aprint_normal("\n"); } memset(&ops, 0, sizeof(ops)); ops.genfb_ioctl = tegra_genfb_ioctl; ops.genfb_mmap = tegra_genfb_mmap; genfb_attach(&sc->sc_gen, &ops); #if defined(DDB) if (is_console) { tegra_genfb_consoledev = self; db_trap_callback = tegra_genfb_ddb_trap_callback; } #endif }
static void tegra_ahcisata_attach(device_t parent, device_t self, void *aux) { struct tegra_ahcisata_softc * const sc = device_private(self); struct tegraio_attach_args * const tio = aux; const struct tegra_locators * const loc = &tio->tio_loc; prop_dictionary_t prop = device_properties(self); const char *pin; sc->sc_bst = tio->tio_bst; bus_space_subregion(tio->tio_bst, tio->tio_bsh, loc->loc_offset, loc->loc_size, &sc->sc_bsh); sc->sc.sc_atac.atac_dev = self; sc->sc.sc_dmat = tio->tio_dmat; sc->sc.sc_ahcit = tio->tio_bst; sc->sc.sc_ahcis = loc->loc_size - TEGRA_AHCISATA_OFFSET; bus_space_subregion(tio->tio_bst, tio->tio_bsh, loc->loc_offset + TEGRA_AHCISATA_OFFSET, loc->loc_size - TEGRA_AHCISATA_OFFSET, &sc->sc.sc_ahcih); sc->sc.sc_ahci_quirks = AHCI_QUIRK_SKIP_RESET; aprint_naive("\n"); aprint_normal(": SATA\n"); if (prop_dictionary_get_cstring_nocopy(prop, "power-gpio", &pin)) { sc->sc_pin_power = tegra_gpio_acquire(pin, GPIO_PIN_OUTPUT); if (sc->sc_pin_power) tegra_gpio_write(sc->sc_pin_power, 1); } tegra_car_periph_sata_enable(); tegra_xusbpad_sata_enable(); tegra_ahcisata_init(sc); sc->sc_ih = intr_establish(loc->loc_intr, IPL_BIO, IST_LEVEL, ahci_intr, &sc->sc); if (sc->sc_ih == NULL) { aprint_error_dev(self, "couldn't establish interrupt %d\n", loc->loc_intr); return; } aprint_normal_dev(self, "interrupting on irq %d\n", loc->loc_intr); ahci_attach(&sc->sc); }
/* * Get the firmware package handle from a device_t. * Assuming we have previously stored it in the device properties * dictionary. */ static int device_ofnode(device_t dev) { prop_dictionary_t props; prop_object_t obj; if (dev == NULL) return 0; props = device_properties(dev); if (props == NULL) return 0; obj = prop_dictionary_get(props, OFNODEKEY); if (obj == NULL) return 0; return prop_number_integer_value(obj); }
static void armadillo9_device_register(device_t dev, void *aux) { /* MAC address for the built-in Ethernet. */ if (device_is_a(dev, "epe")) { prop_data_t pd = prop_data_create_data_nocopy( armadillo9_ethaddr, ETHER_ADDR_LEN); KASSERT(pd != NULL); if (prop_dictionary_set(device_properties(dev), "mac-address", pd) == false) { printf("WARNING: unable to set mac-addr property " "for %s\n", device_xname(dev)); } prop_object_release(pd); } }
device_t device_isa_register(device_t dev, void *aux) { /* * Handle network interfaces here, the attachment information is * not available driver-independently later. * * For disks, there is nothing useful available at attach time. */ if (device_class(dev) == DV_IFNET) { struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF); if (bin == NULL) return NULL; /* * We don't check the driver name against the device name * passed by the boot ROM. The ROM should stay usable if * the driver becomes obsolete. The physical attachment * information (checked below) must be sufficient to * identify the device. */ if (bin->bus == BI_BUS_ISA && device_is_a(device_parent(dev), "isa")) { struct isa_attach_args *iaa = aux; /* Compare IO base address */ /* XXXJRT What about multiple IO addrs? */ if (iaa->ia_nio > 0 && bin->addr.iobase == iaa->ia_io[0].ir_addr) return dev; } } #if NACPICA > 0 #if notyet if (device_is_a(dev, "isa") && acpi_active) { if (!(AcpiGbl_FADT.BootFlags & ACPI_FADT_LEGACY_DEVICES)) prop_dictionary_set_bool(device_properties(dev), "no-legacy-devices", true); } #endif #endif /* NACPICA > 0 */ return NULL; }
/* * Save the firmware package handle inside the properties dictionary * of a device_t. */ static void device_setofnode(device_t dev, int node) { prop_dictionary_t props; prop_object_t obj; if (dev == NULL) return; props = device_properties(dev); if (props == NULL) return; obj = prop_number_create_integer(node); if (obj == NULL) return; prop_dictionary_set(props, OFNODEKEY, obj); prop_object_release(obj); DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ", device_xname(dev), node)); }
static void sdhc_set_gpio_cd(struct sdhc_axi_softc *sc, const char *name) { prop_dictionary_t dict; const char *pin_data; int grp, pin; dict = device_properties(sc->sc_sdhc.sc_dev); if (!prop_dictionary_get_cstring_nocopy(dict, name, &pin_data)) return; /* * "!1,6" -> gpio_cd = GPIO_NO(1,6), gpio_cd_low_active = 1 * "3,31" -> gpio_cd = GPIO_NO(3,31), gpio_cd_low_active = 0 * "!" -> always not detected * none -> always detected */ if (*pin_data == '!') { sc->sc_gpio_cd_low_active = 1; pin_data++; } else sc->sc_gpio_cd_low_active = 0; sc->sc_gpio_cd = -1; if (*pin_data == '\0') return; for (grp = 0; (*pin_data >= '0') && (*pin_data <= '9'); pin_data++) grp = grp * 10 + *pin_data - '0'; KASSERT(*pin_data == ','); pin_data++; for (pin = 0; (*pin_data >= '0') && (*pin_data <= '9'); pin_data++) pin = pin * 10 + *pin_data - '0'; KASSERT(*pin_data == '\0'); sc->sc_gpio_cd = GPIO_NO(grp, pin); #if NIMXGPIO > 0 gpio_set_direction(sc->sc_gpio_cd, GPIO_DIR_IN); #endif }
static void igphyattach(device_t parent, device_t self, void *aux) { struct mii_softc *sc = device_private(self); struct mii_attach_args *ma = aux; struct mii_data *mii = ma->mii_data; const struct mii_phydesc *mpd; struct igphy_softc *igsc = (struct igphy_softc *) sc; prop_dictionary_t dict; mpd = mii_phy_match(ma, igphys); aprint_naive(": Media interface\n"); aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2)); dict = device_properties(parent); if (!prop_dictionary_get_uint32(dict, "mactype", &igsc->sc_mactype)) aprint_error("WARNING! Failed to get mactype\n"); if (!prop_dictionary_get_uint32(dict, "macflags", &igsc->sc_macflags)) aprint_error("WARNING! Failed to get macflags\n"); sc->mii_dev = self; sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_funcs = &igphy_funcs; sc->mii_pdata = mii; sc->mii_flags = ma->mii_flags; sc->mii_anegticks = MII_ANEGTICKS_GIGE; PHY_RESET(sc); sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask; if (sc->mii_capabilities & BMSR_EXTSTAT) sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); aprint_normal_dev(self, ""); if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 && (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0) aprint_error("no media present"); else mii_phy_add_media(sc); aprint_normal("\n"); }
int wsdisplayio_get_edid(device_t dev, struct wsdisplayio_edid_info *d) { prop_data_t edid_data; int edid_size; edid_data = prop_dictionary_get(device_properties(dev), "EDID"); if (edid_data != NULL) { edid_size = prop_data_size(edid_data); /* less than 128 bytes is bogus */ if (edid_size < 128) return ENODEV; d->data_size = edid_size; if (d->buffer_size < edid_size) return EAGAIN; return copyout(prop_data_data_nocopy(edid_data), d->edid_data, edid_size); } return ENODEV; }
void device_register(struct device *dev, void *aux) { struct device *pdev; /* * We don't ever know the boot device. But that's because the * firmware only loads from the network or the parallel port. */ /* * Fetch the MAC address for the built-in Ethernet (we grab it * from PMON earlier in the boot process). */ if ((pdev = device_parent(dev)) != NULL && device_is_a(pdev, "pci")) { struct pci_attach_args *pa = aux; if (BUILTIN_ETHERNET_P(pa)) { prop_data_t pd = prop_data_create_data_nocopy( algor_ethaddr, ETHER_ADDR_LEN); KASSERT(pd != NULL); if (prop_dictionary_set(device_properties(dev), "mac-addr", pd) == false) { printf("WARNING: unable to set mac-addr " "property for %s\n", dev->dv_xname); } prop_object_release(pd); #if defined(ALGOR_P4032) /* * XXX This is gross, disgusting, and otherwise vile, * XXX but V962 rev. < B2 have broken DMA FIFOs. Give * XXX the on-board Ethernet a different DMA window * XXX that has pre-fetching disabled so that Ethernet * XXX performance doesn't completely suck. */ pa->pa_dmat = &p4032_configuration.ac_pci_pf_dmat; pa->pa_dmat64 = NULL; #endif /* ALGOR_P4032 */ } } }
/* ARGSUSED */ static void smsh_axi_attach(device_t parent, device_t self, void *aux) { struct lan9118_softc *sc = device_private(self); struct axi_attach_args *aa = aux; prop_dictionary_t dict = device_properties(self); void *ih; sc->sc_dev = self; /* * Prefer the Ethernet address in device properties. */ prop_data_t ea = prop_dictionary_get(dict, "mac-address"); if (ea != NULL) { KASSERT(prop_object_type(ea) == PROP_TYPE_DATA); KASSERT(prop_data_size(ea) == ETHER_ADDR_LEN); memcpy(sc->sc_enaddr, prop_data_data_nocopy(ea), ETHER_ADDR_LEN); sc->sc_flags |= LAN9118_FLAGS_NO_EEPROM; } /* Map i/o space. */ if (bus_space_map(aa->aa_iot, aa->aa_addr, LAN9118_IOSIZE, 0, &sc->sc_ioh)) panic("smsh_axi_attach: can't map i/o space"); sc->sc_iot = aa->aa_iot; if (lan9118_attach(sc) != 0) { bus_space_unmap(sc->sc_iot, sc->sc_ioh, LAN9118_IOSIZE); return; } /* Establish the interrupt handler. */ ih = intr_establish(aa->aa_irq, IPL_NET, IST_LEVEL, lan9118_intr, sc); if (ih == NULL) { aprint_error_dev(self, "couldn't establish interrupt handler\n"); bus_space_unmap(sc->sc_iot, sc->sc_ioh, LAN9118_IOSIZE); return; } }
static void bthub_attach(device_t parent, device_t self, void *aux) { bdaddr_t *addr = aux; prop_dictionary_t dict; prop_object_t obj; dict = device_properties(self); obj = prop_data_create_data(addr, sizeof(*addr)); prop_dictionary_set(dict, BTDEVladdr, obj); prop_object_release(obj); aprint_verbose(" %s %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", BTDEVladdr, addr->b[5], addr->b[4], addr->b[3], addr->b[2], addr->b[1], addr->b[0]); aprint_normal("\n"); pmf_device_register(self, NULL, NULL); }
void device_register(struct device *dev, void *aux) { struct device *pdev; if ((pdev = device_parent(dev)) != NULL && device_is_a(pdev, "pci")) { /* * cats builtin aceride is on 0:16:0 */ struct pci_attach_args *pa = aux; if (((pa)->pa_bus == 0 && (pa)->pa_device == 16 && (pa)->pa_function == 0)) { if (prop_dictionary_set_bool(device_properties(dev), "ali1543-ide-force-compat-mode", true) == false) { printf("WARNING: unable to set " "ali1543-ide-force-compat-mode " "property for %s\n", dev->dv_xname); } } } }
static void dwctwo_plb_attach(device_t parent, device_t self, void *aux) { struct dwc2_softc *sc = device_private(self); struct plb_attach_args *paa = aux; prop_dictionary_t dict = device_properties(self); uint32_t srst0; sc->sc_dev = self; /* get core parameters */ if (!prop_dictionary_get_uint32(dict, "params", (uint32_t *)&sc->sc_params)) { aprint_error("struct dwc2_core_params not found\n"); return; } dwctwo_tag.pbs_base = paa->plb_addr; dwctwo_tag.pbs_limit += paa->plb_addr; if (bus_space_init(&dwctwo_tag, "dwctwotag", ex_storage, sizeof(ex_storage))) panic("dwctwo_attach: Failed to initialise opb_tag"); sc->sc_iot = &dwctwo_tag; bus_space_map(sc->sc_iot, paa->plb_addr, DWCTWO_SIZE, 0, &sc->sc_ioh); sc->sc_bus.dmatag = paa->plb_dmat; intr_establish(paa->plb_irq, IST_LEVEL, IPL_SCHED, dwc2_intr, sc); /* Enable the USB interface. */ mtsdr(DCR_SDR0_PFC1, mfsdr(DCR_SDR0_PFC1) | SDR0_PFC1_USBEN); srst0 = mfsdr(DCR_SDR0_SRST0); mtsdr(DCR_SDR0_SRST0, srst0 | SDR0_SRST0_UPRST | SDR0_SRST0_AHB); delay(200 * 1000); /* XXXX */ mtsdr(DCR_SDR0_SRST0, srst0); config_defer(self, dwctwo_plb_deferred); }