From patchwork Fri Oct 14 07:53:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9376155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FE0B60779 for ; Fri, 14 Oct 2016 07:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 551C52A4D7 for ; Fri, 14 Oct 2016 07:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4972A2A4E6; Fri, 14 Oct 2016 07:56:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D432A2A4D7 for ; Fri, 14 Oct 2016 07:56:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1buxKz-0003iP-Pp; Fri, 14 Oct 2016 07:55:29 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1buxJt-0002CI-7W for linux-arm-kernel@lists.infradead.org; Fri, 14 Oct 2016 07:54:22 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EDFB0BBCD; Fri, 14 Oct 2016 07:54:04 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-53.ams2.redhat.com [10.36.112.53]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9E7rdoN016706; Fri, 14 Oct 2016 03:54:00 -0400 From: Hans de Goede To: Rob Herring , Mark Rutland , Arnd Bergmann , Greg Kroah-Hartman Subject: [PATCH 4/6] misc: q8-hardwaremgr: Add rda599x wift/bt/fm radio combo detection Date: Fri, 14 Oct 2016 09:53:35 +0200 Message-Id: <20161014075337.10452-5-hdegoede@redhat.com> In-Reply-To: <20161014075337.10452-1-hdegoede@redhat.com> References: <20161014075337.10452-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 14 Oct 2016 07:54:05 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161014_005421_378796_4E07B1EC X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, Hans de Goede MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some q8s have a rda599x sdio wifi/bt + i2c fm radio chip with its i2c interface connected to the same i2c bus as the accelerometer. There is no kernel driver for these devices yet, but it is useful to know if one is present for the touchscreen variant selection heuristics. And when in the future we do get a driver, this detection code will also be useful to automatically register i2c client dt nodes for these devices. Signed-off-by: Hans de Goede --- drivers/misc/q8-hardwaremgr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/misc/q8-hardwaremgr.c b/drivers/misc/q8-hardwaremgr.c index 8ed71a9..21754f5 100644 --- a/drivers/misc/q8-hardwaremgr.c +++ b/drivers/misc/q8-hardwaremgr.c @@ -144,6 +144,7 @@ struct q8_hardwaremgr_data { int touchscreen_invert_y; int touchscreen_swap_x_y; const char *touchscreen_fw_name; + bool has_rda599x; }; typedef int (*bus_probe_func)(struct q8_hardwaremgr_data *data, @@ -454,6 +455,28 @@ static void q8_hardwaremgr_apply_touchscreen(struct q8_hardwaremgr_data *data) of_node_put(np); } +static int q8_hardwaremgr_probe_rda599x(struct q8_hardwaremgr_data *data, + struct i2c_client *client) +{ + int id; + + /* + * Check for the (integrated) rda580x / rda5820 fm receiver at 0x11 + * + * Alternatively we could check for the wifi_rf i2c interface at + * address 0x14, by selecting page/bank 1 through: + * smbus_write_word_swapped(0x3f, 0x01) + * and then doing a smbus_read_word_swapped(0x20) which will + * return 0x5990 for a rda5990. We prefer the fm detect method since + * we want to avoid doing any smbus_writes while probing. + */ + id = i2c_smbus_read_word_swapped(client, 0x0c); + if (id == 0x5802 || id == 0x5803 || id == 0x5805 || id == 0x5820) + data->has_rda599x = true; + + return id == -ETIMEDOUT ? -ETIMEDOUT : -ENODEV; +} + static int q8_hardwaremgr_probe_mxc6225(struct q8_hardwaremgr_data *data, struct i2c_client *client) { @@ -594,6 +617,8 @@ static int q8_hardwaremgr_probe_da311(struct q8_hardwaremgr_data *data, static int q8_hardwaremgr_probe_accelerometer(struct q8_hardwaremgr_data *data, struct i2c_adapter *adap) { + /* The rda599x wifi/bt/fm shares the i2c bus with the accelerometer */ + PROBE_CLIENT(NULL, 0x11, q8_hardwaremgr_probe_rda599x); PROBE_CLIENT(&data->accelerometer, 0x15, q8_hardwaremgr_probe_mxc6225); PROBE_CLIENT(&data->accelerometer, 0x4c, q8_hardwaremgr_probe_mc3230); PROBE_CLIENT(&data->accelerometer, 0x1c, q8_hardwaremgr_probe_dmard06); @@ -749,6 +774,9 @@ static int q8_hardwaremgr_probe(struct platform_device *pdev) if (ret) goto error; + if (data->has_rda599x) + dev_info(data->dev, "Found a rda599x sdio/i2c wifi/bt/fm combo chip\n"); + q8_hardwaremgr_apply_touchscreen(data); q8_hardwaremgr_apply_accelerometer(data);