> From: Johannes Krottmayer <krj...@gmail.com> > Date: Sat, 9 Jun 2018 22:22:44 +0200 > > Hi Mark! > > I inform you that I try to write a spi driver for the rk3328. Called > it rkspi (rkspi.c). Currently I have implement a early version of the > match and attach functions and it works. > > It is based on your rkiic driver. > > _The match function_ > > int > rkspi_match(struct device *parent, void *match, void *aux) > { > struct fdt_attach_args *faa = aux; > > return (OF_is_compatible(faa->fa_node, "rockchip,rk3328-spi")); > } > > _The attach function_ > > void > rkspi_attach(struct device *parent, struct device *self, void *aux) > { > struct rkspi_softc *sc = (struct rkspi_softc *) self; > struct fdt_attach_args *faa = aux; > > if (faa->fa_nreg < 1) { > printf(": no registers\n"); > return; > } > > sc->sc_iot = faa->fa_iot; > sc->sc_node = faa->fa_node; > > if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, > faa->fa_reg[0].size, 0, &sc->sc_ioh)) { > printf(": can't map registers\n"); > return; > } > > printf("rkspi_attach success\n"); > } > > And this piece of code works: > $ dmesg | grep rkspi > rkspi0 at mainbus0 > rkspi_attach success > $ > > My next step is, to configure the spi bus and add a read and > write function. > > What do you think about my intention?
That's a very basic start in the right direction.