/*-1* Copyright 2014 Luiz Otavio O Souza <[email protected]>2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/2526#ifndef _TI_ADCVAR_H_27#define _TI_ADCVAR_H_2829#define TI_ADC_NPINS 83031#define ADC_READ4(_sc, reg) bus_read_4((_sc)->sc_mem_res, reg)32#define ADC_WRITE4(_sc, reg, value) \33bus_write_4((_sc)->sc_mem_res, reg, value)3435struct ti_adc_softc {36device_t sc_dev;37int sc_last_state;38struct mtx sc_mtx;39struct resource *sc_mem_res;40struct resource *sc_irq_res;41void *sc_intrhand;42int sc_tsc_wires;43int sc_tsc_wire_config[TI_ADC_NPINS];44int sc_coord_readouts;45int sc_x_plate_resistance;46int sc_charge_delay;47int sc_adc_nchannels;48int sc_adc_channels[TI_ADC_NPINS];49int sc_xp_bit, sc_xp_inp;50int sc_xn_bit, sc_xn_inp;51int sc_yp_bit, sc_yp_inp;52int sc_yn_bit, sc_yn_inp;53uint32_t sc_tsc_enabled;54int sc_pen_down;55#ifdef EVDEV_SUPPORT56int sc_x;57int sc_y;58struct evdev_dev *sc_evdev;59#endif60};6162struct ti_adc_input {63int32_t enable; /* input enabled */64int32_t samples; /* samples average */65int32_t input; /* input number */66int32_t value; /* raw converted value */67uint32_t stepconfig; /* step config register */68uint32_t stepdelay; /* step delay register */69struct ti_adc_softc *sc; /* pointer to adc softc */70};7172#define TI_ADC_LOCK(_sc) \73mtx_lock(&(_sc)->sc_mtx)74#define TI_ADC_UNLOCK(_sc) \75mtx_unlock(&(_sc)->sc_mtx)76#define TI_ADC_LOCK_INIT(_sc) \77mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->sc_dev), \78"ti_adc", MTX_DEF)79#define TI_ADC_LOCK_DESTROY(_sc) \80mtx_destroy(&_sc->sc_mtx);81#define TI_ADC_LOCK_ASSERT(_sc) \82mtx_assert(&(_sc)->sc_mtx, MA_OWNED)8384#endif /* _TI_ADCVAR_H_ */858687