From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4148D209F51 for ; Mon, 3 Feb 2025 16:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738600636; cv=none; b=EIYJ+r+niXAM8YsAKywAYtQUIO7uRJbNfzyv53jb+/IIRmE7B4pmShZhGowCHjd0R7AR8xE39SwJS9kYhTQ+VaHK0YG9xxmpT/B5luUGXuWElXZsLwsSE1VDR9kEqspZu8XoKiMiKyu08HsRZ/4F974GXqmF1n+qGGsJj9UGXyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738600636; c=relaxed/simple; bh=S5xz3BOn2q5hEPeQurYXiPfbGl/GMz2S1iwPaT+H+7I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=GWaYS3vzoK+duF72BnI0qU+D1PHASGRE1+EOPT6L7pHgturfKItyv2mv1pfqqRlPhG3O+rF9ny6UJwMCLJ+UE93roOv2mVoygEKZXML4qcdVBLy3uhnd81bEG4A7y2T++DqspLtXWkZkRAWbhBcsnC3jPzt+gxvI4J9PCmmQAEQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=eqIlO/HO; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="eqIlO/HO" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20250203163712euoutp01db4be01c0506b29afcff119c76926b50~gwBBta13w1604616046euoutp01B for ; Mon, 3 Feb 2025 16:37:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20250203163712euoutp01db4be01c0506b29afcff119c76926b50~gwBBta13w1604616046euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1738600632; bh=/cjF2im7siOiRdn6B6izW0xKqowa+3BJEzUkFArNsjo=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=eqIlO/HOAFpoGziSEqaOMHHc+ydxjJJu8CpeLv0ufip4qyRX9/GVe4MwHyM18GO4p G5Htabhaa706MiR8mAA5vpe5FN9TkY04l613ObrzbTiQKPG4DHUXQM3TU5TaBHFGeS 9JUVGgJaBHcG8CnDnpnKYrsINeOmFOSXzWQODxQg= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20250203163712eucas1p196275d9f0ceacf6984a9f5673ad536bb~gwBBPupgn2798727987eucas1p1N; Mon, 3 Feb 2025 16:37:12 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id C1.B5.20397.8B0F0A76; Mon, 3 Feb 2025 16:37:12 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20250203163711eucas1p2ab0c98052dc0a04ce4987506bd35a049~gwBAlOVr90838708387eucas1p2D; Mon, 3 Feb 2025 16:37:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20250203163711eusmtrp25c9d58ffb8e37537f418fd4b3409e540~gwBAkaHwf0261902619eusmtrp2P; Mon, 3 Feb 2025 16:37:11 +0000 (GMT) X-AuditID: cbfec7f5-e59c770000004fad-81-67a0f0b809ad Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 64.52.19654.7B0F0A76; Mon, 3 Feb 2025 16:37:11 +0000 (GMT) Received: from [192.168.1.44] (unknown [106.210.136.40]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20250203163709eusmtip19af3cc094845c3ff2a93337b7ae89a3b~gwA_S6qf32821528215eusmtip1O; Mon, 3 Feb 2025 16:37:09 +0000 (GMT) Message-ID: Date: Mon, 3 Feb 2025 17:37:08 +0100 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 02/18] clk: thead: Add clock support for VO subsystem in T-Head TH1520 SoC To: Matt Coster , "mturquette@baylibre.com" , "sboyd@kernel.org" , "robh@kernel.org" , "krzk+dt@kernel.org" , "conor+dt@kernel.org" , "drew@pdp7.com" , "guoren@kernel.org" , "wefu@redhat.com" , "jassisinghbrar@gmail.com" , "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , Frank Binns , "maarten.lankhorst@linux.intel.com" , "mripard@kernel.org" , "tzimmermann@suse.de" , "airlied@gmail.com" , "simona@ffwll.ch" , "ulf.hansson@linaro.org" , "jszhang@kernel.org" , "p.zabel@pengutronix.de" , "m.szyprowski@samsung.com" Cc: "linux-clk@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "dri-devel@lists.freedesktop.org" , "linux-pm@vger.kernel.org" Content-Language: en-US From: Michal Wilczynski In-Reply-To: Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Sa0xTZx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lVWpRfnxRaU5q8SFGU2BgTGSWEk3OBybOvJJ4QzMDU0MTM0sDU0szYyVx XrYr59OEBNITS1KzU1MLUotg+pg4OKUamBadD7rj/1l//7y3gaz7TvfK3/qR5ajo0rVCouH6 p6m+tg6sBUVNdmfFfrH/uG1x1Kbec+WxG9maUu1di0+wCe2PyCu8e2TDj9OvDEOmMFkZ8pee dBDa92xxaA6L7ql7BvyTGy/9PV1lfGGnSna8auSNqw/qko//ehK6okLusubJvX/tz8lZW3qE cpq38h1/0DSRt8Te8arwe7ezaxUuuaZ8Z2K+++rfVZ9SfvUlLLnW5e2ruSz2VW7SSrXJbnNb XvXd8+fMZq3lzBba1UL19s5J7gzTo17z2U1xefe1q3nD1b9KH4VtBCaz3lXtuhSrer7hWrDF BJ51fOf+vsj/4tN15//RjVda/vE+mvnllBJLcUaioRZzUXEiAJshIF/kAwAA X-CMS-MailID: 20250203163711eucas1p2ab0c98052dc0a04ce4987506bd35a049 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20250128194827eucas1p25db822456e223563b8b411f77754c760 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20250128194827eucas1p25db822456e223563b8b411f77754c760 References: <20250128194816.2185326-1-m.wilczynski@samsung.com> <20250128194816.2185326-3-m.wilczynski@samsung.com> On 1/31/25 16:39, Matt Coster wrote: > On 28/01/2025 19:48, Michal Wilczynski wrote: >> The T-Head TH1520 SoC integrates a variety of clocks for its subsystems, >> including the Application Processor (AP) and the Video Output (VO) [1]. >> Up until now, the T-Head clock driver only supported AP clocks. >> >> This commit extends the driver to provide clock functionality for the VO >> subsystem. At this stage, the focus is on implementing the VO clock >> gates, as these are currently the most relevant and required components >> for enabling and disabling the VO subsystem functionality. Future >> enhancements may introduce additional VO-related clocks as necessary. >> >> Link: https://protect2.fireeye.com/v1/url?k=e2f52701-bd6e1e1e-e2f4ac4e-000babdfecba-2c98780e6a3b772c&q=1&e=4ed72090-09ae-4d99-9a05-caed33873a2b&u=https%3A%2F%2Fopenbeagle.org%2Fbeaglev-ahead%2Fbeaglev-ahead%2F-%2Fblob%2Fmain%2Fdocs%2FTH1520%2520System%2520User%2520Manual.pdf [1] >> >> Signed-off-by: Michal Wilczynski >> --- >> drivers/clk/thead/clk-th1520-ap.c | 197 +++++++++++++++++++++++++----- >> 1 file changed, 169 insertions(+), 28 deletions(-) >> >> diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c >> index 4c9555fc6184..57972589f120 100644 >> --- a/drivers/clk/thead/clk-th1520-ap.c >> +++ b/drivers/clk/thead/clk-th1520-ap.c >> @@ -847,6 +847,67 @@ static CCU_GATE(CLK_SRAM1, sram1_clk, "sram1", axi_aclk_pd, 0x20c, BIT(3), 0); >> static CCU_GATE(CLK_SRAM2, sram2_clk, "sram2", axi_aclk_pd, 0x20c, BIT(2), 0); >> static CCU_GATE(CLK_SRAM3, sram3_clk, "sram3", axi_aclk_pd, 0x20c, BIT(1), 0); >> >> +static CCU_GATE(CLK_AXI4_VO_ACLK, axi4_vo_aclk, "axi4-vo-aclk", >> + video_pll_clk_pd, 0x0, BIT(0), 0); >> +static CCU_GATE(CLK_GPU_CORE, gpu_core_clk, "gpu-core-clk", video_pll_clk_pd, >> + 0x0, BIT(3), 0); >> +static CCU_GATE(CLK_GPU_CFG_ACLK, gpu_cfg_aclk, "gpu-cfg-aclk", >> + video_pll_clk_pd, 0x0, BIT(4), 0); > > I see CORE and CFG clocks here; what about MEM? It's listed in the > linked TRM as BIT(2). It is however marked as 'Reserved' in manual, so I assumed I shouldn't touch it. Additionally referring to the vendor kernel, only two clocks are used to program the GPU [1] in the old non-upstream driver. [1] - https://github.com/revyos/thead-kernel/blob/lpi4a/drivers/gpu/drm/img-rogue/thead_sys.c#L400 > > Cheers, > Matt > >> +static CCU_GATE(CLK_DPU_PIXELCLK0, dpu0_pixelclk, "dpu0-pixelclk", >> + video_pll_clk_pd, 0x0, BIT(5), 0); >> +static CCU_GATE(CLK_DPU_PIXELCLK1, dpu1_pixelclk, "dpu1-pixelclk", >> + video_pll_clk_pd, 0x0, BIT(6), 0); >> +static CCU_GATE(CLK_DPU_HCLK, dpu_hclk, "dpu-hclk", video_pll_clk_pd, 0x0, >> + BIT(7), 0); >> +static CCU_GATE(CLK_DPU_ACLK, dpu_aclk, "dpu-aclk", video_pll_clk_pd, 0x0, >> + BIT(8), 0); >> +static CCU_GATE(CLK_DPU_CCLK, dpu_cclk, "dpu-cclk", video_pll_clk_pd, 0x0, >> + BIT(9), 0); >> +static CCU_GATE(CLK_HDMI_SFR, hdmi_sfr_clk, "hdmi-sfr-clk", video_pll_clk_pd, >> + 0x0, BIT(10), 0); >> +static CCU_GATE(CLK_HDMI_PCLK, hdmi_pclk, "hdmi-pclk", video_pll_clk_pd, 0x0, >> + BIT(11), 0); >> +static CCU_GATE(CLK_HDMI_CEC, hdmi_cec_clk, "hdmi-cec-clk", video_pll_clk_pd, >> + 0x0, BIT(12), 0); >> +static CCU_GATE(CLK_MIPI_DSI0_PCLK, mipi_dsi0_pclk, "mipi-dsi0-pclk", >> + video_pll_clk_pd, 0x0, BIT(13), 0); >> +static CCU_GATE(CLK_MIPI_DSI1_PCLK, mipi_dsi1_pclk, "mipi-dsi1-pclk", >> + video_pll_clk_pd, 0x0, BIT(14), 0); >> +static CCU_GATE(CLK_MIPI_DSI0_CFG, mipi_dsi0_cfg_clk, "mipi-dsi0-cfg-clk", >> + video_pll_clk_pd, 0x0, BIT(15), 0); >> +static CCU_GATE(CLK_MIPI_DSI1_CFG, mipi_dsi1_cfg_clk, "mipi-dsi1-cfg-clk", >> + video_pll_clk_pd, 0x0, BIT(16), 0); >> +static CCU_GATE(CLK_MIPI_DSI0_REFCLK, mipi_dsi0_refclk, "mipi-dsi0-refclk", >> + video_pll_clk_pd, 0x0, BIT(17), 0); >> +static CCU_GATE(CLK_MIPI_DSI1_REFCLK, mipi_dsi1_refclk, "mipi-dsi1-refclk", >> + video_pll_clk_pd, 0x0, BIT(18), 0); >> +static CCU_GATE(CLK_HDMI_I2S, hdmi_i2s_clk, "hdmi-i2s-clk", video_pll_clk_pd, >> + 0x0, BIT(19), 0); >> +static CCU_GATE(CLK_X2H_DPU1_ACLK, x2h_dpu1_aclk, "x2h-dpu1-aclk", >> + video_pll_clk_pd, 0x0, BIT(20), 0); >> +static CCU_GATE(CLK_X2H_DPU_ACLK, x2h_dpu_aclk, "x2h-dpu-aclk", >> + video_pll_clk_pd, 0x0, BIT(21), 0); >> +static CCU_GATE(CLK_AXI4_VO_PCLK, axi4_vo_pclk, "axi4-vo-pclk", >> + video_pll_clk_pd, 0x0, BIT(22), 0); >> +static CCU_GATE(CLK_IOPMP_VOSYS_DPU_PCLK, iopmp_vosys_dpu_pclk, >> + "iopmp-vosys-dpu-pclk", video_pll_clk_pd, 0x0, BIT(23), 0); >> +static CCU_GATE(CLK_IOPMP_VOSYS_DPU1_PCLK, iopmp_vosys_dpu1_pclk, >> + "iopmp-vosys-dpu1-pclk", video_pll_clk_pd, 0x0, BIT(24), 0); >> +static CCU_GATE(CLK_IOPMP_VOSYS_GPU_PCLK, iopmp_vosys_gpu_pclk, >> + "iopmp-vosys-gpu-pclk", video_pll_clk_pd, 0x0, BIT(25), 0); >> +static CCU_GATE(CLK_IOPMP_DPU1_ACLK, iopmp_dpu1_aclk, "iopmp-dpu1-aclk", >> + video_pll_clk_pd, 0x0, BIT(27), 0); >> +static CCU_GATE(CLK_IOPMP_DPU_ACLK, iopmp_dpu_aclk, "iopmp-dpu-aclk", >> + video_pll_clk_pd, 0x0, BIT(28), 0); >> +static CCU_GATE(CLK_IOPMP_GPU_ACLK, iopmp_gpu_aclk, "iopmp-gpu-aclk", >> + video_pll_clk_pd, 0x0, BIT(29), 0); >> +static CCU_GATE(CLK_MIPIDSI0_PIXCLK, mipi_dsi0_pixclk, "mipi-dsi0-pixclk", >> + video_pll_clk_pd, 0x0, BIT(30), 0); >> +static CCU_GATE(CLK_MIPIDSI1_PIXCLK, mipi_dsi1_pixclk, "mipi-dsi1-pixclk", >> + video_pll_clk_pd, 0x0, BIT(31), 0); >> +static CCU_GATE(CLK_HDMI_PIXCLK, hdmi_pixclk, "hdmi-pixclk", video_pll_clk_pd, >> + 0x4, BIT(0), 0); >> + >> static CLK_FIXED_FACTOR_HW(gmac_pll_clk_100m, "gmac-pll-clk-100m", >> &gmac_pll_clk.common.hw, 10, 1, 0); >> >> @@ -963,7 +1024,38 @@ static struct ccu_common *th1520_gate_clks[] = { >> &sram3_clk.common, >> }; >> >> -#define NR_CLKS (CLK_UART_SCLK + 1) >> +static struct ccu_common *th1520_vo_gate_clks[] = { >> + &axi4_vo_aclk.common, >> + &gpu_core_clk.common, >> + &gpu_cfg_aclk.common, >> + &dpu0_pixelclk.common, >> + &dpu1_pixelclk.common, >> + &dpu_hclk.common, >> + &dpu_aclk.common, >> + &dpu_cclk.common, >> + &hdmi_sfr_clk.common, >> + &hdmi_pclk.common, >> + &hdmi_cec_clk.common, >> + &mipi_dsi0_pclk.common, >> + &mipi_dsi1_pclk.common, >> + &mipi_dsi0_cfg_clk.common, >> + &mipi_dsi1_cfg_clk.common, >> + &mipi_dsi0_refclk.common, >> + &mipi_dsi1_refclk.common, >> + &hdmi_i2s_clk.common, >> + &x2h_dpu1_aclk.common, >> + &x2h_dpu_aclk.common, >> + &axi4_vo_pclk.common, >> + &iopmp_vosys_dpu_pclk.common, >> + &iopmp_vosys_dpu1_pclk.common, >> + &iopmp_vosys_gpu_pclk.common, >> + &iopmp_dpu1_aclk.common, >> + &iopmp_dpu_aclk.common, >> + &iopmp_gpu_aclk.common, >> + &mipi_dsi0_pixclk.common, >> + &mipi_dsi1_pixclk.common, >> + &hdmi_pixclk.common >> +}; >> >> static const struct regmap_config th1520_clk_regmap_config = { >> .reg_bits = 32, >> @@ -972,8 +1064,44 @@ static const struct regmap_config th1520_clk_regmap_config = { >> .fast_io = true, >> }; >> >> +struct th1520_plat_data { >> + struct ccu_common **th1520_pll_clks; >> + struct ccu_common **th1520_div_clks; >> + struct ccu_common **th1520_mux_clks; >> + struct ccu_common **th1520_gate_clks; >> + >> + int nr_clks; >> + int nr_pll_clks; >> + int nr_div_clks; >> + int nr_mux_clks; >> + int nr_gate_clks; >> +}; >> + >> +static const struct th1520_plat_data th1520_ap_platdata = { >> + .th1520_pll_clks = th1520_pll_clks, >> + .th1520_div_clks = th1520_div_clks, >> + .th1520_mux_clks = th1520_mux_clks, >> + .th1520_gate_clks = th1520_gate_clks, >> + >> + .nr_clks = CLK_UART_SCLK + 1, >> + >> + .nr_pll_clks = ARRAY_SIZE(th1520_pll_clks), >> + .nr_div_clks = ARRAY_SIZE(th1520_div_clks), >> + .nr_mux_clks = ARRAY_SIZE(th1520_mux_clks), >> + .nr_gate_clks = ARRAY_SIZE(th1520_gate_clks), >> +}; >> + >> +static const struct th1520_plat_data th1520_vo_platdata = { >> + .th1520_gate_clks = th1520_vo_gate_clks, >> + >> + .nr_clks = CLK_HDMI_PIXCLK + 1, >> + >> + .nr_gate_clks = ARRAY_SIZE(th1520_vo_gate_clks), >> +}; >> + >> static int th1520_clk_probe(struct platform_device *pdev) >> { >> + const struct th1520_plat_data *plat_data; >> struct device *dev = &pdev->dev; >> struct clk_hw_onecell_data *priv; >> >> @@ -982,11 +1110,17 @@ static int th1520_clk_probe(struct platform_device *pdev) >> struct clk_hw *hw; >> int ret, i; >> >> - priv = devm_kzalloc(dev, struct_size(priv, hws, NR_CLKS), GFP_KERNEL); >> + plat_data = device_get_match_data(&pdev->dev); >> + if (!plat_data) { >> + dev_err(&pdev->dev, "Error: No device match data found\n"); >> + return -ENODEV; >> + } >> + >> + priv = devm_kzalloc(dev, struct_size(priv, hws, plat_data->nr_clks), GFP_KERNEL); >> if (!priv) >> return -ENOMEM; >> >> - priv->num = NR_CLKS; >> + priv->num = plat_data->nr_clks; >> >> base = devm_platform_ioremap_resource(pdev, 0); >> if (IS_ERR(base)) >> @@ -996,35 +1130,35 @@ static int th1520_clk_probe(struct platform_device *pdev) >> if (IS_ERR(map)) >> return PTR_ERR(map); >> >> - for (i = 0; i < ARRAY_SIZE(th1520_pll_clks); i++) { >> - struct ccu_pll *cp = hw_to_ccu_pll(&th1520_pll_clks[i]->hw); >> + for (i = 0; i < plat_data->nr_pll_clks; i++) { >> + struct ccu_pll *cp = hw_to_ccu_pll(&plat_data->th1520_pll_clks[i]->hw); >> >> - th1520_pll_clks[i]->map = map; >> + plat_data->th1520_pll_clks[i]->map = map; >> >> - ret = devm_clk_hw_register(dev, &th1520_pll_clks[i]->hw); >> + ret = devm_clk_hw_register(dev, &plat_data->th1520_pll_clks[i]->hw); >> if (ret) >> return ret; >> >> priv->hws[cp->common.clkid] = &cp->common.hw; >> } >> >> - for (i = 0; i < ARRAY_SIZE(th1520_div_clks); i++) { >> - struct ccu_div *cd = hw_to_ccu_div(&th1520_div_clks[i]->hw); >> + for (i = 0; i < plat_data->nr_div_clks; i++) { >> + struct ccu_div *cd = hw_to_ccu_div(&plat_data->th1520_div_clks[i]->hw); >> >> - th1520_div_clks[i]->map = map; >> + plat_data->th1520_div_clks[i]->map = map; >> >> - ret = devm_clk_hw_register(dev, &th1520_div_clks[i]->hw); >> + ret = devm_clk_hw_register(dev, &plat_data->th1520_div_clks[i]->hw); >> if (ret) >> return ret; >> >> priv->hws[cd->common.clkid] = &cd->common.hw; >> } >> >> - for (i = 0; i < ARRAY_SIZE(th1520_mux_clks); i++) { >> - struct ccu_mux *cm = hw_to_ccu_mux(&th1520_mux_clks[i]->hw); >> + for (i = 0; i < plat_data->nr_mux_clks; i++) { >> + struct ccu_mux *cm = hw_to_ccu_mux(&plat_data->th1520_mux_clks[i]->hw); >> const struct clk_init_data *init = cm->common.hw.init; >> >> - th1520_mux_clks[i]->map = map; >> + plat_data->th1520_mux_clks[i]->map = map; >> hw = devm_clk_hw_register_mux_parent_data_table(dev, >> init->name, >> init->parent_data, >> @@ -1040,10 +1174,10 @@ static int th1520_clk_probe(struct platform_device *pdev) >> priv->hws[cm->common.clkid] = hw; >> } >> >> - for (i = 0; i < ARRAY_SIZE(th1520_gate_clks); i++) { >> - struct ccu_gate *cg = hw_to_ccu_gate(&th1520_gate_clks[i]->hw); >> + for (i = 0; i < plat_data->nr_gate_clks; i++) { >> + struct ccu_gate *cg = hw_to_ccu_gate(&plat_data->th1520_gate_clks[i]->hw); >> >> - th1520_gate_clks[i]->map = map; >> + plat_data->th1520_gate_clks[i]->map = map; >> >> hw = devm_clk_hw_register_gate_parent_data(dev, >> cg->common.hw.init->name, >> @@ -1057,19 +1191,21 @@ static int th1520_clk_probe(struct platform_device *pdev) >> priv->hws[cg->common.clkid] = hw; >> } >> >> - ret = devm_clk_hw_register(dev, &osc12m_clk.hw); >> - if (ret) >> - return ret; >> - priv->hws[CLK_OSC12M] = &osc12m_clk.hw; >> + if (plat_data == &th1520_ap_platdata) { >> + ret = devm_clk_hw_register(dev, &osc12m_clk.hw); >> + if (ret) >> + return ret; >> + priv->hws[CLK_OSC12M] = &osc12m_clk.hw; >> >> - ret = devm_clk_hw_register(dev, &gmac_pll_clk_100m.hw); >> - if (ret) >> - return ret; >> - priv->hws[CLK_PLL_GMAC_100M] = &gmac_pll_clk_100m.hw; >> + ret = devm_clk_hw_register(dev, &gmac_pll_clk_100m.hw); >> + if (ret) >> + return ret; >> + priv->hws[CLK_PLL_GMAC_100M] = &gmac_pll_clk_100m.hw; >> >> - ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); >> - if (ret) >> - return ret; >> + ret = devm_clk_hw_register(dev, &emmc_sdio_ref_clk.hw); >> + if (ret) >> + return ret; >> + } >> >> ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, priv); >> if (ret) >> @@ -1081,6 +1217,11 @@ static int th1520_clk_probe(struct platform_device *pdev) >> static const struct of_device_id th1520_clk_match[] = { >> { >> .compatible = "thead,th1520-clk-ap", >> + .data = &th1520_ap_platdata, >> + }, >> + { >> + .compatible = "thead,th1520-clk-vo", >> + .data = &th1520_vo_platdata, >> }, >> { /* sentinel */ }, >> }; >