Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp349551rdb; Thu, 5 Oct 2023 07:45:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEI5CWU6a2FyoEIiKhrbpsTwu93CHJBoQ9ZHYmFzrfaGM9VFoa0+dzdwfglw4UHnl1SiqMR X-Received: by 2002:a05:6a20:3d03:b0:15e:bb88:b76e with SMTP id y3-20020a056a203d0300b0015ebb88b76emr5804701pzi.14.1696517146203; Thu, 05 Oct 2023 07:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517146; cv=none; d=google.com; s=arc-20160816; b=kTtb7yc/ci6N9j+QUJmJ2u2Ut6J0fxukAmnwpg0Id2vjjYNt3+TZOZgpiw27DTWe6q jpu0anqc77xQ4ssm8hnE82Shkth6f7ggqniJ60a4kDc1sEThlTz5X++y8iXYTFN1Gx9L LcP3mQ7JBhDwzlZuLWwtBA2Wd7sEVeff3cL39fnRrLbSG8+EvGEImnwHbCVy7lMA1shg jTMZM8rmbCMQmMku8s3YWIXMITfVqyuLkzoK9m0vadup9Ms6NI7GSNGCHJKAPkskp7IJ q6YTqrnqIcgp7rNlB+25APPg2n6Pxk90rPvzYIrPRYmGp8vH748BwD6ROPV/qxsMi/m5 cYdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fm56F5hp+/e7UJSHHwDnxbf3KCY68FzCQrhv8b8667M=; fh=dIu2/jEJAoxYYZs6z52csqKFhACsO00ptZQALaOGdYc=; b=ligCZalg4aFG7ahoAFuoew+FsEZxAcdtLsCZXlbIk50Xs0SzAJuGF6jChr72qk3g6o TDADBDPsOfur+fwwNRrFwHeg9F5eFj/epUjfqxnR2RBsFPpxEtnvDoF5WXOsBXwqyIuu 1MI4dfg/K74d7gWlYX25QSSzgMcig2Vql5cDTElIY3F/H3fBlBDAtz+jBt1r/Znz3rNY cmea0OuYRlFAw7KsYNLE3u5lW776nA0XHzZ8sV5IRe6nC+xn7RCyJfIJV45yQdPoE5NU +CuIU59sYt0y9vKLjGP3D3d63nQC2MJvZAMRygRv4+W6C1Ko1/fG5mhMt191zLHsZVek aYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m0lFGNiY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id g1-20020a056a000b8100b00690bc21d900si1632144pfj.136.2023.10.05.07.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m0lFGNiY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 06F188023921; Thu, 5 Oct 2023 07:45:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240011AbjJEOos (ORCPT + 99 others); Thu, 5 Oct 2023 10:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238453AbjJEOk0 (ORCPT ); Thu, 5 Oct 2023 10:40:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BFF04696; Thu, 5 Oct 2023 07:12:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87B76C4AF1E; Thu, 5 Oct 2023 13:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696511856; bh=ZwEQQmVK4H+n0kW8nvtsgTP5t8H63QSZoM2++l8ORYY=; h=From:To:Cc:Subject:Date:From; b=m0lFGNiYYtQacsuitgnC26c/xEIuGTF/d6mEg7LZMwELnEp3XYveg4lfDBtdX2+j2 d7B8QrU/W3DMi2xCWjB/9uI7Dkryi+iLeXYy0JWjn2rHv/jmhsvCGYF/zO6krKtwcy 8DwMpxMvpIiFEMlrQUwymiCvcPd9E9l+DMvBW7FFVpYGdV550bPgIWYhp775uhf/+X bja4ti7neGfPaLxCxXH069V/YM+kK22qms2sb7Z56wMva1jMbOAEPQTHGVRaCsph+W Mw+7PC1Zji87wvazHUlRfbPRBX5XQatdaN1RKilOXxi/FtWpjlyRLin1LlcdlucBCL QJIt99BtOQk2A== From: Jisheng Zhang To: Thierry Reding , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Guo Ren , Fu Wei Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v3 0/2] pwm: add driver for T-THEAD TH1520 SoC Date: Thu, 5 Oct 2023 21:05:17 +0800 Message-Id: <20231005130519.3864-1-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:45:35 -0700 (PDT) T-HEAD SoCs such as the TH1520 contain a PWM controller used to control the LCD backlight, fan and so on. Add the PWM driver support for it. Since the clk part isn't mainlined, so SoC dts(i) changes are not included in this series. However, it can be tested by using fixed-clock. since v2: - collect Reviewed-by tag - add CTRL_ prefix for THEAD_PWM_CTRL register bit macros - use pm_runtime_resume_and_get() instead of pm_runtime_get_sync() and check its return value. - remove unnecessary casts - call pm_runtime_put_sync() when pwm channel is disabled - use devm_pm_runtime_enable() and then drop .remove() - properly consider if pwm is programmed by bootloader or other pre-linux env. - simplify thead_pwm_runtime_resume() code as Uwe suggested - bool ever_started -> u8 channel_ever_started since we have 6 channels - use 3 for #pwm-cells since v1: - update commit msg and yaml filename to address Conor's comment - use devm_clk_get_enabled() and devm_pwmchip_add() - implement .get_state() - properly handle overflow - introduce thead_pwm_from_chip() inline function - document Limitations - address pm_runtime_get/put pingpong comment Jisheng Zhang (2): dt-bindings: pwm: Add T-HEAD PWM controller pwm: add T-HEAD PWM driver .../bindings/pwm/thead,th1520-pwm.yaml | 44 +++ drivers/pwm/Kconfig | 11 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-thead.c | 270 ++++++++++++++++++ 4 files changed, 326 insertions(+) create mode 100644 Documentation/devicetree/bindings/pwm/thead,th1520-pwm.yaml create mode 100644 drivers/pwm/pwm-thead.c -- 2.40.1