Commit 1039d762 authored by Michael Thalmeier's avatar Michael Thalmeier Committed by Samuel Ortiz

mfd: Add pdata to set mc13783-ts conversion delay

MC13783 can be programmed to wait some clock cycles between the
touchscreen polarization and the resistance conversion. This is
needed to adjust for touchscreens with high capacitance between
plates.
Signed-off-by: default avatarMichael Thalmeier <michael.thalmeier@hale.at>
Acked-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 4d75dd61
...@@ -53,7 +53,7 @@ static int mc13783_adc_read(struct device *dev, ...@@ -53,7 +53,7 @@ static int mc13783_adc_read(struct device *dev,
ret = mc13xxx_adc_do_conversion(priv->mc13xxx, ret = mc13xxx_adc_do_conversion(priv->mc13xxx,
MC13XXX_ADC_MODE_MULT_CHAN, MC13XXX_ADC_MODE_MULT_CHAN,
channel, sample); channel, 0, 0, sample);
if (ret) if (ret)
return ret; return ret;
......
...@@ -39,6 +39,7 @@ struct mc13783_ts_priv { ...@@ -39,6 +39,7 @@ struct mc13783_ts_priv {
struct delayed_work work; struct delayed_work work;
struct workqueue_struct *workq; struct workqueue_struct *workq;
unsigned int sample[4]; unsigned int sample[4];
struct mc13xxx_ts_platform_data *touch;
}; };
static irqreturn_t mc13783_ts_handler(int irq, void *data) static irqreturn_t mc13783_ts_handler(int irq, void *data)
...@@ -125,7 +126,9 @@ static void mc13783_ts_work(struct work_struct *work) ...@@ -125,7 +126,9 @@ static void mc13783_ts_work(struct work_struct *work)
unsigned int channel = 12; unsigned int channel = 12;
if (mc13xxx_adc_do_conversion(priv->mc13xxx, if (mc13xxx_adc_do_conversion(priv->mc13xxx,
mode, channel, priv->sample) == 0) mode, channel,
priv->touch->ato, priv->touch->atox,
priv->sample) == 0)
mc13783_ts_report_sample(priv); mc13783_ts_report_sample(priv);
} }
...@@ -179,6 +182,12 @@ static int __init mc13783_ts_probe(struct platform_device *pdev) ...@@ -179,6 +182,12 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&priv->work, mc13783_ts_work); INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
priv->idev = idev; priv->idev = idev;
priv->touch = dev_get_platdata(&pdev->dev);
if (!priv->touch) {
dev_err(&pdev->dev, "missing platform data\n");
ret = -ENODEV;
goto err_free_mem;
}
/* /*
* We need separate workqueue because mc13783_adc_do_conversion * We need separate workqueue because mc13783_adc_do_conversion
......
...@@ -560,6 +560,8 @@ EXPORT_SYMBOL(mc13xxx_get_flags); ...@@ -560,6 +560,8 @@ EXPORT_SYMBOL(mc13xxx_get_flags);
#define MC13XXX_ADC1_CHAN0_SHIFT 5 #define MC13XXX_ADC1_CHAN0_SHIFT 5
#define MC13XXX_ADC1_CHAN1_SHIFT 8 #define MC13XXX_ADC1_CHAN1_SHIFT 8
#define MC13783_ADC1_ATO_SHIFT 11
#define MC13783_ADC1_ATOX (1 << 19)
struct mc13xxx_adcdone_data { struct mc13xxx_adcdone_data {
struct mc13xxx *mc13xxx; struct mc13xxx *mc13xxx;
...@@ -580,7 +582,8 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data) ...@@ -580,7 +582,8 @@ static irqreturn_t mc13xxx_handler_adcdone(int irq, void *data)
#define MC13XXX_ADC_WORKING (1 << 0) #define MC13XXX_ADC_WORKING (1 << 0)
int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode, int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
unsigned int channel, unsigned int *sample) unsigned int channel, u8 ato, bool atox,
unsigned int *sample)
{ {
u32 adc0, adc1, old_adc0; u32 adc0, adc1, old_adc0;
int i, ret; int i, ret;
...@@ -631,6 +634,9 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode, ...@@ -631,6 +634,9 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
return -EINVAL; return -EINVAL;
} }
adc1 |= ato << MC13783_ADC1_ATO_SHIFT;
if (atox)
adc1 |= MC13783_ADC1_ATOX;
dev_dbg(&mc13xxx->spidev->dev, "%s: request irq\n", __func__); dev_dbg(&mc13xxx->spidev->dev, "%s: request irq\n", __func__);
mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE, mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
mc13xxx_handler_adcdone, __func__, &adcdone_data); mc13xxx_handler_adcdone, __func__, &adcdone_data);
...@@ -813,7 +819,8 @@ static int mc13xxx_probe(struct spi_device *spi) ...@@ -813,7 +819,8 @@ static int mc13xxx_probe(struct spi_device *spi)
mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); mc13xxx_add_subdevice(mc13xxx, "%s-rtc");
if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN)
mc13xxx_add_subdevice(mc13xxx, "%s-ts"); mc13xxx_add_subdevice_pdata(mc13xxx, "%s-ts",
&pdata->touch, sizeof(pdata->touch));
if (pdata) { if (pdata) {
mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator",
......
...@@ -38,7 +38,8 @@ int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq); ...@@ -38,7 +38,8 @@ int mc13xxx_irq_ack(struct mc13xxx *mc13xxx, int irq);
int mc13xxx_get_flags(struct mc13xxx *mc13xxx); int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
unsigned int mode, unsigned int channel, unsigned int *sample); unsigned int mode, unsigned int channel,
u8 ato, bool atox, unsigned int *sample);
#define MC13XXX_IRQ_ADCDONE 0 #define MC13XXX_IRQ_ADCDONE 0
#define MC13XXX_IRQ_ADCBISDONE 1 #define MC13XXX_IRQ_ADCBISDONE 1
...@@ -157,6 +158,18 @@ struct mc13xxx_buttons_platform_data { ...@@ -157,6 +158,18 @@ struct mc13xxx_buttons_platform_data {
unsigned short b3on_key; unsigned short b3on_key;
}; };
struct mc13xxx_ts_platform_data {
/* Delay between Touchscreen polarization and ADC Conversion.
* Given in clock ticks of a 32 kHz clock which gives a granularity of
* about 30.5ms */
u8 ato;
#define MC13783_TS_ATO_FIRST false
#define MC13783_TS_ATO_EACH true
/* Use the ATO delay only for the first conversion or for each one */
bool atox;
};
struct mc13xxx_platform_data { struct mc13xxx_platform_data {
#define MC13XXX_USE_TOUCHSCREEN (1 << 0) #define MC13XXX_USE_TOUCHSCREEN (1 << 0)
#define MC13XXX_USE_CODEC (1 << 1) #define MC13XXX_USE_CODEC (1 << 1)
...@@ -167,6 +180,7 @@ struct mc13xxx_platform_data { ...@@ -167,6 +180,7 @@ struct mc13xxx_platform_data {
struct mc13xxx_regulator_platform_data regulators; struct mc13xxx_regulator_platform_data regulators;
struct mc13xxx_leds_platform_data *leds; struct mc13xxx_leds_platform_data *leds;
struct mc13xxx_buttons_platform_data *buttons; struct mc13xxx_buttons_platform_data *buttons;
struct mc13xxx_ts_platform_data touch;
}; };
#define MC13XXX_ADC_MODE_TS 1 #define MC13XXX_ADC_MODE_TS 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment