From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D576C04FFE for ; Tue, 23 Apr 2024 23:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:CC:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e+clYkuCCCbIcHl7zvzhxDrLSjU+JAM+buitdRZHaaw=; b=z9c2lMiFx/mQfc 0sPyD5JPuQu+J2it5IRqmMWdSLu2QNJpSa+kEeaquSBowT8+UFyPuhNkfvslInLpfPv1dD64qhryY udP8ShHPblKsvNC22d+dPL8bN9GSmPSvanIhX96v5M29CODhA59w6jVUL4aAjl4TGtIvc2zs66NhX DKxp36qWt5IOfKPXejSle6H+A2bcl1aOtNDntlWIzX2HGrfDhcznLHHKCv0YtfXPvIAXKxP+UKiL/ CbQ2m6wocAdhznciFx7Cxfxvz52PbxYqff/WAoLpWLZJXdGjifmuOaLT2wUpX5Jkklz3apPG+/dmJ Pn21/wZJ88m71bT7dJ5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzP7n-00000001m6R-09EV; Tue, 23 Apr 2024 23:00:31 +0000 Received: from mx1.sberdevices.ru ([37.18.73.165]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzP7i-00000001m3t-0XXH; Tue, 23 Apr 2024 23:00:28 +0000 Received: from p-infra-ksmg-sc-msk01 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 23725100004; Wed, 24 Apr 2024 02:00:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 23725100004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1713913221; bh=tcVfNzm8I5LEMAd+H5pTx/XXdCO1zxNExqAEu+sh1rk=; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type:From; b=Ey2kgYalHNsRgGMEO8gcRyn3v4qM3sybzmq8nLPF5QgoUxsadY+FbtMZ0/fPt6/sp kDgX9dxk+jdYtPfZQcWaax5+HH8QwHvpuG2+FgPMEi9A8fKwJXD5FUGSBexCT3xdm9 5aGwvjIJqEe16Ep7Fbap0bnVS4+neN8mS/6BczYxn3VP7NYLyrZ3zGciNCXr323hfY i8wSdmMUrkOG1sKC/xLWOlvUcE6jX6Sx2JP5DaDDeihgnPLA8tNr8kGIkg5TlsqK8N D5m7oLk4CPJLiZgmQVayu00tjEACovLNRcwAGfyi+nFm82MuO6mwM41q3XSMyddk2q K1aNgUCRAT6Sg== Received: from smtp.sberdevices.ru (p-i-exch-sc-m02.sberdevices.ru [172.16.192.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Wed, 24 Apr 2024 02:00:20 +0300 (MSK) Received: from [192.168.1.143] (100.64.160.123) by p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 24 Apr 2024 02:00:20 +0300 Message-ID: <4feb8fe3-af72-4483-87b2-30503328cfe2@salutedevices.com> Date: Wed, 24 Apr 2024 02:00:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] pwm: meson: support meson A1 SoC family To: Jerome Brunet CC: , , , , , , , , , , , , , , , George Stark , Dmitry Rokosov References: <20240423161006.2522351-1-gnstark@salutedevices.com> <20240423161006.2522351-3-gnstark@salutedevices.com> <1jv848ezzo.fsf@starbuckisacylon.baylibre.com> Content-Language: en-US From: George Stark In-Reply-To: <1jv848ezzo.fsf@starbuckisacylon.baylibre.com> X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m02.sberdevices.ru (172.16.192.103) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184885 [Apr 23 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: gnstark@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 18 0.3.18 b9d6ada76958f07c6a68617a7ac8df800bc4166c, {Tracking_from_domain_doesnt_match_to}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;100.64.160.123:7.1.2;salutedevices.com:7.1.1;smtp.sberdevices.ru:5.0.1,7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/04/23 19:04:00 #24945065 X-KSMG-AntiVirus-Status: Clean, skipped X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_160026_887838_E96F4123 X-CRM114-Status: GOOD ( 28.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Jerome Thanks for the review On 4/23/24 20:35, Jerome Brunet wrote: > > On Tue 23 Apr 2024 at 19:10, George Stark wrote: > >> From: George Stark >> >> Add a compatible string and configuration for the meson A1 SoC family >> PWM. Additionally, provide an external clock initialization helper >> specifically designed for these PWM IPs. >> >> Signed-off-by: George Stark >> Signed-off-by: Dmitry Rokosov >> --- >> drivers/pwm/pwm-meson.c | 35 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 35 insertions(+) >> >> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c >> index ea96c5973488..529a541ba7b6 100644 >> --- a/drivers/pwm/pwm-meson.c >> +++ b/drivers/pwm/pwm-meson.c >> @@ -462,6 +462,33 @@ static int meson_pwm_init_channels_meson8b_v2(struct pwm_chip *chip) >> return meson_pwm_init_clocks_meson8b(chip, mux_parent_data); >> } >> >> +static int meson_pwm_init_channels_ext_clock(struct pwm_chip *chip) > > That kind on naming (ext) is almost sure to clash with whatever comes next. > Just use the name of the first SoC using the method, a1 for instance. It's true that pwm core in a1 s4, t7 etc is the same AFAWK. I just want to clarify your proposal: I add a1 compatible to the dt-bindings with s4 as fallback, t7 compatible will be added later in the same way. Here in the driver I don't mention a1 at all and use s4-centric naming e.g.: { .compatible = "amlogic,meson-s4-pwm", .data = &pwm_meson_s4_data }, static const struct meson_pwm_data pwm_meson_s4_data = { .channels_init = meson_pwm_init_channels_s4, }; right? >> +{ >> + struct device *dev = pwmchip_parent(chip); >> + struct meson_pwm *meson = to_meson_pwm(chip); >> + struct meson_pwm_channel *channels = meson->channels; >> + struct clk_bulk_data *clks = NULL; >> + unsigned int i; >> + int res; >> + >> + res = devm_clk_bulk_get_all(dev, &clks); >> + if (res < 0) { >> + dev_err(dev, "can't get device clocks\n"); >> + return res; >> + } > > I don't think allocating the 'clk_bulk_data *clks' is necessary or safe. > We know exactly how many clocks we expect, there is no need for a get all. > >> + >> + if (res != MESON_NUM_PWMS) { >> + dev_err(dev, "clock count must be %d, got %d\n", >> + MESON_NUM_PWMS, res); >> + return -EINVAL; >> + } > > ... and this only catches the problem after the fact. > > It is probably convinient but not necessary. > >> + >> + for (i = 0; i < MESON_NUM_PWMS; i++) >> + channels[i].clk = clks[i].clk; > > channels[i].clk could be assigned directly of_clk_get() using clock > indexes. No extra allocation needed. if we use of_clk_get then we'll have to free the clock objects in the end. Could we use devm_clk_bulk_get instead? >> + >> + return 0; >> +} >> + >> 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, >> @@ -500,11 +527,19 @@ static const struct meson_pwm_data pwm_meson8_v2_data = { >> .channels_init = meson_pwm_init_channels_meson8b_v2, >> }; >> >> +static const struct meson_pwm_data pwm_meson_ext_clock_data = { >> + .channels_init = meson_pwm_init_channels_ext_clock, >> +}; >> + >> static const struct of_device_id meson_pwm_matches[] = { >> { >> .compatible = "amlogic,meson8-pwm-v2", >> .data = &pwm_meson8_v2_data >> }, >> + { >> + .compatible = "amlogic,meson-a1-pwm", >> + .data = &pwm_meson_ext_clock_data >> + }, >> /* The following compatibles are obsolete */ >> { >> .compatible = "amlogic,meson8b-pwm", > > -- Best regards George _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel