Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4133212rdb; Mon, 11 Dec 2023 09:42:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGP4A1rTrcj9rWJDRnenaV/C63dz+GlhDlEfIQ3Lmq8ec7EqEx1hVi2+Kbkk6cshkao9iQZ X-Received: by 2002:a05:6a21:1f03:b0:18f:354f:58bd with SMTP id ry3-20020a056a211f0300b0018f354f58bdmr5152862pzb.104.1702316530929; Mon, 11 Dec 2023 09:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702316530; cv=none; d=google.com; s=arc-20160816; b=KJmdRsQlLThwjrAFpz0z1K2zx/wmBjs9Nri9qst1va8/x0NDIlmNiYpgNEd4e8LSGB TyKGKvbsOuetid5GOaD43u2Fob6Yp7lnvmhVuTPTJKoD7EQRG1EyRuG1SA/s4nvZA5OE HtehmTsgWFjtEwQDB/sVXRCjVSDS7MU4P3cH8w/CmRdtJFXSYV4a7pOi04sxS1B8NqX9 2bHqqq2mFx4JqHr1wFFD+9PfEirEpPXa17v2GeEC7UjxAsOtB4+UETgBmxUn7gPC0oCc t2TosM0XLx3/PXxcZnvwqxQKOz5iFrmQH4k7nYDQlDbhLW5IUR4B7+hGtLkeT9zTll8F Ho9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jrpC/171Uw1xJRZXHSMOuU7hdbPvaKty+l7SzqnOtCA=; fh=+tEkbN5PvAVpsF15FCUFJyRrxV6HBvDeicrDK89KZ7A=; b=LU25rDEf8eAj2fxBeZCNXI2Gk+ofpzgixabWQobrQrWWXTUgnolhojsfEpTgHeyg2/ ng/MirwnpnGCWrSxeZzjiL+WVtzEY6cZQQJHlFlUiB6WEiqJkI5ytDj9GDlYq6M/jQ66 TnRu8LO1MGehhkSE5j3auygDwDwVMvcrLdTwxT9jce1LmIUd7ih88U+d72tUiiklFIQd NhaYzrwCI03OCe9o43bEVM9DL8XLrtV8mb3HJ4duXo3zhsZUK1WJ/Q82yhXHBLQiwteH VTySCeJ8HGlOitXLpvHTnXRNRy35MZ9cauW/4FGkxptjZqx1ZbNBgY9MAqZYcCoyzmZN AbNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UWFa33Wd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c37-20020a634e25000000b005c645e1ff20si6216605pgb.73.2023.12.11.09.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 09:42:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UWFa33Wd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E970F807DECC; Mon, 11 Dec 2023 09:42:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235005AbjLKRlv (ORCPT + 99 others); Mon, 11 Dec 2023 12:41:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjLKRlu (ORCPT ); Mon, 11 Dec 2023 12:41:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A215AC8 for ; Mon, 11 Dec 2023 09:41:55 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B642C433CA; Mon, 11 Dec 2023 17:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702316515; bh=8vM15B5r9GNLZ5/wggwUsDIktWh+Yq5/KSnQ542rzvk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=UWFa33Wd4t2HkTUGAkTpn+A6NzBeeFc4fe9rcDJoCyhhQRNVUM/eSa+M2fkK8Yqu7 DIBP1GZc5DTx6AOfluEFI/vtXyutWzwp3kymkpvN5GSA2/OfvxcSN3UVll+gFpunK+ FNNkqI6239iRikxnHd6wFmPmUljKgFzoP1+xDDkvAt0O0JhdH1mkOHft6hlkecxmhS AFsoFRhkNhoEFkgxtHP/6ieTW0hXv2oBVClt/Z/025aCrBBLARIz69tKtRjjMiZ9RF 72ChJGfP2B04IErZzCK7Z9kvnBv0VUzW4D7H/RtVowNXmNjWDAUbL56+Tf/8aVfVTw E5ewHTum5mSHw== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-50d176eb382so4027666e87.2; Mon, 11 Dec 2023 09:41:55 -0800 (PST) X-Gm-Message-State: AOJu0YzsBJDXwyJI9R1sKyzXt6mUswbrdfOEROGhufhLWBnnzz6jtdJJ DsMGYIVVdv4Fvgd4HfIOS++IdkR6Cr1LUbmYsA== X-Received: by 2002:ac2:52ab:0:b0:50b:e109:bed1 with SMTP id r11-20020ac252ab000000b0050be109bed1mr2055001lfm.112.1702316513477; Mon, 11 Dec 2023 09:41:53 -0800 (PST) MIME-Version: 1.0 References: <20231208094209.1910934-1-william.qiu@starfivetech.com> <20231208094209.1910934-3-william.qiu@starfivetech.com> In-Reply-To: <20231208094209.1910934-3-william.qiu@starfivetech.com> From: Rob Herring Date: Mon, 11 Dec 2023 11:41:41 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 2/4] pwm: opencores: Add PWM driver support To: William Qiu Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pwm@vger.kernel.org, Emil Renner Berthing , Thierry Reding , Philipp Zabel , Krzysztof Kozlowski , Conor Dooley , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Hal Feng , Paul Walmsley , Palmer Dabbelt , Albert Ou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 09:42:08 -0800 (PST) On Fri, Dec 8, 2023 at 3:42=E2=80=AFAM William Qiu wrote: > > Add driver for OpenCores PWM Controller. And add compatibility code > which based on StarFive SoC. > > Co-developed-by: Hal Feng > Signed-off-by: Hal Feng > Signed-off-by: William Qiu > --- > MAINTAINERS | 7 ++ > drivers/pwm/Kconfig | 12 ++ > drivers/pwm/Makefile | 1 + > drivers/pwm/pwm-ocores.c | 229 +++++++++++++++++++++++++++++++++++++++ > 4 files changed, 249 insertions(+) > create mode 100644 drivers/pwm/pwm-ocores.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 788be9ab5b73..7a11a22da09e 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -16204,6 +16204,13 @@ F: Documentation/i2c/busses/i2c-ocores.rst > F: drivers/i2c/busses/i2c-ocores.c > F: include/linux/platform_data/i2c-ocores.h > > +OPENCORES PWM DRIVER > +M: William Qiu > +M: Hal Feng > +S: Supported > +F: Documentation/devicetree/bindings/pwm/opencores,pwm.yaml > +F: drivers/pwm/pwm-ocores.c > + > OPENRISC ARCHITECTURE > M: Jonas Bonn > M: Stefan Kristiansson > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig > index 4b956d661755..d87e1bb350ba 100644 > --- a/drivers/pwm/Kconfig > +++ b/drivers/pwm/Kconfig > @@ -444,6 +444,18 @@ config PWM_NTXEC > controller found in certain e-book readers designed by the orig= inal > design manufacturer Netronix. > > +config PWM_OCORES > + tristate "OpenCores PWM support" > + depends on HAS_IOMEM && OF > + depends on COMMON_CLK && RESET_CONTROLLER > + depends on ARCH_STARFIVE || COMPILE_TEST > + help > + If you say yes to this option, support will be included for the > + OpenCores PWM. For details see https://opencores.org/projects/p= tc. > + > + To compile this driver as a module, choose M here: the module > + will be called pwm-ocores. > + > config PWM_OMAP_DMTIMER > tristate "OMAP Dual-Mode Timer PWM support" > depends on OF > diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile > index c5ec9e168ee7..517c4f643058 100644 > --- a/drivers/pwm/Makefile > +++ b/drivers/pwm/Makefile > @@ -40,6 +40,7 @@ obj-$(CONFIG_PWM_MICROCHIP_CORE) +=3D pwm-microchi= p-core.o > obj-$(CONFIG_PWM_MTK_DISP) +=3D pwm-mtk-disp.o > obj-$(CONFIG_PWM_MXS) +=3D pwm-mxs.o > obj-$(CONFIG_PWM_NTXEC) +=3D pwm-ntxec.o > +obj-$(CONFIG_PWM_OCORES) +=3D pwm-ocores.o > obj-$(CONFIG_PWM_OMAP_DMTIMER) +=3D pwm-omap-dmtimer.o > obj-$(CONFIG_PWM_PCA9685) +=3D pwm-pca9685.o > obj-$(CONFIG_PWM_PXA) +=3D pwm-pxa.o > diff --git a/drivers/pwm/pwm-ocores.c b/drivers/pwm/pwm-ocores.c > new file mode 100644 > index 000000000000..996ca3805901 > --- /dev/null > +++ b/drivers/pwm/pwm-ocores.c > @@ -0,0 +1,229 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * OpenCores PWM Driver > + * > + * https://opencores.org/projects/ptc > + * > + * Copyright (C) 2018-2023 StarFive Technology Co., Ltd. > + * > + * Limitations: > + * - The hardware only do inverted polarity. > + * - The hardware minimum period / duty_cycle is (1 / pwm_apb clock freq= uency) ns. > + * - The hardware maximum period / duty_cycle is (U32_MAX / pwm_apb cloc= k frequency) ns. > + */ > + > +#include > +#include > +#include > +#include > +#include You probably don't need this header and the implicit includes it makes are dropped now in linux-next. Please check what you actually need and make them explicit. Rob