Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gabor Juhos and committed by
Ralf Baechle
04225e1d 0bd3acdf

+83
+55
arch/mips/ath79/clock.c
··· 110 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 166 void __init ath79_clocks_init(void) 114 167 { 115 168 if (soc_is_ar71xx()) ··· 171 118 ar724x_clocks_init(); 172 119 else if (soc_is_ar913x()) 173 120 ar913x_clocks_init(); 121 + else if (soc_is_ar933x()) 122 + ar933x_clocks_init(); 174 123 else 175 124 BUG(); 176 125
+22
arch/mips/include/asm/mach-ath79/ar71xx_regs.h
··· 123 123 #define AR913X_AHB_DIV_SHIFT 19 124 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 145 * USB_CONFIG block 128 146 */ ··· 172 154 #define AR913X_RESET_REG_PERFC1 0x28 173 155 174 156 #define AR724X_RESET_REG_RESET_MODULE 0x1c 157 + 158 + #define AR933X_RESET_REG_BOOTSTRAP 0xac 175 159 176 160 #define MISC_INT_ETHSW BIT(12) 177 161 #define MISC_INT_TIMER4 BIT(10) ··· 223 203 #define AR913X_RESET_USBSUS_OVERRIDE BIT(10) 224 204 #define AR913X_RESET_USB_HOST BIT(5) 225 205 #define AR913X_RESET_USB_PHY BIT(4) 206 + 207 + #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0) 226 208 227 209 #define REV_ID_MAJOR_MASK 0xfff0 228 210 #define REV_ID_MAJOR_AR71XX 0x00a0
+6
arch/mips/include/asm/mach-ath79/ath79.h
··· 68 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 77 extern void __iomem *ath79_ddr_base; 72 78 extern void __iomem *ath79_pll_base; 73 79 extern void __iomem *ath79_reset_base;