Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp391284pxu; Thu, 3 Dec 2020 02:57:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZVY7IgAoSYvE3m0AHyFZ9NkjZ/6nnoC3omFdRKQUF49hT4tzzxwP1c7SuaajS7yK+jats X-Received: by 2002:a17:906:ec9:: with SMTP id u9mr1983701eji.400.1606993073849; Thu, 03 Dec 2020 02:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606993073; cv=none; d=google.com; s=arc-20160816; b=oZ4Ctr/dpDhUOj0hgA3YifHUrKkaBcBlyioGyq6x4ORYGxOdqju+pYyrZQGaB91qNK yEpT8BMod6BP/YBItCwOGXm2XsCO6fIxRxZdX1FqPCDq0up0M2P8GSwOp9vuBCMt4pSA g9vFlqmCc9vTEVIlr6sY8Z8yF0ZNG6gH/6hze5ES/BSzpRxZc9UMIp9IpNHVESv5tErr Jhq3nhrn2wGUzz1RZusLy8AHyPI1ffveqs8FyLnYxOWkHKKRfKro3h+sZsyB573RKnGG JJZauoTYM7RQCZ3EhyKGI8yLPZRxJMM+SYDNkB9XAVp9d9MYfGUmRQDMnnujQD2ykd3j n3zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :autocrypt:from:references:cc:to:subject; bh=EP5/oHlktmkiLpAzly/CCeRU1l/INYIo0KbfxwjlnWM=; b=F2hl8UlskG1Z6CtBihoMeHwH4nwd1Iw1mlZbbJR34jdVD2M6/lX8g4FQ+NuxDene6e VtM8U1kIVgNSWT+TtQXtcHJVY+XWUWol+COSf0T1L4Y6D0ZKBCWvAU2xJwnwI6z132T+ O0W+ITrsPDqN6Np9Jai3MOstTDBgI6ATlR5hb8eQFM9jLSZhGcYx6C2ZX/FBV0xeHR+x Lv9QMTVYp/zXEbjvb3vPfJboyFBRW/oaCe6Z0K+hsL2Ne+kShSEh7WKybfnf9zsqt3k4 rckU1z6FQxjqFHbsgxWDUkqejd6GNor+xazvWGqUoK9LI8qjRFGDU/Daed4gZ30q6gZt jxHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr6si1024994ejc.319.2020.12.03.02.57.30; Thu, 03 Dec 2020 02:57:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388957AbgLCKyP (ORCPT + 99 others); Thu, 3 Dec 2020 05:54:15 -0500 Received: from foss.arm.com ([217.140.110.172]:36950 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388781AbgLCKyO (ORCPT ); Thu, 3 Dec 2020 05:54:14 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D53A2113E; Thu, 3 Dec 2020 02:53:27 -0800 (PST) Received: from [192.168.2.22] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D25003F66B; Thu, 3 Dec 2020 02:53:25 -0800 (PST) Subject: Re: [PATCH 4/8] clk: sunxi-ng: Add support for the Allwinner H616 R-CCU To: =?UTF-8?Q?Jernej_=c5=a0krabec?= , Maxime Ripard , Chen-Yu Tsai Cc: Icenowy Zheng , linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Linus Walleij , Rob Herring , Yangtao Li , linux-kernel@vger.kernel.org, Michael Turquette , Stephen Boyd , Philipp Zabel , linux-clk@vger.kernel.org References: <20201202135409.13683-1-andre.przywara@arm.com> <20201202135409.13683-5-andre.przywara@arm.com> <3151878.LmPXbFMbMm@kista> From: =?UTF-8?Q?Andr=c3=a9_Przywara?= Autocrypt: addr=andre.przywara@arm.com; prefer-encrypt=mutual; keydata= xsFNBFNPCKMBEAC+6GVcuP9ri8r+gg2fHZDedOmFRZPtcrMMF2Cx6KrTUT0YEISsqPoJTKld tPfEG0KnRL9CWvftyHseWTnU2Gi7hKNwhRkC0oBL5Er2hhNpoi8x4VcsxQ6bHG5/dA7ctvL6 kYvKAZw4X2Y3GTbAZIOLf+leNPiF9175S8pvqMPi0qu67RWZD5H/uT/TfLpvmmOlRzNiXMBm kGvewkBpL3R2clHquv7pB6KLoY3uvjFhZfEedqSqTwBVu/JVZZO7tvYCJPfyY5JG9+BjPmr+ REe2gS6w/4DJ4D8oMWKoY3r6ZpHx3YS2hWZFUYiCYovPxfj5+bOr78sg3JleEd0OB0yYtzTT esiNlQpCo0oOevwHR+jUiaZevM4xCyt23L2G+euzdRsUZcK/M6qYf41Dy6Afqa+PxgMEiDto ITEH3Dv+zfzwdeqCuNU0VOGrQZs/vrKOUmU/QDlYL7G8OIg5Ekheq4N+Ay+3EYCROXkstQnf YYxRn5F1oeVeqoh1LgGH7YN9H9LeIajwBD8OgiZDVsmb67DdF6EQtklH0ycBcVodG1zTCfqM AavYMfhldNMBg4vaLh0cJ/3ZXZNIyDlV372GmxSJJiidxDm7E1PkgdfCnHk+pD8YeITmSNyb 7qeU08Hqqh4ui8SSeUp7+yie9zBhJB5vVBJoO5D0MikZAODIDwARAQABzS1BbmRyZSBQcnp5 d2FyYSAoQVJNKSA8YW5kcmUucHJ6eXdhcmFAYXJtLmNvbT7CwXsEEwECACUCGwMGC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ifdHyF1J5qeePEhgTA+BaUbiUZf i4aIXCH3Wv6K Organization: ARM Ltd. Message-ID: Date: Thu, 3 Dec 2020 10:52:56 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <3151878.LmPXbFMbMm@kista> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/12/2020 18:20, Jernej Škrabec wrote: Hi, > Dne sreda, 02. december 2020 ob 14:54:05 CET je Andre Przywara napisal(a): >> The clocks itself are identical to the H6 R-CCU, it's just that the H616 >> has not all of them implemented (or connected). >> >> Signed-off-by: Andre Przywara >> --- >> drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 47 +++++++++++++++++++++++++- >> drivers/clk/sunxi-ng/ccu-sun50i-h6-r.h | 3 +- >> 2 files changed, 48 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c >> index 50f8d1bc7046..119d1797f501 100644 >> --- a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c >> +++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c >> @@ -136,6 +136,15 @@ static struct ccu_common *sun50i_h6_r_ccu_clks[] = { >> &w1_clk.common, >> }; >> >> +static struct ccu_common *sun50i_h616_r_ccu_clks[] = { >> + &r_apb1_clk.common, >> + &r_apb2_clk.common, >> + &r_apb1_twd_clk.common, >> + &r_apb2_i2c_clk.common, >> + &r_apb1_ir_clk.common, >> + &ir_clk.common, >> +}; >> + >> static struct clk_hw_onecell_data sun50i_h6_r_hw_clks = { >> .hws = { >> [CLK_AR100] = &ar100_clk.common.hw, >> @@ -152,7 +161,20 @@ static struct clk_hw_onecell_data sun50i_h6_r_hw_clks = { >> [CLK_IR] = &ir_clk.common.hw, >> [CLK_W1] = &w1_clk.common.hw, >> }, >> - .num = CLK_NUMBER, >> + .num = CLK_NUMBER_H616, > > Above macro should be CLK_NUMBER_H6. Ouch, well spotted! >> +}; >> + >> +static struct clk_hw_onecell_data sun50i_h616_r_hw_clks = { >> + .hws = { >> + [CLK_R_AHB] = &r_ahb_clk.hw, >> + [CLK_R_APB1] = &r_apb1_clk.common.hw, >> + [CLK_R_APB2] = &r_apb2_clk.common.hw, >> + [CLK_R_APB1_TWD] = &r_apb1_twd_clk.common.hw, > > Do we know if TWD exists? I tested I2C and IR. What is your source for these > clocks? I poked around in this area, writing all Fs into those clock registers and checked which stuck. There are actually even more clocks still around there, though not all of the H6 (no PWM, for instance). For TWD: it's mentioned in the manual, the clock register is there and can be written to. The normal watchdog registers do not appear to work at 0x7020800 (they are RAZ/WI), but there is a counter at 0x7020820, which increments as long as those TWD clock gates are open. It stops when the clock bits are cleared. So that tells me that this clock is there and is working. I didn't have time yet to check the other (former) peripherals from that area. Cheers, Andre > > Best regards, > Jernej > >> + [CLK_R_APB2_I2C] = &r_apb2_i2c_clk.common.hw, >> + [CLK_R_APB1_IR] = &r_apb1_ir_clk.common.hw, >> + [CLK_IR] = &ir_clk.common.hw, >> + }, >> + .num = CLK_NUMBER_H616, >> }; >> >> static struct ccu_reset_map sun50i_h6_r_ccu_resets[] = { >> @@ -165,6 +187,12 @@ static struct ccu_reset_map sun50i_h6_r_ccu_resets[] = { >> [RST_R_APB1_W1] = { 0x1ec, BIT(16) }, >> }; >> >> +static struct ccu_reset_map sun50i_h616_r_ccu_resets[] = { >> + [RST_R_APB1_TWD] = { 0x12c, BIT(16) }, >> + [RST_R_APB2_I2C] = { 0x19c, BIT(16) }, >> + [RST_R_APB1_IR] = { 0x1cc, BIT(16) }, >> +}; >> + >> static const struct sunxi_ccu_desc sun50i_h6_r_ccu_desc = { >> .ccu_clks = sun50i_h6_r_ccu_clks, >> .num_ccu_clks = ARRAY_SIZE(sun50i_h6_r_ccu_clks), >> @@ -175,6 +203,16 @@ static const struct sunxi_ccu_desc sun50i_h6_r_ccu_desc = { >> .num_resets = ARRAY_SIZE(sun50i_h6_r_ccu_resets), >> }; >> >> +static const struct sunxi_ccu_desc sun50i_h616_r_ccu_desc = { >> + .ccu_clks = sun50i_h616_r_ccu_clks, >> + .num_ccu_clks = ARRAY_SIZE(sun50i_h616_r_ccu_clks), >> + >> + .hw_clks = &sun50i_h616_r_hw_clks, >> + >> + .resets = sun50i_h616_r_ccu_resets, >> + .num_resets = ARRAY_SIZE(sun50i_h616_r_ccu_resets), >> +}; >> + >> static void __init sunxi_r_ccu_init(struct device_node *node, >> const struct sunxi_ccu_desc *desc) >> { >> @@ -195,3 +233,10 @@ static void __init sun50i_h6_r_ccu_setup(struct device_node *node) >> } >> CLK_OF_DECLARE(sun50i_h6_r_ccu, "allwinner,sun50i-h6-r-ccu", >> sun50i_h6_r_ccu_setup); >> + >> +static void __init sun50i_h616_r_ccu_setup(struct device_node *node) >> +{ >> + sunxi_r_ccu_init(node, &sun50i_h616_r_ccu_desc); >> +} >> +CLK_OF_DECLARE(sun50i_h616_r_ccu, "allwinner,sun50i-h616-r-ccu", >> + sun50i_h616_r_ccu_setup); >> diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.h b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.h >> index 782117dc0b28..128302696ca1 100644 >> --- a/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.h >> +++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6-r.h >> @@ -14,6 +14,7 @@ >> >> #define CLK_R_APB2 3 >> >> -#define CLK_NUMBER (CLK_W1 + 1) >> +#define CLK_NUMBER_H6 (CLK_W1 + 1) >> +#define CLK_NUMBER_H616 (CLK_IR + 1) >> >> #endif /* _CCU_SUN50I_H6_R_H */ >> -- >> 2.17.5 >> >>