diff options
author | Richard Zhu <Hong-Xing.Zhu@freescale.com> | 2011-02-28 06:32:03 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-03-07 13:29:19 -0500 |
commit | 359219025e20a3ad61f081a82e0feec0583aca9b (patch) | |
tree | 560c563d32ea1e91839814480b54c137360e8ae4 /arch/arm/mach-mx5 | |
parent | a77dd2aa92388d61f7344a32b06fd1de70e71928 (diff) |
ARM: imx51/53: add sdhc3/4 clock
Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx5')
-rw-r--r-- | arch/arm/mach-mx5/clock-mx51-mx53.c | 140 | ||||
-rw-r--r-- | arch/arm/mach-mx5/crm_regs.h | 7 |
2 files changed, 146 insertions, 1 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c index 8164b1dd952..652ace41382 100644 --- a/arch/arm/mach-mx5/clock-mx51-mx53.c +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c | |||
@@ -42,6 +42,9 @@ static struct clk usboh3_clk; | |||
42 | static struct clk emi_fast_clk; | 42 | static struct clk emi_fast_clk; |
43 | static struct clk ipu_clk; | 43 | static struct clk ipu_clk; |
44 | static struct clk mipi_hsc1_clk; | 44 | static struct clk mipi_hsc1_clk; |
45 | static struct clk esdhc1_clk; | ||
46 | static struct clk esdhc2_clk; | ||
47 | static struct clk esdhc3_mx53_clk; | ||
45 | 48 | ||
46 | #define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ | 49 | #define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */ |
47 | 50 | ||
@@ -1143,10 +1146,80 @@ CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1) | |||
1143 | CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1) | 1146 | CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1) |
1144 | CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1) | 1147 | CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1) |
1145 | 1148 | ||
1149 | /* mx51 specific */ | ||
1146 | CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2) | 1150 | CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2) |
1147 | CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2) | 1151 | CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2) |
1148 | CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2) | 1152 | CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2) |
1149 | 1153 | ||
1154 | static int clk_esdhc3_set_parent(struct clk *clk, struct clk *parent) | ||
1155 | { | ||
1156 | u32 reg; | ||
1157 | |||
1158 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1159 | if (parent == &esdhc1_clk) | ||
1160 | reg &= ~MXC_CCM_CSCMR1_ESDHC3_CLK_SEL; | ||
1161 | else if (parent == &esdhc2_clk) | ||
1162 | reg |= MXC_CCM_CSCMR1_ESDHC3_CLK_SEL; | ||
1163 | else | ||
1164 | return -EINVAL; | ||
1165 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1166 | |||
1167 | return 0; | ||
1168 | } | ||
1169 | |||
1170 | static int clk_esdhc4_set_parent(struct clk *clk, struct clk *parent) | ||
1171 | { | ||
1172 | u32 reg; | ||
1173 | |||
1174 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1175 | if (parent == &esdhc1_clk) | ||
1176 | reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1177 | else if (parent == &esdhc2_clk) | ||
1178 | reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1179 | else | ||
1180 | return -EINVAL; | ||
1181 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1182 | |||
1183 | return 0; | ||
1184 | } | ||
1185 | |||
1186 | /* mx53 specific */ | ||
1187 | static int clk_esdhc2_mx53_set_parent(struct clk *clk, struct clk *parent) | ||
1188 | { | ||
1189 | u32 reg; | ||
1190 | |||
1191 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1192 | if (parent == &esdhc1_clk) | ||
1193 | reg &= ~MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL; | ||
1194 | else if (parent == &esdhc3_mx53_clk) | ||
1195 | reg |= MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL; | ||
1196 | else | ||
1197 | return -EINVAL; | ||
1198 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1199 | |||
1200 | return 0; | ||
1201 | } | ||
1202 | |||
1203 | CLK_GET_RATE(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1204 | CLK_SET_PARENT(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1205 | CLK_SET_RATE(esdhc3_mx53, 1, ESDHC3_MX53) | ||
1206 | |||
1207 | static int clk_esdhc4_mx53_set_parent(struct clk *clk, struct clk *parent) | ||
1208 | { | ||
1209 | u32 reg; | ||
1210 | |||
1211 | reg = __raw_readl(MXC_CCM_CSCMR1); | ||
1212 | if (parent == &esdhc1_clk) | ||
1213 | reg &= ~MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1214 | else if (parent == &esdhc3_mx53_clk) | ||
1215 | reg |= MXC_CCM_CSCMR1_ESDHC4_CLK_SEL; | ||
1216 | else | ||
1217 | return -EINVAL; | ||
1218 | __raw_writel(reg, MXC_CCM_CSCMR1); | ||
1219 | |||
1220 | return 0; | ||
1221 | } | ||
1222 | |||
1150 | #define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \ | 1223 | #define DEFINE_CLOCK_FULL(name, i, er, es, gr, sr, e, d, p, s) \ |
1151 | static struct clk name = { \ | 1224 | static struct clk name = { \ |
1152 | .id = i, \ | 1225 | .id = i, \ |
@@ -1251,9 +1324,62 @@ DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET, | |||
1251 | clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk); | 1324 | clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk); |
1252 | DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET, | 1325 | DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET, |
1253 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | 1326 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); |
1327 | DEFINE_CLOCK_FULL(esdhc3_ipg_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG4_OFFSET, | ||
1328 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1329 | DEFINE_CLOCK_FULL(esdhc4_ipg_clk, 3, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG6_OFFSET, | ||
1330 | NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); | ||
1331 | |||
1332 | /* mx51 specific */ | ||
1254 | DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET, | 1333 | DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET, |
1255 | clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk); | 1334 | clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk); |
1256 | 1335 | ||
1336 | static struct clk esdhc3_clk = { | ||
1337 | .id = 2, | ||
1338 | .parent = &esdhc1_clk, | ||
1339 | .set_parent = clk_esdhc3_set_parent, | ||
1340 | .enable_reg = MXC_CCM_CCGR3, | ||
1341 | .enable_shift = MXC_CCM_CCGRx_CG5_OFFSET, | ||
1342 | .enable = _clk_max_enable, | ||
1343 | .disable = _clk_max_disable, | ||
1344 | .secondary = &esdhc3_ipg_clk, | ||
1345 | }; | ||
1346 | static struct clk esdhc4_clk = { | ||
1347 | .id = 3, | ||
1348 | .parent = &esdhc1_clk, | ||
1349 | .set_parent = clk_esdhc4_set_parent, | ||
1350 | .enable_reg = MXC_CCM_CCGR3, | ||
1351 | .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, | ||
1352 | .enable = _clk_max_enable, | ||
1353 | .disable = _clk_max_disable, | ||
1354 | .secondary = &esdhc4_ipg_clk, | ||
1355 | }; | ||
1356 | |||
1357 | /* mx53 specific */ | ||
1358 | static struct clk esdhc2_mx53_clk = { | ||
1359 | .id = 2, | ||
1360 | .parent = &esdhc1_clk, | ||
1361 | .set_parent = clk_esdhc2_mx53_set_parent, | ||
1362 | .enable_reg = MXC_CCM_CCGR3, | ||
1363 | .enable_shift = MXC_CCM_CCGRx_CG3_OFFSET, | ||
1364 | .enable = _clk_max_enable, | ||
1365 | .disable = _clk_max_disable, | ||
1366 | .secondary = &esdhc3_ipg_clk, | ||
1367 | }; | ||
1368 | |||
1369 | DEFINE_CLOCK_MAX(esdhc3_mx53_clk, 2, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG5_OFFSET, | ||
1370 | clk_esdhc3_mx53, &pll2_sw_clk, &esdhc2_ipg_clk); | ||
1371 | |||
1372 | static struct clk esdhc4_mx53_clk = { | ||
1373 | .id = 3, | ||
1374 | .parent = &esdhc1_clk, | ||
1375 | .set_parent = clk_esdhc4_mx53_set_parent, | ||
1376 | .enable_reg = MXC_CCM_CCGR3, | ||
1377 | .enable_shift = MXC_CCM_CCGRx_CG7_OFFSET, | ||
1378 | .enable = _clk_max_enable, | ||
1379 | .disable = _clk_max_disable, | ||
1380 | .secondary = &esdhc4_ipg_clk, | ||
1381 | }; | ||
1382 | |||
1257 | DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk); | 1383 | DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk); |
1258 | DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk); | 1384 | DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk); |
1259 | DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk); | 1385 | DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk); |
@@ -1312,6 +1438,8 @@ static struct clk_lookup mx51_lookups[] = { | |||
1312 | _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) | 1438 | _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) |
1313 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) | 1439 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) |
1314 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) | 1440 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) |
1441 | _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_clk) | ||
1442 | _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_clk) | ||
1315 | _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) | 1443 | _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) |
1316 | _REGISTER_CLOCK(NULL, "iim_clk", iim_clk) | 1444 | _REGISTER_CLOCK(NULL, "iim_clk", iim_clk) |
1317 | _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk) | 1445 | _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk) |
@@ -1332,7 +1460,9 @@ static struct clk_lookup mx53_lookups[] = { | |||
1332 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) | 1460 | _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) |
1333 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) | 1461 | _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) |
1334 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) | 1462 | _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) |
1335 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_clk) | 1463 | _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc2_mx53_clk) |
1464 | _REGISTER_CLOCK("sdhci-esdhc-imx.2", NULL, esdhc3_mx53_clk) | ||
1465 | _REGISTER_CLOCK("sdhci-esdhc-imx.3", NULL, esdhc4_mx53_clk) | ||
1336 | _REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk) | 1466 | _REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk) |
1337 | _REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk) | 1467 | _REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk) |
1338 | _REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk) | 1468 | _REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk) |
@@ -1425,6 +1555,14 @@ int __init mx53_clocks_init(unsigned long ckil, unsigned long osc, | |||
1425 | mx53_revision(); | 1555 | mx53_revision(); |
1426 | clk_disable(&iim_clk); | 1556 | clk_disable(&iim_clk); |
1427 | 1557 | ||
1558 | /* Set SDHC parents to be PLL2 */ | ||
1559 | clk_set_parent(&esdhc1_clk, &pll2_sw_clk); | ||
1560 | clk_set_parent(&esdhc3_mx53_clk, &pll2_sw_clk); | ||
1561 | |||
1562 | /* set SDHC root clock as 200MHZ*/ | ||
1563 | clk_set_rate(&esdhc1_clk, 200000000); | ||
1564 | clk_set_rate(&esdhc3_mx53_clk, 200000000); | ||
1565 | |||
1428 | /* System timer */ | 1566 | /* System timer */ |
1429 | mxc_timer_init(&gpt_clk, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR), | 1567 | mxc_timer_init(&gpt_clk, MX53_IO_ADDRESS(MX53_GPT1_BASE_ADDR), |
1430 | MX53_INT_GPT); | 1568 | MX53_INT_GPT); |
diff --git a/arch/arm/mach-mx5/crm_regs.h b/arch/arm/mach-mx5/crm_regs.h index b462c22f53d..87c0c58f27a 100644 --- a/arch/arm/mach-mx5/crm_regs.h +++ b/arch/arm/mach-mx5/crm_regs.h | |||
@@ -217,9 +217,12 @@ | |||
217 | #define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_OFFSET (20) | 217 | #define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_OFFSET (20) |
218 | #define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_MASK (0x3 << 20) | 218 | #define MXC_CCM_CSCMR1_ESDHC1_MSHC1_CLK_SEL_MASK (0x3 << 20) |
219 | #define MXC_CCM_CSCMR1_ESDHC3_CLK_SEL (0x1 << 19) | 219 | #define MXC_CCM_CSCMR1_ESDHC3_CLK_SEL (0x1 << 19) |
220 | #define MXC_CCM_CSCMR1_ESDHC2_MSHC2_MX53_CLK_SEL (0x1 << 19) | ||
220 | #define MXC_CCM_CSCMR1_ESDHC4_CLK_SEL (0x1 << 18) | 221 | #define MXC_CCM_CSCMR1_ESDHC4_CLK_SEL (0x1 << 18) |
221 | #define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_OFFSET (16) | 222 | #define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_OFFSET (16) |
222 | #define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_MASK (0x3 << 16) | 223 | #define MXC_CCM_CSCMR1_ESDHC2_MSHC2_CLK_SEL_MASK (0x3 << 16) |
224 | #define MXC_CCM_CSCMR1_ESDHC3_MX53_CLK_SEL_OFFSET (16) | ||
225 | #define MXC_CCM_CSCMR1_ESDHC3_MX53_CLK_SEL_MASK (0x3 << 16) | ||
223 | #define MXC_CCM_CSCMR1_SSI1_CLK_SEL_OFFSET (14) | 226 | #define MXC_CCM_CSCMR1_SSI1_CLK_SEL_OFFSET (14) |
224 | #define MXC_CCM_CSCMR1_SSI1_CLK_SEL_MASK (0x3 << 14) | 227 | #define MXC_CCM_CSCMR1_SSI1_CLK_SEL_MASK (0x3 << 14) |
225 | #define MXC_CCM_CSCMR1_SSI2_CLK_SEL_OFFSET (12) | 228 | #define MXC_CCM_CSCMR1_SSI2_CLK_SEL_OFFSET (12) |
@@ -271,6 +274,10 @@ | |||
271 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PRED_MASK (0x7 << 22) | 274 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PRED_MASK (0x7 << 22) |
272 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_OFFSET (19) | 275 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_OFFSET (19) |
273 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_MASK (0x7 << 19) | 276 | #define MXC_CCM_CSCDR1_ESDHC2_MSHC2_CLK_PODF_MASK (0x7 << 19) |
277 | #define MXC_CCM_CSCDR1_ESDHC3_MX53_CLK_PRED_OFFSET (22) | ||
278 | #define MXC_CCM_CSCDR1_ESDHC3_MX53_CLK_PRED_MASK (0x7 << 22) | ||
279 | #define MXC_CCM_CSCDR1_ESDHC3_MX53_CLK_PODF_OFFSET (19) | ||
280 | #define MXC_CCM_CSCDR1_ESDHC3_MX53_CLK_PODF_MASK (0x7 << 19) | ||
274 | #define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_OFFSET (16) | 281 | #define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_OFFSET (16) |
275 | #define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_MASK (0x7 << 16) | 282 | #define MXC_CCM_CSCDR1_ESDHC1_MSHC1_CLK_PRED_MASK (0x7 << 16) |
276 | #define MXC_CCM_CSCDR1_PGC_CLK_PODF_OFFSET (14) | 283 | #define MXC_CCM_CSCDR1_PGC_CLK_PODF_OFFSET (14) |