Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/ti/ti_mbox.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
#include <dev/ofw/openfirm.h> | #include <dev/ofw/openfirm.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 <machine/bus.h> | #include <machine/bus.h> | ||||
#include <arm/ti/ti_mbox.h> | #include <arm/ti/ti_mbox.h> | ||||
#include <arm/ti/ti_prcm.h> | #include <arm/ti/ti_sysc.h> | ||||
#include "mbox_if.h" | #include "mbox_if.h" | ||||
#ifdef DEBUG | #ifdef DEBUG | ||||
#define DPRINTF(fmt, ...) do { \ | #define DPRINTF(fmt, ...) do { \ | ||||
printf("%s: ", __func__); \ | printf("%s: ", __func__); \ | ||||
printf(fmt, __VA_ARGS__); \ | printf(fmt, __VA_ARGS__); \ | ||||
} while (0) | } while (0) | ||||
Show All 35 Lines | static driver_t ti_mbox_driver = { | ||||
"ti_mbox", | "ti_mbox", | ||||
ti_mbox_methods, | ti_mbox_methods, | ||||
sizeof(struct ti_mbox_softc) | sizeof(struct ti_mbox_softc) | ||||
}; | }; | ||||
static devclass_t ti_mbox_devclass; | static devclass_t ti_mbox_devclass; | ||||
DRIVER_MODULE(ti_mbox, simplebus, ti_mbox_driver, ti_mbox_devclass, 0, 0); | DRIVER_MODULE(ti_mbox, simplebus, ti_mbox_driver, ti_mbox_devclass, 0, 0); | ||||
MODULE_DEPEND(ti_mbox, ti_sysc, 1, 1, 1); | |||||
static __inline uint32_t | static __inline uint32_t | ||||
ti_mbox_reg_read(struct ti_mbox_softc *sc, uint16_t reg) | ti_mbox_reg_read(struct ti_mbox_softc *sc, uint16_t reg) | ||||
{ | { | ||||
return (bus_space_read_4(sc->sc_bt, sc->sc_bh, reg)); | return (bus_space_read_4(sc->sc_bt, sc->sc_bh, reg)); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
Show All 19 Lines | |||||
static int | static int | ||||
ti_mbox_attach(device_t dev) | ti_mbox_attach(device_t dev) | ||||
{ | { | ||||
struct ti_mbox_softc *sc; | struct ti_mbox_softc *sc; | ||||
int rid, delay, chan; | int rid, delay, chan; | ||||
uint32_t rev, sysconfig; | uint32_t rev, sysconfig; | ||||
if (ti_prcm_clk_enable(MAILBOX0_CLK) != 0) { | if (ti_sysc_clock_enable(device_get_parent(dev)) != 0) { | ||||
device_printf(dev, "could not enable MBOX clock\n"); | device_printf(dev, "could not enable MBOX clock\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
rid = 0; | rid = 0; | ||||
mtx_init(&sc->sc_mtx, "TI mbox", NULL, MTX_DEF); | mtx_init(&sc->sc_mtx, "TI mbox", NULL, MTX_DEF); | ||||
sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | ||||
RF_ACTIVE); | RF_ACTIVE); | ||||
if (sc->sc_mem_res == NULL) { | if (sc->sc_mem_res == NULL) { | ||||
device_printf(dev, "could not allocate memory resource\n"); | device_printf(dev, "could not allocate memory resource\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
Show All 31 Lines | if (delay == 0) { | ||||
ti_mbox_detach(dev); | ti_mbox_detach(dev); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
/* | /* | ||||
* Enable smart idle mode. | * Enable smart idle mode. | ||||
*/ | */ | ||||
ti_mbox_reg_write(sc, TI_MBOX_SYSCONFIG, | ti_mbox_reg_write(sc, TI_MBOX_SYSCONFIG, | ||||
ti_mbox_reg_read(sc, TI_MBOX_SYSCONFIG) | TI_MBOX_SYSCONFIG_SMARTIDLE); | ti_mbox_reg_read(sc, TI_MBOX_SYSCONFIG) | TI_MBOX_SYSCONFIG_SMARTIDLE); | ||||
rev = ti_mbox_reg_read(sc, TI_MBOX_REVISION); | rev = ti_mbox_reg_read(sc, | ||||
ti_sysc_get_rev_address_offset_host(device_get_parent(dev))); | |||||
DPRINTF("rev %d\n", rev); | DPRINTF("rev %d\n", rev); | ||||
device_printf(dev, "revision %d.%d\n", (rev >> 8) & 0x4, rev & 0x40); | device_printf(dev, "revision %d.%d\n", (rev >> 8) & 0x4, rev & 0x40); | ||||
/* | /* | ||||
* Enable message interrupts. | * Enable message interrupts. | ||||
*/ | */ | ||||
for (chan = 0; chan < 8; chan++) | for (chan = 0; chan < 8; chan++) | ||||
ti_mbox_reg_write(sc, TI_MBOX_IRQENABLE_SET(chan), 1); | ti_mbox_reg_write(sc, TI_MBOX_IRQENABLE_SET(chan), 1); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |