diff options
Diffstat (limited to 'arch/mips/bcm63xx/clk.c')
-rw-r--r-- | arch/mips/bcm63xx/clk.c | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index 2c68ee9ccee2..9d57c71b7b58 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/mutex.h> | 10 | #include <linux/mutex.h> |
11 | #include <linux/err.h> | 11 | #include <linux/err.h> |
12 | #include <linux/clk.h> | 12 | #include <linux/clk.h> |
13 | #include <linux/delay.h> | ||
13 | #include <bcm63xx_cpu.h> | 14 | #include <bcm63xx_cpu.h> |
14 | #include <bcm63xx_io.h> | 15 | #include <bcm63xx_io.h> |
15 | #include <bcm63xx_regs.h> | 16 | #include <bcm63xx_regs.h> |
@@ -113,6 +114,34 @@ static struct clk clk_ephy = { | |||
113 | }; | 114 | }; |
114 | 115 | ||
115 | /* | 116 | /* |
117 | * Ethernet switch clock | ||
118 | */ | ||
119 | static void enetsw_set(struct clk *clk, int enable) | ||
120 | { | ||
121 | if (!BCMCPU_IS_6368()) | ||
122 | return; | ||
123 | bcm_hwclock_set(CKCTL_6368_ROBOSW_CLK_EN | | ||
124 | CKCTL_6368_SWPKT_USB_EN | | ||
125 | CKCTL_6368_SWPKT_SAR_EN, enable); | ||
126 | if (enable) { | ||
127 | u32 val; | ||
128 | |||
129 | /* reset switch core afer clock change */ | ||
130 | val = bcm_perf_readl(PERF_SOFTRESET_6368_REG); | ||
131 | val &= ~SOFTRESET_6368_ENETSW_MASK; | ||
132 | bcm_perf_writel(val, PERF_SOFTRESET_6368_REG); | ||
133 | msleep(10); | ||
134 | val |= SOFTRESET_6368_ENETSW_MASK; | ||
135 | bcm_perf_writel(val, PERF_SOFTRESET_6368_REG); | ||
136 | msleep(10); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | static struct clk clk_enetsw = { | ||
141 | .set = enetsw_set, | ||
142 | }; | ||
143 | |||
144 | /* | ||
116 | * PCM clock | 145 | * PCM clock |
117 | */ | 146 | */ |
118 | static void pcm_set(struct clk *clk, int enable) | 147 | static void pcm_set(struct clk *clk, int enable) |
@@ -131,9 +160,10 @@ static struct clk clk_pcm = { | |||
131 | */ | 160 | */ |
132 | static void usbh_set(struct clk *clk, int enable) | 161 | static void usbh_set(struct clk *clk, int enable) |
133 | { | 162 | { |
134 | if (!BCMCPU_IS_6348()) | 163 | if (BCMCPU_IS_6348()) |
135 | return; | 164 | bcm_hwclock_set(CKCTL_6348_USBH_EN, enable); |
136 | bcm_hwclock_set(CKCTL_6348_USBH_EN, enable); | 165 | else if (BCMCPU_IS_6368()) |
166 | bcm_hwclock_set(CKCTL_6368_USBH_CLK_EN, enable); | ||
137 | } | 167 | } |
138 | 168 | ||
139 | static struct clk clk_usbh = { | 169 | static struct clk clk_usbh = { |
@@ -162,6 +192,36 @@ static struct clk clk_spi = { | |||
162 | }; | 192 | }; |
163 | 193 | ||
164 | /* | 194 | /* |
195 | * XTM clock | ||
196 | */ | ||
197 | static void xtm_set(struct clk *clk, int enable) | ||
198 | { | ||
199 | if (!BCMCPU_IS_6368()) | ||
200 | return; | ||
201 | |||
202 | bcm_hwclock_set(CKCTL_6368_SAR_CLK_EN | | ||
203 | CKCTL_6368_SWPKT_SAR_EN, enable); | ||
204 | |||
205 | if (enable) { | ||
206 | u32 val; | ||
207 | |||
208 | /* reset sar core afer clock change */ | ||
209 | val = bcm_perf_readl(PERF_SOFTRESET_6368_REG); | ||
210 | val &= ~SOFTRESET_6368_SAR_MASK; | ||
211 | bcm_perf_writel(val, PERF_SOFTRESET_6368_REG); | ||
212 | mdelay(1); | ||
213 | val |= SOFTRESET_6368_SAR_MASK; | ||
214 | bcm_perf_writel(val, PERF_SOFTRESET_6368_REG); | ||
215 | mdelay(1); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | |||
220 | static struct clk clk_xtm = { | ||
221 | .set = xtm_set, | ||
222 | }; | ||
223 | |||
224 | /* | ||
165 | * Internal peripheral clock | 225 | * Internal peripheral clock |
166 | */ | 226 | */ |
167 | static struct clk clk_periph = { | 227 | static struct clk clk_periph = { |
@@ -204,12 +264,16 @@ struct clk *clk_get(struct device *dev, const char *id) | |||
204 | return &clk_enet0; | 264 | return &clk_enet0; |
205 | if (!strcmp(id, "enet1")) | 265 | if (!strcmp(id, "enet1")) |
206 | return &clk_enet1; | 266 | return &clk_enet1; |
267 | if (!strcmp(id, "enetsw")) | ||
268 | return &clk_enetsw; | ||
207 | if (!strcmp(id, "ephy")) | 269 | if (!strcmp(id, "ephy")) |
208 | return &clk_ephy; | 270 | return &clk_ephy; |
209 | if (!strcmp(id, "usbh")) | 271 | if (!strcmp(id, "usbh")) |
210 | return &clk_usbh; | 272 | return &clk_usbh; |
211 | if (!strcmp(id, "spi")) | 273 | if (!strcmp(id, "spi")) |
212 | return &clk_spi; | 274 | return &clk_spi; |
275 | if (!strcmp(id, "xtm")) | ||
276 | return &clk_xtm; | ||
213 | if (!strcmp(id, "periph")) | 277 | if (!strcmp(id, "periph")) |
214 | return &clk_periph; | 278 | return &clk_periph; |
215 | if (BCMCPU_IS_6358() && !strcmp(id, "pcm")) | 279 | if (BCMCPU_IS_6358() && !strcmp(id, "pcm")) |