Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp179471ybc; Mon, 18 Nov 2019 22:54:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwFA9W9ggGjh8iynscRLsMidXDdiw7O2/By/1pY7Z2RZ+H1zicfItd79I6iCjLESP04QtyL X-Received: by 2002:a17:906:27ca:: with SMTP id k10mr31604296ejc.242.1574146446485; Mon, 18 Nov 2019 22:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574146446; cv=none; d=google.com; s=arc-20160816; b=v5I6aK4th5Ya83Dh2HLOwB6BbRctiQBnletUCr0d4UJilqTOydaQp11pS7enB/b4f0 KMkwxv274ZeHrcr35eTk8TMKTtUgPTndVieCXZZsa2SksBufIPD+9H2y1RLoSCYMAj6/ 1s0w+P6b/CRwqawpMmW1VkPqA4Lew+4JxWZTJOA9X77TnImpHM//eLfAPkqGGeJsTD01 ExVJ25ISWZ5jNMy6Y3dkXwZHaC31GkoeIzOd8x/SZcLbtBlU7tWVGPFwQoTotIOo7D1K x5nJGvZx63LdJBhrx1eCaYoU0O1c4u5MOkb4tD4yOjXOe1irb1dYQBJN421mGZn83l8B UhxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=JnMWx14B2+KdSTbFmzqXRALLV0BcZZnbLPSZ/dEK/vY=; b=aUR5RtdO96CcpN1bves1DQo/dZHrmNKa3ZeEH2TmfaYAYMEiDnp8Tzaz7N5yRgX284 r59X5HC5ubWVa9Q+2/oTUyuBRsh7VQbh2FI5k5m/iriVX2y4vH4FpBOzO+mUQx/4mmUT OicdK09OAhlN1Zol4gITo8sIxrRcuxMtXu7myps10FfofTaPpZWuKFb1hM/JQF7az1y6 4rV9R3yFIxoAbiRj+zE42OiVW00ODs6TFE5wyWwLuJ5gXrE8E4i3hkj+oPiRqZD6X4Tq GHX+MTjGut+HDnq+Wys5WgoqidwHJMi4yF8KyxA7qNeIwrIEdMaGZSmxZY1NCT0r4DC2 pNUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Dk1ufo0P; 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 d6si10497016edo.349.2019.11.18.22.53.42; Mon, 18 Nov 2019 22:54: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=Dk1ufo0P; 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 S1727742AbfKSGvF (ORCPT + 99 others); Tue, 19 Nov 2019 01:51:05 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:8281 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbfKSGvD (ORCPT ); Tue, 19 Nov 2019 01:51:03 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 18 Nov 2019 22:51:01 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 18 Nov 2019 22:51:00 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 18 Nov 2019 22:51:00 -0800 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 19 Nov 2019 06:51:00 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 19 Nov 2019 06:51:00 +0000 Received: from skomatineni-linux.nvidia.com (Not Verified[10.2.175.254]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 18 Nov 2019 22:51:00 -0800 From: Sowjanya Komatineni To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , Subject: [PATCH v1 06/17] soc: pmc: Add blink output clock registration to Tegra PMC Date: Mon, 18 Nov 2019 22:50:23 -0800 Message-ID: <1574146234-3871-7-git-send-email-skomatineni@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1574146234-3871-1-git-send-email-skomatineni@nvidia.com> References: <1574146234-3871-1-git-send-email-skomatineni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1574146261; bh=JnMWx14B2+KdSTbFmzqXRALLV0BcZZnbLPSZ/dEK/vY=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=Dk1ufo0POS0cwprhRR2uVG/tOqwMnnz2jgHs8oVyCHDEo+r0fEGEm+EIMkvRvFUg1 8cTvwe+oFbG6DshYx3SoXFSxOj5MrRCOwOKR+kxe/ugcZWezQUKcCKAO4mH2z17ZvK hoM1wY7jl6C1uYEI/8In1OGl2KGMcR6N0i2tL1Q448AJrSmozdEIstUAjbr38A6UZJ UMSmuwfyUYGtL6k23Y/R1fbfYZG3U2QNN1SkV/b7m0Yf48W0KchLp2FGBebowmNvZY 25Jj7qQIU4Ty5BW2J4mwsSWEvecYzggE/i7ptjf9+UEy9jhU8JwMoqpWjVaaat1duy Yz4sH0f0Oyl0A== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/soc/tegra/pmc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 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 @@ #define PMC_CNTRL_SYSCLK_OE BIT(11) /* system clock enable */ #define PMC_CNTRL_SYSCLK_POLARITY BIT(10) /* sys clk polarity */ #define PMC_CNTRL_PWRREQ_POLARITY BIT(8) +#define PMC_CNTRL_BLINK_EN BIT(7) #define PMC_CNTRL_MAIN_RST BIT(4) #define PMC_WAKE_MASK 0x0c #define PMC_WAKE_LEVEL 0x10 #define PMC_WAKE_STATUS 0x14 #define PMC_SW_WAKE_STATUS 0x18 +#define PMC_DPD_PADS_ORIDE 0x1c +#define PMC_DPD_PADS_ORIDE_BLINK BIT(20) #define DPD_SAMPLE 0x020 #define DPD_SAMPLE_ENABLE BIT(0) @@ -79,6 +82,7 @@ #define PWRGATE_STATUS 0x38 +#define TEGRA210_PMC_BLINK_TIMER 0x40 #define PMC_IMPL_E_33V_PWR 0x40 #define PMC_PWR_DET 0x48 @@ -247,6 +251,9 @@ static struct pmc_clk_init_data tegra_pmc_clks_data[] = { PMC_CLK(3, 22, 18, 0, 0), }; +static struct pmc_clk_gate blink_override; +static struct pmc_clk_gate blink; + struct tegra_powergate { struct generic_pm_domain genpd; struct tegra_pmc *pmc; @@ -359,6 +366,7 @@ struct tegra_pmc_soc { struct pmc_clk_init_data *pmc_clks_data; unsigned int num_pmc_clks; + bool has_blink_output; }; static const char * const tegra186_reset_sources[] = { @@ -2530,6 +2538,9 @@ static void tegra_pmc_clock_register(struct tegra_pmc *pmc, /* each pmc clock output has a mux and a gate */ num_clks = pmc->soc->num_pmc_clks * 2; + if (pmc->soc->has_blink_output) + num_clks += 1; + if (!num_clks) return; @@ -2604,6 +2615,30 @@ static void tegra_pmc_clock_register(struct tegra_pmc *pmc, } } + if (pmc->soc->has_blink_output) { + tegra_pmc_writel(pmc, 0x0, TEGRA210_PMC_BLINK_TIMER); + clkgate = tegra_pmc_clk_gate_register("blink_override", + "clk_32k", + 0, &blink_override, + PMC_DPD_PADS_ORIDE, + PMC_DPD_PADS_ORIDE_BLINK, + NULL); + if (IS_ERR(clkgate)) + goto free_clks; + + clkgate = tegra_pmc_clk_gate_register("blink", + "blink_override", + 0, &blink, + PMC_CNTRL, + PMC_CNTRL_BLINK_EN, + NULL); + if (IS_ERR(clkgate)) + goto free_clks; + + clk_data->clks[TEGRA_PMC_CLK_BLINK] = clkgate; + clk_register_clkdev(clkgate, "blink", NULL); + } + of_clk_add_provider(np, of_clk_src_onecell_get, clk_data); return; @@ -2943,6 +2978,7 @@ static const struct tegra_pmc_soc tegra20_pmc_soc = { .num_reset_levels = 0, .pmc_clks_data = NULL, .num_pmc_clks = 0, + .has_blink_output = true, }; static const char * const tegra30_powergates[] = { @@ -2993,6 +3029,7 @@ static const struct tegra_pmc_soc tegra30_pmc_soc = { .num_reset_levels = 0, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = true, }; static const char * const tegra114_powergates[] = { @@ -3047,6 +3084,7 @@ static const struct tegra_pmc_soc tegra114_pmc_soc = { .num_reset_levels = 0, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = true, }; static const char * const tegra124_powergates[] = { @@ -3161,6 +3199,7 @@ static const struct tegra_pmc_soc tegra124_pmc_soc = { .num_reset_levels = 0, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = true, }; static const char * const tegra210_powergates[] = { @@ -3278,6 +3317,7 @@ static const struct tegra_pmc_soc tegra210_pmc_soc = { .wake_events = tegra210_wake_events, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = true, }; #define TEGRA186_IO_PAD_TABLE(_pad) \ @@ -3419,6 +3459,7 @@ static const struct tegra_pmc_soc tegra186_pmc_soc = { .wake_events = tegra186_wake_events, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = false, }; static const struct tegra_io_pad_soc tegra194_io_pads[] = { @@ -3496,6 +3537,7 @@ static const struct tegra_pmc_soc tegra194_pmc_soc = { .wake_events = tegra194_wake_events, .pmc_clks_data = tegra_pmc_clks_data, .num_pmc_clks = ARRAY_SIZE(tegra_pmc_clks_data), + .has_blink_output = false, }; static const struct of_device_id tegra_pmc_match[] = { -- 2.7.4