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

MIPS: BCM63XX: add and use a clock for PCIe

Add a PCIe clock and use that instead of directly touching the clock
control register. While at it, fail if there is no such clock.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/4452
Signed-off-by: John Crispin <blogic@openwrt.org>

authored by

Jonas Gorski and committed by
John Crispin
f2d1035e b8ebbaff

+25 -5
+15
arch/mips/bcm63xx/clk.c
··· 253 253 }; 254 254 255 255 /* 256 + * PCIe clock 257 + */ 258 + 259 + static void pcie_set(struct clk *clk, int enable) 260 + { 261 + bcm_hwclock_set(CKCTL_6328_PCIE_EN, enable); 262 + } 263 + 264 + static struct clk clk_pcie = { 265 + .set = pcie_set, 266 + }; 267 + 268 + /* 256 269 * Internal peripheral clock 257 270 */ 258 271 static struct clk clk_periph = { ··· 326 313 return &clk_pcm; 327 314 if (BCMCPU_IS_6368() && !strcmp(id, "ipsec")) 328 315 return &clk_ipsec; 316 + if (BCMCPU_IS_6328() && !strcmp(id, "pcie")) 317 + return &clk_pcie; 329 318 return ERR_PTR(-ENOENT); 330 319 } 331 320
+10 -5
arch/mips/pci/pci-bcm63xx.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/init.h> 13 13 #include <linux/delay.h> 14 + #include <linux/clk.h> 14 15 #include <asm/bootinfo.h> 15 16 16 17 #include "pci-bcm63xx.h" ··· 120 119 { 121 120 u32 val; 122 121 123 - /* enable clock */ 124 - val = bcm_perf_readl(PERF_CKCTL_REG); 125 - val |= CKCTL_6328_PCIE_EN; 126 - bcm_perf_writel(val, PERF_CKCTL_REG); 127 - 128 122 /* enable SERDES */ 129 123 val = bcm_misc_readl(MISC_SERDES_CTRL_REG); 130 124 val |= SERDES_PCIE_EN | SERDES_PCIE_EXD_EN; ··· 146 150 mdelay(200); 147 151 } 148 152 153 + static struct clk *pcie_clk; 154 + 149 155 static int __init bcm63xx_register_pcie(void) 150 156 { 151 157 u32 val; 158 + 159 + /* enable clock */ 160 + pcie_clk = clk_get(NULL, "pcie"); 161 + if (IS_ERR_OR_NULL(pcie_clk)) 162 + return -ENODEV; 163 + 164 + clk_prepare_enable(pcie_clk); 152 165 153 166 bcm63xx_reset_pcie(); 154 167