diff options
author | Barry Song <Baohua.Song@csr.com> | 2012-12-20 03:51:31 -0500 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-01-18 12:44:01 -0500 |
commit | eb8b8f2e7164b819ca35a3d6240198fdb98d0ef3 (patch) | |
tree | 36c3588aebf0d4bb42d0bfbaf0f3d658ae3e77dc /drivers/clk/clk-prima2.c | |
parent | 38a8b096f86dea54cc64f4daa3402d0c4f2df43e (diff) |
clk: prima2: enable dt-binding clkdev mapping
this patche deletes hard code that registers clkdev by things like:
clk_register_clkdev(clk, NULL, "b0030000.nand");
clk_register_clkdev(clk, NULL, "b0040000.audio");
clk_register_clkdev(clk, NULL, "b0080000.usp");
prima2 clock controller becomes a clock provider and every dt node
just declares its clock sources by dt prop.
it also makes us easier to extend this driver to support both prima2
and marco as marco has different address mapping with prima2.
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/clk-prima2.c')
-rw-r--r-- | drivers/clk/clk-prima2.c | 205 |
1 files changed, 80 insertions, 125 deletions
diff --git a/drivers/clk/clk-prima2.c b/drivers/clk/clk-prima2.c index a203ecccdc4f..f8e9d0c27be2 100644 --- a/drivers/clk/clk-prima2.c +++ b/drivers/clk/clk-prima2.c | |||
@@ -1025,20 +1025,67 @@ static struct of_device_id rsc_ids[] = { | |||
1025 | {}, | 1025 | {}, |
1026 | }; | 1026 | }; |
1027 | 1027 | ||
1028 | enum prima2_clk_index { | ||
1029 | /* 0 1 2 3 4 5 6 7 8 9 */ | ||
1030 | rtc, osc, pll1, pll2, pll3, mem, sys, security, dsp, gps, | ||
1031 | mf, io, cpu, uart0, uart1, uart2, tsc, i2c0, i2c1, spi0, | ||
1032 | spi1, pwmc, efuse, pulse, dmac0, dmac1, nand, audio, usp0, usp1, | ||
1033 | usp2, vip, gfx, mm, lcd, vpp, mmc01, mmc23, mmc45, usbpll, | ||
1034 | usb0, usb1, maxclk, | ||
1035 | }; | ||
1036 | |||
1037 | static __initdata struct clk_hw* prima2_clk_hw_array[maxclk] = { | ||
1038 | NULL, /* dummy */ | ||
1039 | NULL, | ||
1040 | &clk_pll1.hw, | ||
1041 | &clk_pll2.hw, | ||
1042 | &clk_pll3.hw, | ||
1043 | &clk_mem.hw, | ||
1044 | &clk_sys.hw, | ||
1045 | &clk_security.hw, | ||
1046 | &clk_dsp.hw, | ||
1047 | &clk_gps.hw, | ||
1048 | &clk_mf.hw, | ||
1049 | &clk_io.hw, | ||
1050 | &clk_cpu.hw, | ||
1051 | &clk_uart0.hw, | ||
1052 | &clk_uart1.hw, | ||
1053 | &clk_uart2.hw, | ||
1054 | &clk_tsc.hw, | ||
1055 | &clk_i2c0.hw, | ||
1056 | &clk_i2c1.hw, | ||
1057 | &clk_spi0.hw, | ||
1058 | &clk_spi1.hw, | ||
1059 | &clk_pwmc.hw, | ||
1060 | &clk_efuse.hw, | ||
1061 | &clk_pulse.hw, | ||
1062 | &clk_dmac0.hw, | ||
1063 | &clk_dmac1.hw, | ||
1064 | &clk_nand.hw, | ||
1065 | &clk_audio.hw, | ||
1066 | &clk_usp0.hw, | ||
1067 | &clk_usp1.hw, | ||
1068 | &clk_usp2.hw, | ||
1069 | &clk_vip.hw, | ||
1070 | &clk_gfx.hw, | ||
1071 | &clk_mm.hw, | ||
1072 | &clk_lcd.hw, | ||
1073 | &clk_vpp.hw, | ||
1074 | &clk_mmc01.hw, | ||
1075 | &clk_mmc23.hw, | ||
1076 | &clk_mmc45.hw, | ||
1077 | &usb_pll_clk_hw, | ||
1078 | &clk_usb0.hw, | ||
1079 | &clk_usb1.hw, | ||
1080 | }; | ||
1081 | |||
1082 | static struct clk *prima2_clks[maxclk]; | ||
1083 | static struct clk_onecell_data clk_data; | ||
1084 | |||
1028 | void __init sirfsoc_of_clk_init(void) | 1085 | void __init sirfsoc_of_clk_init(void) |
1029 | { | 1086 | { |
1030 | struct clk *clk; | ||
1031 | struct device_node *np; | 1087 | struct device_node *np; |
1032 | 1088 | int i; | |
1033 | np = of_find_matching_node(NULL, clkc_ids); | ||
1034 | if (!np) | ||
1035 | panic("unable to find compatible clkc node in dtb\n"); | ||
1036 | |||
1037 | sirfsoc_clk_vbase = of_iomap(np, 0); | ||
1038 | if (!sirfsoc_clk_vbase) | ||
1039 | panic("unable to map clkc registers\n"); | ||
1040 | |||
1041 | of_node_put(np); | ||
1042 | 1089 | ||
1043 | np = of_find_matching_node(NULL, rsc_ids); | 1090 | np = of_find_matching_node(NULL, rsc_ids); |
1044 | if (!np) | 1091 | if (!np) |
@@ -1050,122 +1097,30 @@ void __init sirfsoc_of_clk_init(void) | |||
1050 | 1097 | ||
1051 | of_node_put(np); | 1098 | of_node_put(np); |
1052 | 1099 | ||
1100 | np = of_find_matching_node(NULL, clkc_ids); | ||
1101 | if (!np) | ||
1102 | return; | ||
1103 | |||
1104 | sirfsoc_clk_vbase = of_iomap(np, 0); | ||
1105 | if (!sirfsoc_clk_vbase) | ||
1106 | panic("unable to map clkc registers\n"); | ||
1053 | 1107 | ||
1054 | /* These are always available (RTC and 26MHz OSC)*/ | 1108 | /* These are always available (RTC and 26MHz OSC)*/ |
1055 | clk = clk_register_fixed_rate(NULL, "rtc", NULL, | 1109 | prima2_clks[rtc] = clk_register_fixed_rate(NULL, "rtc", NULL, |
1056 | CLK_IS_ROOT, 32768); | 1110 | CLK_IS_ROOT, 32768); |
1057 | BUG_ON(IS_ERR(clk)); | 1111 | prima2_clks[osc]= clk_register_fixed_rate(NULL, "osc", NULL, |
1058 | clk = clk_register_fixed_rate(NULL, "osc", NULL, | ||
1059 | CLK_IS_ROOT, 26000000); | 1112 | CLK_IS_ROOT, 26000000); |
1060 | BUG_ON(IS_ERR(clk)); | 1113 | |
1061 | 1114 | for (i = pll1; i < maxclk; i++) { | |
1062 | clk = clk_register(NULL, &clk_pll1.hw); | 1115 | prima2_clks[i] = clk_register(NULL, prima2_clk_hw_array[i]); |
1063 | BUG_ON(IS_ERR(clk)); | 1116 | BUG_ON(!prima2_clks[i]); |
1064 | clk = clk_register(NULL, &clk_pll2.hw); | 1117 | } |
1065 | BUG_ON(IS_ERR(clk)); | 1118 | clk_register_clkdev(prima2_clks[cpu], NULL, "cpu"); |
1066 | clk = clk_register(NULL, &clk_pll3.hw); | 1119 | clk_register_clkdev(prima2_clks[io], NULL, "io"); |
1067 | BUG_ON(IS_ERR(clk)); | 1120 | clk_register_clkdev(prima2_clks[mem], NULL, "mem"); |
1068 | clk = clk_register(NULL, &clk_mem.hw); | 1121 | |
1069 | BUG_ON(IS_ERR(clk)); | 1122 | clk_data.clks = prima2_clks; |
1070 | clk = clk_register(NULL, &clk_sys.hw); | 1123 | clk_data.clk_num = maxclk; |
1071 | BUG_ON(IS_ERR(clk)); | 1124 | |
1072 | clk = clk_register(NULL, &clk_security.hw); | 1125 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); |
1073 | BUG_ON(IS_ERR(clk)); | ||
1074 | clk_register_clkdev(clk, NULL, "b8030000.security"); | ||
1075 | clk = clk_register(NULL, &clk_dsp.hw); | ||
1076 | BUG_ON(IS_ERR(clk)); | ||
1077 | clk = clk_register(NULL, &clk_gps.hw); | ||
1078 | BUG_ON(IS_ERR(clk)); | ||
1079 | clk_register_clkdev(clk, NULL, "a8010000.gps"); | ||
1080 | clk = clk_register(NULL, &clk_mf.hw); | ||
1081 | BUG_ON(IS_ERR(clk)); | ||
1082 | clk = clk_register(NULL, &clk_io.hw); | ||
1083 | BUG_ON(IS_ERR(clk)); | ||
1084 | clk_register_clkdev(clk, NULL, "io"); | ||
1085 | clk = clk_register(NULL, &clk_cpu.hw); | ||
1086 | BUG_ON(IS_ERR(clk)); | ||
1087 | clk_register_clkdev(clk, NULL, "cpu"); | ||
1088 | clk = clk_register(NULL, &clk_uart0.hw); | ||
1089 | BUG_ON(IS_ERR(clk)); | ||
1090 | clk_register_clkdev(clk, NULL, "b0050000.uart"); | ||
1091 | clk = clk_register(NULL, &clk_uart1.hw); | ||
1092 | BUG_ON(IS_ERR(clk)); | ||
1093 | clk_register_clkdev(clk, NULL, "b0060000.uart"); | ||
1094 | clk = clk_register(NULL, &clk_uart2.hw); | ||
1095 | BUG_ON(IS_ERR(clk)); | ||
1096 | clk_register_clkdev(clk, NULL, "b0070000.uart"); | ||
1097 | clk = clk_register(NULL, &clk_tsc.hw); | ||
1098 | BUG_ON(IS_ERR(clk)); | ||
1099 | clk_register_clkdev(clk, NULL, "b0110000.tsc"); | ||
1100 | clk = clk_register(NULL, &clk_i2c0.hw); | ||
1101 | BUG_ON(IS_ERR(clk)); | ||
1102 | clk_register_clkdev(clk, NULL, "b00e0000.i2c"); | ||
1103 | clk = clk_register(NULL, &clk_i2c1.hw); | ||
1104 | BUG_ON(IS_ERR(clk)); | ||
1105 | clk_register_clkdev(clk, NULL, "b00f0000.i2c"); | ||
1106 | clk = clk_register(NULL, &clk_spi0.hw); | ||
1107 | BUG_ON(IS_ERR(clk)); | ||
1108 | clk_register_clkdev(clk, NULL, "b00d0000.spi"); | ||
1109 | clk = clk_register(NULL, &clk_spi1.hw); | ||
1110 | BUG_ON(IS_ERR(clk)); | ||
1111 | clk_register_clkdev(clk, NULL, "b0170000.spi"); | ||
1112 | clk = clk_register(NULL, &clk_pwmc.hw); | ||
1113 | BUG_ON(IS_ERR(clk)); | ||
1114 | clk_register_clkdev(clk, NULL, "b0130000.pwm"); | ||
1115 | clk = clk_register(NULL, &clk_efuse.hw); | ||
1116 | BUG_ON(IS_ERR(clk)); | ||
1117 | clk_register_clkdev(clk, NULL, "b0140000.efusesys"); | ||
1118 | clk = clk_register(NULL, &clk_pulse.hw); | ||
1119 | BUG_ON(IS_ERR(clk)); | ||
1120 | clk_register_clkdev(clk, NULL, "b0150000.pulsec"); | ||
1121 | clk = clk_register(NULL, &clk_dmac0.hw); | ||
1122 | BUG_ON(IS_ERR(clk)); | ||
1123 | clk_register_clkdev(clk, NULL, "b00b0000.dma-controller"); | ||
1124 | clk = clk_register(NULL, &clk_dmac1.hw); | ||
1125 | BUG_ON(IS_ERR(clk)); | ||
1126 | clk_register_clkdev(clk, NULL, "b0160000.dma-controller"); | ||
1127 | clk = clk_register(NULL, &clk_nand.hw); | ||
1128 | BUG_ON(IS_ERR(clk)); | ||
1129 | clk_register_clkdev(clk, NULL, "b0030000.nand"); | ||
1130 | clk = clk_register(NULL, &clk_audio.hw); | ||
1131 | BUG_ON(IS_ERR(clk)); | ||
1132 | clk_register_clkdev(clk, NULL, "b0040000.audio"); | ||
1133 | clk = clk_register(NULL, &clk_usp0.hw); | ||
1134 | BUG_ON(IS_ERR(clk)); | ||
1135 | clk_register_clkdev(clk, NULL, "b0080000.usp"); | ||
1136 | clk = clk_register(NULL, &clk_usp1.hw); | ||
1137 | BUG_ON(IS_ERR(clk)); | ||
1138 | clk_register_clkdev(clk, NULL, "b0090000.usp"); | ||
1139 | clk = clk_register(NULL, &clk_usp2.hw); | ||
1140 | BUG_ON(IS_ERR(clk)); | ||
1141 | clk_register_clkdev(clk, NULL, "b00a0000.usp"); | ||
1142 | clk = clk_register(NULL, &clk_vip.hw); | ||
1143 | BUG_ON(IS_ERR(clk)); | ||
1144 | clk_register_clkdev(clk, NULL, "b00c0000.vip"); | ||
1145 | clk = clk_register(NULL, &clk_gfx.hw); | ||
1146 | BUG_ON(IS_ERR(clk)); | ||
1147 | clk_register_clkdev(clk, NULL, "98000000.graphics"); | ||
1148 | clk = clk_register(NULL, &clk_mm.hw); | ||
1149 | BUG_ON(IS_ERR(clk)); | ||
1150 | clk_register_clkdev(clk, NULL, "a0000000.multimedia"); | ||
1151 | clk = clk_register(NULL, &clk_lcd.hw); | ||
1152 | BUG_ON(IS_ERR(clk)); | ||
1153 | clk_register_clkdev(clk, NULL, "90010000.display"); | ||
1154 | clk = clk_register(NULL, &clk_vpp.hw); | ||
1155 | BUG_ON(IS_ERR(clk)); | ||
1156 | clk_register_clkdev(clk, NULL, "90020000.vpp"); | ||
1157 | clk = clk_register(NULL, &clk_mmc01.hw); | ||
1158 | BUG_ON(IS_ERR(clk)); | ||
1159 | clk = clk_register(NULL, &clk_mmc23.hw); | ||
1160 | BUG_ON(IS_ERR(clk)); | ||
1161 | clk = clk_register(NULL, &clk_mmc45.hw); | ||
1162 | BUG_ON(IS_ERR(clk)); | ||
1163 | clk = clk_register(NULL, &usb_pll_clk_hw); | ||
1164 | BUG_ON(IS_ERR(clk)); | ||
1165 | clk = clk_register(NULL, &clk_usb0.hw); | ||
1166 | BUG_ON(IS_ERR(clk)); | ||
1167 | clk_register_clkdev(clk, NULL, "b00e0000.usb"); | ||
1168 | clk = clk_register(NULL, &clk_usb1.hw); | ||
1169 | BUG_ON(IS_ERR(clk)); | ||
1170 | clk_register_clkdev(clk, NULL, "b00f0000.usb"); | ||
1171 | } | 1126 | } |