From patchwork Wed Dec 12 22:09:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10727241 X-Patchwork-Delegate: paulburton@kernel.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DBFCA1759 for ; Wed, 12 Dec 2018 22:16:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC24C2B76C for ; Wed, 12 Dec 2018 22:16:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFBDE2B780; Wed, 12 Dec 2018 22:16:58 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B4042B78A for ; Wed, 12 Dec 2018 22:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbeLLWQ5 (ORCPT ); Wed, 12 Dec 2018 17:16:57 -0500 Received: from outils.crapouillou.net ([89.234.176.41]:40776 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728629AbeLLWQ4 (ORCPT ); Wed, 12 Dec 2018 17:16:56 -0500 From: Paul Cercueil To: Thierry Reding , Rob Herring , Mark Rutland , Daniel Lezcano , Thomas Gleixner , Ralf Baechle , Paul Burton , James Hogan , Jonathan Corbet Cc: Mathieu Malaterre , Ezequiel Garcia , PrasannaKumar Muralidharan , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@vger.kernel.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, od@zcrc.me, Paul Cercueil Subject: [PATCH v8 15/26] pwm: jz4740: Add support for the JZ4725B Date: Wed, 12 Dec 2018 23:09:10 +0100 Message-Id: <20181212220922.18759-16-paul@crapouillou.net> In-Reply-To: <20181212220922.18759-1-paul@crapouillou.net> References: <20181212220922.18759-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1544652601; bh=ptH1zBuWIb5CX5KHiI5O9NVkaP83AWNLOKEvmZk/hc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=KOU9cIK9qCDtAPM2qQXMmBqHEfAzExSlIJ7pxm6eXnZKXTyPjhlV5xGwUJMDYDVUGU53GO3tHjZXx2kIuM8XzcuJmeqvwP8RsPzZjX6C5uXNYiVo1k+noiYg9RAbsL/iWp9iicx+RIaSrLNamqlE7sg9Jc1yVKxdXZ4XJQaPeNU= Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The PWM in the JZ4725B works the same as in the JZ4740, except that it only has 6 channels available instead of 8. Signed-off-by: Paul Cercueil Acked-by: Thierry Reding --- Notes: v5: New patch v6: - Move of_device_id structure back at the bottom (less noise in patch) - Use device_get_match_data() instead of of_* variant v7: No change v8: No change drivers/pwm/pwm-jz4740.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index cb8d8cec353f..a3a8da8af0de 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -24,6 +24,10 @@ #define NUM_PWM 8 +struct jz4740_soc_info { + unsigned int num_pwms; +}; + struct jz4740_pwm_chip { struct pwm_chip chip; struct clk *clks[NUM_PWM]; @@ -217,9 +221,14 @@ static const struct pwm_ops jz4740_pwm_ops = { static int jz4740_pwm_probe(struct platform_device *pdev) { + const struct jz4740_soc_info *soc_info; struct jz4740_pwm_chip *jz4740; struct device *dev = &pdev->dev; + soc_info = device_get_match_data(dev); + if (!soc_info) + return -EINVAL; + jz4740 = devm_kzalloc(dev, sizeof(*jz4740), GFP_KERNEL); if (!jz4740) return -ENOMEM; @@ -238,7 +247,7 @@ static int jz4740_pwm_probe(struct platform_device *pdev) jz4740->chip.dev = dev; jz4740->chip.ops = &jz4740_pwm_ops; - jz4740->chip.npwm = NUM_PWM; + jz4740->chip.npwm = soc_info->num_pwms; jz4740->chip.base = -1; jz4740->chip.of_xlate = of_pwm_xlate_with_flags; jz4740->chip.of_pwm_n_cells = 3; @@ -256,8 +265,17 @@ static int jz4740_pwm_remove(struct platform_device *pdev) } #ifdef CONFIG_OF +static const struct jz4740_soc_info jz4740_soc_info = { + .num_pwms = 8, +}; + +static const struct jz4740_soc_info jz4725b_soc_info = { + .num_pwms = 6, +}; + static const struct of_device_id jz4740_pwm_dt_ids[] = { - { .compatible = "ingenic,jz4740-pwm", }, + { .compatible = "ingenic,jz4740-pwm", .data = &jz4740_soc_info }, + { .compatible = "ingenic,jz4725b-pwm", .data = &jz4725b_soc_info }, {}, }; MODULE_DEVICE_TABLE(of, jz4740_pwm_dt_ids);