Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/ti/clk/ti_mux_clock.c
Show All 37 Lines | |||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/libkern.h> | #include <sys/libkern.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <machine/bus.h> | #include <machine/bus.h> | ||||
#include <dev/fdt/simplebus.h> | #include <dev/fdt/simplebus.h> | ||||
#include <dev/extres/clk/clk_mux.h> | |||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
#include "ti_clk_mux.h" | |||||
#include "clock_common.h" | #include "clock_common.h" | ||||
#include "syscon_if.h" | |||||
#if 0 | #if 0 | ||||
#define DPRINTF(dev, msg...) device_printf(dev, msg) | #define DPRINTF(dev, msg...) device_printf(dev, msg) | ||||
#else | #else | ||||
#define DPRINTF(dev, msg...) | #define DPRINTF(dev, msg...) | ||||
#endif | #endif | ||||
/* | /* | ||||
* Devicetree description | * Devicetree description | ||||
* Documentation/devicetree/bindings/clock/ti/mux.txt | * Documentation/devicetree/bindings/clock/ti/mux.txt | ||||
*/ | */ | ||||
struct ti_mux_softc { | struct ti_mux_softc { | ||||
device_t sc_dev; | device_t sc_dev; | ||||
bool attach_done; | bool attach_done; | ||||
struct clk_mux_def mux_def; | struct ti_clk_mux_def mux_def; | ||||
struct clock_cell_info clock_cell; | struct clock_cell_info clock_cell; | ||||
struct clkdom *clkdom; | struct clkdom *clkdom; | ||||
}; | }; | ||||
static int ti_mux_probe(device_t dev); | static int ti_mux_probe(device_t dev); | ||||
static int ti_mux_attach(device_t dev); | static int ti_mux_attach(device_t dev); | ||||
static int ti_mux_detach(device_t dev); | static int ti_mux_detach(device_t dev); | ||||
Show All 26 Lines | register_clk(struct ti_mux_softc *sc) { | ||||
int err; | int err; | ||||
sc->clkdom = clkdom_create(sc->sc_dev); | sc->clkdom = clkdom_create(sc->sc_dev); | ||||
if (sc->clkdom == NULL) { | if (sc->clkdom == NULL) { | ||||
DPRINTF(sc->sc_dev, "Failed to create clkdom\n"); | DPRINTF(sc->sc_dev, "Failed to create clkdom\n"); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
err = clknode_mux_register(sc->clkdom, &sc->mux_def); | err = ti_clknode_mux_register(sc->clkdom, &sc->mux_def); | ||||
if (err) { | if (err) { | ||||
DPRINTF(sc->sc_dev, "clknode_mux_register failed %x\n", err); | DPRINTF(sc->sc_dev, "clknode_mux_register failed %x\n", err); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
err = clkdom_finit(sc->clkdom); | err = clkdom_finit(sc->clkdom); | ||||
if (err) { | if (err) { | ||||
DPRINTF(sc->sc_dev, "Clk domain finit fails %x.\n", err); | DPRINTF(sc->sc_dev, "Clk domain finit fails %x.\n", err); | ||||
Show All 9 Lines | ti_mux_attach(device_t dev) | ||||
struct ti_mux_softc *sc; | struct ti_mux_softc *sc; | ||||
phandle_t node; | phandle_t node; | ||||
int err; | int err; | ||||
cell_t value; | cell_t value; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
sc->sc_dev = dev; | sc->sc_dev = dev; | ||||
node = ofw_bus_get_node(dev); | node = ofw_bus_get_node(dev); | ||||
/* Get syscon */ | |||||
SYSCON_GET_HANDLE(dev, &sc->mux_def.sysc); | |||||
/* Grab the content of reg properties */ | /* Grab the content of reg properties */ | ||||
OF_getencprop(node, "reg", &value, sizeof(value)); | OF_getencprop(node, "reg", &value, sizeof(value)); | ||||
sc->mux_def.offset = value; | sc->mux_def.offset = value; | ||||
if (OF_hasprop(node, "ti,bit-shift")) { | if (OF_hasprop(node, "ti,bit-shift")) { | ||||
OF_getencprop(node, "ti,bit-shift", &value, sizeof(value)); | OF_getencprop(node, "ti,bit-shift", &value, sizeof(value)); | ||||
sc->mux_def.shift = value; | sc->mux_def.shift = value; | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |