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

MIPS, clk: move jz4740 clock suspend, resume functions to jz4740-cgu

The jz4740-cgu driver already has access to the CGU, so it makes sense
to move the few remaining accesses to the CGU from arch/mips/jz4740
there too. Move the jz4740_clock_{suspend,resume} functions there for
such consistency. The arch/mips/jz4740/clock.c file now contains nothing
more of use & so is removed.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: linux-clk@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: Deng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/10158/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
50d893ff ed286ca5

+38 -99
-2
arch/mips/include/asm/mach-jz4740/clock.h
··· 20 20 JZ4740_WAIT_MODE_SLEEP, 21 21 }; 22 22 23 - int jz4740_clock_init(void); 24 - 25 23 void jz4740_clock_set_wait_mode(enum jz4740_wait_mode mode); 26 24 27 25 void jz4740_clock_udc_enable_auto_suspend(void);
+1 -1
arch/mips/jz4740/Makefile
··· 5 5 # Object file lists. 6 6 7 7 obj-y += prom.o time.o reset.o setup.o \ 8 - gpio.o clock.o platform.o timer.o serial.o 8 + gpio.o platform.o timer.o serial.o 9 9 10 10 # board specific support 11 11
-95
arch/mips/jz4740/clock.c
··· 1 - /* 2 - * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> 3 - * JZ4740 SoC clock support 4 - * 5 - * This program is free software; you can redistribute it and/or modify it 6 - * under the terms of the GNU General Public License as published by the 7 - * Free Software Foundation; either version 2 of the License, or (at your 8 - * option) any later version. 9 - * 10 - * You should have received a copy of the GNU General Public License along 11 - * with this program; if not, write to the Free Software Foundation, Inc., 12 - * 675 Mass Ave, Cambridge, MA 02139, USA. 13 - * 14 - */ 15 - 16 - #include <linux/kernel.h> 17 - #include <linux/errno.h> 18 - #include <linux/clk.h> 19 - #include <linux/clk-provider.h> 20 - #include <linux/spinlock.h> 21 - #include <linux/io.h> 22 - #include <linux/module.h> 23 - #include <linux/list.h> 24 - #include <linux/err.h> 25 - 26 - #include <asm/mach-jz4740/clock.h> 27 - #include <asm/mach-jz4740/base.h> 28 - 29 - #include "clock.h" 30 - 31 - #define JZ_REG_CLOCK_PLL 0x10 32 - #define JZ_REG_CLOCK_GATE 0x20 33 - 34 - #define JZ_CLOCK_GATE_UART0 BIT(0) 35 - #define JZ_CLOCK_GATE_TCU BIT(1) 36 - #define JZ_CLOCK_GATE_DMAC BIT(12) 37 - 38 - #define JZ_CLOCK_PLL_STABLE BIT(10) 39 - #define JZ_CLOCK_PLL_ENABLED BIT(8) 40 - 41 - static void __iomem *jz_clock_base; 42 - 43 - static uint32_t jz_clk_reg_read(int reg) 44 - { 45 - return readl(jz_clock_base + reg); 46 - } 47 - 48 - static void jz_clk_reg_set_bits(int reg, uint32_t mask) 49 - { 50 - uint32_t val; 51 - 52 - val = readl(jz_clock_base + reg); 53 - val |= mask; 54 - writel(val, jz_clock_base + reg); 55 - } 56 - 57 - static void jz_clk_reg_clear_bits(int reg, uint32_t mask) 58 - { 59 - uint32_t val; 60 - 61 - val = readl(jz_clock_base + reg); 62 - val &= ~mask; 63 - writel(val, jz_clock_base + reg); 64 - } 65 - 66 - void jz4740_clock_suspend(void) 67 - { 68 - jz_clk_reg_set_bits(JZ_REG_CLOCK_GATE, 69 - JZ_CLOCK_GATE_TCU | JZ_CLOCK_GATE_DMAC | JZ_CLOCK_GATE_UART0); 70 - 71 - jz_clk_reg_clear_bits(JZ_REG_CLOCK_PLL, JZ_CLOCK_PLL_ENABLED); 72 - } 73 - 74 - void jz4740_clock_resume(void) 75 - { 76 - uint32_t pll; 77 - 78 - jz_clk_reg_set_bits(JZ_REG_CLOCK_PLL, JZ_CLOCK_PLL_ENABLED); 79 - 80 - do { 81 - pll = jz_clk_reg_read(JZ_REG_CLOCK_PLL); 82 - } while (!(pll & JZ_CLOCK_PLL_STABLE)); 83 - 84 - jz_clk_reg_clear_bits(JZ_REG_CLOCK_GATE, 85 - JZ_CLOCK_GATE_TCU | JZ_CLOCK_GATE_DMAC | JZ_CLOCK_GATE_UART0); 86 - } 87 - 88 - int jz4740_clock_init(void) 89 - { 90 - jz_clock_base = ioremap(JZ4740_CPM_BASE_ADDR, 0x100); 91 - if (!jz_clock_base) 92 - return -EBUSY; 93 - 94 - return 0; 95 - }
-1
arch/mips/jz4740/time.c
··· 120 120 struct clk *ext_clk; 121 121 122 122 of_clk_init(NULL); 123 - jz4740_clock_init(); 124 123 jz4740_timer_init(); 125 124 126 125 ext_clk = clk_get(NULL, "ext");
+37
drivers/clk/ingenic/jz4740-cgu.c
··· 264 264 writel(clkgr, cgu->base + CGU_REG_CLKGR); 265 265 } 266 266 EXPORT_SYMBOL_GPL(jz4740_clock_udc_enable_auto_suspend); 267 + 268 + #define JZ_CLOCK_GATE_UART0 BIT(0) 269 + #define JZ_CLOCK_GATE_TCU BIT(1) 270 + #define JZ_CLOCK_GATE_DMAC BIT(12) 271 + 272 + void jz4740_clock_suspend(void) 273 + { 274 + uint32_t clkgr, cppcr; 275 + 276 + clkgr = readl(cgu->base + CGU_REG_CLKGR); 277 + clkgr |= JZ_CLOCK_GATE_TCU | JZ_CLOCK_GATE_DMAC | JZ_CLOCK_GATE_UART0; 278 + writel(clkgr, cgu->base + CGU_REG_CLKGR); 279 + 280 + cppcr = readl(cgu->base + CGU_REG_CPPCR); 281 + cppcr &= ~BIT(jz4740_cgu_clocks[JZ4740_CLK_PLL].pll.enable_bit); 282 + writel(cppcr, cgu->base + CGU_REG_CPPCR); 283 + } 284 + 285 + void jz4740_clock_resume(void) 286 + { 287 + uint32_t clkgr, cppcr, stable; 288 + 289 + cppcr = readl(cgu->base + CGU_REG_CPPCR); 290 + cppcr |= BIT(jz4740_cgu_clocks[JZ4740_CLK_PLL].pll.enable_bit); 291 + writel(cppcr, cgu->base + CGU_REG_CPPCR); 292 + 293 + stable = BIT(jz4740_cgu_clocks[JZ4740_CLK_PLL].pll.stable_bit); 294 + do { 295 + cppcr = readl(cgu->base + CGU_REG_CPPCR); 296 + } while (!(cppcr & stable)); 297 + 298 + clkgr = readl(cgu->base + CGU_REG_CLKGR); 299 + clkgr &= ~JZ_CLOCK_GATE_TCU; 300 + clkgr &= ~JZ_CLOCK_GATE_DMAC; 301 + clkgr &= ~JZ_CLOCK_GATE_UART0; 302 + writel(clkgr, cgu->base + CGU_REG_CLKGR); 303 + }