Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 1 | #include <linux/clk.h> |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 2 | #include <linux/clk-provider.h> |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 3 | #include <linux/clkdev.h> |
| 4 | #include <linux/err.h> |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 5 | #include <linux/of.h> |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 6 | #include <linux/of_address.h> |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 7 | #include <dt-bindings/clock/imx27-clock.h> |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 8 | |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 9 | #include "clk.h" |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 10 | #include "common.h" |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 11 | #include "hardware.h" |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 12 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 13 | static void __iomem *ccm __initdata; |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 14 | |
| 15 | /* Register offsets */ |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 16 | #define CCM_CSCR (ccm + 0x00) |
| 17 | #define CCM_MPCTL0 (ccm + 0x04) |
| 18 | #define CCM_MPCTL1 (ccm + 0x08) |
| 19 | #define CCM_SPCTL0 (ccm + 0x0c) |
| 20 | #define CCM_SPCTL1 (ccm + 0x10) |
| 21 | #define CCM_OSC26MCTL (ccm + 0x14) |
| 22 | #define CCM_PCDR0 (ccm + 0x18) |
| 23 | #define CCM_PCDR1 (ccm + 0x1c) |
| 24 | #define CCM_PCCR0 (ccm + 0x20) |
| 25 | #define CCM_PCCR1 (ccm + 0x24) |
| 26 | #define CCM_CCSR (ccm + 0x28) |
| 27 | #define CCM_PMCTL (ccm + 0x2c) |
| 28 | #define CCM_PMCOUNT (ccm + 0x30) |
| 29 | #define CCM_WKGDCTL (ccm + 0x34) |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 30 | |
| 31 | #define CCM_CSCR_UPDATE_DIS (1 << 31) |
| 32 | #define CCM_CSCR_SSI2 (1 << 23) |
| 33 | #define CCM_CSCR_SSI1 (1 << 22) |
| 34 | #define CCM_CSCR_VPU (1 << 21) |
| 35 | #define CCM_CSCR_MSHC (1 << 20) |
| 36 | #define CCM_CSCR_SPLLRES (1 << 19) |
| 37 | #define CCM_CSCR_MPLLRES (1 << 18) |
| 38 | #define CCM_CSCR_SP (1 << 17) |
| 39 | #define CCM_CSCR_MCU (1 << 16) |
| 40 | #define CCM_CSCR_OSC26MDIV (1 << 4) |
| 41 | #define CCM_CSCR_OSC26M (1 << 3) |
| 42 | #define CCM_CSCR_FPM (1 << 2) |
| 43 | #define CCM_CSCR_SPEN (1 << 1) |
| 44 | #define CCM_CSCR_MPEN (1 << 0) |
| 45 | |
| 46 | /* i.MX27 TO 2+ */ |
| 47 | #define CCM_CSCR_ARM_SRC (1 << 15) |
| 48 | |
| 49 | #define CCM_SPCTL1_LF (1 << 15) |
| 50 | #define CCM_SPCTL1_BRMO (1 << 6) |
| 51 | |
| 52 | static const char *vpu_sel_clks[] = { "spll", "mpll_main2", }; |
| 53 | static const char *cpu_sel_clks[] = { "mpll_main2", "mpll", }; |
Sascha Hauer | 4ea9e85 | 2012-10-31 08:25:08 +0100 | [diff] [blame] | 54 | static const char *mpll_sel_clks[] = { "fpm", "mpll_osc_sel", }; |
| 55 | static const char *mpll_osc_sel_clks[] = { "ckih", "ckih_div1p5", }; |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 56 | static const char *clko_sel_clks[] = { |
Sascha Hauer | 4ea9e85 | 2012-10-31 08:25:08 +0100 | [diff] [blame] | 57 | "ckil", "fpm", "ckih", "ckih", |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 58 | "ckih", "mpll", "spll", "cpu_div", |
| 59 | "ahb", "ipg", "per1_div", "per2_div", |
| 60 | "per3_div", "per4_div", "ssi1_div", "ssi2_div", |
| 61 | "nfc_div", "mshc_div", "vpu_div", "60m", |
| 62 | "32k", "usb_div", "dptc", |
| 63 | }; |
| 64 | |
Gwenhael Goavec-Merou | b7eed20 | 2013-01-13 15:15:01 +0100 | [diff] [blame] | 65 | static const char *ssi_sel_clks[] = { "spll_gate", "mpll", }; |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 66 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 67 | static struct clk *clk[IMX27_CLK_MAX]; |
Fabio Estevam | c20736f | 2012-11-28 15:55:30 -0200 | [diff] [blame] | 68 | static struct clk_onecell_data clk_data; |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 69 | |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 70 | static void __init _mx27_clocks_init(unsigned long fref) |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 71 | { |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 72 | BUG_ON(!ccm); |
| 73 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 74 | clk[IMX27_CLK_DUMMY] = imx_clk_fixed("dummy", 0); |
| 75 | clk[IMX27_CLK_CKIH] = imx_clk_fixed("ckih", fref); |
| 76 | clk[IMX27_CLK_CKIL] = imx_clk_fixed("ckil", 32768); |
| 77 | clk[IMX27_CLK_FPM] = imx_clk_fixed_factor("fpm", "ckil", 1024, 1); |
| 78 | clk[IMX27_CLK_CKIH_DIV1P5] = imx_clk_fixed_factor("ckih_div1p5", "ckih", 2, 3); |
| 79 | clk[IMX27_CLK_MPLL_OSC_SEL] = imx_clk_mux("mpll_osc_sel", CCM_CSCR, 4, 1, mpll_osc_sel_clks, ARRAY_SIZE(mpll_osc_sel_clks)); |
| 80 | clk[IMX27_CLK_MPLL_SEL] = imx_clk_mux("mpll_sel", CCM_CSCR, 16, 1, mpll_sel_clks, ARRAY_SIZE(mpll_sel_clks)); |
| 81 | clk[IMX27_CLK_MPLL] = imx_clk_pllv1("mpll", "mpll_sel", CCM_MPCTL0); |
| 82 | clk[IMX27_CLK_SPLL] = imx_clk_pllv1("spll", "ckih", CCM_SPCTL0); |
| 83 | clk[IMX27_CLK_SPLL_GATE] = imx_clk_gate("spll_gate", "spll", CCM_CSCR, 1); |
| 84 | clk[IMX27_CLK_MPLL_MAIN2] = imx_clk_fixed_factor("mpll_main2", "mpll", 2, 3); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 85 | |
| 86 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) { |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 87 | clk[IMX27_CLK_AHB] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 8, 2); |
| 88 | clk[IMX27_CLK_IPG] = imx_clk_fixed_factor("ipg", "ahb", 1, 2); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 89 | } else { |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 90 | clk[IMX27_CLK_AHB] = imx_clk_divider("ahb", "mpll_main2", CCM_CSCR, 9, 4); |
| 91 | clk[IMX27_CLK_IPG] = imx_clk_divider("ipg", "ahb", CCM_CSCR, 8, 1); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 92 | } |
| 93 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 94 | clk[IMX27_CLK_MSHC_DIV] = imx_clk_divider("mshc_div", "ahb", CCM_PCDR0, 0, 6); |
| 95 | clk[IMX27_CLK_NFC_DIV] = imx_clk_divider("nfc_div", "ahb", CCM_PCDR0, 6, 4); |
| 96 | clk[IMX27_CLK_PER1_DIV] = imx_clk_divider("per1_div", "mpll_main2", CCM_PCDR1, 0, 6); |
| 97 | clk[IMX27_CLK_PER2_DIV] = imx_clk_divider("per2_div", "mpll_main2", CCM_PCDR1, 8, 6); |
| 98 | clk[IMX27_CLK_PER3_DIV] = imx_clk_divider("per3_div", "mpll_main2", CCM_PCDR1, 16, 6); |
| 99 | clk[IMX27_CLK_PER4_DIV] = imx_clk_divider("per4_div", "mpll_main2", CCM_PCDR1, 24, 6); |
| 100 | clk[IMX27_CLK_VPU_SEL] = imx_clk_mux("vpu_sel", CCM_CSCR, 21, 1, vpu_sel_clks, ARRAY_SIZE(vpu_sel_clks)); |
| 101 | clk[IMX27_CLK_VPU_DIV] = imx_clk_divider("vpu_div", "vpu_sel", CCM_PCDR0, 10, 6); |
| 102 | clk[IMX27_CLK_USB_DIV] = imx_clk_divider("usb_div", "spll_gate", CCM_CSCR, 28, 3); |
| 103 | clk[IMX27_CLK_CPU_SEL] = imx_clk_mux("cpu_sel", CCM_CSCR, 15, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks)); |
| 104 | clk[IMX27_CLK_CLKO_SEL] = imx_clk_mux("clko_sel", CCM_CCSR, 0, 5, clko_sel_clks, ARRAY_SIZE(clko_sel_clks)); |
| 105 | |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 106 | if (mx27_revision() >= IMX_CHIP_REVISION_2_0) |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 107 | clk[IMX27_CLK_CPU_DIV] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 12, 2); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 108 | else |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 109 | clk[IMX27_CLK_CPU_DIV] = imx_clk_divider("cpu_div", "cpu_sel", CCM_CSCR, 13, 3); |
| 110 | |
| 111 | clk[IMX27_CLK_CLKO_DIV] = imx_clk_divider("clko_div", "clko_sel", CCM_PCDR0, 22, 3); |
| 112 | clk[IMX27_CLK_SSI1_SEL] = imx_clk_mux("ssi1_sel", CCM_CSCR, 22, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); |
| 113 | clk[IMX27_CLK_SSI2_SEL] = imx_clk_mux("ssi2_sel", CCM_CSCR, 23, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); |
| 114 | clk[IMX27_CLK_SSI1_DIV] = imx_clk_divider("ssi1_div", "ssi1_sel", CCM_PCDR0, 16, 6); |
| 115 | clk[IMX27_CLK_SSI2_DIV] = imx_clk_divider("ssi2_div", "ssi2_sel", CCM_PCDR0, 26, 6); |
| 116 | clk[IMX27_CLK_CLKO_EN] = imx_clk_gate("clko_en", "clko_div", CCM_PCCR0, 0); |
| 117 | clk[IMX27_CLK_SSI2_IPG_GATE] = imx_clk_gate("ssi2_ipg_gate", "ipg", CCM_PCCR0, 0); |
| 118 | clk[IMX27_CLK_SSI1_IPG_GATE] = imx_clk_gate("ssi1_ipg_gate", "ipg", CCM_PCCR0, 1); |
| 119 | clk[IMX27_CLK_SLCDC_IPG_GATE] = imx_clk_gate("slcdc_ipg_gate", "ipg", CCM_PCCR0, 2); |
| 120 | clk[IMX27_CLK_SDHC3_IPG_GATE] = imx_clk_gate("sdhc3_ipg_gate", "ipg", CCM_PCCR0, 3); |
| 121 | clk[IMX27_CLK_SDHC2_IPG_GATE] = imx_clk_gate("sdhc2_ipg_gate", "ipg", CCM_PCCR0, 4); |
| 122 | clk[IMX27_CLK_SDHC1_IPG_GATE] = imx_clk_gate("sdhc1_ipg_gate", "ipg", CCM_PCCR0, 5); |
| 123 | clk[IMX27_CLK_SCC_IPG_GATE] = imx_clk_gate("scc_ipg_gate", "ipg", CCM_PCCR0, 6); |
| 124 | clk[IMX27_CLK_SAHARA_IPG_GATE] = imx_clk_gate("sahara_ipg_gate", "ipg", CCM_PCCR0, 7); |
| 125 | clk[IMX27_CLK_RTIC_IPG_GATE] = imx_clk_gate("rtic_ipg_gate", "ipg", CCM_PCCR0, 8); |
| 126 | clk[IMX27_CLK_RTC_IPG_GATE] = imx_clk_gate("rtc_ipg_gate", "ipg", CCM_PCCR0, 9); |
| 127 | clk[IMX27_CLK_PWM_IPG_GATE] = imx_clk_gate("pwm_ipg_gate", "ipg", CCM_PCCR0, 11); |
| 128 | clk[IMX27_CLK_OWIRE_IPG_GATE] = imx_clk_gate("owire_ipg_gate", "ipg", CCM_PCCR0, 12); |
| 129 | clk[IMX27_CLK_MSHC_IPG_GATE] = imx_clk_gate("mshc_ipg_gate", "ipg", CCM_PCCR0, 13); |
| 130 | clk[IMX27_CLK_LCDC_IPG_GATE] = imx_clk_gate("lcdc_ipg_gate", "ipg", CCM_PCCR0, 14); |
| 131 | clk[IMX27_CLK_KPP_IPG_GATE] = imx_clk_gate("kpp_ipg_gate", "ipg", CCM_PCCR0, 15); |
| 132 | clk[IMX27_CLK_IIM_IPG_GATE] = imx_clk_gate("iim_ipg_gate", "ipg", CCM_PCCR0, 16); |
| 133 | clk[IMX27_CLK_I2C2_IPG_GATE] = imx_clk_gate("i2c2_ipg_gate", "ipg", CCM_PCCR0, 17); |
| 134 | clk[IMX27_CLK_I2C1_IPG_GATE] = imx_clk_gate("i2c1_ipg_gate", "ipg", CCM_PCCR0, 18); |
| 135 | clk[IMX27_CLK_GPT6_IPG_GATE] = imx_clk_gate("gpt6_ipg_gate", "ipg", CCM_PCCR0, 19); |
| 136 | clk[IMX27_CLK_GPT5_IPG_GATE] = imx_clk_gate("gpt5_ipg_gate", "ipg", CCM_PCCR0, 20); |
| 137 | clk[IMX27_CLK_GPT4_IPG_GATE] = imx_clk_gate("gpt4_ipg_gate", "ipg", CCM_PCCR0, 21); |
| 138 | clk[IMX27_CLK_GPT3_IPG_GATE] = imx_clk_gate("gpt3_ipg_gate", "ipg", CCM_PCCR0, 22); |
| 139 | clk[IMX27_CLK_GPT2_IPG_GATE] = imx_clk_gate("gpt2_ipg_gate", "ipg", CCM_PCCR0, 23); |
| 140 | clk[IMX27_CLK_GPT1_IPG_GATE] = imx_clk_gate("gpt1_ipg_gate", "ipg", CCM_PCCR0, 24); |
| 141 | clk[IMX27_CLK_GPIO_IPG_GATE] = imx_clk_gate("gpio_ipg_gate", "ipg", CCM_PCCR0, 25); |
| 142 | clk[IMX27_CLK_FEC_IPG_GATE] = imx_clk_gate("fec_ipg_gate", "ipg", CCM_PCCR0, 26); |
| 143 | clk[IMX27_CLK_EMMA_IPG_GATE] = imx_clk_gate("emma_ipg_gate", "ipg", CCM_PCCR0, 27); |
| 144 | clk[IMX27_CLK_DMA_IPG_GATE] = imx_clk_gate("dma_ipg_gate", "ipg", CCM_PCCR0, 28); |
| 145 | clk[IMX27_CLK_CSPI3_IPG_GATE] = imx_clk_gate("cspi3_ipg_gate", "ipg", CCM_PCCR0, 29); |
| 146 | clk[IMX27_CLK_CSPI2_IPG_GATE] = imx_clk_gate("cspi2_ipg_gate", "ipg", CCM_PCCR0, 30); |
| 147 | clk[IMX27_CLK_CSPI1_IPG_GATE] = imx_clk_gate("cspi1_ipg_gate", "ipg", CCM_PCCR0, 31); |
| 148 | clk[IMX27_CLK_MSHC_BAUD_GATE] = imx_clk_gate("mshc_baud_gate", "mshc_div", CCM_PCCR1, 2); |
| 149 | clk[IMX27_CLK_NFC_BAUD_GATE] = imx_clk_gate("nfc_baud_gate", "nfc_div", CCM_PCCR1, 3); |
| 150 | clk[IMX27_CLK_SSI2_BAUD_GATE] = imx_clk_gate("ssi2_baud_gate", "ssi2_div", CCM_PCCR1, 4); |
| 151 | clk[IMX27_CLK_SSI1_BAUD_GATE] = imx_clk_gate("ssi1_baud_gate", "ssi1_div", CCM_PCCR1, 5); |
| 152 | clk[IMX27_CLK_VPU_BAUD_GATE] = imx_clk_gate("vpu_baud_gate", "vpu_div", CCM_PCCR1, 6); |
| 153 | clk[IMX27_CLK_PER4_GATE] = imx_clk_gate("per4_gate", "per4_div", CCM_PCCR1, 7); |
| 154 | clk[IMX27_CLK_PER3_GATE] = imx_clk_gate("per3_gate", "per3_div", CCM_PCCR1, 8); |
| 155 | clk[IMX27_CLK_PER2_GATE] = imx_clk_gate("per2_gate", "per2_div", CCM_PCCR1, 9); |
| 156 | clk[IMX27_CLK_PER1_GATE] = imx_clk_gate("per1_gate", "per1_div", CCM_PCCR1, 10); |
| 157 | clk[IMX27_CLK_USB_AHB_GATE] = imx_clk_gate("usb_ahb_gate", "ahb", CCM_PCCR1, 11); |
| 158 | clk[IMX27_CLK_SLCDC_AHB_GATE] = imx_clk_gate("slcdc_ahb_gate", "ahb", CCM_PCCR1, 12); |
| 159 | clk[IMX27_CLK_SAHARA_AHB_GATE] = imx_clk_gate("sahara_ahb_gate", "ahb", CCM_PCCR1, 13); |
| 160 | clk[IMX27_CLK_RTIC_AHB_GATE] = imx_clk_gate("rtic_ahb_gate", "ahb", CCM_PCCR1, 14); |
| 161 | clk[IMX27_CLK_LCDC_AHB_GATE] = imx_clk_gate("lcdc_ahb_gate", "ahb", CCM_PCCR1, 15); |
| 162 | clk[IMX27_CLK_VPU_AHB_GATE] = imx_clk_gate("vpu_ahb_gate", "ahb", CCM_PCCR1, 16); |
| 163 | clk[IMX27_CLK_FEC_AHB_GATE] = imx_clk_gate("fec_ahb_gate", "ahb", CCM_PCCR1, 17); |
| 164 | clk[IMX27_CLK_EMMA_AHB_GATE] = imx_clk_gate("emma_ahb_gate", "ahb", CCM_PCCR1, 18); |
| 165 | clk[IMX27_CLK_EMI_AHB_GATE] = imx_clk_gate("emi_ahb_gate", "ahb", CCM_PCCR1, 19); |
| 166 | clk[IMX27_CLK_DMA_AHB_GATE] = imx_clk_gate("dma_ahb_gate", "ahb", CCM_PCCR1, 20); |
| 167 | clk[IMX27_CLK_CSI_AHB_GATE] = imx_clk_gate("csi_ahb_gate", "ahb", CCM_PCCR1, 21); |
| 168 | clk[IMX27_CLK_BROM_AHB_GATE] = imx_clk_gate("brom_ahb_gate", "ahb", CCM_PCCR1, 22); |
| 169 | clk[IMX27_CLK_ATA_AHB_GATE] = imx_clk_gate("ata_ahb_gate", "ahb", CCM_PCCR1, 23); |
| 170 | clk[IMX27_CLK_WDOG_IPG_GATE] = imx_clk_gate("wdog_ipg_gate", "ipg", CCM_PCCR1, 24); |
| 171 | clk[IMX27_CLK_USB_IPG_GATE] = imx_clk_gate("usb_ipg_gate", "ipg", CCM_PCCR1, 25); |
| 172 | clk[IMX27_CLK_UART6_IPG_GATE] = imx_clk_gate("uart6_ipg_gate", "ipg", CCM_PCCR1, 26); |
| 173 | clk[IMX27_CLK_UART5_IPG_GATE] = imx_clk_gate("uart5_ipg_gate", "ipg", CCM_PCCR1, 27); |
| 174 | clk[IMX27_CLK_UART4_IPG_GATE] = imx_clk_gate("uart4_ipg_gate", "ipg", CCM_PCCR1, 28); |
| 175 | clk[IMX27_CLK_UART3_IPG_GATE] = imx_clk_gate("uart3_ipg_gate", "ipg", CCM_PCCR1, 29); |
| 176 | clk[IMX27_CLK_UART2_IPG_GATE] = imx_clk_gate("uart2_ipg_gate", "ipg", CCM_PCCR1, 30); |
| 177 | clk[IMX27_CLK_UART1_IPG_GATE] = imx_clk_gate("uart1_ipg_gate", "ipg", CCM_PCCR1, 31); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 178 | |
Alexander Shiyan | 229be9c | 2014-06-10 19:40:26 +0400 | [diff] [blame] | 179 | imx_check_clocks(clk, ARRAY_SIZE(clk)); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 180 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 181 | clk_register_clkdev(clk[IMX27_CLK_CPU_DIV], NULL, "cpu0"); |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 182 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 183 | clk_prepare_enable(clk[IMX27_CLK_EMI_AHB_GATE]); |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 184 | |
| 185 | imx_print_silicon_rev("i.MX27", mx27_revision()); |
| 186 | } |
| 187 | |
| 188 | int __init mx27_clocks_init(unsigned long fref) |
| 189 | { |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 190 | ccm = ioremap(MX27_CCM_BASE_ADDR, SZ_4K); |
| 191 | |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 192 | _mx27_clocks_init(fref); |
Fabio Estevam | c20736f | 2012-11-28 15:55:30 -0200 | [diff] [blame] | 193 | |
Alexander Shiyan | e8e3faa | 2014-07-05 09:36:06 +0400 | [diff] [blame^] | 194 | clk_register_clkdev(clk[IMX27_CLK_UART1_IPG_GATE], "ipg", "imx21-uart.0"); |
| 195 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.0"); |
| 196 | clk_register_clkdev(clk[IMX27_CLK_UART2_IPG_GATE], "ipg", "imx21-uart.1"); |
| 197 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.1"); |
| 198 | clk_register_clkdev(clk[IMX27_CLK_UART3_IPG_GATE], "ipg", "imx21-uart.2"); |
| 199 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.2"); |
| 200 | clk_register_clkdev(clk[IMX27_CLK_UART4_IPG_GATE], "ipg", "imx21-uart.3"); |
| 201 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.3"); |
| 202 | clk_register_clkdev(clk[IMX27_CLK_UART5_IPG_GATE], "ipg", "imx21-uart.4"); |
| 203 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.4"); |
| 204 | clk_register_clkdev(clk[IMX27_CLK_UART6_IPG_GATE], "ipg", "imx21-uart.5"); |
| 205 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx21-uart.5"); |
| 206 | clk_register_clkdev(clk[IMX27_CLK_GPT1_IPG_GATE], "ipg", "imx-gpt.0"); |
| 207 | clk_register_clkdev(clk[IMX27_CLK_PER1_GATE], "per", "imx-gpt.0"); |
| 208 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx21-mmc.0"); |
| 209 | clk_register_clkdev(clk[IMX27_CLK_SDHC1_IPG_GATE], "ipg", "imx21-mmc.0"); |
| 210 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx21-mmc.1"); |
| 211 | clk_register_clkdev(clk[IMX27_CLK_SDHC2_IPG_GATE], "ipg", "imx21-mmc.1"); |
| 212 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx21-mmc.2"); |
| 213 | clk_register_clkdev(clk[IMX27_CLK_SDHC2_IPG_GATE], "ipg", "imx21-mmc.2"); |
| 214 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx27-cspi.0"); |
| 215 | clk_register_clkdev(clk[IMX27_CLK_CSPI1_IPG_GATE], "ipg", "imx27-cspi.0"); |
| 216 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx27-cspi.1"); |
| 217 | clk_register_clkdev(clk[IMX27_CLK_CSPI2_IPG_GATE], "ipg", "imx27-cspi.1"); |
| 218 | clk_register_clkdev(clk[IMX27_CLK_PER2_GATE], "per", "imx27-cspi.2"); |
| 219 | clk_register_clkdev(clk[IMX27_CLK_CSPI3_IPG_GATE], "ipg", "imx27-cspi.2"); |
| 220 | clk_register_clkdev(clk[IMX27_CLK_PER3_GATE], "per", "imx21-fb.0"); |
| 221 | clk_register_clkdev(clk[IMX27_CLK_LCDC_IPG_GATE], "ipg", "imx21-fb.0"); |
| 222 | clk_register_clkdev(clk[IMX27_CLK_LCDC_AHB_GATE], "ahb", "imx21-fb.0"); |
| 223 | clk_register_clkdev(clk[IMX27_CLK_CSI_AHB_GATE], "ahb", "imx27-camera.0"); |
| 224 | clk_register_clkdev(clk[IMX27_CLK_PER4_GATE], "per", "imx27-camera.0"); |
| 225 | clk_register_clkdev(clk[IMX27_CLK_USB_DIV], "per", "imx-udc-mx27"); |
| 226 | clk_register_clkdev(clk[IMX27_CLK_USB_IPG_GATE], "ipg", "imx-udc-mx27"); |
| 227 | clk_register_clkdev(clk[IMX27_CLK_USB_AHB_GATE], "ahb", "imx-udc-mx27"); |
| 228 | clk_register_clkdev(clk[IMX27_CLK_USB_DIV], "per", "mxc-ehci.0"); |
| 229 | clk_register_clkdev(clk[IMX27_CLK_USB_IPG_GATE], "ipg", "mxc-ehci.0"); |
| 230 | clk_register_clkdev(clk[IMX27_CLK_USB_AHB_GATE], "ahb", "mxc-ehci.0"); |
| 231 | clk_register_clkdev(clk[IMX27_CLK_USB_DIV], "per", "mxc-ehci.1"); |
| 232 | clk_register_clkdev(clk[IMX27_CLK_USB_IPG_GATE], "ipg", "mxc-ehci.1"); |
| 233 | clk_register_clkdev(clk[IMX27_CLK_USB_AHB_GATE], "ahb", "mxc-ehci.1"); |
| 234 | clk_register_clkdev(clk[IMX27_CLK_USB_DIV], "per", "mxc-ehci.2"); |
| 235 | clk_register_clkdev(clk[IMX27_CLK_USB_IPG_GATE], "ipg", "mxc-ehci.2"); |
| 236 | clk_register_clkdev(clk[IMX27_CLK_USB_AHB_GATE], "ahb", "mxc-ehci.2"); |
| 237 | clk_register_clkdev(clk[IMX27_CLK_SSI1_IPG_GATE], NULL, "imx-ssi.0"); |
| 238 | clk_register_clkdev(clk[IMX27_CLK_SSI2_IPG_GATE], NULL, "imx-ssi.1"); |
| 239 | clk_register_clkdev(clk[IMX27_CLK_NFC_BAUD_GATE], NULL, "imx27-nand.0"); |
| 240 | clk_register_clkdev(clk[IMX27_CLK_VPU_BAUD_GATE], "per", "coda-imx27.0"); |
| 241 | clk_register_clkdev(clk[IMX27_CLK_VPU_AHB_GATE], "ahb", "coda-imx27.0"); |
| 242 | clk_register_clkdev(clk[IMX27_CLK_DMA_AHB_GATE], "ahb", "imx27-dma"); |
| 243 | clk_register_clkdev(clk[IMX27_CLK_DMA_IPG_GATE], "ipg", "imx27-dma"); |
| 244 | clk_register_clkdev(clk[IMX27_CLK_FEC_IPG_GATE], "ipg", "imx27-fec.0"); |
| 245 | clk_register_clkdev(clk[IMX27_CLK_FEC_AHB_GATE], "ahb", "imx27-fec.0"); |
| 246 | clk_register_clkdev(clk[IMX27_CLK_WDOG_IPG_GATE], NULL, "imx2-wdt.0"); |
| 247 | clk_register_clkdev(clk[IMX27_CLK_I2C1_IPG_GATE], NULL, "imx21-i2c.0"); |
| 248 | clk_register_clkdev(clk[IMX27_CLK_I2C2_IPG_GATE], NULL, "imx21-i2c.1"); |
| 249 | clk_register_clkdev(clk[IMX27_CLK_OWIRE_IPG_GATE], NULL, "mxc_w1.0"); |
| 250 | clk_register_clkdev(clk[IMX27_CLK_KPP_IPG_GATE], NULL, "imx-keypad"); |
| 251 | clk_register_clkdev(clk[IMX27_CLK_EMMA_AHB_GATE], "emma-ahb", "imx27-camera.0"); |
| 252 | clk_register_clkdev(clk[IMX27_CLK_EMMA_IPG_GATE], "emma-ipg", "imx27-camera.0"); |
| 253 | clk_register_clkdev(clk[IMX27_CLK_EMMA_AHB_GATE], "ahb", "m2m-emmaprp.0"); |
| 254 | clk_register_clkdev(clk[IMX27_CLK_EMMA_IPG_GATE], "ipg", "m2m-emmaprp.0"); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 255 | |
Sascha Hauer | 2cfb451 | 2012-05-16 12:29:53 +0200 | [diff] [blame] | 256 | mxc_timer_init(MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), MX27_INT_GPT1); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 257 | |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 258 | return 0; |
| 259 | } |
| 260 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 261 | static void __init mx27_clocks_init_dt(struct device_node *np) |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 262 | { |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 263 | struct device_node *refnp; |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 264 | u32 fref = 26000000; /* default */ |
| 265 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 266 | for_each_compatible_node(refnp, NULL, "fixed-clock") { |
| 267 | if (!of_device_is_compatible(refnp, "fsl,imx-osc26m")) |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 268 | continue; |
| 269 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 270 | if (!of_property_read_u32(refnp, "clock-frequency", &fref)) |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 271 | break; |
| 272 | } |
| 273 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 274 | ccm = of_iomap(np, 0); |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 275 | |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 276 | _mx27_clocks_init(fref); |
Alexander Shiyan | bb9c339 | 2014-06-07 20:09:25 +0400 | [diff] [blame] | 277 | |
| 278 | clk_data.clks = clk; |
| 279 | clk_data.clk_num = ARRAY_SIZE(clk); |
| 280 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); |
| 281 | |
| 282 | mxc_timer_init_dt(of_find_compatible_node(NULL, NULL, "fsl,imx1-gpt")); |
Sascha Hauer | e038ed5 | 2012-03-09 09:11:46 +0100 | [diff] [blame] | 283 | } |
Alexander Shiyan | c349add | 2014-06-07 20:09:26 +0400 | [diff] [blame] | 284 | CLK_OF_DECLARE(imx27_ccm, "fsl,imx27-ccm", mx27_clocks_init_dt); |