From patchwork Sun Mar 29 10:48:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 202688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00EC3C43331 for ; Sun, 29 Mar 2020 10:48:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9773206DB for ; Sun, 29 Mar 2020 10:48:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="wU9meT5m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727985AbgC2KsP (ORCPT ); Sun, 29 Mar 2020 06:48:15 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:35622 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbgC2KsP (ORCPT ); Sun, 29 Mar 2020 06:48:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:To:From:References:In-Reply-To :Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GLHX83WiWrbw0xWg/XQ2tOkwXBY7qtdG5WKMA6uMzmI=; b=wU9meT5mbVeDOSgiRqSCPJg/Zf 0T0clGOblmDumfK3Y2tu+E3t3fOxYSDpjGem+CcAkFso+FOvjwljDzqk8wHUy6frWOWCZW0kc8NIF lPjSwLJ7/446HaV/xRidkBxBPY83m/KuzZPuzzm9/4reWPGK43GDcsHgy/0zoQggEqmB2bjdbnb/u QNgEH2jWJ+sV4l3On3Iv/OcCJpGAzOJzgS3KZcKp3cRXACgO/JUM3kVP5AVvH2lpg5Ytm6cZ0Tqjq aoWe9Bu7S1NB1/zZmJ3b+MrNxcI0uLZ/nxrw36oFok1qDbbkN6jDn7Gsi269m0P8NonvKZ41Mbgqw rY8xFbXQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([2001:4d48:ad52:3201:222:68ff:fe15:37dd]:37646 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jIVU5-0004VG-O8; Sun, 29 Mar 2020 11:48:05 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jIVU4-0005gx-Mh; Sun, 29 Mar 2020 11:48:04 +0100 In-Reply-To: <20200329104549.GX25745@shell.armlinux.org.uk> References: <20200329104549.GX25745@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Bartosz Golaszewski , devicetree@vger.kernel.org, Gregory Clement , Jason Cooper , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org, Mark Rutland , Rob Herring , Sebastian Hesselbarth , Thierry Reding , "Uwe Kleine-Konig" Subject: [PATCH RFC 1/6] gpio: mvebu: convert pwm to regmap MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sun, 29 Mar 2020 11:48:04 +0100 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert mvebu's pwm support to use regmap to access the registers to prepare the driver to support the "blink" support on CP110. Signed-off-by: Russell King --- drivers/gpio/gpio-mvebu.c | 69 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index e64c40095356..fa5641615db6 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -94,7 +94,8 @@ #define MVEBU_MAX_GPIO_PER_BANK 32 struct mvebu_pwm { - void __iomem *membase; + struct regmap *regs; + u32 offset; unsigned long clk_rate; struct gpio_desc *gpiod; struct pwm_chip chip; @@ -129,6 +130,13 @@ struct mvebu_gpio_chip { u32 level_mask_regs[4]; }; +static const struct regmap_config mvebu_gpio_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .fast_io = true, +}; + /* * Functions returning addresses of individual registers for a given * GPIO controller. @@ -280,17 +288,17 @@ mvebu_gpio_write_level_mask(struct mvebu_gpio_chip *mvchip, u32 val) } /* - * Functions returning addresses of individual registers for a given + * Functions returning regmap offsets of individual registers for a given * PWM controller. */ -static void __iomem *mvebu_pwmreg_blink_on_duration(struct mvebu_pwm *mvpwm) +static u32 mvebu_pwmreg_blink_on_duration(struct mvebu_pwm *mvpwm) { - return mvpwm->membase + PWM_BLINK_ON_DURATION_OFF; + return PWM_BLINK_ON_DURATION_OFF + mvpwm->offset; } -static void __iomem *mvebu_pwmreg_blink_off_duration(struct mvebu_pwm *mvpwm) +static u32 mvebu_pwmreg_blink_off_duration(struct mvebu_pwm *mvpwm) { - return mvpwm->membase + PWM_BLINK_OFF_DURATION_OFF; + return PWM_BLINK_OFF_DURATION_OFF + mvpwm->offset; } /* @@ -660,8 +668,8 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, spin_lock_irqsave(&mvpwm->lock, flags); - val = (unsigned long long) - readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); + regmap_read(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), &u); + val = (unsigned long long)u; val *= NSEC_PER_SEC; do_div(val, mvpwm->clk_rate); if (val > UINT_MAX) @@ -671,8 +679,8 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, else state->duty_cycle = 1; - val = (unsigned long long) - readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); + regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), &u); + val = (unsigned long long)u; val *= NSEC_PER_SEC; do_div(val, mvpwm->clk_rate); if (val < state->duty_cycle) { @@ -726,8 +734,8 @@ static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, spin_lock_irqsave(&mvpwm->lock, flags); - writel_relaxed(on, mvebu_pwmreg_blink_on_duration(mvpwm)); - writel_relaxed(off, mvebu_pwmreg_blink_off_duration(mvpwm)); + regmap_write(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), on); + regmap_write(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), off); if (state->enabled) mvebu_gpio_blink(&mvchip->chip, pwm->hwpwm, 1); else @@ -752,10 +760,10 @@ static void __maybe_unused mvebu_pwm_suspend(struct mvebu_gpio_chip *mvchip) regmap_read(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, &mvpwm->blink_select); - mvpwm->blink_on_duration = - readl_relaxed(mvebu_pwmreg_blink_on_duration(mvpwm)); - mvpwm->blink_off_duration = - readl_relaxed(mvebu_pwmreg_blink_off_duration(mvpwm)); + regmap_read(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), + &mvpwm->blink_on_duration); + regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), + &mvpwm->blink_off_duration); } static void __maybe_unused mvebu_pwm_resume(struct mvebu_gpio_chip *mvchip) @@ -764,10 +772,10 @@ static void __maybe_unused mvebu_pwm_resume(struct mvebu_gpio_chip *mvchip) regmap_write(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, mvpwm->blink_select); - writel_relaxed(mvpwm->blink_on_duration, - mvebu_pwmreg_blink_on_duration(mvpwm)); - writel_relaxed(mvpwm->blink_off_duration, - mvebu_pwmreg_blink_off_duration(mvpwm)); + regmap_write(mvpwm->regs, mvebu_pwmreg_blink_on_duration(mvpwm), + mvpwm->blink_on_duration); + regmap_write(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), + mvpwm->blink_off_duration); } static int mvebu_pwm_probe(struct platform_device *pdev, @@ -776,6 +784,7 @@ static int mvebu_pwm_probe(struct platform_device *pdev, { struct device *dev = &pdev->dev; struct mvebu_pwm *mvpwm; + void __iomem *base; u32 set; if (!of_device_is_compatible(mvchip->chip.of_node, @@ -795,12 +804,14 @@ static int mvebu_pwm_probe(struct platform_device *pdev, set = U32_MAX; else return -EINVAL; + regmap_write(mvchip->regs, GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, set); mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL); if (!mvpwm) return -ENOMEM; + mvchip->mvpwm = mvpwm; mvpwm->mvchip = mvchip; @@ -810,9 +821,14 @@ static int mvebu_pwm_probe(struct platform_device *pdev, * for the first two GPIO chips. So if the resource is missing * we can't treat it as an error. */ - mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm"); - if (IS_ERR(mvpwm->membase)) - return PTR_ERR(mvpwm->membase); + base = devm_platform_ioremap_resource_byname(pdev, "pwm"); + if (IS_ERR(base)) + return PTR_ERR(base); + + mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base, + &mvebu_gpio_regmap_config); + if (IS_ERR(mvpwm->regs)) + return PTR_ERR(mvpwm->regs); mvpwm->clk_rate = clk_get_rate(mvchip->clk); if (!mvpwm->clk_rate) { @@ -1023,13 +1039,6 @@ static int mvebu_gpio_resume(struct platform_device *pdev) return 0; } -static const struct regmap_config mvebu_gpio_regmap_config = { - .reg_bits = 32, - .reg_stride = 4, - .val_bits = 32, - .fast_io = true, -}; - static int mvebu_gpio_probe_raw(struct platform_device *pdev, struct mvebu_gpio_chip *mvchip) { From patchwork Sun Mar 29 10:48:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 202687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D332C2D0EB for ; Sun, 29 Mar 2020 10:48:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 250F720732 for ; Sun, 29 Mar 2020 10:48:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="p3HVp5DJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728035AbgC2Ksw (ORCPT ); Sun, 29 Mar 2020 06:48:52 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:35686 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727901AbgC2Ksw (ORCPT ); Sun, 29 Mar 2020 06:48:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:To:From:References:In-Reply-To :Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9aOq9z488KIHPkDe3al2kyUgAlP9GMiE864eA+YbUp4=; b=p3HVp5DJapbDj7hKnpbszmnwuP YSsedQhMd+OYnbNa1nJVYud1xj5KAeGisUdqUfsVautz3o0lltoFZxn620nyoaSAM2qr0f0Gjj949 nJ6JfIhLXbFo0OiwP72sF1ftkb2VTUAozX4lriagx7Vx+8ZMRS/dvx7hCRIAbRfVa8RMF8SpFm7// m4X+7bof2S+m2NfA9XYr2mCqF7cZREPx/FpM7zX+MB9YKSn8aAKxf89O4oHcZ8AaMRwa0nKO/sWF5 HhFWyyrXegv4VidEibCc0CR/PstaXTeGqdZcl5t6uQrs3vmWlefseI5F07aA0hMfnS/xDMo6pHdiZ ip6TFXQQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:45284 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jIVUI-0004Vo-0B; Sun, 29 Mar 2020 11:48:18 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jIVUE-0005hC-VU; Sun, 29 Mar 2020 11:48:15 +0100 In-Reply-To: <20200329104549.GX25745@shell.armlinux.org.uk> References: <20200329104549.GX25745@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Bartosz Golaszewski , devicetree@vger.kernel.org, Gregory Clement , Jason Cooper , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org, Mark Rutland , Rob Herring , Sebastian Hesselbarth , Thierry Reding , "Uwe Kleine-Konig" Subject: [PATCH RFC 3/6] gpio: mvebu: add PWM support for Armada 8k MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sun, 29 Mar 2020 11:48:14 +0100 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for PWM devices on the Armada 8k, which are useful on the Macchiatobin and Clearfog GT 8K platforms for controlling the fan speed. Signed-off-by: Russell King --- drivers/gpio/gpio-mvebu.c | 166 +++++++++++++++++++++++++------------- 1 file changed, 111 insertions(+), 55 deletions(-) diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index ee13b11c5298..4abe298e9c0f 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c @@ -91,8 +91,16 @@ #define MVEBU_GPIO_SOC_VARIANT_ARMADAXP 0x3 #define MVEBU_GPIO_SOC_VARIANT_A8K 0x4 +#define MVEBU_PWM_SOC_VARIANT_ARMADA370 1 +#define MVEBU_PWM_SOC_VARIANT_A8K 2 + #define MVEBU_MAX_GPIO_PER_BANK 32 +struct mvebu_gpio_soc_variant { + int gpio; + int pwm; +}; + struct mvebu_pwm { struct regmap *regs; u32 offset; @@ -679,21 +687,17 @@ static void mvebu_pwm_get_state(struct pwm_chip *chip, else state->duty_cycle = 1; - regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), &u); val = (unsigned long long)u; + regmap_read(mvpwm->regs, mvebu_pwmreg_blink_off_duration(mvpwm), &u); + val += (unsigned long long)u; val *= NSEC_PER_SEC; do_div(val, mvpwm->clk_rate); - if (val < state->duty_cycle) { + if (val > UINT_MAX) + state->period = UINT_MAX; + else if (val) + state->period = val; + else state->period = 1; - } else { - val -= state->duty_cycle; - if (val > UINT_MAX) - state->period = UINT_MAX; - else if (val) - state->period = val; - else - state->period = 1; - } regmap_read(mvchip->regs, GPIO_BLINK_EN_OFF + mvchip->offset, &u); if (u) @@ -779,6 +783,7 @@ static void __maybe_unused mvebu_pwm_resume(struct mvebu_gpio_chip *mvchip) } static int mvebu_pwm_probe(struct platform_device *pdev, + const struct mvebu_gpio_soc_variant *soc_variant, struct mvebu_gpio_chip *mvchip, int id) { @@ -787,27 +792,9 @@ static int mvebu_pwm_probe(struct platform_device *pdev, void __iomem *base; u32 set; - if (!of_device_is_compatible(mvchip->chip.of_node, - "marvell,armada-370-gpio")) + if (!soc_variant->pwm) return 0; - if (IS_ERR(mvchip->clk)) - return PTR_ERR(mvchip->clk); - - /* - * Use set A for lines of GPIO chip with id 0, B for GPIO chip - * with id 1. Don't allow further GPIO chips to be used for PWM. - */ - if (id == 0) - set = 0; - else if (id == 1) - set = U32_MAX; - else - return -EINVAL; - - regmap_write(mvchip->regs, - GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, set); - mvpwm = devm_kzalloc(dev, sizeof(struct mvebu_pwm), GFP_KERNEL); if (!mvpwm) return -ENOMEM; @@ -815,20 +802,67 @@ static int mvebu_pwm_probe(struct platform_device *pdev, mvchip->mvpwm = mvpwm; mvpwm->mvchip = mvchip; - /* - * There are only two sets of PWM configuration registers for - * all the GPIO lines on those SoCs which this driver reserves - * for the first two GPIO chips. So if the resource is missing - * we can't treat it as an error. - */ - base = devm_platform_ioremap_resource_byname(pdev, "pwm"); - if (IS_ERR(base)) - return PTR_ERR(base); + switch (soc_variant->pwm) { + case MVEBU_PWM_SOC_VARIANT_ARMADA370: + if (IS_ERR(mvchip->clk)) + return PTR_ERR(mvchip->clk); + + /* + * There are only two sets of PWM configuration registers for + * all the GPIO lines on those SoCs which this driver reserves + * for the first two GPIO chips. So if the resource is missing + * we can't treat it as an error. + */ + base = devm_platform_ioremap_resource_byname(pdev, "pwm"); + if (IS_ERR(base)) + return PTR_ERR(base); - mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base, - &mvebu_gpio_regmap_config); - if (IS_ERR(mvpwm->regs)) - return PTR_ERR(mvpwm->regs); + mvpwm->regs = devm_regmap_init_mmio(&pdev->dev, base, + &mvebu_gpio_regmap_config); + if (IS_ERR(mvpwm->regs)) + return PTR_ERR(mvpwm->regs); + + /* + * Use set A for lines of GPIO chip with id 0, B for GPIO chip + * with id 1. Don't allow further GPIO chips to be used for PWM. + */ + if (id == 0) + set = 0; + else if (id == 1) + set = U32_MAX; + else + return -EINVAL; + break; + + case MVEBU_PWM_SOC_VARIANT_A8K: + /* + * If there is no clock, this is an older DT, so avoid + * registering the PWM. + */ + if (IS_ERR(mvchip->clk)) + return 0; + + mvpwm->regs = mvchip->regs; + switch (id) { + case 1: + mvpwm->offset = 0x1f0; + set = 0; + break; + case 2: + mvpwm->offset = 0x1f8; + set = U32_MAX; + break; + default: + return -EINVAL; + } + break; + + default: + return -EINVAL; + } + + regmap_write(mvchip->regs, + GPIO_BLINK_CNT_SELECT_OFF + mvchip->offset, set); mvpwm->clk_rate = clk_get_rate(mvchip->clk); if (!mvpwm->clk_rate) { @@ -909,26 +943,48 @@ static void mvebu_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) #define mvebu_gpio_dbg_show NULL #endif +static const struct mvebu_gpio_soc_variant mvebu_gpio_orion_variant = { + .gpio = MVEBU_GPIO_SOC_VARIANT_ORION, +}; + +static const struct mvebu_gpio_soc_variant mvebu_gpio_mv78200_variant = { + .gpio = MVEBU_GPIO_SOC_VARIANT_MV78200, +}; + +static const struct mvebu_gpio_soc_variant mvebu_gpio_armadaxp_variant = { + .gpio = MVEBU_GPIO_SOC_VARIANT_ARMADAXP, +}; + +static const struct mvebu_gpio_soc_variant mvebu_gpio_armada370_variant = { + .gpio = MVEBU_GPIO_SOC_VARIANT_ORION, + .pwm = MVEBU_PWM_SOC_VARIANT_ARMADA370, +}; + +static const struct mvebu_gpio_soc_variant mvebu_gpio_a8k_variant = { + .gpio = MVEBU_GPIO_SOC_VARIANT_A8K, + .pwm = MVEBU_PWM_SOC_VARIANT_A8K, +}; + static const struct of_device_id mvebu_gpio_of_match[] = { { .compatible = "marvell,orion-gpio", - .data = (void *) MVEBU_GPIO_SOC_VARIANT_ORION, + .data = &mvebu_gpio_orion_variant, }, { .compatible = "marvell,mv78200-gpio", - .data = (void *) MVEBU_GPIO_SOC_VARIANT_MV78200, + .data = &mvebu_gpio_mv78200_variant, }, { .compatible = "marvell,armadaxp-gpio", - .data = (void *) MVEBU_GPIO_SOC_VARIANT_ARMADAXP, + .data = &mvebu_gpio_armadaxp_variant, }, { .compatible = "marvell,armada-370-gpio", - .data = (void *) MVEBU_GPIO_SOC_VARIANT_ORION, + .data = &mvebu_gpio_armada370_variant, }, { .compatible = "marvell,armada-8k-gpio", - .data = (void *) MVEBU_GPIO_SOC_VARIANT_A8K, + .data = &mvebu_gpio_a8k_variant, }, { /* sentinel */ @@ -1093,6 +1149,7 @@ static int mvebu_gpio_probe_syscon(struct platform_device *pdev, static int mvebu_gpio_probe(struct platform_device *pdev) { + const struct mvebu_gpio_soc_variant *soc_variant; struct mvebu_gpio_chip *mvchip; const struct of_device_id *match; struct device_node *np = pdev->dev.of_node; @@ -1100,15 +1157,14 @@ static int mvebu_gpio_probe(struct platform_device *pdev) struct irq_chip_type *ct; unsigned int ngpios; bool have_irqs; - int soc_variant; int i, cpu, id; int err; match = of_match_device(mvebu_gpio_of_match, &pdev->dev); if (match) - soc_variant = (unsigned long) match->data; + soc_variant = match->data; else - soc_variant = MVEBU_GPIO_SOC_VARIANT_ORION; + soc_variant = &mvebu_gpio_orion_variant; /* Some gpio controllers do not provide irq support */ have_irqs = of_irq_count(np) != 0; @@ -1139,7 +1195,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) if (!IS_ERR(mvchip->clk)) clk_prepare_enable(mvchip->clk); - mvchip->soc_variant = soc_variant; + mvchip->soc_variant = soc_variant->gpio; mvchip->chip.label = dev_name(&pdev->dev); mvchip->chip.parent = &pdev->dev; mvchip->chip.request = gpiochip_generic_request; @@ -1157,7 +1213,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) mvchip->chip.of_node = np; mvchip->chip.dbg_show = mvebu_gpio_dbg_show; - if (soc_variant == MVEBU_GPIO_SOC_VARIANT_A8K) + if (soc_variant->gpio == MVEBU_GPIO_SOC_VARIANT_A8K) err = mvebu_gpio_probe_syscon(pdev, mvchip); else err = mvebu_gpio_probe_raw(pdev, mvchip); @@ -1168,7 +1224,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) /* * Mask and clear GPIO interrupts. */ - switch (soc_variant) { + switch (soc_variant->gpio) { case MVEBU_GPIO_SOC_VARIANT_ORION: case MVEBU_GPIO_SOC_VARIANT_A8K: regmap_write(mvchip->regs, @@ -1265,7 +1321,7 @@ static int mvebu_gpio_probe(struct platform_device *pdev) /* Some MVEBU SoCs have simple PWM support for GPIO lines */ if (IS_ENABLED(CONFIG_PWM)) - return mvebu_pwm_probe(pdev, mvchip, id); + return mvebu_pwm_probe(pdev, soc_variant, mvchip, id); return 0; From patchwork Sun Mar 29 10:48:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 202686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1742C2D0EB for ; Sun, 29 Mar 2020 10:49:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 987522076A for ; Sun, 29 Mar 2020 10:49:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="EPP3zCmv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728057AbgC2KtJ (ORCPT ); Sun, 29 Mar 2020 06:49:09 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:35690 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbgC2KtI (ORCPT ); Sun, 29 Mar 2020 06:49:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:To:From:References:In-Reply-To :Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vXYY5z/ib46qhy4U0CkhLW8/nfu/Rd7Z0xRYxAP+zvg=; b=EPP3zCmvtwDEKZ34xgnrULqxyR 5Q/QgHDRH4o0axsJX7Rnlgv1EWspoyyXL/IBDi7/IoSbv0xVFplWfk18V3s4lSHjW7MJyDN1oP7eY AinoNgFi066dRPKpQTiQp0HpqwbFUtxfAdqVD8WJ6rIiPcJYNjXA1vEaRjKsFYXfWZk77iTtemWZG vELSsVzzjWi6qZFahx4v5IZ/ufwzOJ2rREjldloy2l5nvnWtk2djg5D8tWTu54604m6jqYpyT3kwa CnjAoXH1W2nogBdH91OI5eDsL0mC1ebUg1rPhkURQL9rsTqwcAZYkniok7p666rd2Eunyd9k2HE0s 1dhXJrow==; Received: from e0022681537dd.dyn.armlinux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:45286 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jIVUN-0004Vu-4x; Sun, 29 Mar 2020 11:48:23 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1jIVUK-0005hJ-33; Sun, 29 Mar 2020 11:48:20 +0100 In-Reply-To: <20200329104549.GX25745@shell.armlinux.org.uk> References: <20200329104549.GX25745@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Bartosz Golaszewski , devicetree@vger.kernel.org, Gregory Clement , Jason Cooper , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-pwm@vger.kernel.org, Mark Rutland , Rob Herring , Sebastian Hesselbarth , Thierry Reding , "Uwe Kleine-Konig" Subject: [PATCH RFC 4/6] arm64: dts: armada-cp11x: add pwm support to GPIO blocks MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sun, 29 Mar 2020 11:48:20 +0100 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add PWM support to the GPIO blocks. Signed-off-by: Russell King --- arch/arm64/boot/dts/marvell/armada-cp11x.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/boot/dts/marvell/armada-cp11x.dtsi b/arch/arm64/boot/dts/marvell/armada-cp11x.dtsi index 024073edfc1c..dfd251acc194 100644 --- a/arch/arm64/boot/dts/marvell/armada-cp11x.dtsi +++ b/arch/arm64/boot/dts/marvell/armada-cp11x.dtsi @@ -311,6 +311,7 @@ ngpios = <32>; gpio-controller; #gpio-cells = <2>; + #pwm-cells = <2>; gpio-ranges = <&CP11X_LABEL(pinctrl) 0 0 32>; interrupt-controller; interrupts = <86 IRQ_TYPE_LEVEL_HIGH>, @@ -319,6 +320,8 @@ <83 IRQ_TYPE_LEVEL_HIGH>; #interrupt-cells = <2>; status = "disabled"; + clock-names = "core"; + clocks = <&CP11X_LABEL(clk) 1 21>; }; CP11X_LABEL(gpio2): gpio@140 { @@ -327,6 +330,7 @@ ngpios = <31>; gpio-controller; #gpio-cells = <2>; + #pwm-cells = <2>; gpio-ranges = <&CP11X_LABEL(pinctrl) 0 32 31>; interrupt-controller; interrupts = <82 IRQ_TYPE_LEVEL_HIGH>, @@ -335,6 +339,8 @@ <79 IRQ_TYPE_LEVEL_HIGH>; #interrupt-cells = <2>; status = "disabled"; + clock-names = "core"; + clocks = <&CP11X_LABEL(clk) 1 21>; }; };