Annotation of sys/dev/spi.c, Revision 1.1.1.1
1.1 nbrk 1: /* $Id$ */
2: /*
3: * SPI bus.
4: */
5: #include <sys/param.h>
6: #include <sys/systm.h>
7: #include <sys/device.h>
8: #include <sys/kernel.h>
9: #include <sys/malloc.h>
10: #include <sys/proc.h>
11: #include <sys/queue.h>
12: #include <sys/rwlock.h>
13:
14: #include <dev/spivar.h>
15:
16: struct spi_softc {
17: struct device sc_dev;
18: struct spi_bus *sc_bus;
19: };
20:
21: int spi_match(struct device *parent, void *cf, void *aux);
22: void spi_attach(struct device *parent, struct device *self, void *aux);
23:
24: struct cfattach spibus_ca = {
25: sizeof(struct spi_softc),
26: spi_match,
27: spi_attach,
28: NULL,
29: NULL
30: };
31:
32: struct cfdriver spibus_cd = {
33: NULL,
34: "spibus",
35: DV_DULL
36: };
37:
38:
39: int
40: spi_match(struct device *parent, void *cf, void *aux)
41: {
42: return(1);
43: }
44:
45: void
46: spi_attach(struct device *parent, struct device *self, void *aux)
47: {
48: struct spi_softc *sc = (struct spi_softc *)self;
49: struct spibus_attach_args *sba = aux;
50:
51: sc->sc_bus = sba->sba_bus;
52: sba->sba_spisc = sc;
53:
54: printf("\n");
55:
56: /* attach slave */
57: config_found(&sc->sc_dev, sba, spibus_print);
58: }
59:
60: int
61: spibus_print(void *aux, const char *pnp)
62: {
63: return(QUIET);
64: }
65:
66: int
67: spi_shift_1(void *arg, uint8_t data)
68: {
69: struct spi_softc *sc = arg;
70: struct spi_bus *sb = sc->sc_bus;
71:
72: /*
73: * TODO: locking.
74: */
75:
76: return(sb->bus_shift_1(sb->bus_cookie, data));
77: }
78:
79: int
80: spi_acquire(void *arg)
81: {
82: struct spi_softc *sc = arg;
83: struct spi_bus *sb = sc->sc_bus;
84:
85: return(sb->bus_acquire(sb->bus_cookie));
86: }
87:
88: void
89: spi_release(void *arg)
90: {
91: struct spi_softc *sc = arg;
92: struct spi_bus *sb = sc->sc_bus;
93:
94: return(sb->bus_release(sb->bus_cookie));
95: }
96:
CVSweb