From: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
Cc: Maxime Ripard
<maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 4/6] misc: q8-hardwaremgr: Add rda599x wift/bt/fm radio combo detection
Date: Fri, 14 Oct 2016 09:53:35 +0200 [thread overview]
Message-ID: <20161014075337.10452-5-hdegoede@redhat.com> (raw)
In-Reply-To: <20161014075337.10452-1-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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 <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
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);
--
2.9.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-10-14 7:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-14 7:53 Add Allwinner Q8 tablets hardware manager Hans de Goede
[not found] ` <20161014075337.10452-1-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-14 7:53 ` [PATCH 1/6] dt: bindings: Add Allwinner Q8 tablets hardware manager bindings Hans de Goede
[not found] ` <20161014075337.10452-2-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-26 20:39 ` Rob Herring
2016-10-14 7:53 ` [PATCH 2/6] misc: Add Allwinner Q8 tablet hardware manager Hans de Goede
2016-10-14 7:53 ` [PATCH 3/6] misc: q8-hardwaremgr: Add accelerometer detection Hans de Goede
2016-10-14 7:53 ` Hans de Goede [this message]
2016-10-14 7:53 ` [PATCH 5/6] misc: q8-hardwaremgr: Better touchscreen defaults based on heuristics Hans de Goede
2016-10-14 7:53 ` [PATCH 6/6] misc: q8-hardwaremgr: Add quirk handling Hans de Goede
2016-10-24 17:39 ` Add Allwinner Q8 tablets hardware manager Mark Rutland
2016-10-26 11:46 ` Hans de Goede
[not found] ` <CAJ-oXjQbOkrkNToEXYmPUZOgYBGbxQREZ4NL4bMcZmG=KP2vQQ@mail.gmail.com>
[not found] ` <CAJ-oXjQbOkrkNToEXYmPUZOgYBGbxQREZ4NL4bMcZmG=KP2vQQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 9:14 ` Hans de Goede
2016-10-27 12:57 ` Pierre-Hugues Husson
2016-10-27 14:53 ` Hans de Goede
[not found] ` <4cfdd415-1965-7be9-b204-86a9931683a6-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-27 16:27 ` Pantelis Antoniou
2016-10-27 17:31 ` Pierre-Hugues Husson
[not found] ` <CAJ-oXjRJrs77yE-skpZ-V4e=rdhRyfNve9bibf1VOaZYy2=tRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 21:15 ` Hans de Goede
[not found] ` <4cfbedb2-0249-e881-3577-dda0b0d4cabe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-10-27 15:52 ` Pantelis Antoniou
[not found] ` <9B288597-7812-459D-A5C7-B61107751DA6-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-10-27 16:59 ` Pierre-Hugues Husson
[not found] ` <CAJ-oXjT=eVwEk7t5WoZAhjMhiZZkq0NN5tFLidSnUNO97D62zQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 17:11 ` Pantelis Antoniou
[not found] ` <D75CB7DE-4165-4D2F-B40B-D2B6875C0172-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-10-27 19:04 ` Pierre-Hugues Husson
[not found] ` <CAJ-oXjS_=k4qE25t2b9eNnuqvVHf-1g7CZr81pPJx==aftF4xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 19:23 ` Pantelis Antoniou
2016-10-27 21:10 ` Hans de Goede
2016-10-26 20:54 ` Rob Herring
2016-10-27 8:10 ` Pierre-Hugues Husson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161014075337.10452-5-hdegoede@redhat.com \
--to=hdegoede-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).