From patchwork Mon Sep 23 14:36:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Borleis X-Patchwork-Id: 2928501 Return-Path: X-Original-To: patchwork-linux-input@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 C6F73BFF05 for ; Mon, 23 Sep 2013 14:37:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B23C202A7 for ; Mon, 23 Sep 2013 14:37:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94625202D1 for ; Mon, 23 Sep 2013 14:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753986Ab3IWOg4 (ORCPT ); Mon, 23 Sep 2013 10:36:56 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:51062 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456Ab3IWOgy (ORCPT ); Mon, 23 Sep 2013 10:36:54 -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-0000kE-VB; Mon, 23 Sep 2013 16:36:44 +0200 Received: from jbe by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1VO7Fj-0005gV-Tn; Mon, 23 Sep 2013 16:36:43 +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 3/9] Staging/iio/adc/touchscreen/MXS: separate i.MX28 specific register bits Date: Mon, 23 Sep 2013 16:36:32 +0200 Message-Id: <1379946998-23041-4-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 In order to support i.MX23 and i.MX28 within one driver we need to separate the register definitions which differ in both SoC variants. 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 | 61 ++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 3abc91f..f2fb10a 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -182,24 +182,29 @@ struct mxs_lradc { }; #define LRADC_CTRL0 0x00 -#define LRADC_CTRL0_TOUCH_DETECT_ENABLE (1 << 23) -#define LRADC_CTRL0_TOUCH_SCREEN_TYPE (1 << 22) -#define LRADC_CTRL0_YNNSW /* YM */ (1 << 21) -#define LRADC_CTRL0_YPNSW /* YP */ (1 << 20) -#define LRADC_CTRL0_YPPSW /* YP */ (1 << 19) -#define LRADC_CTRL0_XNNSW /* XM */ (1 << 18) -#define LRADC_CTRL0_XNPSW /* XM */ (1 << 17) -#define LRADC_CTRL0_XPPSW /* XP */ (1 << 16) -#define LRADC_CTRL0_PLATE_MASK (0x3f << 16) +# define LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE (1 << 23) +# define LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE (1 << 22) +# define LRADC_CTRL0_MX28_YNNSW /* YM */ (1 << 21) +# define LRADC_CTRL0_MX28_YPNSW /* YP */ (1 << 20) +# define LRADC_CTRL0_MX28_YPPSW /* YP */ (1 << 19) +# define LRADC_CTRL0_MX28_XNNSW /* XM */ (1 << 18) +# define LRADC_CTRL0_MX28_XNPSW /* XM */ (1 << 17) +# define LRADC_CTRL0_MX28_XPPSW /* XP */ (1 << 16) + +# define LRADC_CTRL0_MX28_PLATE_MASK \ + (LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE | \ + LRADC_CTRL0_MX28_YNNSW | LRADC_CTRL0_MX28_YPNSW | \ + LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW | \ + LRADC_CTRL0_MX28_XNPSW | LRADC_CTRL0_MX28_XPPSW) #define LRADC_CTRL1 0x10 #define LRADC_CTRL1_TOUCH_DETECT_IRQ_EN (1 << 24) #define LRADC_CTRL1_LRADC_IRQ_EN(n) (1 << ((n) + 16)) -#define LRADC_CTRL1_LRADC_IRQ_EN_MASK (0x1fff << 16) +#define LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK (0x1fff << 16) #define LRADC_CTRL1_LRADC_IRQ_EN_OFFSET 16 #define LRADC_CTRL1_TOUCH_DETECT_IRQ (1 << 8) #define LRADC_CTRL1_LRADC_IRQ(n) (1 << (n)) -#define LRADC_CTRL1_LRADC_IRQ_MASK 0x1fff +#define LRADC_CTRL1_MX28_LRADC_IRQ_MASK 0x1fff #define LRADC_CTRL1_LRADC_IRQ_OFFSET 0 #define LRADC_CTRL2 0x20 @@ -267,7 +272,7 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev, * Virtual channel 0 is always used here as the others are always not * used if doing raw sampling. */ - writel(LRADC_CTRL1_LRADC_IRQ_EN_MASK, + writel(LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); writel(0xff, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); @@ -322,9 +327,9 @@ static int mxs_lradc_ts_touched(struct mxs_lradc *lradc) uint32_t reg; /* Enable touch detection. */ - writel(LRADC_CTRL0_PLATE_MASK, + writel(LRADC_CTRL0_MX28_PLATE_MASK, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); msleep(LRADC_TS_SAMPLE_DELAY_MS); @@ -370,21 +375,21 @@ static int32_t mxs_lradc_ts_sample(struct mxs_lradc *lradc, */ switch (plate) { case LRADC_SAMPLE_X: - ctrl0 = LRADC_CTRL0_XPPSW | LRADC_CTRL0_XNNSW; + ctrl0 = LRADC_CTRL0_MX28_XPPSW | LRADC_CTRL0_MX28_XNNSW; chan = 3; break; case LRADC_SAMPLE_Y: - ctrl0 = LRADC_CTRL0_YPPSW | LRADC_CTRL0_YNNSW; + ctrl0 = LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_YNNSW; chan = 4; break; case LRADC_SAMPLE_PRESSURE: - ctrl0 = LRADC_CTRL0_YPPSW | LRADC_CTRL0_XNNSW; + ctrl0 = LRADC_CTRL0_MX28_YPPSW | LRADC_CTRL0_MX28_XNNSW; chan = 5; break; } if (change) { - writel(LRADC_CTRL0_PLATE_MASK, + writel(LRADC_CTRL0_MX28_PLATE_MASK, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); writel(ctrl0, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); @@ -445,7 +450,7 @@ static void mxs_lradc_ts_work(struct work_struct *ts_work) while (mxs_lradc_ts_touched(lradc)) { /* Disable touch detector so we can sample the touchscreen. */ - writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); if (likely(valid)) { @@ -494,7 +499,7 @@ static int mxs_lradc_ts_open(struct input_dev *dev) lradc->stop_touchscreen = false; /* Enable the touch-detect circuitry. */ - writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); /* Enable the touch-detect IRQ. */ @@ -520,7 +525,7 @@ static void mxs_lradc_ts_close(struct input_dev *dev) lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); /* Power-down touchscreen touch-detect circuitry. */ - writel(LRADC_CTRL0_TOUCH_DETECT_ENABLE, + writel(LRADC_CTRL0_MX28_TOUCH_DETECT_ENABLE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); } @@ -584,7 +589,7 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) LRADC_CTRL1_TOUCH_DETECT_IRQ_EN | LRADC_CTRL1_TOUCH_DETECT_IRQ; - if (!(reg & LRADC_CTRL1_LRADC_IRQ_MASK)) + if (!(reg & LRADC_CTRL1_MX28_LRADC_IRQ_MASK)) return IRQ_NONE; /* @@ -604,7 +609,7 @@ static irqreturn_t mxs_lradc_handle_irq(int irq, void *data) else if (reg & LRADC_CTRL1_LRADC_IRQ(0)) complete(&lradc->completion); - writel(reg & LRADC_CTRL1_LRADC_IRQ_MASK, + writel(reg & LRADC_CTRL1_MX28_LRADC_IRQ_MASK, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); return IRQ_HANDLED; @@ -725,7 +730,7 @@ static int mxs_lradc_buffer_preenable(struct iio_dev *iio) if (ret < 0) goto err_buf; - writel(LRADC_CTRL1_LRADC_IRQ_EN_MASK, + writel(LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); writel(0xff, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); @@ -766,7 +771,7 @@ static int mxs_lradc_buffer_postdisable(struct iio_dev *iio) lradc->base + LRADC_DELAY(0) + STMP_OFFSET_REG_CLR); writel(0xff, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); - writel(LRADC_CTRL1_LRADC_IRQ_EN_MASK, + writel(LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); kfree(lradc->buffer); @@ -870,11 +875,11 @@ static int mxs_lradc_hw_init(struct mxs_lradc *lradc) writel(0, lradc->base + LRADC_DELAY(3)); /* Configure the touchscreen type */ - writel(LRADC_CTRL0_TOUCH_SCREEN_TYPE, + writel(LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_CLR); if (lradc->use_touchscreen == MXS_LRADC_TOUCHSCREEN_5WIRE) { - writel(LRADC_CTRL0_TOUCH_SCREEN_TYPE, + writel(LRADC_CTRL0_MX28_TOUCH_SCREEN_TYPE, lradc->base + LRADC_CTRL0 + STMP_OFFSET_REG_SET); } @@ -888,7 +893,7 @@ static void mxs_lradc_hw_stop(struct mxs_lradc *lradc) { int i; - writel(LRADC_CTRL1_LRADC_IRQ_EN_MASK, + writel(LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK, lradc->base + LRADC_CTRL1 + STMP_OFFSET_REG_CLR); for (i = 0; i < LRADC_MAX_DELAY_CHANS; i++)