From patchwork Tue Sep 3 19:23:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Dunn X-Patchwork-Id: 2853386 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 70B6B9F3DC for ; Tue, 3 Sep 2013 19:26:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8085E2041C for ; Tue, 3 Sep 2013 19:26:46 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14E822041B for ; Tue, 3 Sep 2013 19:26:45 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGwFE-00057R-Qf; Tue, 03 Sep 2013 19:26:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGwFC-0001VM-MR; Tue, 03 Sep 2013 19:26:30 +0000 Received: from smtp.newsguy.com ([74.209.136.69]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VGwF9-0001TQ-N2 for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2013 19:26:28 +0000 Received: from localhost.localdomain (53.sub-70-199-135.myvzw.com [70.199.135.53]) by smtp.newsguy.com (8.14.3/8.14.3) with ESMTP id r83JODaX032324 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Sep 2013 12:24:14 -0700 (PDT) (envelope-from mikedunn@newsguy.com) From: Mike Dunn To: linux-pwm@vger.kernel.org Subject: [PATCH] pwm: pxa: add device tree support to pwm driver Date: Tue, 3 Sep 2013 12:23:53 -0700 Message-Id: <1378236233-15637-1-git-send-email-mikedunn@newsguy.com> X-Mailer: git-send-email 1.8.1.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130903_152627_848047_6171F5B5 X-CRM114-Status: GOOD ( 16.03 ) X-Spam-Score: -4.3 (----) Cc: Marek Vasut , devicetree@vger.kernel.org, Mike Dunn , Rob Herring , Thierry Reding , Haojian Zhuang , Grant Likely , Robert Jarzmik , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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=-6.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This patch adds device tree support to the pxa's pwm driver. Only an OF match table is added; nothing needs to be extracted from the device tree node. The existing platform_device id table is reused for the match table data. Tested on a Palm Treo 680 (both platform data and DT cases). Signed-off-by: Mike Dunn --- I don't have data sheets handy for the newer Marvell pxa's (and I'm confused about the presence of a pwm unit on pxa25x), so only pxa27x.dtsi was updated. Thanks for looking! arch/arm/boot/dts/pxa27x.dtsi | 12 ++++++++++++ drivers/pwm/pwm-pxa.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/arch/arm/boot/dts/pxa27x.dtsi b/arch/arm/boot/dts/pxa27x.dtsi index d7c5d72..4031dce 100644 --- a/arch/arm/boot/dts/pxa27x.dtsi +++ b/arch/arm/boot/dts/pxa27x.dtsi @@ -10,5 +10,17 @@ marvell,intc-priority; marvell,intc-nr-irqs = <34>; }; + + pwm0: pwm@40b00000 { + compatible = "marvell,pxa27x-pwm"; + reg = <0x40b00000 0x100000>; + #pwm-cells = <2>; + }; + + pwm1: pwm@40c00000 { + compatible = "marvell,pxa27x-pwm"; + reg = <0x40c00000 0x100000>; + #pwm-cells = <2>; + }; }; }; diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index a4d2164..be5f914 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -124,6 +125,30 @@ static struct pwm_ops pxa_pwm_ops = { .owner = THIS_MODULE, }; +#ifdef CONFIG_OF +/* use the platform_device id table for OF match table data */ +static struct of_device_id pwm_of_match[] = { + { .compatible = "marvell,pxa25x-pwm", .data = &pwm_id_table[0] }, + { .compatible = "marvell,pxa27x-pwm", .data = &pwm_id_table[1] }, + { .compatible = "marvell,pxa168-pwm", .data = &pwm_id_table[2] }, + { .compatible = "marvell,pxa910-pwm", .data = &pwm_id_table[3] }, + { } +}; +MODULE_DEVICE_TABLE(of, pwm_of_match); + +static const struct platform_device_id *pxa_pwm_get_id_dt(struct device *dev) +{ + const struct of_device_id *pwm_pxa_devid = + of_match_device(pwm_of_match, dev); + if (pwm_pxa_devid) + return (const struct platform_device_id *)pwm_pxa_devid->data; + else + return NULL; +} +#else /* !CONFIG_OF */ +#define pxa_pwm_get_id_dt(dev) ((const struct platform_device_id *)NULL) +#endif + static int pwm_probe(struct platform_device *pdev) { const struct platform_device_id *id = platform_get_device_id(pdev); @@ -131,6 +156,11 @@ static int pwm_probe(struct platform_device *pdev) struct resource *r; int ret = 0; + if (id == NULL) /* using device tree */ + id = pxa_pwm_get_id_dt(&pdev->dev); + if (id == NULL) + return -ENODEV; + pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); if (pwm == NULL) { dev_err(&pdev->dev, "failed to allocate memory\n"); @@ -176,6 +206,7 @@ static struct platform_driver pwm_driver = { .driver = { .name = "pxa25x-pwm", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(pwm_of_match), }, .probe = pwm_probe, .remove = pwm_remove,