Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp105725rdb; Wed, 29 Nov 2023 22:38:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfJOT+RjfgyCnIN52gvVVyQ4+JVObckNViUqGHtN+tx/hnT9iniF8gCiRbPfPbKPyUUROO X-Received: by 2002:a05:6a21:3293:b0:18c:f9a7:6f75 with SMTP id yt19-20020a056a21329300b0018cf9a76f75mr7040543pzb.3.1701326308023; Wed, 29 Nov 2023 22:38:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701326308; cv=pass; d=google.com; s=arc-20160816; b=OwRlOpzwXJSWVUDp4UwctcUQIgXXptZRKmBk3xAPDNUTU03GPjY4x2f+91yASdpFpr lecgHdi9RqVdj6ZGjVwLqwBzsbh74jKST/D45+isgrNgkR0NklirWvOIpDQhVzngFXMh IRBXJfZZYvOwBmG+mWFfEVcyVC9fQchWLK+a/euB3MFJwrT34DORHHI4awFT2H2/swEN 9ToUBlYnRUOicGG9P0XEylFnw/58r0OG+CEbZPMSuOQC5UA14C5OQSnhdgAOW7xI3qSk /HYAqTvpVV+Lby2BqVbZkbhVpuGskvM2qEvXNMX3rOaRNF/6hOfu9u5JxVNEsSKzCs63 bAiA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:to:subject:user-agent:date:message-id :dkim-signature; bh=uFUnN5+Z/T+3Sn/F8l87wL+5TkPSteAcYQs0rK6dcaw=; fh=5EmbzvBHOVe5+uiYBp8VfLQy4eIAXU454xRG7FiMbOM=; b=G7KZ5veTvXxMWiEd3NNCnM1nqXM7ngzwz+V7QSBspMEaUhRICgtRDD/jwsOh7Hf2cP XyYnjHpUwFlSOWUYX6m2pSb1uDiIBkWgs60LlmCbB3lHpNjvaweUhY/h/daD4NSaDarv OjSk6ZImaxGcdhtgNFnikNQisd624DXgLJ+ntXBqpnSe/XCvvM9uUSSqtKObpslmDEfs zGRpFsCv1C0RzfS2gX2Houi32Ga2OrpQif5Xzq0/BYZxoRD9D7hguVHI/lxNMkE0esbG TZeHWWPmJKir2+j/BjU6KZB7Sni/ptvRp3/Wb+92hrL5IZ1t4JZgcce3I27EMMB6XPbl m/Kw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=er7nT+Lx; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cf9-20020a056a02084900b005b966a6960csi735371pgb.786.2023.11.29.22.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 22:38:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=er7nT+Lx; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B10C9826E370; Wed, 29 Nov 2023 22:38:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbjK3GiK (ORCPT + 99 others); Thu, 30 Nov 2023 01:38:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjK3GiI (ORCPT ); Thu, 30 Nov 2023 01:38:08 -0500 Received: from IND01-MAX-obe.outbound.protection.outlook.com (mail-maxind01olkn2089.outbound.protection.outlook.com [40.92.102.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A59CA3; Wed, 29 Nov 2023 22:38:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JEARcJvMZ15c644taDkHmqlE3IzKHnEqiPG5sHagibo8QysDwipwHo++801aPAxPSA5ic9PfcP6Je11vED4XgVOHSXTTGiLbAaTPfGvVmI5FEGwO3bPUU0VoCO79MDWydDj0xMHZ8DPhV7Zwa1NDJ8WQhEj62is+MErPD/Kb3pUnepVd+LpmYcSEsTey1sGDpasz0tfvShisAHl+Z3LIHtnliy1XQHevgq7ZPWWnsBkwJL0C5bBx16LGYakorX/NNKi+Z6ZL03U7JzTKUZfwgMHnFukxmmyT2LHpEsnjXZ2qWwvITxueqkamf1oaVAqpdZnNc7uAwr+UuZlHEPpCKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uFUnN5+Z/T+3Sn/F8l87wL+5TkPSteAcYQs0rK6dcaw=; b=Ag+cnllIVeMGa+xK+Qou2r1vfbK+ywNXASl65AFJR2aSz1+ZWaJh6wd85wQ8tqUzmC7jFvIz6tmBcrJtW/j0OaKAnM3f3+f8066wvt8NuK5gBKlkBdc9BocL1NnE6B9gQfJg9Ay8fghc2jezl6Rpf9sccjdXTiOE+QXsVLQS9shghj/RbBN5YK4RE8AG9hvCU/nWyuUU04thEsOHv3IBJLUVmiTTOqY+Z0USS4PiakkIfCb/FkdMJN/DMzLhmDfPvPMylzngODTUIKpI131RoMjgs9MTYtkaADkCFdqxVSPdMYVETcHNwqr/YrB7zIl7IQGaJ9WYarCUBp/R0T6iHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uFUnN5+Z/T+3Sn/F8l87wL+5TkPSteAcYQs0rK6dcaw=; b=er7nT+LxFYKmy96nXKw1gmLdasT0T1OfsmHzWWmwhOFa0x6N1I/JC+3zfdIdXmERcSVXXqpe3qAYyONKIwjMEZByyreFIgkr4oW9gF8F2wRazKgOkDz4hGTMObe6ZJT/mgkV17ZFMwiD5RvRow7JMeYWpXsPGEfaDzpvqIQynReB74Ca0Yy0JoVMluYchuzw/GuT0Sp0v3kIKyrKvtRaFkY2yVwUlLxmwljVets7TTIKdcNy+OozvGFPCnWp5ZtTMeZx5fNUNi+PPHqByTKw4uU6IUaSIRqDGq1SuqiBFtnngp/JmA+x9/ZD8p0Uz544iquMpmxE7bkldjsCues3Lw== Received: from MA0P287MB0332.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:ab::5) by PN0P287MB0133.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.24; Thu, 30 Nov 2023 06:38:04 +0000 Received: from MA0P287MB0332.INDP287.PROD.OUTLOOK.COM ([fe80::b1a7:eee7:e903:9ef3]) by MA0P287MB0332.INDP287.PROD.OUTLOOK.COM ([fe80::b1a7:eee7:e903:9ef3%7]) with mapi id 15.20.7046.024; Thu, 30 Nov 2023 06:38:04 +0000 Message-ID: Date: Thu, 30 Nov 2023 14:37:53 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] clk: sophgo: Add SG2042 clock generator driver To: Krzysztof Kozlowski , Chen Wang , aou@eecs.berkeley.edu, chao.wei@sophgo.com, conor@kernel.org, krzysztof.kozlowski+dt@linaro.org, mturquette@baylibre.com, palmer@dabbelt.com, paul.walmsley@sifive.com, richardcochran@gmail.com, robh+dt@kernel.org, sboyd@kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, haijiao.liu@sophgo.com, xiaoguang.xing@sophgo.com, guoren@kernel.org, jszhang@kernel.org, inochiama@outlook.com, samuel.holland@sifive.com References: <81d421c8-bfd6-42b5-9da1-f067792f8f48@linaro.org> <2a268c8c-ce55-4321-b390-092b8df61407@linaro.org> From: Chen Wang In-Reply-To: <2a268c8c-ce55-4321-b390-092b8df61407@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TMN: [Z5PXKzV1h+cLQJ62JNHz8SqROQojsi9c] X-ClientProxiedBy: SE2P216CA0014.KORP216.PROD.OUTLOOK.COM (2603:1096:101:117::11) To MA0P287MB0332.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:ab::5) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MA0P287MB0332:EE_|PN0P287MB0133:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f6c8fae-9f95-40c1-d67d-08dbf16ee6e1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xFfcfx6+Mx+qWbwUDl/Ltvv5SiE7+Mb41+EgF4iPKbWjVLPR/sI2NyvxkF7V3mi5bLwzD/BqYEB0H0XSdYXkBl88CeA4vmvF5aPzONYFZOpYzGNIT9WSYN8Ywknr+G3TtbyAWR6fFCb7SDdT3NUUntwX0+cfqCAZQie+5gTwXGGLallI4XgBicgdcln4PKYtlfSujnBMo4Ah19c6UCYO+svIoUO/IIKRw54NAlZykDstYrKLU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= =?utf-8?B?cVZOTXppR3lUSGNiY2JsSWtlNjhMbzF1OEs4Z2tRSnkxSllUeks1M2wyWjdS?= =?utf-8?B?VWI0Q0EycVFqa2M4QUxtR3lIZ3lySWlvSDNZUU1VZkhwRVI3eXV5bk9CSytn?= =?utf-8?B?VFd4bkxFMkJqUnBqVXoxaEJPK3BSeXpTL3RWM2pDeFkxWFd2S2o5cFFvOGdu?= =?utf-8?B?QjkrMWRSb091NS9Vb2V4ZkpzcVQyekZkYmR3QUkxYXRvQkJya2dXR0lvRnp0?= =?utf-8?Q?2NiZOA0pyoXh7w/tTWfinMcwLOZDKeWT57cQN7yDmfvM=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f6c8fae-9f95-40c1-d67d-08dbf16ee6e1 X-MS-Exchange-CrossTenant-AuthSource: MA0P287MB0332.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2023 06:38:04.1890 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN0P287MB0133 X-Spam-Status: No, score=1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FORGED_MUA_MOZILLA,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Wed, 29 Nov 2023 22:38:24 -0800 (PST) On 2023/11/27 17:16, Krzysztof Kozlowski wrote: > On 27/11/2023 09:07, Chen Wang wrote: >> On 2023/11/27 15:12, Krzysztof Kozlowski wrote: >>> On 27/11/2023 02:15, Chen Wang wrote: >>>> From: Chen Wang >>>> >>>> Add a driver for the SOPHGO SG2042 clock generator. >>>> >>>> Signed-off-by: Chen Wang >>> ... >>> >>> +} >>> + >>> +CLK_OF_DECLARE(sg2042_clk, "sophgo,sg2042-clkgen", sg2042_clk_init); >>> No, this should be platform device. It's a child of another device, so >>> you cannot use other way of init ordering. >> hi, Krzysztof, >> >> Thanks for your review. >> >> I don't quite understand your opinion. Do you mean CLK_OF_DECLARE is >> only used for platform device so it can not be use here? But I think > No, I meant you mix init ordering: you depend now on syscon earlier > initcall than CLK_OF_DECLARE. Do you remember which one is first? If > anything changes here, your driver is broken. There is no dependency, no > probe deferral. hi, Krzysztof, I found that the initcall method cannot be used for the clock controller of sg2042. We need to initialize the clock earlier because there are two dw-apb-timers in sg2042 (Sorry, I have not added them in the current DTS of sg2042, will be submitted later). The initialization of these timers (timer_probe()) depends on the initialization of the clock controller. If we use the initcall mechanism, it will be too late for the timer. So it seems better to use CLK_OF_DECLARE provided by CCF. I have a question here that I would like to discuss. The design of sg2042 is like this, according to the design of memorymap in its TRM: 070:3001:0000 ~ 070:3001:0FFF SYS_CTRL 4K 070:3001:1000 ~ 070:3001:1FFF PINMUX 4K 070:3001:2000 ~ 070:3001:2FFF CLOCK 4K 070:3001:3000 ~ 070:3001:3FFF RESET 4K But also as per hw design (I don't know why and I don't like it also :( ), some of the PLL/GATE CLOCK control registers are defined in the scope of SYS_CTRL, and others are defined in the scope of CLOCK. That's why in the current code, I define the syscon node corresponding to SYS_CTRL. The purpose is just to get the regmap of syscon for the clock controller through the device tree (through device_node_to_regmap()), so that the syscon defined in SYS_CTRL can be accessed through the regmap from clock. The clock controller driver itself does not rely on other operations of syscon. So based on the above analysis, is it still necessary for us to define the clock controller as a child node of syscon? In the version v1 of this patch, I actually did not define the clock controller as a child node of syscon, but only accessed syscon through the phandle method. [1] After more read of the TRM, I believe this situation only exists for clock. That is to say, there will be only one child node of clook under syscon. From a hardware design perspective, CLOCK and SYS_CTRL are two different blocks. So I think it is better to restore the original method, that is, restore clock and syscon to nodes of the same level, and let clock use phandle to access syscon. What do you think or do you have any good suggestions? Link: https://lore.kernel.org/linux-riscv/20231114-timid-habitat-a06e52e59c9c@squawk/#t [1] Thanks Chen > >> this driver is still for platform device though I move the clock >> controller node as a child of the system contoller node. System >> controller node is just a block of registers which are used to control >> some other platform devices ,such as clock controller, reset controller >> and pin controller for this SoC. >> >> And I also see other similar code in kernel, for example: >> drivers/clk/clk-k210.c. >> >> And I'm confused by your input "so you cannot use other way of init >> ordering." Do you mean "so you CAN use other way of init ordering"? > No, I meant you cannot. If you want to use syscon, then your driver > should be a proper driver. Therefore add a driver. > >> What's the other way of init ordering do you mean? > The one coming not from initcalls but driver model. > > Best regards, > Krzysztof >