/* * icattach() */ static int icattach(device_t dev) { struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev); struct ifnet *ifp = &sc->ic_if; sc->ic_addr = iicbus_get_addr(dev); ifp->if_softc = sc; ifp->if_name = "ic"; ifp->if_unit = device_get_unit(dev); ifp->if_mtu = ICMTU; ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST; ifp->if_ioctl = icioctl; ifp->if_output = icoutput; ifp->if_type = IFT_PARA; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; if_attach(ifp); bpfattach(ifp, DLT_NULL, ICHDRLEN); return (0); }
static int iic_probe(device_t dev) { if (iicbus_get_addr(dev) > 0) return (ENXIO); device_set_desc(dev, "I2C generic I/O"); return (0); }
static int onyx_attach(device_t dev) { struct onyx_softc *sc; sc = device_get_softc(dev); sc->sc_dev = dev; sc->sc_addr = iicbus_get_addr(dev); i2s_mixer_class = &onyx_mixer_class; i2s_mixer = dev; return (0); }
static int am335x_pmic_probe(device_t dev) { struct am335x_pmic_softc *sc; if (!ofw_bus_is_compatible(dev, "ti,am335x-pmic")) return (ENXIO); sc = device_get_softc(dev); sc->sc_dev = dev; sc->sc_addr = iicbus_get_addr(dev); device_set_desc(dev, "TI TPS65217 Power Management IC"); return (0); }
static int tumbler_probe(device_t dev) { const char *name; name = ofw_bus_get_name(dev); if (name == NULL) return (ENXIO); if (strcmp(name, "deq") == 0 && iicbus_get_addr(dev) == TUMBLER_IICADDR) { device_set_desc(dev, "Texas Instruments TAS3001 Audio Codec"); return (0); } return (ENXIO); }
static int am335x_pmic_probe(device_t dev) { struct am335x_pmic_softc *sc; if (!ofw_bus_is_compatible(dev, "ti,tps65217")) return (ENXIO); sc = device_get_softc(dev); sc->sc_dev = dev; /* Convert to 8-bit addressing */ sc->sc_addr = iicbus_get_addr(dev) << 1; device_set_desc(dev, "TI TPS65217 Power Management IC"); return (0); }
static int at24co2n_attach(device_t dev) { struct at24co2n_softc *sc = device_get_softc(dev); struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); struct sysctl_oid *tree = device_get_sysctl_tree(dev); if(sc == NULL) { printf("at24co2n_attach device_get_softc failed\n"); return (0); } sc->sc_dev = dev; sc->sc_addr = iicbus_get_addr(dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "eeprom-mac", CTLTYPE_STRING | CTLFLAG_RD, sc, 0, at24co2n_mac_sysctl, "A", "mac address"); return (0); }
static int ds1307_attach(device_t dev) { struct ds1307_softc *sc; sc = device_get_softc(dev); sc->sc_dev = dev; sc->sc_addr = iicbus_get_addr(dev); sc->sc_year0 = 1900; sc->enum_hook.ich_func = ds1307_start; sc->enum_hook.ich_arg = dev; /* * We have to wait until interrupts are enabled. Usually I2C read * and write only works when the interrupts are available. */ if (config_intrhook_establish(&sc->enum_hook) != 0) return (ENOMEM); return (0); }
static int onyx_probe(device_t dev) { const char *name, *compat; name = ofw_bus_get_name(dev); if (name == NULL) return (ENXIO); if (strcmp(name, "codec") == 0) { if (iicbus_get_addr(dev) != PCM3052_IICADDR) return (ENXIO); } else if (strcmp(name, "codec") == 0) { compat = ofw_bus_get_compat(dev); if (compat == NULL || strcmp(compat, "pcm3052") != 0) return (ENXIO); } else return (ENXIO); device_set_desc(dev, "Texas Instruments PCM3052 Audio Codec"); return (0); }
static int pcf8563_attach(device_t dev) { struct pcf8563_softc *sc; sc = device_get_softc(dev); sc->sc_addr = iicbus_get_addr(dev); if (sc->sc_addr == 0) sc->sc_addr = PCF8563_ADDR; sc->sc_year0 = 1900; sc->enum_hook.ich_func = pcf8563_start; sc->enum_hook.ich_arg = dev; /* * We have to wait until interrupts are enabled. Sometimes I2C read * and write only works when the interrupts are available. */ if (config_intrhook_establish(&sc->enum_hook) != 0) return (ENOMEM); return (0); }
static int snapper_probe(device_t dev) { const char *name, *compat; name = ofw_bus_get_name(dev); if (name == NULL) return (ENXIO); if (strcmp(name, "deq") == 0) { if (iicbus_get_addr(dev) != SNAPPER_IICADDR) return (ENXIO); } else if (strcmp(name, "codec") == 0) { compat = ofw_bus_get_compat(dev); if (compat == NULL || strcmp(compat, "tas3004") != 0) return (ENXIO); } else { return (ENXIO); } device_set_desc(dev, "Texas Instruments TAS3004 Audio Codec"); return (0); }
static int max6657_attach(device_t dev) { struct max6657_softc *sc = device_get_softc(dev); struct sysctl_ctx_list *ctx = device_get_sysctl_ctx(dev); struct sysctl_oid *tree = device_get_sysctl_tree(dev); if(sc==NULL) { printf("max6657_attach device_get_softc failed\n"); return (0); } sc->sc_dev = dev; sc->sc_addr = iicbus_get_addr(dev); SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "temp", CTLTYPE_INT | CTLFLAG_RD, sc, 0, max6657_sysctl_temp, "I", "operating temperature"); device_printf(dev, "Chip temperature {%d} Degree Celsius\n", max6657_read(sc->sc_dev, sc->sc_addr, MAX6657_EXT_TEMP)); return (0); }