blob: d5388c69aefe91cc5ecbbe6cfb5c10b2187d021f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: BSD-3-Clause
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +01002/*
3 * Clock drivers for Qualcomm APQ8096
4 *
5 * (C) Copyright 2017 Jorge Ramirez Ortiz <jorge.ramirez-ortiz@linaro.org>
6 *
7 * Based on Little Kernel driver, simplified
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +01008 */
9
10#include <common.h>
11#include <clk-uclass.h>
12#include <dm.h>
13#include <errno.h>
14#include <asm/io.h>
15#include <linux/bitops.h>
Caleb Connolly878b26a2023-11-07 12:40:59 +000016
17#include "clock-qcom.h"
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010018
19/* GPLL0 clock control registers */
20#define GPLL0_STATUS_ACTIVE BIT(30)
21#define APCS_GPLL_ENA_VOTE_GPLL0 BIT(0)
22
23static const struct bcr_regs sdc_regs = {
24 .cfg_rcgr = SDCC2_CFG_RCGR,
25 .cmd_rcgr = SDCC2_CMD_RCGR,
26 .M = SDCC2_M,
27 .N = SDCC2_N,
28 .D = SDCC2_D,
29};
30
Ramon Friedae299772018-05-16 12:13:39 +030031static const struct pll_vote_clk gpll0_vote_clk = {
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010032 .status = GPLL0_STATUS,
33 .status_bit = GPLL0_STATUS_ACTIVE,
34 .ena_vote = APCS_GPLL_ENA_VOTE,
35 .vote_bit = APCS_GPLL_ENA_VOTE_GPLL0,
36};
37
Ramon Frieded09eef2019-01-12 11:47:24 +020038static struct vote_clk gcc_blsp2_ahb_clk = {
39 .cbcr_reg = BLSP2_AHB_CBCR,
40 .ena_vote = APCS_CLOCK_BRANCH_ENA_VOTE,
41 .vote_bit = BIT(15),
42};
43
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010044static int clk_init_sdc(struct msm_clk_priv *priv, uint rate)
45{
46 int div = 3;
47
48 clk_enable_cbc(priv->base + SDCC2_AHB_CBCR);
49 clk_rcg_set_rate_mnd(priv->base, &sdc_regs, div, 0, 0,
50 CFG_CLK_SRC_GPLL0);
Ramon Friedae299772018-05-16 12:13:39 +030051 clk_enable_gpll0(priv->base, &gpll0_vote_clk);
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010052 clk_enable_cbc(priv->base + SDCC2_APPS_CBCR);
53
54 return rate;
55}
56
Ramon Frieded09eef2019-01-12 11:47:24 +020057static const struct bcr_regs uart2_regs = {
58 .cfg_rcgr = BLSP2_UART2_APPS_CFG_RCGR,
59 .cmd_rcgr = BLSP2_UART2_APPS_CMD_RCGR,
60 .M = BLSP2_UART2_APPS_M,
61 .N = BLSP2_UART2_APPS_N,
62 .D = BLSP2_UART2_APPS_D,
63};
64
65static int clk_init_uart(struct msm_clk_priv *priv)
66{
67 /* Enable AHB clock */
68 clk_enable_vote_clk(priv->base, &gcc_blsp2_ahb_clk);
69
70 /* 7372800 uart block clock @ GPLL0 */
71 clk_rcg_set_rate_mnd(priv->base, &uart2_regs, 1, 192, 15625,
72 CFG_CLK_SRC_GPLL0);
73
74 /* Vote for gpll0 clock */
75 clk_enable_gpll0(priv->base, &gpll0_vote_clk);
76
77 /* Enable core clk */
78 clk_enable_cbc(priv->base + BLSP2_UART2_APPS_CBCR);
79
80 return 0;
81}
82
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010083ulong msm_set_rate(struct clk *clk, ulong rate)
84{
85 struct msm_clk_priv *priv = dev_get_priv(clk->dev);
86
87 switch (clk->id) {
88 case 0: /* SDC1 */
89 return clk_init_sdc(priv, rate);
90 break;
Ramon Frieded09eef2019-01-12 11:47:24 +020091 case 4: /*UART2*/
92 return clk_init_uart(priv);
Jorge Ramirez-Ortiz9f2d1b22018-01-10 11:33:50 +010093 default:
94 return 0;
95 }
96}
Sumit Garg1d1ca6e2022-08-04 19:57:14 +053097
98int msm_enable(struct clk *clk)
99{
100 return 0;
101}