Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2119404rwb; Thu, 19 Jan 2023 21:28:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbBrzR7Lz2LOttfaALb2brH/DenTS1rlPT0KiKWbnv9ZpSvIGhC5SreiO5JBVNFZuWFS5P X-Received: by 2002:a05:6a20:8e10:b0:b2:6105:e960 with SMTP id y16-20020a056a208e1000b000b26105e960mr18936097pzj.32.1674192487969; Thu, 19 Jan 2023 21:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674192487; cv=none; d=google.com; s=arc-20160816; b=AntQciV1Yt9QqgpvGEAlb6Y/G9M1juAnijy7QjnZBgp//Sh85YPw5L5Lp/HOYEfMNY 54GUTcpwRdzC+wD9jPNZlCamq/gpM33gIUosQiQBjSVB5APPUQC0q1CFb+LzgzOAGZWQ V7O9ZXIOa/AGFU2iOnuamRaLX8DDImKHbByljdxdPfcDPQD/66obA0bjJ4OTjl89U/5v cHhSUiDQRsrugEQqDpmpXzmi55mctJ8a71YbxUdDOF+Qo6QB+sPZmzEpDilwpoL6N9Gg /wudi5jgG2hwRd9yhitW5fuPuPRsuryd5YIVuFSg5WDGhOxsLAHGxngQd2VVcFFvNybn WI9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=QtZrE46UQQtXLCnyIhGifCGTHHs7CaoZ1KSA6/R0zF8=; b=dmgwOZ0wH3eT1vuUT4Zt5cSTbSOuhL+GlQNEWZBGanb/BOnwPlwQDPTO1pcoSNuWMJ he79U5cjUt7QlC6rwbjej8InMy4RyHffDygYtJz2iTRur1kFkoWaYKvBXk5zqPsUCrJE MDCBPXNB2hzmgnc7/2tVd5f1tp2ZTN6P4or9GzcYJjTv003aZ0Tb1SdfIPFr6N6sw0LF Do7z9SEDIIQkTQwUX+kCbxLevR6lnuj7o/OTmGj2MM9/yjTvaJvXsdGZsuozsNy60OfK dxSCdp9wDXeY6CA2m4o//UMbkGQtLKFYdGNz1FrNR7pXTT3PXEpTfZJHcIoqAnXJXDcI E/hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i36-20020a635864000000b004d2c0d8e5d9si2324853pgm.402.2023.01.19.21.28.02; Thu, 19 Jan 2023 21:28:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbjATDem (ORCPT + 46 others); Thu, 19 Jan 2023 22:34:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjATDek (ORCPT ); Thu, 19 Jan 2023 22:34:40 -0500 Received: from mail-sh.amlogic.com (mail-sh.amlogic.com [58.32.228.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB1517EE51; Thu, 19 Jan 2023 19:33:54 -0800 (PST) Received: from [10.18.29.47] (10.18.29.47) by mail-sh.amlogic.com (10.18.11.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.13; Fri, 20 Jan 2023 11:33:52 +0800 Message-ID: Date: Fri, 20 Jan 2023 11:33:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH V6 3/3] clk: meson: s4: add support for Amlogic S4 SoC peripheral clock controller Content-Language: en-US To: Jerome Brunet , , , , , , Rob Herring , Neil Armstrong , Kevin Hilman , Michael Turquette , Stephen Boyd , Krzysztof Kozlowski , Martin Blumenstingl CC: "kelvin . zhang" , "qi . duan" References: <20230116074214.2326-1-yu.tu@amlogic.com> <20230116074214.2326-4-yu.tu@amlogic.com> <1ja62eybrv.fsf@starbuckisacylon.baylibre.com> From: Yu Tu In-Reply-To: <1ja62eybrv.fsf@starbuckisacylon.baylibre.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.18.29.47] X-ClientProxiedBy: mail-sh.amlogic.com (10.18.11.5) To mail-sh.amlogic.com (10.18.11.5) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hi On 2023/1/19 19:37, Jerome Brunet wrote: > [ EXTERNAL EMAIL ] > > > On Mon 16 Jan 2023 at 15:42, Yu Tu wrote: > >> Add the peripherals clock controller driver in the s4 SoC family. >> >> Signed-off-by: Yu Tu > > [...] > >> + >> +/* Video Clocks */ >> +static struct clk_regmap s4_vid_pll_div = { >> + .data = &(struct meson_vid_pll_div_data){ >> + .val = { >> + .reg_off = CLKCTRL_VID_PLL_CLK_DIV, >> + .shift = 0, >> + .width = 15, >> + }, >> + .sel = { >> + .reg_off = CLKCTRL_VID_PLL_CLK_DIV, >> + .shift = 16, >> + .width = 2, >> + }, >> + }, >> + .hw.init = &(struct clk_init_data) { >> + .name = "vid_pll_div", >> + /* >> + * The frequency division from the hdmi_pll clock to the vid_pll_div >> + * clock is the default value of this register. When designing the >> + * video module of the chip, a default value that can meet the >> + * requirements of the video module will be solidified according >> + * to the usage requirements of the chip, so as to facilitate chip >> + * simulation. So this is ro_ops. >> + * It is important to note that this clock is not used on this >> + * chip and is described only for the integrity of the clock tree. >> + */ > > If it is reset value and will be applicable to all the design, regarless > of the use-case, then yes RO ops is OK > >>From what I understand here, the value will depend on the use-case requirements. > This is a typical case where the DT prop "assigned-rate" should be used, not RO ops. Check the previous chip history, the actual scene is not used at all, basically is used in simulation. So the previous SOC was "ro_ops" without any problems. This S4 SOC is not actually useful either. So when you were upstream, you had no problem making "ro_ops". I wonder if I could delete this useless clock, so you don't have to worry about it. > >> + .ops = &meson_vid_pll_div_ro_ops, >> + .parent_data = (const struct clk_parent_data []) { >> + { .fw_name = "hdmi_pll", } >> + }, >> + .num_parents = 1, >> + .flags = CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > >> + >> +/* VDEC clocks */ >> +static const struct clk_parent_data s4_dec_parent_data[] = { >> + { .fw_name = "fclk_div2p5", }, >> + { .fw_name = "fclk_div3", }, >> + { .fw_name = "fclk_div4", }, >> + { .fw_name = "fclk_div5", }, >> + { .fw_name = "fclk_div7", }, >> + { .fw_name = "hifi_pll", }, >> + { .fw_name = "gp0_pll", }, >> + { .fw_name = "xtal", } >> +}; >> + >> +static struct clk_regmap s4_vdec_p0_mux = { >> + .data = &(struct clk_regmap_mux_data){ >> + .offset = CLKCTRL_VDEC_CLK_CTRL, >> + .mask = 0x7, >> + .shift = 9, >> + .flags = CLK_MUX_ROUND_CLOSEST, >> + }, >> + .hw.init = &(struct clk_init_data) { >> + .name = "vdec_p0_mux", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = s4_dec_parent_data, >> + .num_parents = ARRAY_SIZE(s4_dec_parent_data), >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. > > s/patent/parent ? > s/he wants/it requires ? Okay. > >> + */ >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > > [...] > >> +static const struct clk_parent_data s4_vpu_clkc_parent_data[] = { >> + { .fw_name = "fclk_div4", }, >> + { .fw_name = "fclk_div3", }, >> + { .fw_name = "fclk_div5", }, >> + { .fw_name = "fclk_div7", }, >> + { .fw_name = "mpll1", }, >> + { .hw = &s4_vid_pll.hw }, >> + { .fw_name = "mpll2", }, >> + { .fw_name = "gp0_pll", }, >> +}; >> + >> +static struct clk_regmap s4_vpu_clkc_p0_mux = { >> + .data = &(struct clk_regmap_mux_data){ >> + .offset = CLKCTRL_VPU_CLKC_CTRL, >> + .mask = 0x7, >> + .shift = 9, >> + }, >> + .hw.init = &(struct clk_init_data) { >> + .name = "vpu_clkc_p0_mux", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = s4_vpu_clkc_parent_data, >> + .num_parents = ARRAY_SIZE(s4_vpu_clkc_parent_data), >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. >> + */ > > That's quite a lot of occurences of the same comment. > At the same time, other clocks with the same flag have no comment. > > Please make general comment, before the Video/VPU section, explaining > which clocks needs on a use-case basis (through DT) and possibly how it > should be set, what should drive the choices. > The owner of the corresponding driver module wants to have a fixed clock, but I can't explain every specific reason. So I'm going to change it all to.flags = CLK_SET_RATE_PARENT in the next version. Let CCF choose the appropriate clock as you suggested. If there is a corresponding module you want to change, ask him to give you a specific explanation. Do you think that's all right? I will not reply to you below. >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > >> + >> +/* EMMC/NAND clock */ >> +static const struct clk_parent_data s4_sd_emmc_clk0_parent_data[] = { >> + { .fw_name = "xtal", }, >> + { .fw_name = "fclk_div2", }, >> + { .fw_name = "fclk_div3", }, >> + { .fw_name = "hifi_pll", }, >> + { .fw_name = "fclk_div2p5", }, >> + { .fw_name = "mpll2", }, >> + { .fw_name = "mpll3", }, >> + { .fw_name = "gp0_pll", }, >> +}; >> + >> +static struct clk_regmap s4_sd_emmc_c_clk0_sel = { >> + .data = &(struct clk_regmap_mux_data){ >> + .offset = CLKCTRL_NAND_CLK_CTRL, >> + .mask = 0x7, >> + .shift = 9, >> + }, >> + .hw.init = &(struct clk_init_data) { >> + .name = "sd_emmc_c_clk0_sel", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = s4_sd_emmc_clk0_parent_data, >> + .num_parents = ARRAY_SIZE(s4_sd_emmc_clk0_parent_data), >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. >> + */ > > I'm getting a bit suspicious about the use (and abuse ...) of this flag. > I don't quite get how selecting the base PLL for MMC should be done on > use-case basis and should be up the board DT ... > > Other SoC have all used fdiv2 so far. Do you expect this setting to be > part of the dtsi SoC file ? > >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > >> + >> +/* SPICC Clock */ >> +static const struct clk_parent_data s4_spicc_parent_data[] = { >> + { .fw_name = "xtal", }, >> + { .hw = &s4_sys_clk.hw }, >> + { .fw_name = "fclk_div4", }, >> + { .fw_name = "fclk_div3", }, >> + { .fw_name = "fclk_div2", }, >> + { .fw_name = "fclk_div5", }, >> + { .fw_name = "fclk_div7", }, >> +}; >> + >> +static struct clk_regmap s4_spicc0_mux = { >> + .data = &(struct clk_regmap_mux_data){ >> + .offset = CLKCTRL_SPICC_CLK_CTRL, >> + .mask = 0x7, >> + .shift = 7, >> + }, >> + .hw.init = &(struct clk_init_data) { >> + .name = "spicc0_mux", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = s4_spicc_parent_data, >> + .num_parents = ARRAY_SIZE(s4_spicc_parent_data), >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. >> + */ > > This is getting too far. All the parent clocks are fixed. > Let CCF do the job of picking the most adequate clock for the job > instead of manually settings things > >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > > >> + >> +/* PWM Clock */ >> +static const struct clk_parent_data s4_pwm_parent_data[] = { >> + { .fw_name = "xtal", }, >> + { .hw = &s4_vid_pll.hw }, >> + { .fw_name = "fclk_div4", }, >> + { .fw_name = "fclk_div3", }, >> +}; >> + >> +static struct clk_regmap s4_pwm_a_mux = { >> + .data = &(struct clk_regmap_mux_data) { >> + .offset = CLKCTRL_PWM_CLK_AB_CTRL, >> + .mask = 0x3, >> + .shift = 9, >> + }, >> + .hw.init = &(struct clk_init_data){ >> + .name = "pwm_a_mux", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = s4_pwm_parent_data, >> + .num_parents = ARRAY_SIZE(s4_pwm_parent_data), >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. >> + */ > > Same here ... this is really going to far. > >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >> + > >> + >> +static struct clk_regmap s4_saradc_mux = { >> + .data = &(struct clk_regmap_mux_data) { >> + .offset = CLKCTRL_SAR_CLK_CTRL, >> + .mask = 0x3, >> + .shift = 9, >> + }, >> + .hw.init = &(struct clk_init_data){ >> + .name = "saradc_mux", >> + .ops = &clk_regmap_mux_ops, >> + .parent_data = (const struct clk_parent_data []) { >> + { .fw_name = "xtal", }, >> + { .hw = &s4_sys_clk.hw }, >> + }, >> + .num_parents = 2, >> + /* >> + * When the driver uses this clock, needs to specify the patent clock >> + * he wants in the dts. >> + */ > > For each clock type, if this flag is going to be used, I'd like a clear > explanation about why it is use-case dependent and why you need manual > control over this. Same applies to all the occurence. > >> + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, >> + }, >> +}; >