diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2011-06-20 15:26:04 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-12-07 17:02:45 -0500 |
commit | 04225e1d227c8e68d685936ecf42ac175fec0e54 (patch) | |
tree | e7ecd726ca40a58c1d11bc6753dd7e4c8c72c107 | |
parent | 0bd3acdf7d559c8289de73c4c711fd2381e6c7ad (diff) |
MIPS: ath79: add AR933X specific clock init
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: Kathy Giori <kgiori@qca.qualcomm.com>
Cc: "Luis R. Rodriguez" <rodrigue@qca.qualcomm.com>
Patchwork: https://patchwork.linux-mips.org/patch/2522/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/ath79/clock.c | 55 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 22 | ||||
-rw-r--r-- | arch/mips/include/asm/mach-ath79/ath79.h | 6 |
3 files changed, 83 insertions, 0 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 680bde99a26c..54d0eb4db987 100644 --- a/arch/mips/ath79/clock.c +++ b/arch/mips/ath79/clock.c | |||
@@ -110,6 +110,59 @@ static void __init ar913x_clocks_init(void) | |||
110 | ath79_uart_clk.rate = ath79_ahb_clk.rate; | 110 | ath79_uart_clk.rate = ath79_ahb_clk.rate; |
111 | } | 111 | } |
112 | 112 | ||
113 | static void __init ar933x_clocks_init(void) | ||
114 | { | ||
115 | u32 clock_ctrl; | ||
116 | u32 cpu_config; | ||
117 | u32 freq; | ||
118 | u32 t; | ||
119 | |||
120 | t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP); | ||
121 | if (t & AR933X_BOOTSTRAP_REF_CLK_40) | ||
122 | ath79_ref_clk.rate = (40 * 1000 * 1000); | ||
123 | else | ||
124 | ath79_ref_clk.rate = (25 * 1000 * 1000); | ||
125 | |||
126 | clock_ctrl = ath79_pll_rr(AR933X_PLL_CLOCK_CTRL_REG); | ||
127 | if (clock_ctrl & AR933X_PLL_CLOCK_CTRL_BYPASS) { | ||
128 | ath79_cpu_clk.rate = ath79_ref_clk.rate; | ||
129 | ath79_ahb_clk.rate = ath79_ref_clk.rate; | ||
130 | ath79_ddr_clk.rate = ath79_ref_clk.rate; | ||
131 | } else { | ||
132 | cpu_config = ath79_pll_rr(AR933X_PLL_CPU_CONFIG_REG); | ||
133 | |||
134 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT) & | ||
135 | AR933X_PLL_CPU_CONFIG_REFDIV_MASK; | ||
136 | freq = ath79_ref_clk.rate / t; | ||
137 | |||
138 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_NINT_SHIFT) & | ||
139 | AR933X_PLL_CPU_CONFIG_NINT_MASK; | ||
140 | freq *= t; | ||
141 | |||
142 | t = (cpu_config >> AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT) & | ||
143 | AR933X_PLL_CPU_CONFIG_OUTDIV_MASK; | ||
144 | if (t == 0) | ||
145 | t = 1; | ||
146 | |||
147 | freq >>= t; | ||
148 | |||
149 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT) & | ||
150 | AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK) + 1; | ||
151 | ath79_cpu_clk.rate = freq / t; | ||
152 | |||
153 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT) & | ||
154 | AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK) + 1; | ||
155 | ath79_ddr_clk.rate = freq / t; | ||
156 | |||
157 | t = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT) & | ||
158 | AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK) + 1; | ||
159 | ath79_ahb_clk.rate = freq / t; | ||
160 | } | ||
161 | |||
162 | ath79_wdt_clk.rate = ath79_ref_clk.rate; | ||
163 | ath79_uart_clk.rate = ath79_ref_clk.rate; | ||
164 | } | ||
165 | |||
113 | void __init ath79_clocks_init(void) | 166 | void __init ath79_clocks_init(void) |
114 | { | 167 | { |
115 | if (soc_is_ar71xx()) | 168 | if (soc_is_ar71xx()) |
@@ -118,6 +171,8 @@ void __init ath79_clocks_init(void) | |||
118 | ar724x_clocks_init(); | 171 | ar724x_clocks_init(); |
119 | else if (soc_is_ar913x()) | 172 | else if (soc_is_ar913x()) |
120 | ar913x_clocks_init(); | 173 | ar913x_clocks_init(); |
174 | else if (soc_is_ar933x()) | ||
175 | ar933x_clocks_init(); | ||
121 | else | 176 | else |
122 | BUG(); | 177 | BUG(); |
123 | 178 | ||
diff --git a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h index 90223f206610..418b7392e8c3 100644 --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h | |||
@@ -123,6 +123,24 @@ | |||
123 | #define AR913X_AHB_DIV_SHIFT 19 | 123 | #define AR913X_AHB_DIV_SHIFT 19 |
124 | #define AR913X_AHB_DIV_MASK 0x1 | 124 | #define AR913X_AHB_DIV_MASK 0x1 |
125 | 125 | ||
126 | #define AR933X_PLL_CPU_CONFIG_REG 0x00 | ||
127 | #define AR933X_PLL_CLOCK_CTRL_REG 0x08 | ||
128 | |||
129 | #define AR933X_PLL_CPU_CONFIG_NINT_SHIFT 10 | ||
130 | #define AR933X_PLL_CPU_CONFIG_NINT_MASK 0x3f | ||
131 | #define AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT 16 | ||
132 | #define AR933X_PLL_CPU_CONFIG_REFDIV_MASK 0x1f | ||
133 | #define AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT 23 | ||
134 | #define AR933X_PLL_CPU_CONFIG_OUTDIV_MASK 0x7 | ||
135 | |||
136 | #define AR933X_PLL_CLOCK_CTRL_BYPASS BIT(2) | ||
137 | #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT 5 | ||
138 | #define AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK 0x3 | ||
139 | #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT 10 | ||
140 | #define AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK 0x3 | ||
141 | #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT 15 | ||
142 | #define AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK 0x7 | ||
143 | |||
126 | /* | 144 | /* |
127 | * USB_CONFIG block | 145 | * USB_CONFIG block |
128 | */ | 146 | */ |
@@ -155,6 +173,8 @@ | |||
155 | 173 | ||
156 | #define AR724X_RESET_REG_RESET_MODULE 0x1c | 174 | #define AR724X_RESET_REG_RESET_MODULE 0x1c |
157 | 175 | ||
176 | #define AR933X_RESET_REG_BOOTSTRAP 0xac | ||
177 | |||
158 | #define MISC_INT_ETHSW BIT(12) | 178 | #define MISC_INT_ETHSW BIT(12) |
159 | #define MISC_INT_TIMER4 BIT(10) | 179 | #define MISC_INT_TIMER4 BIT(10) |
160 | #define MISC_INT_TIMER3 BIT(9) | 180 | #define MISC_INT_TIMER3 BIT(9) |
@@ -204,6 +224,8 @@ | |||
204 | #define AR913X_RESET_USB_HOST BIT(5) | 224 | #define AR913X_RESET_USB_HOST BIT(5) |
205 | #define AR913X_RESET_USB_PHY BIT(4) | 225 | #define AR913X_RESET_USB_PHY BIT(4) |
206 | 226 | ||
227 | #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0) | ||
228 | |||
207 | #define REV_ID_MAJOR_MASK 0xfff0 | 229 | #define REV_ID_MAJOR_MASK 0xfff0 |
208 | #define REV_ID_MAJOR_AR71XX 0x00a0 | 230 | #define REV_ID_MAJOR_AR71XX 0x00a0 |
209 | #define REV_ID_MAJOR_AR913X 0x00b0 | 231 | #define REV_ID_MAJOR_AR913X 0x00b0 |
diff --git a/arch/mips/include/asm/mach-ath79/ath79.h b/arch/mips/include/asm/mach-ath79/ath79.h index 2dfc94c0444b..407c9354f747 100644 --- a/arch/mips/include/asm/mach-ath79/ath79.h +++ b/arch/mips/include/asm/mach-ath79/ath79.h | |||
@@ -68,6 +68,12 @@ static inline int soc_is_ar913x(void) | |||
68 | ath79_soc == ATH79_SOC_AR9132); | 68 | ath79_soc == ATH79_SOC_AR9132); |
69 | } | 69 | } |
70 | 70 | ||
71 | static inline int soc_is_ar933x(void) | ||
72 | { | ||
73 | return (ath79_soc == ATH79_SOC_AR9330 || | ||
74 | ath79_soc == ATH79_SOC_AR9331); | ||
75 | } | ||
76 | |||
71 | extern void __iomem *ath79_ddr_base; | 77 | extern void __iomem *ath79_ddr_base; |
72 | extern void __iomem *ath79_pll_base; | 78 | extern void __iomem *ath79_pll_base; |
73 | extern void __iomem *ath79_reset_base; | 79 | extern void __iomem *ath79_reset_base; |