From patchwork Wed Sep 4 13:01:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Borleis X-Patchwork-Id: 2853657 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 799D6C0AB5 for ; Wed, 4 Sep 2013 13:06:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A072520254 for ; Wed, 4 Sep 2013 13:06:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7ED0A20253 for ; Wed, 4 Sep 2013 13:06:02 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VHCkr-0006t1-29; Wed, 04 Sep 2013 13:04:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VHCjk-0004L2-CA; Wed, 04 Sep 2013 13:03:08 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VHCj6-0004DP-IG for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2013 13:02:39 +0000 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 1VHCii-00013A-GA; Wed, 04 Sep 2013 15:02:04 +0200 Received: from jbe by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1VHCig-00023j-3y; Wed, 04 Sep 2013 15:02:02 +0200 From: Juergen Beisert To: linux-iio@vger.kernel.org Subject: [PATCH 5/5] Staging/iio/adc/touchscreen/MXS: Remove old touchscreen detection implementation Date: Wed, 4 Sep 2013 15:01:46 +0200 Message-Id: <1378299706-6742-6-git-send-email-jbe@pengutronix.de> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1378299706-6742-1-git-send-email-jbe@pengutronix.de> References: <1378299706-6742-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-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130904_090230_116156_CE7E5451 X-CRM114-Status: GOOD ( 19.40 ) X-Spam-Score: -4.3 (----) Cc: devel@driverdev.osuosl.org, Marek Vasut , Fabio Estevam , linux-arm-kernel@lists.infradead.org, Jonathan Cameron X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: devel@driverdev.osuosl.org CC: Marek Vasut CC: Fabio Estevam CC: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 193 ------------------------------------ 1 file changed, 193 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 9462af0..f81d827 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -183,7 +183,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 */ @@ -821,196 +820,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. */ - if (lradc->soc == IMX28_LRADC) { - writel(LRADC_CTRL0_MX28_PLATE_MASK, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); - } else { - writel(LRADC_CTRL0_MX23_PLATE_MASK, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - writel(LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); - } - - 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: - if (lradc->soc == IMX28_LRADC) - ctrl0 = LRADC_CTRL0_MX28_XPPSW | LRADC_CTRL0_MX28_XNNSW; - else - ctrl0 = LRADC_CTRL0_MX23_XP | LRADC_CTRL0_MX23_XM; - chan = 3; - break; - case LRADC_SAMPLE_Y: - if (lradc->soc == IMX28_LRADC) - ctrl0 = LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_YNNSW; - else - ctrl0 = LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_YM; - chan = 4; - break; - case LRADC_SAMPLE_PRESSURE: - if (lradc->soc == IMX28_LRADC) - ctrl0 = LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW; - else - ctrl0 = LRADC_CTRL0_MX23_YP | LRADC_CTRL0_MX23_XM; - chan = 5; - break; - } - - if (change) { - if (lradc->soc == IMX28_LRADC) - writel(LRADC_CTRL0_MX28_PLATE_MASK, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - else - writel(LRADC_CTRL0_MX23_PLATE_MASK, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - - writel(ctrl0, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); - - writel(LRADC_CTRL4_LRADCSELECT_MASK(slot), - lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_CLR); - writel(chan << LRADC_CTRL4_LRADCSELECT_OFFSET(slot), - lradc->base + LRADC_CTRL4 + STMP_OFFSET_REG_SET); - } - - writel(0xffffffff, lradc->base + LRADC_CH(slot) + STMP_OFFSET_REG_CLR); - writel(1 << slot, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); - - 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)); - - writel(LRADC_CTRL1_LRADC_IRQ(slot), - lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); - - 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. */ - if (lradc->soc == IMX28_LRADC) - writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - else - writel(LRADC_CTRL0_MX23_TOUCH_DETECT_ENABLE, - lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - - 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. */ - writel(LRADC_CTRL1_TOUCH_DETECT_IRQ, - lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); - writel(LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, - lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_SET); -} - static int mxs_lradc_ts_open(struct input_dev *dev) { struct mxs_lradc *lradc = input_get_drvdata(dev); @@ -1090,8 +899,6 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc) if (!lradc->use_touchscreen) return; - cancel_work_sync(&lradc->ts_work); - mxs_lradc_disable_ts(lradc); input_unregister_device(lradc->ts_input); }