Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1296996ybc; Tue, 19 Nov 2019 18:12:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwy9xhR+5+QlkdzSZoR5VXRbtLd/xk0DvRJ6KsjMChh7rNelxrXdKzbFJIlAl2ds9EHvbI7 X-Received: by 2002:a17:906:a411:: with SMTP id l17mr1536931ejz.274.1574215926486; Tue, 19 Nov 2019 18:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574215926; cv=none; d=google.com; s=arc-20160816; b=g/bp51VzOb2h+zfr3IsmTTCLVofZHfHKLRNFMd+Z8cQupN2abT2RKvGyJa7OlW/jfG ECgniSXxDwCrr2B1XNxWHos7Ms9yA9jNWe1vhKvfM+pGsRV7X5MpiFew7XGHRkraL/6r 6RjPQnR+ku6oixgitBFMuad+26WHoRB+GsUYUw5JgFavCTJprUuMguiKX4j+qzPk+kkU 76cArzRyuMivaJuvOS9gsVprDA6xjbdJyc5fpdyhwYjDjCE2Mv5zLSTCzl7YywseHOOz p+I33aTH9idI8mlFZ3I1UPqLtvNaL0Yt/o5vqgREMzXAIgWX/327H0GR2mFnrr3z9rEf A82w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=Hh0GOH7eI+EM4yn3akfErP+WyL6jbWR7To3u3en8SIo=; b=q3AwybtSjwLImMgnNKNL4jiDCMgVu6aLUPS0ABChuhjzXP7xCGx5fTP4zRIX14BM7d /i7ZATjQMbH6yJDlbuk+8g3EPZSvEiq9TQYCOMz3Yx5DekY2UnUUCZ3XMC0QE8ZTw6iY wXtqDJBIvPhFw1S1nrr/4zUQbjCEQQKfS0kWn29Dz45ae/daxfeQRS1f9GRZmS5WRTxv 3ZLYvK02c+Vgcx8AmKApwxJ3feNqNkGe94f0eRBgOBq38BGSC6cAh4zboTqbP5EOwd8C Cxpn6rC4QU5fgV/zqCJHrKAzyRgEhnGOJTIwDZBHH9uP04SjeCczVoHL2oh9HlxSr5sW wdzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Z0GrXToO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7si6598249edq.134.2019.11.19.18.11.41; Tue, 19 Nov 2019 18:12:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Z0GrXToO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbfKTCK0 (ORCPT + 99 others); Tue, 19 Nov 2019 21:10:26 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:10518 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbfKTCK0 (ORCPT ); Tue, 19 Nov 2019 21:10:26 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 19 Nov 2019 18:10:27 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 19 Nov 2019 18:10:24 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 19 Nov 2019 18:10:24 -0800 Received: from [10.2.175.254] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 20 Nov 2019 02:10:22 +0000 Subject: Re: [PATCH v1 06/17] soc: pmc: Add blink output clock registration to Tegra PMC From: Sowjanya Komatineni To: Dmitry Osipenko , , , , , , , , CC: , , , , , , , , , , , , , , , , , References: <1574146234-3871-1-git-send-email-skomatineni@nvidia.com> <1574146234-3871-7-git-send-email-skomatineni@nvidia.com> <95f3e928-3e08-abbd-5617-d3570a592c06@gmail.com> <87dca259-1f3f-6e74-db45-411ed84afba7@nvidia.com> Message-ID: <53c70a0a-edf0-b806-1320-215affba4c28@nvidia.com> Date: Tue, 19 Nov 2019 18:09:34 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <87dca259-1f3f-6e74-db45-411ed84afba7@nvidia.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1574215827; bh=Hh0GOH7eI+EM4yn3akfErP+WyL6jbWR7To3u3en8SIo=; h=X-PGP-Universal:Subject:From:To:CC:References:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:X-Originating-IP: X-ClientProxiedBy:Content-Type:Content-Transfer-Encoding: Content-Language; b=Z0GrXToOU+Vy64rqC1jX65K2twoBOnObV/c2SJp14BVJtIyagbX5EME0bks8+k+Jb I9cc+1GKzojlzO9/gspVpYyrpvhXVJ2aQRK6so56D6gK9Ecdr+WKggmDj2rQtrQjoB vQbMZ86064Kl0mv/ztAjsbasmPP67Xd9w5DzrRuXesMrKiqJqvxHGd4BrlCstZonSC X+HV3vucBvB+4KtUuTMXQcBtfUlKsHsrZFFyll74AUAMyHWGZgAwQyEoHSBwRLSQWh Rm1ze6oZkAJCEUJ4CTutvOY+HGmCUrWnT9r+Jgod6QokDYMZTmczmOHOEtCU5drP/a Yct8TTZhr4XcA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/19 2:13 PM, Sowjanya Komatineni wrote: > > On 11/19/19 11:34 AM, Dmitry Osipenko wrote: >> 19.11.2019 09:50, Sowjanya Komatineni =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>> Tegra PMC has blink control to output 32 Khz clock out to Tegra >>> blink pin. Blink pad DPD state and enable controls are part of >>> Tegra PMC register space. >>> >>> Currently Tegra clock driver registers blink control by passing >>> PMC address and register offset to clk_register_gate which performs >>> direct PMC access during clk_ops and with this when PMC is in secure >>> mode, any access from non-secure world does not go through. >>> >>> This patch adds blink control registration to the Tegra PMC driver >>> using PMC specific clock gate operations that use tegra_pmc_readl >>> and tegra_pmc_writel to support both secure mode and non-secure >>> mode PMC register access. >>> >>> Signed-off-by: Sowjanya Komatineni >>> --- >>> =C2=A0 drivers/soc/tegra/pmc.c | 42=20 >>> ++++++++++++++++++++++++++++++++++++++++++ >>> =C2=A0 1 file changed, 42 insertions(+) >>> >>> diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c >>> index 790a6619ba32..095e89c7fa3f 100644 >>> --- a/drivers/soc/tegra/pmc.c >>> +++ b/drivers/soc/tegra/pmc.c >>> @@ -61,12 +61,15 @@ >>> =C2=A0 #define=C2=A0 PMC_CNTRL_SYSCLK_OE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 BIT(11) /* system clock enable */ >>> =C2=A0 #define=C2=A0 PMC_CNTRL_SYSCLK_POLARITY=C2=A0=C2=A0=C2=A0 BIT(10= ) /* sys clk polarity */ >>> =C2=A0 #define=C2=A0 PMC_CNTRL_PWRREQ_POLARITY=C2=A0=C2=A0=C2=A0 BIT(8) >>> +#define=C2=A0 PMC_CNTRL_BLINK_EN=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 BIT(7) >>> =C2=A0 #define=C2=A0 PMC_CNTRL_MAIN_RST=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 BIT(4) >>> =C2=A0 =C2=A0 #define PMC_WAKE_MASK=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x0c >>> =C2=A0 #define PMC_WAKE_LEVEL=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 0x10 >>> =C2=A0 #define PMC_WAKE_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 0x14 >>> =C2=A0 #define PMC_SW_WAKE_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x18 >>> +#define PMC_DPD_PADS_ORIDE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0= x1c >>> +#define=C2=A0 PMC_DPD_PADS_ORIDE_BLINK=C2=A0=C2=A0=C2=A0 BIT(20) >>> =C2=A0 =C2=A0 #define DPD_SAMPLE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 0x020 >>> =C2=A0 #define=C2=A0 DPD_SAMPLE_ENABLE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 BIT(0) >>> @@ -79,6 +82,7 @@ >>> =C2=A0 =C2=A0 #define PWRGATE_STATUS=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x38 >>> =C2=A0 +#define TEGRA210_PMC_BLINK_TIMER=C2=A0=C2=A0=C2=A0 0x40 >>> =C2=A0 #define PMC_IMPL_E_33V_PWR=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 0x40 >>> =C2=A0 =C2=A0 #define PMC_PWR_DET=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x48 >>> @@ -247,6 +251,9 @@ static struct pmc_clk_init_data=20 >>> tegra_pmc_clks_data[] =3D { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PMC_CLK(3, 22, 18, 0, 0), >>> =C2=A0 }; >>> =C2=A0 +static struct pmc_clk_gate blink_override; >>> +static struct pmc_clk_gate blink; >>> + >>> =C2=A0 struct tegra_powergate { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct generic_pm_domain genpd; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct tegra_pmc *pmc; >>> @@ -359,6 +366,7 @@ struct tegra_pmc_soc { >>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct pmc_clk_init_data *pmc_clk= s_data; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int num_pmc_clks; >>> +=C2=A0=C2=A0=C2=A0 bool has_blink_output; >>> =C2=A0 }; >>> =C2=A0 =C2=A0 static const char * const tegra186_reset_sources[] =3D { >>> @@ -2530,6 +2538,9 @@ static void tegra_pmc_clock_register(struct=20 >>> tegra_pmc *pmc, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* each pmc clock output has a mux and a= gate */ >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 num_clks =3D pmc->soc->num_pmc_clks * 2; >>> =C2=A0 +=C2=A0=C2=A0=C2=A0 if (pmc->soc->has_blink_output) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 num_clks +=3D 1; >>> + >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!num_clks) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; >>> =C2=A0 @@ -2604,6 +2615,30 @@ static void tegra_pmc_clock_register(stru= ct=20 >>> tegra_pmc *pmc, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> =C2=A0 +=C2=A0=C2=A0=C2=A0 if (pmc->soc->has_blink_output) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tegra_pmc_writel(pmc, 0x0, = TEGRA210_PMC_BLINK_TIMER); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 clkgate =3D tegra_pmc_clk_g= ate_register("blink_override", >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "clk_32k", >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0, &blink_override, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 P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2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PMC_CNTRL, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 PMC_CNTRL_BLINK_EN, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 NULL); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(clkgate)) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 got= o free_clks; >>> + >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 clk_data->clks[TEGRA_PMC_CL= K_BLINK] =3D clkgate; >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 clk_register_clkdev(clkgate= , "blink", NULL); >> Tegra20 has pmc->soc->num_pmc_clks =3D 0 and thus num_clks =3D 1, while >> TEGRA_PMC_CLK_BLINK =3D 6. >> >> BTW, Tegra30 doesn't boot. I'll try again v2. >> >> Please fix it all in v2. Compile-test all patches and make at least a >> boot-test where possible. >> >> [snip] > > looks like blink output should be enabled during boot for Tegra20 and=20 > Tegra30 platforms. > > Will add init state for blink output in V2. Will compile for old=20 > Tegra's as well and will try boot-test. > Hi Thierry, With implementation of PMC helper functions for PLLM overrides and PLLE=20 IDDQ PMC programming to use in clock driver during registering PLLM,=20 need tegra_pmc_early_init to happen prior to tegra_clk_init as all=20 helper functions have to use tegra_pmc_soc for flags and pmc register=20 offset. Any suggestion?