aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mx5/clock-mx51-mx53.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-mx5/clock-mx51-mx53.c')
-rw-r--r--arch/arm/mach-mx5/clock-mx51-mx53.c148
1 files changed, 142 insertions, 6 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c
index 0a19e7567c0b..652ace413825 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;
42static struct clk emi_fast_clk; 42static struct clk emi_fast_clk;
43static struct clk ipu_clk; 43static struct clk ipu_clk;
44static struct clk mipi_hsc1_clk; 44static struct clk mipi_hsc1_clk;
45static struct clk esdhc1_clk;
46static struct clk esdhc2_clk;
47static 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
@@ -867,10 +870,6 @@ static struct clk gpt_32k_clk = {
867 .parent = &ckil_clk, 870 .parent = &ckil_clk,
868}; 871};
869 872
870static struct clk kpp_clk = {
871 .id = 0,
872};
873
874static struct clk dummy_clk = { 873static struct clk dummy_clk = {
875 .id = 0, 874 .id = 0,
876}; 875};
@@ -1147,10 +1146,80 @@ CLK_GET_RATE(esdhc1, 1, ESDHC1_MSHC1)
1147CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1) 1146CLK_SET_PARENT(esdhc1, 1, ESDHC1_MSHC1)
1148CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1) 1147CLK_SET_RATE(esdhc1, 1, ESDHC1_MSHC1)
1149 1148
1149/* mx51 specific */
1150CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2) 1150CLK_GET_RATE(esdhc2, 1, ESDHC2_MSHC2)
1151CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2) 1151CLK_SET_PARENT(esdhc2, 1, ESDHC2_MSHC2)
1152CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2) 1152CLK_SET_RATE(esdhc2, 1, ESDHC2_MSHC2)
1153 1153
1154static 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
1170static 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 */
1187static 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
1203CLK_GET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
1204CLK_SET_PARENT(esdhc3_mx53, 1, ESDHC3_MX53)
1205CLK_SET_RATE(esdhc3_mx53, 1, ESDHC3_MX53)
1206
1207static 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
1154#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) \
1155 static struct clk name = { \ 1224 static struct clk name = { \
1156 .id = i, \ 1225 .id = i, \
@@ -1255,9 +1324,62 @@ DEFINE_CLOCK_MAX(esdhc1_clk, 0, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG1_OFFSET,
1255 clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk); 1324 clk_esdhc1, &pll2_sw_clk, &esdhc1_ipg_clk);
1256DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET, 1325DEFINE_CLOCK_FULL(esdhc2_ipg_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG2_OFFSET,
1257 NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL); 1326 NULL, NULL, _clk_max_enable, _clk_max_disable, &ipg_clk, NULL);
1327DEFINE_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);
1329DEFINE_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 */
1258DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET, 1333DEFINE_CLOCK_MAX(esdhc2_clk, 1, MXC_CCM_CCGR3, MXC_CCM_CCGRx_CG3_OFFSET,
1259 clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk); 1334 clk_esdhc2, &pll2_sw_clk, &esdhc2_ipg_clk);
1260 1335
1336static 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};
1346static 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 */
1358static 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
1369DEFINE_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
1372static 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
1261DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk); 1383DEFINE_CLOCK(mipi_esc_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG5_OFFSET, NULL, NULL, NULL, &pll2_sw_clk);
1262DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk); 1384DEFINE_CLOCK(mipi_hsc2_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG4_OFFSET, NULL, NULL, &mipi_esc_clk, &pll2_sw_clk);
1263DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk); 1385DEFINE_CLOCK(mipi_hsc1_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG3_OFFSET, NULL, NULL, &mipi_hsc2_clk, &pll2_sw_clk);
@@ -1302,7 +1424,7 @@ static struct clk_lookup mx51_lookups[] = {
1302 _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_ahb_clk) 1424 _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_ahb_clk)
1303 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk) 1425 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
1304 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk) 1426 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
1305 _REGISTER_CLOCK("imx-keypad", NULL, kpp_clk) 1427 _REGISTER_CLOCK("imx-keypad", NULL, dummy_clk)
1306 _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk) 1428 _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk)
1307 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk) 1429 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
1308 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk) 1430 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
@@ -1316,6 +1438,8 @@ static struct clk_lookup mx51_lookups[] = {
1316 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk) 1438 _REGISTER_CLOCK("imx51-cspi.0", NULL, cspi_clk)
1317 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) 1439 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
1318 _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)
1319 _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk) 1443 _REGISTER_CLOCK(NULL, "cpu_clk", cpu_clk)
1320 _REGISTER_CLOCK(NULL, "iim_clk", iim_clk) 1444 _REGISTER_CLOCK(NULL, "iim_clk", iim_clk)
1321 _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk) 1445 _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
@@ -1336,10 +1460,14 @@ static struct clk_lookup mx53_lookups[] = {
1336 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk) 1460 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
1337 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk) 1461 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
1338 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk) 1462 _REGISTER_CLOCK("sdhci-esdhc-imx.0", NULL, esdhc1_clk)
1339 _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)
1340 _REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk) 1466 _REGISTER_CLOCK("imx53-ecspi.0", NULL, ecspi1_clk)
1341 _REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk) 1467 _REGISTER_CLOCK("imx53-ecspi.1", NULL, ecspi2_clk)
1342 _REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk) 1468 _REGISTER_CLOCK("imx53-cspi.0", NULL, cspi_clk)
1469 _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk)
1470 _REGISTER_CLOCK("imx2-wdt.1", NULL, dummy_clk)
1343}; 1471};
1344 1472
1345static void clk_tree_init(void) 1473static void clk_tree_init(void)
@@ -1427,6 +1555,14 @@ int __init mx53_clocks_init(unsigned long ckil, unsigned long osc,
1427 mx53_revision(); 1555 mx53_revision();
1428 clk_disable(&iim_clk); 1556 clk_disable(&iim_clk);
1429 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
1430 /* System timer */ 1566 /* System timer */
1431 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),
1432 MX53_INT_GPT); 1568 MX53_INT_GPT);