Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/ti/ti_adc.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#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> | ||||
#ifdef EVDEV_SUPPORT | #ifdef EVDEV_SUPPORT | ||||
#include <dev/evdev/input.h> | #include <dev/evdev/input.h> | ||||
#include <dev/evdev/evdev.h> | #include <dev/evdev/evdev.h> | ||||
#endif | #endif | ||||
#include <arm/ti/ti_prcm.h> | #include <arm/ti/ti_sysc.h> | ||||
#include <arm/ti/ti_adcreg.h> | #include <arm/ti/ti_adcreg.h> | ||||
#include <arm/ti/ti_adcvar.h> | #include <arm/ti/ti_adcvar.h> | ||||
#undef DEBUG_TSC | #undef DEBUG_TSC | ||||
#define DEFAULT_CHARGE_DELAY 0x400 | #define DEFAULT_CHARGE_DELAY 0x400 | ||||
#define STEPDLY_OPEN 0x98 | #define STEPDLY_OPEN 0x98 | ||||
▲ Show 20 Lines • Show All 749 Lines • ▼ Show 20 Lines | ti_adc_attach(device_t dev) | ||||
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) { | if (!sc->sc_mem_res) { | ||||
device_printf(dev, "cannot allocate memory window\n"); | device_printf(dev, "cannot allocate memory window\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
/* Activate the ADC_TSC module. */ | /* Activate the ADC_TSC module. */ | ||||
err = ti_prcm_clk_enable(TSC_ADC_CLK); | err = ti_sysc_clock_enable(device_get_parent(dev)); | ||||
if (err) | if (err) | ||||
return (err); | return (err); | ||||
rid = 0; | rid = 0; | ||||
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, | sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, | ||||
RF_ACTIVE); | RF_ACTIVE); | ||||
if (!sc->sc_irq_res) { | if (!sc->sc_irq_res) { | ||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); | bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); | ||||
device_printf(dev, "cannot allocate interrupt\n"); | device_printf(dev, "cannot allocate interrupt\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, | if (bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, | ||||
NULL, ti_adc_intr, sc, &sc->sc_intrhand) != 0) { | NULL, ti_adc_intr, sc, &sc->sc_intrhand) != 0) { | ||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res); | bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq_res); | ||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); | bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res); | ||||
device_printf(dev, "Unable to setup the irq handler.\n"); | device_printf(dev, "Unable to setup the irq handler.\n"); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
/* Check the ADC revision. */ | /* Check the ADC revision. */ | ||||
rev = ADC_READ4(sc, ADC_REVISION); | rev = ADC_READ4(sc, ti_sysc_get_rev_address_offset_host(device_get_parent(dev))); | ||||
device_printf(dev, | device_printf(dev, | ||||
"scheme: %#x func: %#x rtl: %d rev: %d.%d custom rev: %d\n", | "scheme: %#x func: %#x rtl: %d rev: %d.%d custom rev: %d\n", | ||||
(rev & ADC_REV_SCHEME_MSK) >> ADC_REV_SCHEME_SHIFT, | (rev & ADC_REV_SCHEME_MSK) >> ADC_REV_SCHEME_SHIFT, | ||||
(rev & ADC_REV_FUNC_MSK) >> ADC_REV_FUNC_SHIFT, | (rev & ADC_REV_FUNC_MSK) >> ADC_REV_FUNC_SHIFT, | ||||
(rev & ADC_REV_RTL_MSK) >> ADC_REV_RTL_SHIFT, | (rev & ADC_REV_RTL_MSK) >> ADC_REV_RTL_SHIFT, | ||||
(rev & ADC_REV_MAJOR_MSK) >> ADC_REV_MAJOR_SHIFT, | (rev & ADC_REV_MAJOR_MSK) >> ADC_REV_MAJOR_SHIFT, | ||||
rev & ADC_REV_MINOR_MSK, | rev & ADC_REV_MINOR_MSK, | ||||
(rev & ADC_REV_CUSTOM_MSK) >> ADC_REV_CUSTOM_SHIFT); | (rev & ADC_REV_CUSTOM_MSK) >> ADC_REV_CUSTOM_SHIFT); | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | static driver_t ti_adc_driver = { | ||||
sizeof(struct ti_adc_softc), | sizeof(struct ti_adc_softc), | ||||
}; | }; | ||||
static devclass_t ti_adc_devclass; | static devclass_t ti_adc_devclass; | ||||
DRIVER_MODULE(ti_adc, simplebus, ti_adc_driver, ti_adc_devclass, 0, 0); | DRIVER_MODULE(ti_adc, simplebus, ti_adc_driver, ti_adc_devclass, 0, 0); | ||||
MODULE_VERSION(ti_adc, 1); | MODULE_VERSION(ti_adc, 1); | ||||
MODULE_DEPEND(ti_adc, simplebus, 1, 1, 1); | MODULE_DEPEND(ti_adc, simplebus, 1, 1, 1); | ||||
MODULE_DEPEND(ti_adc, ti_sysc, 1, 1, 1); | |||||
#ifdef EVDEV_SUPPORT | #ifdef EVDEV_SUPPORT | ||||
MODULE_DEPEND(ti_adc, evdev, 1, 1, 1); | MODULE_DEPEND(ti_adc, evdev, 1, 1, 1); | ||||
#endif | #endif |