From patchwork Mon Sep 23 14:36:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Borleis X-Patchwork-Id: 2928531 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 26EAE9F289 for ; Mon, 23 Sep 2013 14:37:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96EF9201F8 for ; Mon, 23 Sep 2013 14:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DD8B202C1 for ; Mon, 23 Sep 2013 14:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752298Ab3IWOg5 (ORCPT ); Mon, 23 Sep 2013 10:36:57 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:51066 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753976Ab3IWOg4 (ORCPT ); Mon, 23 Sep 2013 10:36:56 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1VO7Fk-0000kI-V9; Mon, 23 Sep 2013 16:36:44 +0200 Received: from jbe by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1VO7Fk-0005gp-0t; Mon, 23 Sep 2013 16:36:44 +0200 From: Juergen Beisert To: linux-iio@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, marex@denx.de, fabio.estevam@freescale.com, jic23@cam.ac.uk, linux-input@vger.kernel.org Subject: [PATCH 7/9] Staging/iio/adc/touchscreen/MXS: remove old touchscreen detection implementation Date: Mon, 23 Sep 2013 16:36:36 +0200 Message-Id: <1379946998-23041-8-git-send-email-jbe@pengutronix.de> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1379946998-23041-1-git-send-email-jbe@pengutronix.de> References: <1379946998-23041-1-git-send-email-jbe@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: jbe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-input@vger.kernel.org Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Juergen Beisert CC: linux-arm-kernel@lists.infradead.org CC: linux-input@vger.kernel.org CC: devel@driverdev.osuosl.org CC: Marek Vasut CC: Fabio Estevam CC: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 163 ------------------------------------ 1 file changed, 163 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 76a900d..aa1f337 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -186,7 +186,6 @@ struct mxs_lradc { bool use_touchbutton; struct input_dev *ts_input; - struct work_struct ts_work; enum mxs_lradc_id soc; enum lradc_ts_plate cur_plate; /* statemachine */ @@ -830,168 +829,6 @@ static const struct iio_info mxs_lradc_iio_info = { .read_raw = mxs_lradc_read_raw, }; -static int mxs_lradc_ts_touched(struct mxs_lradc *lradc) -{ - uint32_t reg; - - /* Enable touch detection. */ - mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), LRADC_CTRL0); - mxs_lradc_reg_set(lradc, mxs_lradc_touch_detect_bit(lradc), - LRADC_CTRL0); - - msleep(LRADC_TS_SAMPLE_DELAY_MS); - - reg = readl(lradc->base + LRADC_STATUS); - - return reg & LRADC_STATUS_TOUCH_DETECT_RAW; -} - -static int32_t mxs_lradc_ts_sample(struct mxs_lradc *lradc, - enum lradc_ts_plate plate, int change) -{ - unsigned long delay, jiff; - uint32_t reg, ctrl0 = 0, chan = 0; - /* The touchscreen always uses CTRL4 slot #7. */ - const uint8_t slot = 7; - uint32_t val; - - /* - * There are three correct configurations of the controller sampling - * the touchscreen, each of these configuration provides different - * information from the touchscreen. - * - * The following table describes the sampling configurations: - * +-------------+-------+-------+-------+ - * | Wire \ Axis | X | Y | Z | - * +---------------------+-------+-------+ - * | X+ (CH2) | HI | TS | TS | - * +-------------+-------+-------+-------+ - * | X- (CH4) | LO | SH | HI | - * +-------------+-------+-------+-------+ - * | Y+ (CH3) | SH | HI | HI | - * +-------------+-------+-------+-------+ - * | Y- (CH5) | TS | LO | SH | - * +-------------+-------+-------+-------+ - * - * HI ... strong '1' ; LO ... strong '0' - * SH ... sample here ; TS ... tri-state - * - * There are a few other ways of obtaining the Z coordinate - * (aka. pressure), but the one in the table seems to be the - * most reliable one. - */ - switch (plate) { - case LRADC_SAMPLE_X: - ctrl0 = mxs_lradc_drive_x_plate(lradc); - chan = 3; - break; - case LRADC_SAMPLE_Y: - ctrl0 = mxs_lradc_drive_y_plate(lradc); - chan = 4; - break; - case LRADC_SAMPLE_PRESSURE: - ctrl0 = mxs_lradc_drive_pressure(lradc); - chan = 5; - break; - } - - if (change) { - mxs_lradc_reg_clear(lradc, mxs_lradc_plate_mask(lradc), - LRADC_CTRL0); - mxs_lradc_reg_set(lradc, ctrl0, LRADC_CTRL0); - - mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(slot), - LRADC_CTRL4); - mxs_lradc_reg_set(lradc, - chan << LRADC_CTRL4_LRADCSELECT_OFFSET(slot), - LRADC_CTRL4); - } - - mxs_lradc_reg_clear(lradc, 0xffffffff, LRADC_CH(slot)); - mxs_lradc_reg_set(lradc, 1 << slot, LRADC_CTRL0); - - delay = jiffies + msecs_to_jiffies(LRADC_TS_SAMPLE_DELAY_MS); - do { - jiff = jiffies; - reg = readl_relaxed(lradc->base + LRADC_CTRL1); - if (reg & LRADC_CTRL1_LRADC_IRQ(slot)) - break; - } while (time_before(jiff, delay)); - - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_LRADC_IRQ(slot), LRADC_CTRL1); - - if (time_after_eq(jiff, delay)) - return -ETIMEDOUT; - - val = readl(lradc->base + LRADC_CH(slot)); - val &= LRADC_CH_VALUE_MASK; - - return val; -} - -static int32_t mxs_lradc_ts_sample_filter(struct mxs_lradc *lradc, - enum lradc_ts_plate plate) -{ - int32_t val, tot = 0; - int i; - - val = mxs_lradc_ts_sample(lradc, plate, 1); - - /* Delay a bit so the touchscreen is stable. */ - mdelay(2); - - for (i = 0; i < LRADC_TS_SAMPLE_AMOUNT; i++) { - val = mxs_lradc_ts_sample(lradc, plate, 0); - tot += val; - } - - return tot / LRADC_TS_SAMPLE_AMOUNT; -} - -static void mxs_lradc_ts_work(struct work_struct *ts_work) -{ - struct mxs_lradc *lradc = container_of(ts_work, - struct mxs_lradc, ts_work); - int val_x, val_y, val_p; - bool valid = false; - - while (mxs_lradc_ts_touched(lradc)) { - /* Disable touch detector so we can sample the touchscreen. */ - mxs_lradc_reg_clear(lradc, mxs_lradc_touch_detect_bit(lradc), - LRADC_CTRL0); - - if (likely(valid)) { - input_report_abs(lradc->ts_input, ABS_X, val_x); - input_report_abs(lradc->ts_input, ABS_Y, val_y); - input_report_abs(lradc->ts_input, ABS_PRESSURE, val_p); - input_report_key(lradc->ts_input, BTN_TOUCH, 1); - input_sync(lradc->ts_input); - } - - valid = false; - - val_x = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_X); - if (val_x < 0) - continue; - val_y = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_Y); - if (val_y < 0) - continue; - val_p = mxs_lradc_ts_sample_filter(lradc, LRADC_SAMPLE_PRESSURE); - if (val_p < 0) - continue; - - valid = true; - } - - input_report_abs(lradc->ts_input, ABS_PRESSURE, 0); - input_report_key(lradc->ts_input, BTN_TOUCH, 0); - input_sync(lradc->ts_input); - - /* Restart the touchscreen interrupts. */ - mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, LRADC_CTRL1); - mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); -} - static int mxs_lradc_ts_open(struct input_dev *dev) { struct mxs_lradc *lradc = input_get_drvdata(dev);