From patchwork Wed Jul 20 08:29:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 9239123 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 DC2FA600CB for ; Wed, 20 Jul 2016 08:32:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBC3120499 for ; Wed, 20 Jul 2016 08:32:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C078E2793D; Wed, 20 Jul 2016 08:32:43 +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=unavailable 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 6A9F520499 for ; Wed, 20 Jul 2016 08:32:43 +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 1bPmuc-0005i1-8R; Wed, 20 Jul 2016 08:31:26 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPmtn-00055w-QH for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2016 08:30:37 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id A01341E75; Wed, 20 Jul 2016 10:30:02 +0200 (CEST) Received: from quentin-Latitude-E6320.home (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 17CC03F4; Wed, 20 Jul 2016 10:29:44 +0200 (CEST) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, maxime.ripard@free-electrons.com, wens@csie.org, dmitry.torokhov@gmail.com, lee.jones@linaro.org Subject: [PATCH 5/5] mfd: sunxi-gpadc-mfd: probe sunxi-gpadc-ts driver Date: Wed, 20 Jul 2016 10:29:11 +0200 Message-Id: <1469003351-15263-6-git-send-email-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1469003351-15263-1-git-send-email-quentin.schulz@free-electrons.com> References: <1469003351-15263-1-git-send-email-quentin.schulz@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160720_013036_371109_A2DF4B52 X-CRM114-Status: GOOD ( 12.52 ) 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: thomas.petazzoni@free-electrons.com, linux-iio@vger.kernel.org, antoine.tenart@free-electrons.com, linux-kernel@vger.kernel.org, Quentin Schulz , linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 This probes the touchscreen driver for Allwinner SoCs (A10, A13 and A31) when the property "allwinner,ts-attached" is set in the GPADC (rtp) node of the DT. Some comestic modifications done to shorten and increase readability of the code. Signed-off-by: Quentin Schulz --- drivers/mfd/sunxi-gpadc-mfd.c | 115 ++++++++++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 38 deletions(-) diff --git a/drivers/mfd/sunxi-gpadc-mfd.c b/drivers/mfd/sunxi-gpadc-mfd.c index 05a000b..9b9ed0b 100644 --- a/drivers/mfd/sunxi-gpadc-mfd.c +++ b/drivers/mfd/sunxi-gpadc-mfd.c @@ -21,6 +21,11 @@ #define SUNXI_IRQ_TEMP_DATA 1 #define SUNXI_IRQ_TP_UP 2 +#define SUNXI_GPADC_MFD_CELL(_name, _resources, _num_resources) { \ + .name = _name, \ + .resources = _resources, \ + .num_resources = _num_resources \ +} static struct resource adc_resources[] = { { @@ -64,33 +69,45 @@ static const struct regmap_irq_chip sunxi_gpadc_mfd_regmap_irq_chip = { }; static struct mfd_cell sun4i_gpadc_mfd_cells[] = { - { - .name = "sun4i-a10-gpadc-iio", - .resources = adc_resources, - .num_resources = ARRAY_SIZE(adc_resources), - }, { - .name = "iio_hwmon", - } + SUNXI_GPADC_MFD_CELL("sun4i-a10-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), }; static struct mfd_cell sun5i_gpadc_mfd_cells[] = { - { - .name = "sun5i-a13-gpadc-iio", - .resources = adc_resources, - .num_resources = ARRAY_SIZE(adc_resources), - }, { - .name = "iio_hwmon", - }, + SUNXI_GPADC_MFD_CELL("sun5i-a13-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), }; static struct mfd_cell sun6i_gpadc_mfd_cells[] = { - { - .name = "sun6i-a31-gpadc-iio", - .resources = adc_resources, - .num_resources = ARRAY_SIZE(adc_resources), - }, { - .name = "iio_hwmon", - }, + SUNXI_GPADC_MFD_CELL("sun6i-a31-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), +}; + +static struct mfd_cell sun4i_gpadc_mfd_cells_ts[] = { + SUNXI_GPADC_MFD_CELL("sun6i-a31-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), + SUNXI_GPADC_MFD_CELL("sunxi-gpadc-ts", ts_resources, + ARRAY_SIZE(ts_resources)), +}; + +static struct mfd_cell sun5i_gpadc_mfd_cells_ts[] = { + SUNXI_GPADC_MFD_CELL("sun5i-a13-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), + SUNXI_GPADC_MFD_CELL("sunxi-gpadc-ts", ts_resources, + ARRAY_SIZE(ts_resources)), +}; + +static struct mfd_cell sun6i_gpadc_mfd_cells_ts[] = { + SUNXI_GPADC_MFD_CELL("sun6i-a31-gpadc-iio", adc_resources, + ARRAY_SIZE(adc_resources)), + SUNXI_GPADC_MFD_CELL("iio_hwmon", NULL, 0), + SUNXI_GPADC_MFD_CELL("sunxi-gpadc-ts", ts_resources, + ARRAY_SIZE(ts_resources)), }; static const struct regmap_config sunxi_gpadc_mfd_regmap_config = { @@ -142,23 +159,45 @@ static int sunxi_gpadc_mfd_probe(struct platform_device *pdev) } if (of_device_is_compatible(pdev->dev.of_node, - "allwinner,sun4i-a10-ts")) - ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, - sun4i_gpadc_mfd_cells, - ARRAY_SIZE(sun4i_gpadc_mfd_cells), NULL, - 0, NULL); - else if (of_device_is_compatible(pdev->dev.of_node, - "allwinner,sun5i-a13-ts")) - ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, - sun5i_gpadc_mfd_cells, - ARRAY_SIZE(sun5i_gpadc_mfd_cells), NULL, - 0, NULL); - else if (of_device_is_compatible(pdev->dev.of_node, - "allwinner,sun6i-a31-ts")) - ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, - sun6i_gpadc_mfd_cells, - ARRAY_SIZE(sun6i_gpadc_mfd_cells), NULL, - 0, NULL); + "allwinner,sun4i-a10-ts")) { + if (of_property_read_bool(pdev->dev.of_node, + "allwinner,ts-attached")) + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun4i_gpadc_mfd_cells_ts, + ARRAY_SIZE(sun4i_gpadc_mfd_cells_ts), + NULL, 0, NULL); + else + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun4i_gpadc_mfd_cells, + ARRAY_SIZE(sun4i_gpadc_mfd_cells), + NULL, 0, NULL); + } else if (of_device_is_compatible(pdev->dev.of_node, + "allwinner,sun5i-a13-ts")) { + if (of_property_read_bool(pdev->dev.of_node, + "allwinner,ts-attached")) + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun5i_gpadc_mfd_cells_ts, + ARRAY_SIZE(sun5i_gpadc_mfd_cells_ts), + NULL, 0, NULL); + else + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun5i_gpadc_mfd_cells, + ARRAY_SIZE(sun5i_gpadc_mfd_cells), + NULL, 0, NULL); + } else if (of_device_is_compatible(pdev->dev.of_node, + "allwinner,sun6i-a31-ts")) { + if (of_property_read_bool(pdev->dev.of_node, + "allwinner,ts-attached")) + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun6i_gpadc_mfd_cells_ts, + ARRAY_SIZE(sun6i_gpadc_mfd_cells_ts), + NULL, 0, NULL); + else + ret = mfd_add_devices(sunxi_gpadc_mfd_dev->dev, 0, + sun6i_gpadc_mfd_cells, + ARRAY_SIZE(sun6i_gpadc_mfd_cells), + NULL, 0, NULL); + } if (ret) { dev_err(&pdev->dev, "failed to add MFD devices: %d\n", ret);