From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38909606A332 for ; Tue, 1 Dec 2026 03:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=L9SQgXUI; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IN9j0Elv DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References: Message-Id:MIME-Version:Subject:Date:From:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=z/2yRHj+/GWuiZtmhxRK+bmRTUMF8GepoliER3xuTxw=; b=L9SQgXUI6CkbVG2CC2TAMvmxif eLLx/zPOSm/JI8PK2ec6PH1boDPfrTKiidCRF/+UZVEpZs56QeWE8h+gyFy+kize5sH5Q/kS9AI75 uyPHAYZQUktQdsy089FPZzL4H4YGbkOAIL+zCOvZVZWzsxqyXZPDbJqpl6+co+kiNK5EIcgtRZvTV 3NY//cSg5hBpfslILm+uYxGp/9bb029YOrk2PYVBohlUbABO79ASwTwYWOAqJLhvmDqz1aWGKNiDa bdMLvQ6FMPROYxzRv5zG978T9hd9kvGPP+wt5D0eXI5OEgPBvP8Xg8IoH5HRqgFi0L2ALdRzXLDJX l6Y+Igxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYEdK-00000006SiR-16x7; Tue, 01 Dec 2026 03:34:22 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYEdI-00000006ShF-0lmc; Tue, 01 Dec 2026 03:34:20 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 95D2544FBB; Tue, 1 Dec 2026 03:34:19 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796096059; b=oy8RaSyi+hPAz2tzelrDCQDBIjzdwAZs+PBUxiBx/+nojbAI5nE7QVpYkCIwn0SYEPRq jKtX8Bu9ILtbjeisusxy5mW2HdGt/k5l+Q+O1c91x2OtkXiovRnKJaqcxpuD6hx94IsAS 8gy2tACjTJlWiU/Ms4SENiECV6zJvTir0PgGJ6cQ314kUUidr4vijUgT7gP525xtvD6EA tNIUvxHPlW/br6n3uslcqNlI/2Y9hORehwspKjEAxxJs2h+9rd/Svq4fUVFslkLa6260Z tL4P+riVWUWG3HpRKR+qDZ7fl3SSomvbhJ5xUOqKg//Pj+wBpWSq9lg5pEhHk3zHpzA== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796096059; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=k2PhNlRdf3UMy/yro65A7BnPgX5pbM/sWV2DnMBJqNg=; b=sTsL9OUlQav0WfKymlxAw1yCD9X+Za3N+NQrwT6CrIIqhVSD40DoK88X5DOpVqlueo3b UhkuebBImTl0efVdHS4IvW4AUjY9BZS40Oh5saMZNzE+gt7ONmijE1MhxngxL4HFCu8Xy aWB1xKJoNHIWXEmQ6rHdHMdCGJXkwmbQZibcmMhNES4eEU8yyd4gg6GyAHQxuyUXKVlfQ wchLSZJu3Sfi8CngKKyx7PHUD/q61PoxtvwctPdgzROsJS0CRPh0lfkxSV180N6omMLB4 JwuWjp1HbxxpcRfmUG0Z0G8QO3YTE1PElzjfuV72njth4GJfpZtwvr4pGCHNYp4IRuw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 5CF5F1F00898; Tue, 1 Dec 2026 03:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796096059; bh=k2PhNlRdf3UMy/yro65A7BnPgX5pbM/sWV2DnMBJqNg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=IN9j0ElvkgJhPiI/GaROstFLDftUavSVqtiRHcRKkJ6kFlEl4HDDcvJOYS4tGWn0b lFACtthSzF2L8LFWT7UX8BaQXVfvxwVbvQvvRfA8+CaCjyTswNZk7CAwXiCWkoWyfX 69Xq/0ENXhRHXSvABr62BF9uopqQX9f4Fzv0/g3xTIZLcz+FZ6HvKejhjSZasOi8+3 4dCAKeECfqiBZ1gdb6ik+WOzbLSkPbzN5IO7e9WX6PPRvWBF8eK7fJwult6twggjpW VVgWzpEXWMCKqkD577PW951f+bjWVoU7ZtUH6MxI7BMt/0T4DtNHGq3j46KGdBsmfo 2ODkfgY0Rv4mA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id DA6C44EB88; Tue, 1 Dec 2026 03:34:17 +0000 (UTC) From: Xianwei Zhao via B4 Relay Date: Tue, 01 Dec 2026 03:34:13 +0000 Subject: [PATCH v6 2/3] pwm: meson: add the PWM count driver data X-Archived-By: MIME-Version: 1.0 Message-Id: <20261201-s6-s7-pwm-v6-2-703cc13d4da5@amlogic.com> References: <20261201-s6-s7-pwm-v6-0-703cc13d4da5@amlogic.com> In-Reply-To: <20261201-s6-s7-pwm-v6-0-703cc13d4da5@amlogic.com> To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiner Kallweit , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl Cc: linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, Xianwei Zhao , Alexandre Mergnat X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796096055; l=4472; i=xianwei.zhao@amlogic.com; s=20251216; h=from:subject:message-id; bh=pJmPfSjrLy+aF8ACF0qLVlPkUg23JW3ODuezyMtYQcM=; b=YteqhLptLY+roG6cwTb5EiD4YxZctpd9UrTuPcVhWrZqBHvEIDLH/UtyrHhlOsxl/+Im3kyEb 6LozwtIg2FSDAdb5KMK8diOSYmpklRJNzh631LM8rMjqBn1tN/Wpdlk X-Developer-Key: i=xianwei.zhao@amlogic.com; a=ed25519; pk=dWwxtWCxC6FHRurOmxEtr34SuBYU+WJowV/ZmRJ7H+k= X-Endpoint-Received: by B4 Relay for xianwei.zhao@amlogic.com/20251216 with auth_id=578 X-Original-From: Xianwei Zhao X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: xianwei.zhao@amlogic.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Xianwei Zhao To prepare adding support for S6, S7 and S7D SoCs which don't have 2 but 1 PWM outputs, make the various loops iterate using chip->npwm instead of the constant MESON_NUM_PWMS. Add npwm to struct meson_pwm_data, and set .npwm = 2 for existing variants. Reviewed-by: Alexandre Mergnat Signed-off-by: Xianwei Zhao --- drivers/pwm/pwm-meson.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c index 3a28c853089f..a4b5f3877607 100644 --- a/drivers/pwm/pwm-meson.c +++ b/drivers/pwm/pwm-meson.c @@ -108,6 +108,7 @@ struct meson_pwm_data { int (*channels_init)(struct pwm_chip *chip); bool has_constant; bool has_polarity; + u8 npwm; }; struct meson_pwm { @@ -440,7 +441,7 @@ static int meson_pwm_init_clocks_meson8b(struct pwm_chip *chip, char name[255]; int err; - for (i = 0; i < MESON_NUM_PWMS; i++) { + for (i = 0; i < chip->npwm; i++) { struct meson_pwm_channel *channel = &meson->channels[i]; struct clk_parent_data div_parent = {}, gate_parent = {}; struct clk_init_data init = {}; @@ -580,6 +581,7 @@ static int meson_pwm_init_channels_per_channel_clk(struct pwm_chip *chip) static const struct meson_pwm_data pwm_meson8b_data = { .parent_names = { "xtal", NULL, "fclk_div4", "fclk_div3" }, .channels_init = meson_pwm_init_channels_meson8b_legacy, + .npwm = 2, }; /* @@ -589,6 +591,7 @@ static const struct meson_pwm_data pwm_meson8b_data = { static const struct meson_pwm_data pwm_gxbb_ao_data = { .parent_names = { "xtal", "clk81", NULL, NULL }, .channels_init = meson_pwm_init_channels_meson8b_legacy, + .npwm = 2, }; static const struct meson_pwm_data pwm_axg_ee_data = { @@ -596,6 +599,7 @@ static const struct meson_pwm_data pwm_axg_ee_data = { .channels_init = meson_pwm_init_channels_meson8b_legacy, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_axg_ao_data = { @@ -603,6 +607,7 @@ static const struct meson_pwm_data pwm_axg_ao_data = { .channels_init = meson_pwm_init_channels_meson8b_legacy, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_g12a_ee_data = { @@ -610,6 +615,7 @@ static const struct meson_pwm_data pwm_g12a_ee_data = { .channels_init = meson_pwm_init_channels_meson8b_legacy, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_g12a_ao_ab_data = { @@ -617,6 +623,7 @@ static const struct meson_pwm_data pwm_g12a_ao_ab_data = { .channels_init = meson_pwm_init_channels_meson8b_legacy, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_g12a_ao_cd_data = { @@ -624,22 +631,26 @@ static const struct meson_pwm_data pwm_g12a_ao_cd_data = { .channels_init = meson_pwm_init_channels_meson8b_legacy, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_meson8_v2_data = { .channels_init = meson_pwm_init_channels_meson8b_v2, + .npwm = 2, }; static const struct meson_pwm_data pwm_meson_axg_v2_data = { .channels_init = meson_pwm_init_channels_meson8b_v2, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct meson_pwm_data pwm_s4_data = { .channels_init = meson_pwm_init_channels_per_channel_clk, .has_constant = true, .has_polarity = true, + .npwm = 2, }; static const struct of_device_id meson_pwm_matches[] = { @@ -699,9 +710,12 @@ static int meson_pwm_probe(struct platform_device *pdev) { struct pwm_chip *chip; struct meson_pwm *meson; + const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev); int err; - chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson)); + if (pdata->npwm > 2) + return -EINVAL; + chip = devm_pwmchip_alloc(&pdev->dev, pdata->npwm, sizeof(*meson)); if (IS_ERR(chip)) return PTR_ERR(chip); meson = to_meson_pwm(chip); @@ -713,7 +727,7 @@ static int meson_pwm_probe(struct platform_device *pdev) spin_lock_init(&meson->lock); chip->ops = &meson_pwm_ops; - meson->data = of_device_get_match_data(&pdev->dev); + meson->data = pdata; err = meson->data->channels_init(chip); if (err < 0) -- 2.52.0 _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic