Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2529140imm; Thu, 9 Aug 2018 14:47:02 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxuGXyeHAi8YSmdtFIwbUs5YkySZOnEm4bYAxPTqQIwNo9qWd0eoyR7akV45jxSNmQBNevd X-Received: by 2002:a17:902:9687:: with SMTP id n7-v6mr3440298plp.33.1533851222772; Thu, 09 Aug 2018 14:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533851222; cv=none; d=google.com; s=arc-20160816; b=fT4rKUvSkvfDY9lW4+YpR1peXApKNe+vOVLR9U1ereU6tcHTyI5UM4bYCrVQKynyhP k+WWk8slz+3hUqxVnV396z9sUpstquRQPrB5aGPMEb6e+1fSWJOro0BCkZE834SEAb9M DeCp/d8cXhGczic7vDq/vQ9Fa2unXWl0R3s+kif4Zjhz3hUN50VO8b/cK9SlVCQrAzqF w1mNN7Yo3SGUyH2XM88bzvDgjWYY671REGdP/MBKaj4Y+mWU3p/+OPBd3FoOkHLMwmZh ZAotPohiPTPwgOI9jiN8L1QS8kBehIXcDi/JbzzoSTIdAZbmiskCykkqs8SKT56XKTw/ KUuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=UyBLAsOOTuJ4f+TurpqvcRjgdULRZ8b5sl56Lf3CILM=; b=TRGef9Ly4kg+5ZWRkSVjc9LDxY7HzJMtwlGij4vNHjCWEekvxwqYSTcF16BPzANUVh LEHlD4czfL384kiqLhK/5bYde91AZEaRT9gZrgqtMkiwFr2nXYhr+qsS0aX6cn0RTe7c BbBiIn+nrsm+cnegjUBRUqzrsKHNjRKIWzvDO8OUr36h9OWOrTzA9TPl1Vy2CzyScm7c N63bnhGz+1Js+Rf9uqR+DaVlfcl8L22JM28brPP/2VLcebEzXArgHxeCRP5+n3GUfVv/ blCbs2h017RbHZu9AOS7djRsFJetq2hYDOr6wkruCGFJRm3dTnu2kbP+gVg0ySBQ8pmB 8r4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=VRK8mpgz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 20-v6si8365579pfr.242.2018.08.09.14.46.48; Thu, 09 Aug 2018 14:47:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=VRK8mpgz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbeHJAMG (ORCPT + 99 others); Thu, 9 Aug 2018 20:12:06 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:33964 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727821AbeHJAMF (ORCPT ); Thu, 9 Aug 2018 20:12:05 -0400 From: Paul Cercueil To: Rob Herring , Mark Rutland , Thierry Reding , Daniel Lezcano , Thomas Gleixner , Wim Van Sebroeck , Guenter Roeck , Ralf Baechle , Paul Burton , James Hogan , Jonathan Corbet , Lee Jones , Mathieu Malaterre , Ezequiel Garcia Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-mips@linux-mips.org, linux-doc@vger.kernel.org, linux-clk@vger.kernel.org, Paul Cercueil Subject: [PATCH v6 16/24] pwm: jz4740: Add support for the JZ4725B Date: Thu, 9 Aug 2018 23:44:06 +0200 Message-Id: <20180809214414.20905-17-paul@crapouillou.net> In-Reply-To: <20180809214414.20905-1-paul@crapouillou.net> References: <20180809214414.20905-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1533851117; bh=UyBLAsOOTuJ4f+TurpqvcRjgdULRZ8b5sl56Lf3CILM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=VRK8mpgziRyqvIyB35CWOT/oc1hJlf1XMo7a1RQlY3tTOcbYUUbqKwS7Za+dEDneYPsLZ09p9X6uGuD9sfX5VJRhCyHAQUwNKCpLFSumX2wwXT1TtfNimWkfG85gieMfaBpnvY1EyFiWrTWVsMepErfxjtuQKqe2OJBHTWMtRsM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/pwm/pwm-jz4740.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 diff --git a/drivers/pwm/pwm-jz4740.c b/drivers/pwm/pwm-jz4740.c index 5814825d9bed..66a72bd7424f 100644 --- a/drivers/pwm/pwm-jz4740.c +++ b/drivers/pwm/pwm-jz4740.c @@ -25,6 +25,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]; @@ -200,9 +204,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; @@ -215,7 +224,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; @@ -233,8 +242,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); -- 2.11.0