/* $Id: spi.c,v 1.1.1.1 2008/03/04 16:09:35 nbrk Exp $ */ /* * SPI bus. */ #include #include #include #include #include #include #include #include #include struct spi_softc { struct device sc_dev; struct spi_bus *sc_bus; }; int spi_match(struct device *parent, void *cf, void *aux); void spi_attach(struct device *parent, struct device *self, void *aux); struct cfattach spibus_ca = { sizeof(struct spi_softc), spi_match, spi_attach, NULL, NULL }; struct cfdriver spibus_cd = { NULL, "spibus", DV_DULL }; int spi_match(struct device *parent, void *cf, void *aux) { return(1); } void spi_attach(struct device *parent, struct device *self, void *aux) { struct spi_softc *sc = (struct spi_softc *)self; struct spibus_attach_args *sba = aux; sc->sc_bus = sba->sba_bus; sba->sba_spisc = sc; printf("\n"); /* attach slave */ config_found(&sc->sc_dev, sba, spibus_print); } int spibus_print(void *aux, const char *pnp) { return(QUIET); } int spi_shift_1(void *arg, uint8_t data) { struct spi_softc *sc = arg; struct spi_bus *sb = sc->sc_bus; /* * TODO: locking. */ return(sb->bus_shift_1(sb->bus_cookie, data)); } int spi_acquire(void *arg) { struct spi_softc *sc = arg; struct spi_bus *sb = sc->sc_bus; return(sb->bus_acquire(sb->bus_cookie)); } void spi_release(void *arg) { struct spi_softc *sc = arg; struct spi_bus *sb = sc->sc_bus; return(sb->bus_release(sb->bus_cookie)); }