Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp672903pxb; Thu, 30 Sep 2021 14:41:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3mYdxCRl28PMVce7WG6CYdwlifWGsXznudJZmEMSdqh8PJT1en4uBYbKq/SMEqyVOjyfR X-Received: by 2002:a17:906:2b47:: with SMTP id b7mr1843357ejg.390.1633038060781; Thu, 30 Sep 2021 14:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633038060; cv=none; d=google.com; s=arc-20160816; b=lX7H736I4bCmilF/95dnv8JWwRoqLJu93Oef+OSj28YyXguhv4o9WPDgyBJMR9abyK vqcP1ZwYiIr4afHf9/I936AW1z2YpnDZEngGHN5inzVfUlTHZCXA8w/CgqdIvjFhdElO ifmYtHGr87CXhIS4B/pCn6uPwrtjQaKUcriDKaaJe/OP6uNATd3B8L2jwkX5LKR2cq3p EWaYUO4SHJXy/DnTdyWlLlZj7fgy+oVlYGi6rephJb+F8IPWD0A8JzeIYxefxLkC6RNX 1ja2NZyYbeFZtJN6+aIfbO/OLOudMO9r9bbi1RMtPOVn9nXuUnxOIhwRawSmyHzsMa+e Dpbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=e0NcfULf3wNNjVF33uwiRx+dy6Dmhwkfi1qdAZs9US4=; b=PLk4/KQkqj8BwqWJG96tXEM94HJlfpxSJ4sa/OXHXOOFH9MruBQAPNVEip/qIzH5du JhrfneZLFK7+L47WZS3ZxnGvm4S1VDlKuxQJXaKyNaZw8JIGH2pxoKZ1bPb00LRjM13o M45Ynb6BTs7asTnMdE/74OCupxZ88SL8lTkqBErYRYBGbasADyK+IIbVnX++rqBLsOcr Hx4okF36UvVCLKb37vmJr2wToUe0mjUt1p4zNXh9tgLo2XVu937p+gUZtk3YCAPpFxiy 2nllfFWNYvZFFgraihGZiQMXnz3mxkI+uRVlCcnxO513SyT4oH8JEaP8+rmoZvhsWLQ1 wOWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kali.org header.s=google header.b=DBjew3S0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kali.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si5940507ejd.294.2021.09.30.14.40.35; Thu, 30 Sep 2021 14:41:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kali.org header.s=google header.b=DBjew3S0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kali.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349978AbhI3VhK (ORCPT + 99 others); Thu, 30 Sep 2021 17:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350014AbhI3VhJ (ORCPT ); Thu, 30 Sep 2021 17:37:09 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813D0C06176C for ; Thu, 30 Sep 2021 14:35:26 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id 24so9145526oix.0 for ; Thu, 30 Sep 2021 14:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kali.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=e0NcfULf3wNNjVF33uwiRx+dy6Dmhwkfi1qdAZs9US4=; b=DBjew3S0URka73F8hSVwAUYD20OGHDuGURaoBEn3oYxUADnCPbuh2AkHxd1rWzWBWb CT67tzsTYkVTDq03fcfZAEdnq8OfBHkIzO8dVmgq8aXWXDO+dr0qKnWkYc/iInzciKrI qf94lP+haQyQtcD/9YWmnGQz59MfjETnwL1VthNXS7D8tVXddyVGX8bxyasjYcZfATcC fjasSaMS8S72GOuG5glNpDe3++79AAN+UBKQaI0He99CT4idFjPqVbxMMzrgwELHkBnn ZxYBAVOCh0HJ+fgW1izeqqzlpAADFgXWh8RmiAIqS/5JHVLemV7NcIt5PHsXQfJ1dG6J ebBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=e0NcfULf3wNNjVF33uwiRx+dy6Dmhwkfi1qdAZs9US4=; b=6II6MnKUGtgmW1RGs/3E/p1AUBy2hYgb1QV3lrhfjEfz9Hs2xfkF3F17/jItiNBMDN cP4h7WBmeyqkRuv/qAQROj3h0posiK0Gt6pNZAS9ilWbfeCGC9V6vEh4n9ZC2g3HLFhZ n1pjwijFoXKVlllJWXBhfJUIJqcfjHqgpJZZzyFwaIVRtpO28givhz/RT1jFxX17pJYC +r6SaRGVMZoiHJb4B7Smb/ijWRB9wtUjG53KL7FVk0AJuGoW9aI7DpYpScX9/+4Z8BQT gHLVNPKbw97fo6DYXpeQ7TP3/7HVjJizXqs2ObmZlpSpjVAfo/Z+iphmp4/fBgxuyaeX oy2Q== X-Gm-Message-State: AOAM533F5FEG/ct3XhGY3APrfwrDqsPqV4R/S0WqU3/uF/FnBZt9+n3M zEUFzteWc0hoEXs2TXMQauUgmg== X-Received: by 2002:a05:6808:107:: with SMTP id b7mr1237518oie.146.1633037725892; Thu, 30 Sep 2021 14:35:25 -0700 (PDT) Received: from MacBook-Pro.hackershack.net (cpe-173-173-107-246.satx.res.rr.com. [173.173.107.246]) by smtp.gmail.com with ESMTPSA id w17sm775133otu.54.2021.09.30.14.35.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Sep 2021 14:35:25 -0700 (PDT) Subject: Re: [PATCH v6 1/3] pwm: Introduce single-PWM of_xlate function To: Bjorn Andersson , Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Lee Jones Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-arm-msm@vger.kernel.org, Doug Anderson References: <20210930030557.1426-1-bjorn.andersson@linaro.org> From: Steev Klimaszewski Message-ID: Date: Thu, 30 Sep 2021 16:35:23 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210930030557.1426-1-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/29/21 10:05 PM, Bjorn Andersson wrote: > The existing pxa driver and the upcoming addition of PWM support in the > TI sn565dsi86 DSI/eDP bridge driver both has a single PWM channel and > thereby a need for a of_xlate function with the period as its single > argument. > > Introduce a common helper function in the core that can be used as > of_xlate by such drivers and migrate the pxa driver to use this. > > Signed-off-by: Bjorn Andersson > --- > > Changes since v4: > - None > > drivers/pwm/core.c | 26 ++++++++++++++++++++++++++ > drivers/pwm/pwm-pxa.c | 16 +--------------- > include/linux/pwm.h | 2 ++ > 3 files changed, 29 insertions(+), 15 deletions(-) > > diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c > index 4527f09a5c50..2c6b155002a2 100644 > --- a/drivers/pwm/core.c > +++ b/drivers/pwm/core.c > @@ -152,6 +152,32 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) > } > EXPORT_SYMBOL_GPL(of_pwm_xlate_with_flags); > > +struct pwm_device * > +of_pwm_single_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) > +{ > + struct pwm_device *pwm; > + > + if (pc->of_pwm_n_cells < 1) > + return ERR_PTR(-EINVAL); > + > + /* validate that one cell is specified, optionally with flags */ > + if (args->args_count != 1 && args->args_count != 2) > + return ERR_PTR(-EINVAL); > + > + pwm = pwm_request_from_chip(pc, 0, NULL); > + if (IS_ERR(pwm)) > + return pwm; > + > + pwm->args.period = args->args[0]; > + pwm->args.polarity = PWM_POLARITY_NORMAL; > + > + if (args->args_count == 2 && args->args[2] & PWM_POLARITY_INVERTED) > + pwm->args.polarity = PWM_POLARITY_INVERSED; > + > + return pwm; > +} > +EXPORT_SYMBOL_GPL(of_pwm_single_xlate); > + > static void of_pwmchip_add(struct pwm_chip *chip) > { > if (!chip->dev || !chip->dev->of_node) > diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c > index a9efdcf839ae..238ec88c130b 100644 > --- a/drivers/pwm/pwm-pxa.c > +++ b/drivers/pwm/pwm-pxa.c > @@ -148,20 +148,6 @@ static const struct platform_device_id *pxa_pwm_get_id_dt(struct device *dev) > return id ? id->data : NULL; > } > > -static struct pwm_device * > -pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) > -{ > - struct pwm_device *pwm; > - > - pwm = pwm_request_from_chip(pc, 0, NULL); > - if (IS_ERR(pwm)) > - return pwm; > - > - pwm->args.period = args->args[0]; > - > - return pwm; > -} > - > static int pwm_probe(struct platform_device *pdev) > { > const struct platform_device_id *id = platform_get_device_id(pdev); > @@ -187,7 +173,7 @@ static int pwm_probe(struct platform_device *pdev) > pc->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1; > > if (IS_ENABLED(CONFIG_OF)) { > - pc->chip.of_xlate = pxa_pwm_of_xlate; > + pc->chip.of_xlate = of_pwm_single_xlate; > pc->chip.of_pwm_n_cells = 1; > } > > diff --git a/include/linux/pwm.h b/include/linux/pwm.h > index 725c9b784e60..dd51d4931fdc 100644 > --- a/include/linux/pwm.h > +++ b/include/linux/pwm.h > @@ -414,6 +414,8 @@ struct pwm_device *pwm_request_from_chip(struct pwm_chip *chip, > > struct pwm_device *of_pwm_xlate_with_flags(struct pwm_chip *pc, > const struct of_phandle_args *args); > +struct pwm_device *of_pwm_single_xlate(struct pwm_chip *pc, > + const struct of_phandle_args *args); > > struct pwm_device *pwm_get(struct device *dev, const char *con_id); > struct pwm_device *of_pwm_get(struct device *dev, struct device_node *np, I've tested these v6 all 3 patches on the Lenovo Yoga C630 Tested-by: Steev Klimaszewski