From patchwork Sat Jan 24 14:33:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 5699711 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F1C0C058E for ; Sat, 24 Jan 2015 14:36:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6404202C8 for ; Sat, 24 Jan 2015 14:36:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9CE0202E9 for ; Sat, 24 Jan 2015 14:36:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YF1nV-00033o-GT; Sat, 24 Jan 2015 14:34:49 +0000 Received: from smtp.csie.ntu.edu.tw ([140.112.30.61]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YF1mv-0002iW-8C for linux-arm-kernel@lists.infradead.org; Sat, 24 Jan 2015 14:34:14 +0000 Received: from mirror2.csie.ntu.edu.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (Authenticated sender: b93043) by smtp.csie.ntu.edu.tw (Postfix) with ESMTPSA id 86A50201FD; Sat, 24 Jan 2015 22:33:49 +0800 (CST) Received: by mirror2.csie.ntu.edu.tw (Postfix, from userid 1000) id 6C3915F731; Sat, 24 Jan 2015 22:33:49 +0800 (CST) From: Chen-Yu Tsai To: Dmitry Torokhov , Maxime Ripard Subject: [PATCH 1/2] Input: sun4i-ts: Add support for touchpanel controller on A31 Date: Sat, 24 Jan 2015 22:33:47 +0800 Message-Id: <1422110028-30270-2-git-send-email-wens@csie.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422110028-30270-1-git-send-email-wens@csie.org> References: <1422110028-30270-1-git-send-email-wens@csie.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150124_063413_612488_8BB56F46 X-CRM114-Status: GOOD ( 16.78 ) X-Spam-Score: -2.3 (--) Cc: Hans de Goede , Chen-Yu Tsai , linux-input@vger.kernel.org, Sugar , Meng Zhang , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 The Allwinner A31 SoC (sun6i) has the same resistive touchpanel controller as on other sunxi platforms. The only difference between the variants is the control bits for enabling operations are left-shifted by 1 on the A31. This patch adds support for this variant. Also update the comment for the original temperature sensor with information from Allwinner. Signed-off-by: Chen-Yu Tsai --- .../bindings/input/touchscreen/sun4i.txt | 2 +- drivers/input/touchscreen/sun4i-ts.c | 46 ++++++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt index a8405bab6c00..433332d3b2ba 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt @@ -2,7 +2,7 @@ sun4i resistive touchscreen controller -------------------------------------- Required properties: - - compatible: "allwinner,sun4i-a10-ts" + - compatible: "allwinner,sun4i-a10-ts" or "allwinner,sun6i-a31-ts" - reg: mmio address range of the chip - interrupts: interrupt to which the chip is connected - #thermal-sensor-cells: shall be 0 diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c index 9ae53d4289fb..b93a28b955fd 100644 --- a/drivers/input/touchscreen/sun4i-ts.c +++ b/drivers/input/touchscreen/sun4i-ts.c @@ -72,6 +72,9 @@ #define TP_ADC_SELECT(x) ((x) << 3) #define ADC_CHAN_SELECT(x) ((x) << 0) /* 3 bits */ +/* on sun6i, bits 3~6 are left shifted by 1 to 4~7 */ +#define SUN6I_TP_MODE_EN(x) ((x) << 5) + /* TP_CTRL2 bits */ #define TP_SENSITIVE_ADJUST(x) ((x) << 28) /* 4 bits */ #define TP_MODE_SELECT(x) ((x) << 26) /* 2 bits */ @@ -113,6 +116,8 @@ struct sun4i_ts_data { unsigned int irq; bool ignore_fifo_data; int temp_data; + int temp_offset; + int temp_step; }; static void sun4i_ts_irq_handle_input(struct sun4i_ts_data *ts, u32 reg_val) @@ -188,17 +193,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, long *temp) if (ts->temp_data == -1) return -EAGAIN; - /* - * The user manuals do not contain the formula for calculating - * the temperature. The formula used here is from the AXP209, - * which is designed by X-Powers, an affiliate of Allwinner: - * - * temperature = -144.7 + (value * 0.1) - * - * This should be replaced with the correct one if such information - * becomes available. - */ - *temp = (ts->temp_data - 1447) * 100; + *temp = (ts->temp_data - ts->temp_offset) * ts->temp_step; return 0; } @@ -249,6 +244,7 @@ static int sun4i_ts_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; struct device *hwmon; int error; + u32 reg; bool ts_attached; ts = devm_kzalloc(dev, sizeof(struct sun4i_ts_data), GFP_KERNEL); @@ -258,6 +254,25 @@ static int sun4i_ts_probe(struct platform_device *pdev) ts->dev = dev; ts->ignore_fifo_data = true; ts->temp_data = -1; + if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) { + /* Allwinner SDK has temperature = -271 + (value / 6) (C) */ + ts->temp_offset = 1626; + ts->temp_step = 167; + } else { + /* + * The user manuals do not contain the formula for calculating + * the temperature. The formula used here is from the AXP209, + * which is designed by X-Powers, an affiliate of Allwinner: + * + * temperature = -144.7 + (value * 0.1) + * + * Allwinner does not have any documentation whatsoever for + * this hardware. Moreover, it is claimed that the sensor + * is inaccurate and cannot work properly. + */ + ts->temp_offset = 1447; + ts->temp_step = 100; + } ts_attached = of_property_read_bool(np, "allwinner,ts-attached"); if (ts_attached) { @@ -314,8 +329,12 @@ static int sun4i_ts_probe(struct platform_device *pdev) * Set stylus up debounce to aprox 10 ms, enable debounce, and * finally enable tp mode. */ - writel(STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1) | TP_MODE_EN(1), - ts->base + TP_CTRL1); + reg = STYLUS_UP_DEBOUN(5) | STYLUS_UP_DEBOUN_EN(1); + if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) + reg |= TP_MODE_EN(1); + else + reg |= SUN6I_TP_MODE_EN(1); + writel(reg, ts->base + TP_CTRL1); /* * The thermal core does not register hwmon devices for DT-based @@ -364,6 +383,7 @@ static int sun4i_ts_remove(struct platform_device *pdev) static const struct of_device_id sun4i_ts_of_match[] = { { .compatible = "allwinner,sun4i-a10-ts", }, + { .compatible = "allwinner,sun6i-a31-ts", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun4i_ts_of_match);