Lines Matching defs:sc
81 struct moxtet_softc *sc = (struct moxtet_softc *)self;
86 sc->sc_spi_tag = sa->sa_tag;
87 sc->sc_node = *(int *)sa->sa_cookie;
89 pinctrl_byname(sc->sc_node, "default");
91 sc->sc_spi_conf.sc_bpw = 8;
92 sc->sc_spi_conf.sc_freq = OF_getpropint(sc->sc_node,
94 sc->sc_spi_conf.sc_cs = OF_getpropint(sc->sc_node, "reg", 0);
95 if (OF_getproplen(sc->sc_node, "spi-cpol") == 0)
96 sc->sc_spi_conf.sc_flags |= SPI_CONFIG_CPOL;
97 if (OF_getproplen(sc->sc_node, "spi-cpha") == 0)
98 sc->sc_spi_conf.sc_flags |= SPI_CONFIG_CPHA;
99 if (OF_getproplen(sc->sc_node, "spi-cs-high") == 0)
100 sc->sc_spi_conf.sc_flags |= SPI_CONFIG_CS_HIGH;
102 if (moxtet_read(sc, buf, sizeof(buf))) {
119 sc->sc_nmodule++;
155 moxtet_read(struct moxtet_softc *sc, char *buf, size_t len)
159 spi_acquire_bus(sc->sc_spi_tag, 0);
160 spi_config(sc->sc_spi_tag, &sc->sc_spi_conf);
161 error = spi_read(sc->sc_spi_tag, buf, len);
162 spi_release_bus(sc->sc_spi_tag, 0);
167 moxtet_write(struct moxtet_softc *sc, char *buf, size_t len)
171 spi_acquire_bus(sc->sc_spi_tag, 0);
172 spi_config(sc->sc_spi_tag, &sc->sc_spi_conf);
173 error = spi_write(sc->sc_spi_tag, buf, len);
174 spi_release_bus(sc->sc_spi_tag, 0);