void armadillo9iic_bb_set_dir(void *cookie, uint32_t bits) { struct armadillo9iic_softc *sc = cookie; if(bits) epgpio_out(sc->sc_gpio, sc->sc_port, sc->sc_sda); else epgpio_in(sc->sc_gpio, sc->sc_port, sc->sc_sda); }
void epled_attach(device_t parent, device_t self, void *aux) { struct epled_softc *sc = device_private(self); struct epgpio_attach_args *ga = aux; sc->sc_port = ga->ga_port; sc->sc_green = ga->ga_bit1; sc->sc_red = ga->ga_bit2; sc->sc_gpio = (struct epgpio_softc *)parent; printf("\n"); if (!the_epled_sc) the_epled_sc = sc; #ifdef DIAGNOSTIC else printf("%s is already configured\n", device_xname(self)); #endif epgpio_out(sc->sc_gpio, sc->sc_port, sc->sc_green); epgpio_out(sc->sc_gpio, sc->sc_port, sc->sc_red); }
void armadillo9iic_attach(struct device *parent, struct device *self, void *aux) { struct armadillo9iic_softc *sc = (struct armadillo9iic_softc*)self; struct i2cbus_attach_args iba; #if NSEEPROM > 0 struct epgpio_attach_args *ga = aux; #endif mutex_init(&sc->sc_buslock, MUTEX_DEFAULT, IPL_NONE); sc->sc_port = ga->ga_port; sc->sc_sda = ga->ga_bit1; sc->sc_scl = ga->ga_bit2; sc->sc_gpio = (struct epgpio_softc *)parent; armadillo9iic_bbops.ibo_bits[I2C_BIT_SDA] = (1<<sc->sc_sda); armadillo9iic_bbops.ibo_bits[I2C_BIT_SCL] = (1<<sc->sc_scl); armadillo9iic_bbops.ibo_bits[I2C_BIT_OUTPUT] = sc->sc_sda; armadillo9iic_bbops.ibo_bits[I2C_BIT_INPUT] = 0; sc->sc_i2c.ic_cookie = sc; sc->sc_i2c.ic_acquire_bus = armadillo9iic_acquire_bus; sc->sc_i2c.ic_release_bus = armadillo9iic_release_bus; sc->sc_i2c.ic_send_start = armadillo9iic_send_start; sc->sc_i2c.ic_send_stop = armadillo9iic_send_stop; sc->sc_i2c.ic_initiate_xfer = armadillo9iic_initiate_xfer; sc->sc_i2c.ic_read_byte = armadillo9iic_read_byte; sc->sc_i2c.ic_write_byte = armadillo9iic_write_byte; iba.iba_tag = &sc->sc_i2c; epgpio_in(sc->sc_gpio, sc->sc_port, sc->sc_sda); epgpio_out(sc->sc_gpio, sc->sc_port, sc->sc_scl); epgpio_set(sc->sc_gpio, sc->sc_port, sc->sc_scl); printf("\n"); config_found_ia(&sc->sc_dev, "i2cbus", &iba, iicbus_print); #if NSEEPROM > 0 /* read mac address */ /* XXX This should probably be done elsewhere, earlier in bootstrap. */ if (seeprom_bootstrap_read(&sc->sc_i2c, 0x50, 0x00, 128, armadillo9_ethaddr, ETHER_ADDR_LEN) != 0) { printf("%s: WARNING: unable to read MAC address from SEEPROM\n", sc->sc_dev.dv_xname); } #endif }