#include <sys/param.h>
#include <sys/device.h>
#include <machine/fdt.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_clock.h>
#include <dev/ofw/fdt.h>
#include <machine/simplebusvar.h>
struct omsysc_softc {
struct simplebus_softc sc_bus;
};
int omsysc_match(struct device *, void *, void *);
void omsysc_attach(struct device *, struct device *, void *);
const struct cfattach omsysc_ca = {
sizeof(struct omsysc_softc), omsysc_match, omsysc_attach
};
struct cfdriver omsysc_cd = {
NULL, "omsysc", DV_DULL
};
int
omsysc_match(struct device *parent, void *cfdata, void *aux)
{
struct fdt_attach_args *faa = aux;
struct cfdata *cf = cfdata;
int node;
node = OF_child(faa->fa_node);
if (node && cf->cf_loc[0]) {
return (OF_is_compatible(node, "ti,am3-prcm") ||
OF_is_compatible(node, "ti,am3-scm"));
}
return OF_is_compatible(faa->fa_node, "ti,sysc");
}
void
omsysc_attach(struct device *parent, struct device *self, void *aux)
{
struct omsysc_softc *sc = (struct omsysc_softc *)self;
struct fdt_attach_args *faa = aux;
if (OF_getproplen(faa->fa_node, "ti,hwmods") < 0 &&
OF_is_compatible(faa->fa_node, "ti,sysc-omap2"))
clock_enable(faa->fa_node, "fck");
simplebus_attach(parent, &sc->sc_bus.sc_dev, faa);
}