diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 20:56:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-11 20:56:37 -0500 |
commit | c0222ac086669a631814bbf857f8c8023452a4d7 (patch) | |
tree | bb1d9908031fcf69016eeefa7b35a4f68f414333 /drivers/clk | |
parent | 140cd7fb04a4a2bc09a30980bc8104cc89e09330 (diff) | |
parent | e2965cd0003f222bd49f67907c2bc6ed691c6d20 (diff) |
Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus
Pull MIPS updates from Ralf Baechle:
"This is an unusually large pull request for MIPS - in parts because
lots of patches missed the 3.18 deadline but primarily because some
folks opened the flood gates.
- Retire the MIPS-specific phys_t with the generic phys_addr_t.
- Improvments for the backtrace code used by oprofile.
- Better backtraces on SMP systems.
- Cleanups for the Octeon platform code.
- Cleanups and fixes for the Loongson platform code.
- Cleanups and fixes to the firmware library.
- Switch ATH79 platform to use the firmware library.
- Grand overhault to the SEAD3 and Malta interrupt code.
- Move the GIC interrupt code to drivers/irqchip
- Lots of GIC cleanups and updates to the GIC code to use modern IRQ
infrastructures and features of the kernel.
- OF documentation updates for the GIC bindings
- Move GIC clocksource driver to drivers/clocksource
- Merge GIC clocksource driver with clockevent driver.
- Further updates to bring the GIC clocksource driver up to date.
- R3000 TLB code cleanups
- Improvments to the Loongson 3 platform code.
- Convert pr_warning to pr_warn.
- Merge a bunch of small lantiq and ralink fixes that have been
staged/lingering inside the openwrt tree for a while.
- Update archhelp for IP22/IP32
- Fix a number of issues for Loongson 1B.
- New clocksource and clockevent driver for Loongson 1B.
- Further work on clk handling for Loongson 1B.
- Platform work for Broadcom BMIPS.
- Error handling cleanups for TurboChannel.
- Fixes and optimization to the microMIPS support.
- Option to disable the FTLB.
- Dump more relevant information on machine check exception
- Change binfmt to allow arch to examine PT_*PROC headers
- Support for new style FPU register model in O32
- VDSO randomization.
- BCM47xx cleanups
- BCM47xx reimplement the way the kernel accesses NVRAM information.
- Random cleanups
- Add support for ATH25 platforms
- Remove pointless locking code in some PCI platforms.
- Some improvments to EVA support
- Minor Alchemy cleanup"
* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (185 commits)
MIPS: Add MFHC0 and MTHC0 instructions to uasm.
MIPS: Cosmetic cleanups of page table headers.
MIPS: Add CP0 macros for extended EntryLo registers
MIPS: Remove now unused definition of phys_t.
MIPS: Replace use of phys_t with phys_addr_t.
MIPS: Replace MIPS-specific 64BIT_PHYS_ADDR with generic PHYS_ADDR_T_64BIT
PCMCIA: Alchemy Don't select 64BIT_PHYS_ADDR in Kconfig.
MIPS: lib: memset: Clean up some MIPS{EL,EB} ifdefery
MIPS: iomap: Use __mem_{read,write}{b,w,l} for MMIO
MIPS: <asm/types.h> fix indentation.
MAINTAINERS: Add entry for BMIPS multiplatform kernel
MIPS: Enable VDSO randomization
MIPS: Remove a temporary hack for debugging cache flushes in SMTC configuration
MIPS: Remove declaration of obsolete arch_init_clk_ops()
MIPS: atomic.h: Reformat to fit in 79 columns
MIPS: Apply `.insn' to fixup labels throughout
MIPS: Fix microMIPS LL/SC immediate offsets
MIPS: Kconfig: Only allow 32-bit microMIPS builds
MIPS: signal.c: Fix an invalid cast in ISA mode bit handling
MIPS: mm: Only build one microassembler that is suitable
...
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-ls1x.c | 109 |
1 files changed, 80 insertions, 29 deletions
diff --git a/drivers/clk/clk-ls1x.c b/drivers/clk/clk-ls1x.c index f20b750235f6..ca80103ac188 100644 --- a/drivers/clk/clk-ls1x.c +++ b/drivers/clk/clk-ls1x.c | |||
@@ -15,7 +15,8 @@ | |||
15 | 15 | ||
16 | #include <loongson1.h> | 16 | #include <loongson1.h> |
17 | 17 | ||
18 | #define OSC 33 | 18 | #define OSC (33 * 1000000) |
19 | #define DIV_APB 2 | ||
19 | 20 | ||
20 | static DEFINE_SPINLOCK(_lock); | 21 | static DEFINE_SPINLOCK(_lock); |
21 | 22 | ||
@@ -29,13 +30,12 @@ static void ls1x_pll_clk_disable(struct clk_hw *hw) | |||
29 | } | 30 | } |
30 | 31 | ||
31 | static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, | 32 | static unsigned long ls1x_pll_recalc_rate(struct clk_hw *hw, |
32 | unsigned long parent_rate) | 33 | unsigned long parent_rate) |
33 | { | 34 | { |
34 | u32 pll, rate; | 35 | u32 pll, rate; |
35 | 36 | ||
36 | pll = __raw_readl(LS1X_CLK_PLL_FREQ); | 37 | pll = __raw_readl(LS1X_CLK_PLL_FREQ); |
37 | rate = ((12 + (pll & 0x3f)) * 1000000) + | 38 | rate = 12 + (pll & 0x3f) + (((pll >> 8) & 0x3ff) >> 10); |
38 | ((((pll >> 8) & 0x3ff) * 1000000) >> 10); | ||
39 | rate *= OSC; | 39 | rate *= OSC; |
40 | rate >>= 1; | 40 | rate >>= 1; |
41 | 41 | ||
@@ -48,8 +48,10 @@ static const struct clk_ops ls1x_pll_clk_ops = { | |||
48 | .recalc_rate = ls1x_pll_recalc_rate, | 48 | .recalc_rate = ls1x_pll_recalc_rate, |
49 | }; | 49 | }; |
50 | 50 | ||
51 | static struct clk * __init clk_register_pll(struct device *dev, | 51 | static struct clk *__init clk_register_pll(struct device *dev, |
52 | const char *name, const char *parent_name, unsigned long flags) | 52 | const char *name, |
53 | const char *parent_name, | ||
54 | unsigned long flags) | ||
53 | { | 55 | { |
54 | struct clk_hw *hw; | 56 | struct clk_hw *hw; |
55 | struct clk *clk; | 57 | struct clk *clk; |
@@ -78,34 +80,83 @@ static struct clk * __init clk_register_pll(struct device *dev, | |||
78 | return clk; | 80 | return clk; |
79 | } | 81 | } |
80 | 82 | ||
83 | static const char const *cpu_parents[] = { "cpu_clk_div", "osc_33m_clk", }; | ||
84 | static const char const *ahb_parents[] = { "ahb_clk_div", "osc_33m_clk", }; | ||
85 | static const char const *dc_parents[] = { "dc_clk_div", "osc_33m_clk", }; | ||
86 | |||
81 | void __init ls1x_clk_init(void) | 87 | void __init ls1x_clk_init(void) |
82 | { | 88 | { |
83 | struct clk *clk; | 89 | struct clk *clk; |
84 | 90 | ||
85 | clk = clk_register_pll(NULL, "pll_clk", NULL, CLK_IS_ROOT); | 91 | clk = clk_register_fixed_rate(NULL, "osc_33m_clk", NULL, CLK_IS_ROOT, |
86 | clk_prepare_enable(clk); | 92 | OSC); |
87 | 93 | clk_register_clkdev(clk, "osc_33m_clk", NULL); | |
88 | clk = clk_register_divider(NULL, "cpu_clk", "pll_clk", | 94 | |
89 | CLK_SET_RATE_PARENT, LS1X_CLK_PLL_DIV, DIV_CPU_SHIFT, | 95 | /* clock derived from 33 MHz OSC clk */ |
90 | DIV_CPU_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); | 96 | clk = clk_register_pll(NULL, "pll_clk", "osc_33m_clk", 0); |
91 | clk_prepare_enable(clk); | 97 | clk_register_clkdev(clk, "pll_clk", NULL); |
92 | clk_register_clkdev(clk, "cpu", NULL); | 98 | |
93 | 99 | /* clock derived from PLL clk */ | |
94 | clk = clk_register_divider(NULL, "dc_clk", "pll_clk", | 100 | /* _____ |
95 | CLK_SET_RATE_PARENT, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, | 101 | * _______________________| | |
96 | DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); | 102 | * OSC ___/ | MUX |___ CPU CLK |
97 | clk_prepare_enable(clk); | 103 | * \___ PLL ___ CPU DIV ___| | |
98 | clk_register_clkdev(clk, "dc", NULL); | 104 | * |_____| |
99 | 105 | */ | |
100 | clk = clk_register_divider(NULL, "ahb_clk", "pll_clk", | 106 | clk = clk_register_divider(NULL, "cpu_clk_div", "pll_clk", |
101 | CLK_SET_RATE_PARENT, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT, | 107 | CLK_GET_RATE_NOCACHE, LS1X_CLK_PLL_DIV, |
102 | DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); | 108 | DIV_CPU_SHIFT, DIV_CPU_WIDTH, |
103 | clk_prepare_enable(clk); | 109 | CLK_DIVIDER_ONE_BASED | |
104 | clk_register_clkdev(clk, "ahb", NULL); | 110 | CLK_DIVIDER_ROUND_CLOSEST, &_lock); |
111 | clk_register_clkdev(clk, "cpu_clk_div", NULL); | ||
112 | clk = clk_register_mux(NULL, "cpu_clk", cpu_parents, | ||
113 | ARRAY_SIZE(cpu_parents), | ||
114 | CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, | ||
115 | BYPASS_CPU_SHIFT, BYPASS_CPU_WIDTH, 0, &_lock); | ||
116 | clk_register_clkdev(clk, "cpu_clk", NULL); | ||
117 | |||
118 | /* _____ | ||
119 | * _______________________| | | ||
120 | * OSC ___/ | MUX |___ DC CLK | ||
121 | * \___ PLL ___ DC DIV ___| | | ||
122 | * |_____| | ||
123 | */ | ||
124 | clk = clk_register_divider(NULL, "dc_clk_div", "pll_clk", | ||
125 | 0, LS1X_CLK_PLL_DIV, DIV_DC_SHIFT, | ||
126 | DIV_DC_WIDTH, CLK_DIVIDER_ONE_BASED, &_lock); | ||
127 | clk_register_clkdev(clk, "dc_clk_div", NULL); | ||
128 | clk = clk_register_mux(NULL, "dc_clk", dc_parents, | ||
129 | ARRAY_SIZE(dc_parents), | ||
130 | CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, | ||
131 | BYPASS_DC_SHIFT, BYPASS_DC_WIDTH, 0, &_lock); | ||
132 | clk_register_clkdev(clk, "dc_clk", NULL); | ||
133 | |||
134 | /* _____ | ||
135 | * _______________________| | | ||
136 | * OSC ___/ | MUX |___ DDR CLK | ||
137 | * \___ PLL ___ DDR DIV ___| | | ||
138 | * |_____| | ||
139 | */ | ||
140 | clk = clk_register_divider(NULL, "ahb_clk_div", "pll_clk", | ||
141 | 0, LS1X_CLK_PLL_DIV, DIV_DDR_SHIFT, | ||
142 | DIV_DDR_WIDTH, CLK_DIVIDER_ONE_BASED, | ||
143 | &_lock); | ||
144 | clk_register_clkdev(clk, "ahb_clk_div", NULL); | ||
145 | clk = clk_register_mux(NULL, "ahb_clk", ahb_parents, | ||
146 | ARRAY_SIZE(ahb_parents), | ||
147 | CLK_SET_RATE_NO_REPARENT, LS1X_CLK_PLL_DIV, | ||
148 | BYPASS_DDR_SHIFT, BYPASS_DDR_WIDTH, 0, &_lock); | ||
149 | clk_register_clkdev(clk, "ahb_clk", NULL); | ||
105 | clk_register_clkdev(clk, "stmmaceth", NULL); | 150 | clk_register_clkdev(clk, "stmmaceth", NULL); |
106 | 151 | ||
107 | clk = clk_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, 2); | 152 | /* clock derived from AHB clk */ |
108 | clk_prepare_enable(clk); | 153 | /* APB clk is always half of the AHB clk */ |
109 | clk_register_clkdev(clk, "apb", NULL); | 154 | clk = clk_register_fixed_factor(NULL, "apb_clk", "ahb_clk", 0, 1, |
155 | DIV_APB); | ||
156 | clk_register_clkdev(clk, "apb_clk", NULL); | ||
157 | clk_register_clkdev(clk, "ls1x_i2c", NULL); | ||
158 | clk_register_clkdev(clk, "ls1x_pwmtimer", NULL); | ||
159 | clk_register_clkdev(clk, "ls1x_spi", NULL); | ||
160 | clk_register_clkdev(clk, "ls1x_wdt", NULL); | ||
110 | clk_register_clkdev(clk, "serial8250", NULL); | 161 | clk_register_clkdev(clk, "serial8250", NULL); |
111 | } | 162 | } |