blob: 7b55ef89baa53c7ef6d59c19dcf8c9287b773199 [file] [log] [blame]
Lee Jones82b0f4b2013-09-17 10:11:53 +01001/*
2 * Clock definitions for u8500 platform.
3 *
4 * Copyright (C) 2012 ST-Ericsson SA
5 * Author: Ulf Hansson <ulf.hansson@linaro.org>
6 *
7 * License terms: GNU General Public License (GPL) version 2
8 */
9
Lee Jonesdec759d2013-09-17 10:26:24 +010010#include <linux/of.h>
Lee Jones82b0f4b2013-09-17 10:11:53 +010011#include <linux/clk.h>
12#include <linux/clkdev.h>
13#include <linux/clk-provider.h>
14#include <linux/mfd/dbx500-prcmu.h>
15#include <linux/platform_data/clk-ux500.h>
16#include "clk.h"
17
Lee Jones2d080302013-09-17 10:31:39 +010018#define PRCC_NUM_PERIPH_CLUSTERS 6
19#define PRCC_PERIPHS_PER_CLUSTER 32
20
Lee Jonesf9fcb8e2013-09-17 10:30:19 +010021static struct clk *prcmu_clk[PRCMU_NUM_CLKS];
Lee Jones2d080302013-09-17 10:31:39 +010022static struct clk *prcc_pclk[(PRCC_NUM_PERIPH_CLUSTERS + 1) * PRCC_PERIPHS_PER_CLUSTER];
Lee Jones89da2df2013-09-17 10:33:05 +010023static struct clk *prcc_kclk[(PRCC_NUM_PERIPH_CLUSTERS + 1) * PRCC_PERIPHS_PER_CLUSTER];
Lee Jonesf9fcb8e2013-09-17 10:30:19 +010024
Lee Jonesb4bdc812013-07-22 13:13:01 +010025#define PRCC_SHOW(clk, base, bit) \
26 clk[(base * PRCC_PERIPHS_PER_CLUSTER) + bit]
Lee Jones2d080302013-09-17 10:31:39 +010027#define PRCC_PCLK_STORE(clk, base, bit) \
28 prcc_pclk[(base * PRCC_PERIPHS_PER_CLUSTER) + bit] = clk
Lee Jones89da2df2013-09-17 10:33:05 +010029#define PRCC_KCLK_STORE(clk, base, bit) \
30 prcc_kclk[(base * PRCC_PERIPHS_PER_CLUSTER) + bit] = clk
Lee Jonesb4bdc812013-07-22 13:13:01 +010031
Sachin Kamatc112c1d2014-01-15 11:13:26 +053032static struct clk *ux500_twocell_get(struct of_phandle_args *clkspec,
33 void *data)
Lee Jonesb4bdc812013-07-22 13:13:01 +010034{
35 struct clk **clk_data = data;
36 unsigned int base, bit;
37
38 if (clkspec->args_count != 2)
39 return ERR_PTR(-EINVAL);
40
41 base = clkspec->args[0];
42 bit = clkspec->args[1];
43
44 if (base != 1 && base != 2 && base != 3 && base != 5 && base != 6) {
45 pr_err("%s: invalid PRCC base %d\n", __func__, base);
46 return ERR_PTR(-EINVAL);
47 }
48
49 return PRCC_SHOW(clk_data, base, bit);
50}
51
Lee Jonesdec759d2013-09-17 10:26:24 +010052static const struct of_device_id u8500_clk_of_match[] = {
53 { .compatible = "stericsson,u8500-clks", },
54 { },
55};
56
Lee Jones82b0f4b2013-09-17 10:11:53 +010057void u8500_of_clk_init(u32 clkrst1_base, u32 clkrst2_base, u32 clkrst3_base,
58 u32 clkrst5_base, u32 clkrst6_base)
59{
60 struct prcmu_fw_version *fw_version;
Lee Jonesdec759d2013-09-17 10:26:24 +010061 struct device_node *np = NULL;
62 struct device_node *child = NULL;
Lee Jones82b0f4b2013-09-17 10:11:53 +010063 const char *sgaclk_parent = NULL;
Lee Jones4e334662013-09-17 10:35:00 +010064 struct clk *clk, *rtc_clk, *twd_clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +010065
Lee Jonesdec759d2013-09-17 10:26:24 +010066 if (of_have_populated_dt())
67 np = of_find_matching_node(NULL, u8500_clk_of_match);
68 if (!np) {
69 pr_err("Either DT or U8500 Clock node not found\n");
70 return;
71 }
72
Lee Jones82b0f4b2013-09-17 10:11:53 +010073 /* Clock sources */
74 clk = clk_reg_prcmu_gate("soc0_pll", NULL, PRCMU_PLLSOC0,
75 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +010076 prcmu_clk[PRCMU_PLLSOC0] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +010077
78 clk = clk_reg_prcmu_gate("soc1_pll", NULL, PRCMU_PLLSOC1,
79 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +010080 prcmu_clk[PRCMU_PLLSOC1] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +010081
82 clk = clk_reg_prcmu_gate("ddr_pll", NULL, PRCMU_PLLDDR,
83 CLK_IS_ROOT|CLK_IGNORE_UNUSED);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +010084 prcmu_clk[PRCMU_PLLDDR] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +010085
86 /* FIXME: Add sys, ulp and int clocks here. */
87
Lee Jonesd625a732013-09-17 10:34:24 +010088 rtc_clk = clk_register_fixed_rate(NULL, "rtc32k", "NULL",
Lee Jones82b0f4b2013-09-17 10:11:53 +010089 CLK_IS_ROOT|CLK_IGNORE_UNUSED,
90 32768);
91
92 /* PRCMU clocks */
93 fw_version = prcmu_get_fw_version();
94 if (fw_version != NULL) {
95 switch (fw_version->project) {
96 case PRCMU_FW_PROJECT_U8500_C2:
97 case PRCMU_FW_PROJECT_U8520:
98 case PRCMU_FW_PROJECT_U8420:
99 sgaclk_parent = "soc0_pll";
100 break;
101 default:
102 break;
103 }
104 }
105
106 if (sgaclk_parent)
107 clk = clk_reg_prcmu_gate("sgclk", sgaclk_parent,
108 PRCMU_SGACLK, 0);
109 else
110 clk = clk_reg_prcmu_gate("sgclk", NULL,
111 PRCMU_SGACLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100112 prcmu_clk[PRCMU_SGACLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100113
114 clk = clk_reg_prcmu_gate("uartclk", NULL, PRCMU_UARTCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100115 prcmu_clk[PRCMU_UARTCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100116
117 clk = clk_reg_prcmu_gate("msp02clk", NULL, PRCMU_MSP02CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100118 prcmu_clk[PRCMU_MSP02CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100119
120 clk = clk_reg_prcmu_gate("msp1clk", NULL, PRCMU_MSP1CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100121 prcmu_clk[PRCMU_MSP1CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100122
123 clk = clk_reg_prcmu_gate("i2cclk", NULL, PRCMU_I2CCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100124 prcmu_clk[PRCMU_I2CCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100125
126 clk = clk_reg_prcmu_gate("slimclk", NULL, PRCMU_SLIMCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100127 prcmu_clk[PRCMU_SLIMCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100128
129 clk = clk_reg_prcmu_gate("per1clk", NULL, PRCMU_PER1CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100130 prcmu_clk[PRCMU_PER1CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100131
132 clk = clk_reg_prcmu_gate("per2clk", NULL, PRCMU_PER2CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100133 prcmu_clk[PRCMU_PER2CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100134
135 clk = clk_reg_prcmu_gate("per3clk", NULL, PRCMU_PER3CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100136 prcmu_clk[PRCMU_PER3CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100137
138 clk = clk_reg_prcmu_gate("per5clk", NULL, PRCMU_PER5CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100139 prcmu_clk[PRCMU_PER5CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100140
141 clk = clk_reg_prcmu_gate("per6clk", NULL, PRCMU_PER6CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100142 prcmu_clk[PRCMU_PER6CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100143
144 clk = clk_reg_prcmu_gate("per7clk", NULL, PRCMU_PER7CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100145 prcmu_clk[PRCMU_PER7CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100146
147 clk = clk_reg_prcmu_scalable("lcdclk", NULL, PRCMU_LCDCLK, 0,
148 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100149 prcmu_clk[PRCMU_LCDCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100150
151 clk = clk_reg_prcmu_opp_gate("bmlclk", NULL, PRCMU_BMLCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100152 prcmu_clk[PRCMU_BMLCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100153
154 clk = clk_reg_prcmu_scalable("hsitxclk", NULL, PRCMU_HSITXCLK, 0,
155 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100156 prcmu_clk[PRCMU_HSITXCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100157
158 clk = clk_reg_prcmu_scalable("hsirxclk", NULL, PRCMU_HSIRXCLK, 0,
159 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100160 prcmu_clk[PRCMU_HSIRXCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100161
162 clk = clk_reg_prcmu_scalable("hdmiclk", NULL, PRCMU_HDMICLK, 0,
163 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100164 prcmu_clk[PRCMU_HDMICLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100165
166 clk = clk_reg_prcmu_gate("apeatclk", NULL, PRCMU_APEATCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100167 prcmu_clk[PRCMU_APEATCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100168
169 clk = clk_reg_prcmu_gate("apetraceclk", NULL, PRCMU_APETRACECLK,
170 CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100171 prcmu_clk[PRCMU_APETRACECLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100172
173 clk = clk_reg_prcmu_gate("mcdeclk", NULL, PRCMU_MCDECLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100174 prcmu_clk[PRCMU_MCDECLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100175
176 clk = clk_reg_prcmu_opp_gate("ipi2cclk", NULL, PRCMU_IPI2CCLK,
177 CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100178 prcmu_clk[PRCMU_IPI2CCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100179
180 clk = clk_reg_prcmu_gate("dsialtclk", NULL, PRCMU_DSIALTCLK,
181 CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100182 prcmu_clk[PRCMU_DSIALTCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100183
184 clk = clk_reg_prcmu_gate("dmaclk", NULL, PRCMU_DMACLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100185 prcmu_clk[PRCMU_DMACLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100186
187 clk = clk_reg_prcmu_gate("b2r2clk", NULL, PRCMU_B2R2CLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100188 prcmu_clk[PRCMU_B2R2CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100189
190 clk = clk_reg_prcmu_scalable("tvclk", NULL, PRCMU_TVCLK, 0,
191 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100192 prcmu_clk[PRCMU_TVCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100193
194 clk = clk_reg_prcmu_gate("sspclk", NULL, PRCMU_SSPCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100195 prcmu_clk[PRCMU_SSPCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100196
197 clk = clk_reg_prcmu_gate("rngclk", NULL, PRCMU_RNGCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100198 prcmu_clk[PRCMU_RNGCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100199
200 clk = clk_reg_prcmu_gate("uiccclk", NULL, PRCMU_UICCCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100201 prcmu_clk[PRCMU_UICCCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100202
203 clk = clk_reg_prcmu_gate("timclk", NULL, PRCMU_TIMCLK, CLK_IS_ROOT);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100204 prcmu_clk[PRCMU_TIMCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100205
206 clk = clk_reg_prcmu_opp_volt_scalable("sdmmcclk", NULL, PRCMU_SDMMCCLK,
207 100000000,
208 CLK_IS_ROOT|CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100209 prcmu_clk[PRCMU_SDMMCCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100210
211 clk = clk_reg_prcmu_scalable("dsi_pll", "hdmiclk",
212 PRCMU_PLLDSI, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100213 prcmu_clk[PRCMU_PLLDSI] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100214
215 clk = clk_reg_prcmu_scalable("dsi0clk", "dsi_pll",
216 PRCMU_DSI0CLK, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100217 prcmu_clk[PRCMU_DSI0CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100218
219 clk = clk_reg_prcmu_scalable("dsi1clk", "dsi_pll",
220 PRCMU_DSI1CLK, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100221 prcmu_clk[PRCMU_DSI1CLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100222
223 clk = clk_reg_prcmu_scalable("dsi0escclk", "tvclk",
224 PRCMU_DSI0ESCCLK, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100225 prcmu_clk[PRCMU_DSI0ESCCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100226
227 clk = clk_reg_prcmu_scalable("dsi1escclk", "tvclk",
228 PRCMU_DSI1ESCCLK, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100229 prcmu_clk[PRCMU_DSI1ESCCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100230
231 clk = clk_reg_prcmu_scalable("dsi2escclk", "tvclk",
232 PRCMU_DSI2ESCCLK, 0, CLK_SET_RATE_GATE);
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100233 prcmu_clk[PRCMU_DSI2ESCCLK] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100234
235 clk = clk_reg_prcmu_scalable_rate("armss", NULL,
236 PRCMU_ARMSS, 0, CLK_IS_ROOT|CLK_IGNORE_UNUSED);
Lee Jones257015a2013-09-18 16:09:38 +0100237 prcmu_clk[PRCMU_ARMSS] = clk;
Lee Jones82b0f4b2013-09-17 10:11:53 +0100238
Lee Jones4e334662013-09-17 10:35:00 +0100239 twd_clk = clk_register_fixed_factor(NULL, "smp_twd", "armss",
Lee Jones82b0f4b2013-09-17 10:11:53 +0100240 CLK_IGNORE_UNUSED, 1, 2);
241
242 /*
243 * FIXME: Add special handled PRCMU clocks here:
244 * 1. clkout0yuv, use PRCMU as parent + need regulator + pinctrl.
245 * 2. ab9540_clkout1yuv, see clkout0yuv
246 */
247
248 /* PRCC P-clocks */
249 clk = clk_reg_prcc_pclk("p1_pclk0", "per1clk", clkrst1_base,
250 BIT(0), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100251 PRCC_PCLK_STORE(clk, 1, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100252
253 clk = clk_reg_prcc_pclk("p1_pclk1", "per1clk", clkrst1_base,
254 BIT(1), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100255 PRCC_PCLK_STORE(clk, 1, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100256
257 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", clkrst1_base,
258 BIT(2), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100259 PRCC_PCLK_STORE(clk, 1, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100260
261 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", clkrst1_base,
262 BIT(3), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100263 PRCC_PCLK_STORE(clk, 1, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100264
265 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", clkrst1_base,
266 BIT(4), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100267 PRCC_PCLK_STORE(clk, 1, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100268
269 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", clkrst1_base,
270 BIT(5), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100271 PRCC_PCLK_STORE(clk, 1, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100272
273 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", clkrst1_base,
274 BIT(6), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100275 PRCC_PCLK_STORE(clk, 1, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100276
277 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", clkrst1_base,
278 BIT(7), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100279 PRCC_PCLK_STORE(clk, 1, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100280
281 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", clkrst1_base,
282 BIT(8), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100283 PRCC_PCLK_STORE(clk, 1, 8);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100284
285 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", clkrst1_base,
286 BIT(9), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100287 PRCC_PCLK_STORE(clk, 1, 9);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100288
289 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", clkrst1_base,
290 BIT(10), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100291 PRCC_PCLK_STORE(clk, 1, 10);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100292
293 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", clkrst1_base,
294 BIT(11), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100295 PRCC_PCLK_STORE(clk, 1, 11);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100296
297 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", clkrst2_base,
298 BIT(0), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100299 PRCC_PCLK_STORE(clk, 2, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100300
301 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", clkrst2_base,
302 BIT(1), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100303 PRCC_PCLK_STORE(clk, 2, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100304
305 clk = clk_reg_prcc_pclk("p2_pclk2", "per2clk", clkrst2_base,
306 BIT(2), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100307 PRCC_PCLK_STORE(clk, 2, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100308
309 clk = clk_reg_prcc_pclk("p2_pclk3", "per2clk", clkrst2_base,
310 BIT(3), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100311 PRCC_PCLK_STORE(clk, 2, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100312
313 clk = clk_reg_prcc_pclk("p2_pclk4", "per2clk", clkrst2_base,
314 BIT(4), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100315 PRCC_PCLK_STORE(clk, 2, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100316
317 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", clkrst2_base,
318 BIT(5), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100319 PRCC_PCLK_STORE(clk, 2, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100320
321 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", clkrst2_base,
322 BIT(6), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100323 PRCC_PCLK_STORE(clk, 2, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100324
325 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", clkrst2_base,
326 BIT(7), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100327 PRCC_PCLK_STORE(clk, 2, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100328
329 clk = clk_reg_prcc_pclk("p2_pclk8", "per2clk", clkrst2_base,
330 BIT(8), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100331 PRCC_PCLK_STORE(clk, 2, 8);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100332
333 clk = clk_reg_prcc_pclk("p2_pclk9", "per2clk", clkrst2_base,
334 BIT(9), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100335 PRCC_PCLK_STORE(clk, 2, 9);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100336
337 clk = clk_reg_prcc_pclk("p2_pclk10", "per2clk", clkrst2_base,
338 BIT(10), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100339 PRCC_PCLK_STORE(clk, 2, 10);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100340
341 clk = clk_reg_prcc_pclk("p2_pclk11", "per2clk", clkrst2_base,
342 BIT(11), 0);
Linus Walleijf5ff9a12013-10-18 10:56:14 +0200343 PRCC_PCLK_STORE(clk, 2, 11);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100344
345 clk = clk_reg_prcc_pclk("p2_pclk12", "per2clk", clkrst2_base,
346 BIT(12), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100347 PRCC_PCLK_STORE(clk, 2, 12);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100348
349 clk = clk_reg_prcc_pclk("p3_pclk0", "per3clk", clkrst3_base,
350 BIT(0), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100351 PRCC_PCLK_STORE(clk, 3, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100352
353 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", clkrst3_base,
354 BIT(1), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100355 PRCC_PCLK_STORE(clk, 3, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100356
357 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", clkrst3_base,
358 BIT(2), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100359 PRCC_PCLK_STORE(clk, 3, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100360
361 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", clkrst3_base,
362 BIT(3), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100363 PRCC_PCLK_STORE(clk, 3, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100364
365 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", clkrst3_base,
366 BIT(4), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100367 PRCC_PCLK_STORE(clk, 3, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100368
369 clk = clk_reg_prcc_pclk("p3_pclk5", "per3clk", clkrst3_base,
370 BIT(5), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100371 PRCC_PCLK_STORE(clk, 3, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100372
373 clk = clk_reg_prcc_pclk("p3_pclk6", "per3clk", clkrst3_base,
374 BIT(6), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100375 PRCC_PCLK_STORE(clk, 3, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100376
377 clk = clk_reg_prcc_pclk("p3_pclk7", "per3clk", clkrst3_base,
378 BIT(7), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100379 PRCC_PCLK_STORE(clk, 3, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100380
381 clk = clk_reg_prcc_pclk("p3_pclk8", "per3clk", clkrst3_base,
382 BIT(8), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100383 PRCC_PCLK_STORE(clk, 3, 8);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100384
385 clk = clk_reg_prcc_pclk("p5_pclk0", "per5clk", clkrst5_base,
386 BIT(0), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100387 PRCC_PCLK_STORE(clk, 5, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100388
389 clk = clk_reg_prcc_pclk("p5_pclk1", "per5clk", clkrst5_base,
390 BIT(1), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100391 PRCC_PCLK_STORE(clk, 5, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100392
393 clk = clk_reg_prcc_pclk("p6_pclk0", "per6clk", clkrst6_base,
394 BIT(0), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100395 PRCC_PCLK_STORE(clk, 6, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100396
397 clk = clk_reg_prcc_pclk("p6_pclk1", "per6clk", clkrst6_base,
398 BIT(1), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100399 PRCC_PCLK_STORE(clk, 6, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100400
401 clk = clk_reg_prcc_pclk("p6_pclk2", "per6clk", clkrst6_base,
402 BIT(2), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100403 PRCC_PCLK_STORE(clk, 6, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100404
405 clk = clk_reg_prcc_pclk("p6_pclk3", "per6clk", clkrst6_base,
406 BIT(3), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100407 PRCC_PCLK_STORE(clk, 6, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100408
409 clk = clk_reg_prcc_pclk("p6_pclk4", "per6clk", clkrst6_base,
410 BIT(4), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100411 PRCC_PCLK_STORE(clk, 6, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100412
413 clk = clk_reg_prcc_pclk("p6_pclk5", "per6clk", clkrst6_base,
414 BIT(5), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100415 PRCC_PCLK_STORE(clk, 6, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100416
417 clk = clk_reg_prcc_pclk("p6_pclk6", "per6clk", clkrst6_base,
418 BIT(6), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100419 PRCC_PCLK_STORE(clk, 6, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100420
421 clk = clk_reg_prcc_pclk("p6_pclk7", "per6clk", clkrst6_base,
422 BIT(7), 0);
Lee Jones2d080302013-09-17 10:31:39 +0100423 PRCC_PCLK_STORE(clk, 6, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100424
425 /* PRCC K-clocks
426 *
427 * FIXME: Some drivers requires PERPIH[n| to be automatically enabled
428 * by enabling just the K-clock, even if it is not a valid parent to
429 * the K-clock. Until drivers get fixed we might need some kind of
430 * "parent muxed join".
431 */
432
433 /* Periph1 */
434 clk = clk_reg_prcc_kclk("p1_uart0_kclk", "uartclk",
435 clkrst1_base, BIT(0), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100436 PRCC_KCLK_STORE(clk, 1, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100437
438 clk = clk_reg_prcc_kclk("p1_uart1_kclk", "uartclk",
439 clkrst1_base, BIT(1), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100440 PRCC_KCLK_STORE(clk, 1, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100441
442 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk",
443 clkrst1_base, BIT(2), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100444 PRCC_KCLK_STORE(clk, 1, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100445
446 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk",
447 clkrst1_base, BIT(3), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100448 PRCC_KCLK_STORE(clk, 1, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100449
450 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk",
451 clkrst1_base, BIT(4), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100452 PRCC_KCLK_STORE(clk, 1, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100453
454 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk",
455 clkrst1_base, BIT(5), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100456 PRCC_KCLK_STORE(clk, 1, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100457
458 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk",
459 clkrst1_base, BIT(6), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100460 PRCC_KCLK_STORE(clk, 1, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100461
462 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk",
463 clkrst1_base, BIT(8), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100464 PRCC_KCLK_STORE(clk, 1, 8);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100465
466 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk",
467 clkrst1_base, BIT(9), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100468 PRCC_KCLK_STORE(clk, 1, 9);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100469
470 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk",
471 clkrst1_base, BIT(10), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100472 PRCC_KCLK_STORE(clk, 1, 10);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100473
474 /* Periph2 */
475 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk",
476 clkrst2_base, BIT(0), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100477 PRCC_KCLK_STORE(clk, 2, 0);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100478
479 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk",
480 clkrst2_base, BIT(2), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100481 PRCC_KCLK_STORE(clk, 2, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100482
483 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk",
484 clkrst2_base, BIT(3), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100485 PRCC_KCLK_STORE(clk, 2, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100486
487 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk",
488 clkrst2_base, BIT(4), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100489 PRCC_KCLK_STORE(clk, 2, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100490
491 clk = clk_reg_prcc_kclk("p2_sdi3_kclk", "sdmmcclk",
492 clkrst2_base, BIT(5), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100493 PRCC_KCLK_STORE(clk, 2, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100494
495 /* Note that rate is received from parent. */
496 clk = clk_reg_prcc_kclk("p2_ssirx_kclk", "hsirxclk",
497 clkrst2_base, BIT(6),
498 CLK_SET_RATE_GATE|CLK_SET_RATE_PARENT);
Lee Jones89da2df2013-09-17 10:33:05 +0100499 PRCC_KCLK_STORE(clk, 2, 6);
500
Lee Jones82b0f4b2013-09-17 10:11:53 +0100501 clk = clk_reg_prcc_kclk("p2_ssitx_kclk", "hsitxclk",
502 clkrst2_base, BIT(7),
503 CLK_SET_RATE_GATE|CLK_SET_RATE_PARENT);
Lee Jones89da2df2013-09-17 10:33:05 +0100504 PRCC_KCLK_STORE(clk, 2, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100505
506 /* Periph3 */
507 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk",
508 clkrst3_base, BIT(1), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100509 PRCC_KCLK_STORE(clk, 3, 1);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100510
511 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk",
512 clkrst3_base, BIT(2), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100513 PRCC_KCLK_STORE(clk, 3, 2);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100514
515 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk",
516 clkrst3_base, BIT(3), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100517 PRCC_KCLK_STORE(clk, 3, 3);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100518
519 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk",
520 clkrst3_base, BIT(4), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100521 PRCC_KCLK_STORE(clk, 3, 4);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100522
523 clk = clk_reg_prcc_kclk("p3_ske_kclk", "rtc32k",
524 clkrst3_base, BIT(5), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100525 PRCC_KCLK_STORE(clk, 3, 5);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100526
527 clk = clk_reg_prcc_kclk("p3_uart2_kclk", "uartclk",
528 clkrst3_base, BIT(6), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100529 PRCC_KCLK_STORE(clk, 3, 6);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100530
531 clk = clk_reg_prcc_kclk("p3_sdi5_kclk", "sdmmcclk",
532 clkrst3_base, BIT(7), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100533 PRCC_KCLK_STORE(clk, 3, 7);
Lee Jones82b0f4b2013-09-17 10:11:53 +0100534
535 /* Periph6 */
536 clk = clk_reg_prcc_kclk("p3_rng_kclk", "rngclk",
537 clkrst6_base, BIT(0), CLK_SET_RATE_GATE);
Lee Jones89da2df2013-09-17 10:33:05 +0100538 PRCC_KCLK_STORE(clk, 6, 0);
Lee Jonesdec759d2013-09-17 10:26:24 +0100539
540 for_each_child_of_node(np, child) {
Lee Jonesf9fcb8e2013-09-17 10:30:19 +0100541 static struct clk_onecell_data clk_data;
542
543 if (!of_node_cmp(child->name, "prcmu-clock")) {
544 clk_data.clks = prcmu_clk;
545 clk_data.clk_num = ARRAY_SIZE(prcmu_clk);
546 of_clk_add_provider(child, of_clk_src_onecell_get, &clk_data);
547 }
Lee Jones2d080302013-09-17 10:31:39 +0100548 if (!of_node_cmp(child->name, "prcc-periph-clock"))
549 of_clk_add_provider(child, ux500_twocell_get, prcc_pclk);
Lee Jones89da2df2013-09-17 10:33:05 +0100550
551 if (!of_node_cmp(child->name, "prcc-kernel-clock"))
552 of_clk_add_provider(child, ux500_twocell_get, prcc_kclk);
Lee Jonesd625a732013-09-17 10:34:24 +0100553
554 if (!of_node_cmp(child->name, "rtc32k-clock"))
555 of_clk_add_provider(child, of_clk_src_simple_get, rtc_clk);
Lee Jones4e334662013-09-17 10:35:00 +0100556
557 if (!of_node_cmp(child->name, "smp-twd-clock"))
558 of_clk_add_provider(child, of_clk_src_simple_get, twd_clk);
Lee Jonesdec759d2013-09-17 10:26:24 +0100559 }
Lee Jones82b0f4b2013-09-17 10:11:53 +0100560}