Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp169159imu; Wed, 12 Dec 2018 14:19:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/VikaiFA5FYQzxINhh2HymmEF1QEVlBZu5WQPrxT/F/eDbKDW0Yp6P0F5sEzx+OmsS9s7eF X-Received: by 2002:a62:56c7:: with SMTP id h68mr22897633pfj.134.1544653156549; Wed, 12 Dec 2018 14:19:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544653156; cv=none; d=google.com; s=arc-20160816; b=OfPw5nFnN2WFcf6DNVudaicvx0BlHdOHVtcT0btlqWshcEJWEdz0aKlYzrv1U5hGBo i4Uh3RfK/1nog2JbzcyjQ0sH3CrOR7xg5azB0akl6xrFCSb86foLSpeyyMdy8u/tpiB+ i18kydaxpgMbOemG8we4yn90z99y1LK01FHB15gC3M/e6Z5/I6qA0Mc8GtEgbAprULHO T18Ny8m0U71gSpkjV8mspoR1Ejz4fOJIDOBgYCgN0hig8cr/oBwCVPmMp2HpXxLcyFO0 mgEl2FHLYcuepe7BlBaE2vPgelSLZdXgd1Jy4hyPFHqy7PDMlmCiB0m9I8qrhjcL7Hbx 3NkQ== 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; bh=ptH1zBuWIb5CX5KHiI5O9NVkaP83AWNLOKEvmZk/hc4=; b=IWVpKI8rqIiBzHw2r9G+gtajS7hIzneKjY5ovB90XvRGLFxUdD+Ia9GCuEk23FNRd7 6znV/CLyTq21x7X1XP3ydYBjOjvB8lZKfKD8lSPew+ZK0iv1wVn5gQ3v7GjnKR8rax/y Fj7/O/FyQFkUZ4q2LocG5+Gv4Bsee2DzlBWGF/MZsFc5DHccAPznvGQXjLlvKqotl1Vh YVBsMzGg0GHiGruMbtEz4boXDBmcX759XVUzJXkCnCY1UH1NNjssdsrH+0VYkwf12Wku F4C2usN9dcKqbjpICmDlK4iVzz+szfuCky5BjGaemoXtf6TqHu0FBZC+HjNHycRyUidj KBug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=KOU9cIK9; 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 e136si31391pfh.17.2018.12.12.14.19.01; Wed, 12 Dec 2018 14:19:16 -0800 (PST) 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=KOU9cIK9; 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 S1728732AbeLLWRB (ORCPT + 99 others); Wed, 12 Dec 2018 17:17:01 -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-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 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); -- 2.11.0