mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 00:38:55 +00:00
3ffdea3fec
A number of new drivers and some new functionality + a lot of cleanups all over IIO. New Core Elements 1) New INT_TIME info_mask element for integration time, which may have different effects on measurement noise and similar, than an amplifier and hence is different from existing SCALE. Already existed in some drivers as a custom attribute. 2) Introduce a iio_push_buffers_with_timestamp helper to cover the common case of filling the last 64 bits of data to be passed to the buffer with a timestamp. Applied to lots of drivers. Cuts down on repeated code and moves a slightly fiddly bit of logic into a single location. 3) Introduce info_mask_[shared_by_dir/shared_by_all] elements to allow support of elements such as sampling_frequency which is typically shared by all input channels on a device. This reduces code and makes these controls available from in kernel consumers of IIO devices. New drivers 1) MCP3422/3/4 ADC 2) TSL4531 ambient light sensor 3) TCS3472/5 color light sensor 4) GP2AP020A00F ambient light / proximity sensor 5) LPS001WP support added to ST pressure sensor driver. New driver functionality 1) ti_am335x_adc Add buffered sampling support. This device has a hardware fifo that is fed directly into an IIO kfifo buffer based on a watershed interrupt. Note this will act as an example of how to handle this increasingly common type of device. The only previous example - sca3000 - take a less than optimal approach which is largely why it is still in staging. A couple of little cleanups for that new functionality followed later. Core cleanups: 1) MAINTAINERS - Sachin actually brought my email address up to date because I said I'd do it and never got around to it :) 2) Assign buffer list elements as single element lists to simplify the iio_buffer_is_active logic. 3) wake_up_interruptible_poll instead of wake_up_interruptible to only wake up threads waiting for poll notifications. 4) Add O_CLOEXEC flag to anon_inode_get_fd call for IIO event interface. 5) Change iio_push_to_buffers to take a void * pointer so as to avoid some annoying and unnecessary type casts. 6) iio_compute_scan_bytes incorrectly took a long rather than unsigned long. 7) Various minor tidy ups. Driver cleanups (in no particular order) 1) Another set of devm_ allocations patches from Sachin Kamat. 2) tsl2x7x - 0 to NULL cleanup. 3) hmc5843 - fix missing > in MODULE_AUTHOR 4) Set of strict_strto* to kstrto* conversions. 5) mxs-lradc - fix ordering of resource removal to match creation 6) mxs-lradc - add MODULE_ALIAS 7) adc7606 - drop a work pending test duplicated in core functions. 8) hmc5843 - devm_ allocation patch 9) Series of redundant breaks removed. 10) ad2s1200 - pr_err -> dev_err 11) adjd_s311 - use INT_TIME 12) ST sensors - large set of cleanups from Lee Jones and removed restriction to using only triggers provided by the st_sensors themselves from Dennis Ciocca. 13) dummy and tmp006 provide sampling_frequency via info_mask_shared_by_all. 14) tcs3472 - fix incorrect buffer size and wrong device pointer used in suspend / resume functions. 15) max1363 - use defaults for buffer setup ops as provided by the triggered buffer helpers as they are the same as were specified in max1363 driver. 16) Trivial tidy ups in a number of other drivers. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (GNU/Linux) iQIcBAABAgAGBQJSP0HUAAoJEFSFNJnE9BaIwiQQAKuJaoPrdMezm1TDaqgrzQWQ U95mSJ19xPYVSQVNHFLFidcajhADRMFhMUGOJF64VZObEdOtFWI0UkrJjFhYtJTt n1B6qAqPjatmruj434+n5PW32XtareOPThso5EDCAW0X+CNgSOgda+TVj+9g1Ilg Onltb3wugMcs27FakZpKv1YuGyKAKE6uT/33qr++cuynR89JZOlp0QmLgIXobVRR WdjuiH8OXFA4LsP7dWQhoSejs6+JPMn992qkACUc5fztQfFfCk0eJsgQIsOXkz1e U6MFvab0LtdPKDRyzT1kIpK/Jxf1OVNiOYaQNIGuNMipa+5WRz2lF1sZyERQTJWR HOZehkikBdL73WaaKwyaLTsYyDMbYM9ZkpLrBEFRr7ocZpg/0LA84BWYYDWu1Nok 9Ib9xNAxcAgFwQMJpiz9J3ap/IzV2qJT9rv78q1chVwhNhVDs2CbwcuZKAB4UvWs Oz7C0Xx5DA/K7DlpJMLaVB1+BRJ3C1I9Jbr84mnu0clgOqFE+nrdKZcUTrOTFXdy 2yTp7Bkc2JiRtOYhI40UL79N08KCGNTUfigmUDQseF2dsaNlz5rTOiMifYQCRw9+ C1kxY00emzlGTvfUDdPwkiQTtz8tWf9Ahvjx/ufGfed68KWDMs1VuGNcqEzgqKNI SMP0VTEXbCiLeWYMqGep =mMgm -----END PGP SIGNATURE----- Merge tag 'iio-for-3.13a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: First round of new drivers, functionality and cleanups for IIO in the 3.13 cycle A number of new drivers and some new functionality + a lot of cleanups all over IIO. New Core Elements 1) New INT_TIME info_mask element for integration time, which may have different effects on measurement noise and similar, than an amplifier and hence is different from existing SCALE. Already existed in some drivers as a custom attribute. 2) Introduce a iio_push_buffers_with_timestamp helper to cover the common case of filling the last 64 bits of data to be passed to the buffer with a timestamp. Applied to lots of drivers. Cuts down on repeated code and moves a slightly fiddly bit of logic into a single location. 3) Introduce info_mask_[shared_by_dir/shared_by_all] elements to allow support of elements such as sampling_frequency which is typically shared by all input channels on a device. This reduces code and makes these controls available from in kernel consumers of IIO devices. New drivers 1) MCP3422/3/4 ADC 2) TSL4531 ambient light sensor 3) TCS3472/5 color light sensor 4) GP2AP020A00F ambient light / proximity sensor 5) LPS001WP support added to ST pressure sensor driver. New driver functionality 1) ti_am335x_adc Add buffered sampling support. This device has a hardware fifo that is fed directly into an IIO kfifo buffer based on a watershed interrupt. Note this will act as an example of how to handle this increasingly common type of device. The only previous example - sca3000 - take a less than optimal approach which is largely why it is still in staging. A couple of little cleanups for that new functionality followed later. Core cleanups: 1) MAINTAINERS - Sachin actually brought my email address up to date because I said I'd do it and never got around to it :) 2) Assign buffer list elements as single element lists to simplify the iio_buffer_is_active logic. 3) wake_up_interruptible_poll instead of wake_up_interruptible to only wake up threads waiting for poll notifications. 4) Add O_CLOEXEC flag to anon_inode_get_fd call for IIO event interface. 5) Change iio_push_to_buffers to take a void * pointer so as to avoid some annoying and unnecessary type casts. 6) iio_compute_scan_bytes incorrectly took a long rather than unsigned long. 7) Various minor tidy ups. Driver cleanups (in no particular order) 1) Another set of devm_ allocations patches from Sachin Kamat. 2) tsl2x7x - 0 to NULL cleanup. 3) hmc5843 - fix missing > in MODULE_AUTHOR 4) Set of strict_strto* to kstrto* conversions. 5) mxs-lradc - fix ordering of resource removal to match creation 6) mxs-lradc - add MODULE_ALIAS 7) adc7606 - drop a work pending test duplicated in core functions. 8) hmc5843 - devm_ allocation patch 9) Series of redundant breaks removed. 10) ad2s1200 - pr_err -> dev_err 11) adjd_s311 - use INT_TIME 12) ST sensors - large set of cleanups from Lee Jones and removed restriction to using only triggers provided by the st_sensors themselves from Dennis Ciocca. 13) dummy and tmp006 provide sampling_frequency via info_mask_shared_by_all. 14) tcs3472 - fix incorrect buffer size and wrong device pointer used in suspend / resume functions. 15) max1363 - use defaults for buffer setup ops as provided by the triggered buffer helpers as they are the same as were specified in max1363 driver. 16) Trivial tidy ups in a number of other drivers.
178 lines
5.1 KiB
C
178 lines
5.1 KiB
C
#ifndef __LINUX_TI_AM335X_TSCADC_MFD_H
|
|
#define __LINUX_TI_AM335X_TSCADC_MFD_H
|
|
|
|
/*
|
|
* TI Touch Screen / ADC MFD driver
|
|
*
|
|
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation version 2.
|
|
*
|
|
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
|
* kind, whether express or implied; without even the implied warranty
|
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/mfd/core.h>
|
|
|
|
#define REG_RAWIRQSTATUS 0x024
|
|
#define REG_IRQSTATUS 0x028
|
|
#define REG_IRQENABLE 0x02C
|
|
#define REG_IRQCLR 0x030
|
|
#define REG_IRQWAKEUP 0x034
|
|
#define REG_CTRL 0x040
|
|
#define REG_ADCFSM 0x044
|
|
#define REG_CLKDIV 0x04C
|
|
#define REG_SE 0x054
|
|
#define REG_IDLECONFIG 0x058
|
|
#define REG_CHARGECONFIG 0x05C
|
|
#define REG_CHARGEDELAY 0x060
|
|
#define REG_STEPCONFIG(n) (0x64 + ((n) * 8))
|
|
#define REG_STEPDELAY(n) (0x68 + ((n) * 8))
|
|
#define REG_FIFO0CNT 0xE4
|
|
#define REG_FIFO0THR 0xE8
|
|
#define REG_FIFO1CNT 0xF0
|
|
#define REG_FIFO1THR 0xF4
|
|
#define REG_FIFO0 0x100
|
|
#define REG_FIFO1 0x200
|
|
|
|
/* Register Bitfields */
|
|
/* IRQ wakeup enable */
|
|
#define IRQWKUP_ENB BIT(0)
|
|
|
|
/* Step Enable */
|
|
#define STEPENB_MASK (0x1FFFF << 0)
|
|
#define STEPENB(val) ((val) << 0)
|
|
#define ENB(val) (1 << (val))
|
|
#define STPENB_STEPENB STEPENB(0x1FFFF)
|
|
#define STPENB_STEPENB_TC STEPENB(0x1FFF)
|
|
|
|
/* IRQ enable */
|
|
#define IRQENB_HW_PEN BIT(0)
|
|
#define IRQENB_FIFO0THRES BIT(2)
|
|
#define IRQENB_FIFO0OVRRUN BIT(3)
|
|
#define IRQENB_FIFO0UNDRFLW BIT(4)
|
|
#define IRQENB_FIFO1THRES BIT(5)
|
|
#define IRQENB_FIFO1OVRRUN BIT(6)
|
|
#define IRQENB_FIFO1UNDRFLW BIT(7)
|
|
#define IRQENB_PENUP BIT(9)
|
|
|
|
/* Step Configuration */
|
|
#define STEPCONFIG_MODE_MASK (3 << 0)
|
|
#define STEPCONFIG_MODE(val) ((val) << 0)
|
|
#define STEPCONFIG_MODE_SWCNT STEPCONFIG_MODE(1)
|
|
#define STEPCONFIG_MODE_HWSYNC STEPCONFIG_MODE(2)
|
|
#define STEPCONFIG_AVG_MASK (7 << 2)
|
|
#define STEPCONFIG_AVG(val) ((val) << 2)
|
|
#define STEPCONFIG_AVG_16 STEPCONFIG_AVG(4)
|
|
#define STEPCONFIG_XPP BIT(5)
|
|
#define STEPCONFIG_XNN BIT(6)
|
|
#define STEPCONFIG_YPP BIT(7)
|
|
#define STEPCONFIG_YNN BIT(8)
|
|
#define STEPCONFIG_XNP BIT(9)
|
|
#define STEPCONFIG_YPN BIT(10)
|
|
#define STEPCONFIG_INM_MASK (0xF << 15)
|
|
#define STEPCONFIG_INM(val) ((val) << 15)
|
|
#define STEPCONFIG_INM_ADCREFM STEPCONFIG_INM(8)
|
|
#define STEPCONFIG_INP_MASK (0xF << 19)
|
|
#define STEPCONFIG_INP(val) ((val) << 19)
|
|
#define STEPCONFIG_INP_AN4 STEPCONFIG_INP(4)
|
|
#define STEPCONFIG_INP_ADCREFM STEPCONFIG_INP(8)
|
|
#define STEPCONFIG_FIFO1 BIT(26)
|
|
|
|
/* Delay register */
|
|
#define STEPDELAY_OPEN_MASK (0x3FFFF << 0)
|
|
#define STEPDELAY_OPEN(val) ((val) << 0)
|
|
#define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098)
|
|
#define STEPDELAY_SAMPLE_MASK (0xFF << 24)
|
|
#define STEPDELAY_SAMPLE(val) ((val) << 24)
|
|
#define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0)
|
|
|
|
/* Charge Config */
|
|
#define STEPCHARGE_RFP_MASK (7 << 12)
|
|
#define STEPCHARGE_RFP(val) ((val) << 12)
|
|
#define STEPCHARGE_RFP_XPUL STEPCHARGE_RFP(1)
|
|
#define STEPCHARGE_INM_MASK (0xF << 15)
|
|
#define STEPCHARGE_INM(val) ((val) << 15)
|
|
#define STEPCHARGE_INM_AN1 STEPCHARGE_INM(1)
|
|
#define STEPCHARGE_INP_MASK (0xF << 19)
|
|
#define STEPCHARGE_INP(val) ((val) << 19)
|
|
#define STEPCHARGE_RFM_MASK (3 << 23)
|
|
#define STEPCHARGE_RFM(val) ((val) << 23)
|
|
#define STEPCHARGE_RFM_XNUR STEPCHARGE_RFM(1)
|
|
|
|
/* Charge delay */
|
|
#define CHARGEDLY_OPEN_MASK (0x3FFFF << 0)
|
|
#define CHARGEDLY_OPEN(val) ((val) << 0)
|
|
#define CHARGEDLY_OPENDLY CHARGEDLY_OPEN(1)
|
|
|
|
/* Control register */
|
|
#define CNTRLREG_TSCSSENB BIT(0)
|
|
#define CNTRLREG_STEPID BIT(1)
|
|
#define CNTRLREG_STEPCONFIGWRT BIT(2)
|
|
#define CNTRLREG_POWERDOWN BIT(4)
|
|
#define CNTRLREG_AFE_CTRL_MASK (3 << 5)
|
|
#define CNTRLREG_AFE_CTRL(val) ((val) << 5)
|
|
#define CNTRLREG_4WIRE CNTRLREG_AFE_CTRL(1)
|
|
#define CNTRLREG_5WIRE CNTRLREG_AFE_CTRL(2)
|
|
#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3)
|
|
#define CNTRLREG_TSCENB BIT(7)
|
|
|
|
/* FIFO READ Register */
|
|
#define FIFOREAD_DATA_MASK (0xfff << 0)
|
|
#define FIFOREAD_CHNLID_MASK (0xf << 16)
|
|
|
|
/* Sequencer Status */
|
|
#define SEQ_STATUS BIT(5)
|
|
|
|
#define ADC_CLK 3000000
|
|
#define TOTAL_STEPS 16
|
|
#define TOTAL_CHANNELS 8
|
|
#define FIFO1_THRESHOLD 19
|
|
|
|
/*
|
|
* ADC runs at 3MHz, and it takes
|
|
* 15 cycles to latch one data output.
|
|
* Hence the idle time for ADC to
|
|
* process one sample data would be
|
|
* around 5 micro seconds.
|
|
*/
|
|
#define IDLE_TIMEOUT 5 /* microsec */
|
|
|
|
#define TSCADC_CELLS 2
|
|
|
|
struct ti_tscadc_dev {
|
|
struct device *dev;
|
|
struct regmap *regmap_tscadc;
|
|
void __iomem *tscadc_base;
|
|
int irq;
|
|
int used_cells; /* 1-2 */
|
|
int tsc_cell; /* -1 if not used */
|
|
int adc_cell; /* -1 if not used */
|
|
struct mfd_cell cells[TSCADC_CELLS];
|
|
u32 reg_se_cache;
|
|
spinlock_t reg_lock;
|
|
|
|
/* tsc device */
|
|
struct titsc *tsc;
|
|
|
|
/* adc device */
|
|
struct adc_device *adc;
|
|
};
|
|
|
|
static inline struct ti_tscadc_dev *ti_tscadc_dev_get(struct platform_device *p)
|
|
{
|
|
struct ti_tscadc_dev **tscadc_dev = p->dev.platform_data;
|
|
|
|
return *tscadc_dev;
|
|
}
|
|
|
|
void am335x_tsc_se_update(struct ti_tscadc_dev *tsadc);
|
|
void am335x_tsc_se_set(struct ti_tscadc_dev *tsadc, u32 val);
|
|
void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val);
|
|
|
|
#endif
|