16 #include <linux/kernel.h>
25 #include <mach/common.h>
26 #include <mach/time.h>
27 #include <mach/cputype.h>
30 #include <mach/irqs.h>
31 #include <mach/hardware.h>
39 #define TNETV107X_INTC_BASE 0x03000000
40 #define TNETV107X_TIMER0_BASE 0x08086500
41 #define TNETV107X_TIMER1_BASE 0x08086600
42 #define TNETV107X_CHIP_CFG_BASE 0x08087000
43 #define TNETV107X_GPIO_BASE 0x08088000
44 #define TNETV107X_CLOCK_CONTROL_BASE 0x0808a000
45 #define TNETV107X_PSC_BASE 0x0808b000
48 #define OSC_FREQ_ONCHIP (24000 * 1000)
49 #define OSC_FREQ_OFFCHIP_SYS (25000 * 1000)
50 #define OSC_FREQ_OFFCHIP_ETH (25000 * 1000)
51 #define OSC_FREQ_OFFCHIP_TDM (19200 * 1000)
95 static int sspll_regs_base[
N_PLLS] = { 0x40, 0x80, 0xc0 };
101 static u32 pll_ext_freq[] = {
111 static u32 intc_host_map[] = { 0x01010000, 0x01010101, -1 };
113 static unsigned long clk_sspll_recalc(
struct clk *
clk);
116 #define define_pll_clk(cname, pll, divmask, base) \
117 static struct pll_data pll_##cname##_data = { \
119 .div_ratio_mask = divmask, \
120 .phys_base = base + \
121 TNETV107X_CLOCK_CONTROL_BASE, \
123 static struct clk pll_##cname##_clk = { \
124 .name = "pll_" #cname "_clk", \
125 .pll_data = &pll_##cname##_data, \
127 .recalc = clk_sspll_recalc, \
135 #define define_pll_div_clk(pll, cname, div) \
136 static struct clk pll##_##cname##_clk = { \
137 .name = #pll "_" #cname "_clk", \
138 .parent = &pll_##pll##_clk, \
140 .div_reg = PLLDIV##div, \
141 .set_rate = davinci_set_sysclk_rate, \
165 #define __lpsc_clk(cname, _parent, mod, flg) \
166 static struct clk clk_##cname = { \
168 .parent = &_parent, \
169 .lpsc = TNETV107X_LPSC_##mod,\
173 #define lpsc_clk_enabled(cname, parent, mod) \
174 __lpsc_clk(cname, parent, mod, ALWAYS_ENABLED)
176 #define lpsc_clk(cname, parent, mod) \
177 __lpsc_clk(cname, parent, mod, 0)
199 lpsc_clk(mbx_lite, sys_arm1176_clk, MBX_LITE);
200 lpsc_clk(ethss, eth_125mhz_clk, ETHSS);
202 lpsc_clk(uart0, sys_half_clk, UART0);
203 lpsc_clk(uart1, sys_half_clk, UART1);
204 lpsc_clk(uart2, sys_half_clk, UART2);
205 lpsc_clk(pktsec, sys_half_clk, PKTSEC);
206 lpsc_clk(keypad, sys_half_clk, KEYPAD);
208 lpsc_clk(sdio0, sys_half_clk, SDIO0);
209 lpsc_clk(sdio1, sys_half_clk, SDIO1);
211 lpsc_clk(wdt_dsp, sys_half_clk, WDT_DSP);
215 lpsc_clk(vlynq, sys_vlynq_ref_clk, VLYNQ);
216 lpsc_clk(mcdma, sys_half_clk, MCDMA);
217 lpsc_clk(usbss, sys_half_clk, USBSS);
220 lpsc_clk(ethss_rgmii, eth_250mhz_clk, ETHSS_RGMII);
221 lpsc_clk(imcop, sys_dsp_clk, IMCOP);
229 static struct clk clk_rng = { .name =
"rng", .parent = &clk_pktsec };
230 static struct clk clk_pka = { .name =
"pka", .parent = &clk_pktsec };
233 CLK(
NULL,
"pll_sys_clk", &pll_sys_clk),
234 CLK(
NULL,
"pll_eth_clk", &pll_eth_clk),
235 CLK(
NULL,
"pll_tdm_clk", &pll_tdm_clk),
236 CLK(
NULL,
"sys_arm1176_clk", &sys_arm1176_clk),
237 CLK(
NULL,
"sys_dsp_clk", &sys_dsp_clk),
238 CLK(
NULL,
"sys_ddr_clk", &sys_ddr_clk),
239 CLK(
NULL,
"sys_full_clk", &sys_full_clk),
240 CLK(
NULL,
"sys_lcd_clk", &sys_lcd_clk),
241 CLK(
NULL,
"sys_vlynq_ref_clk", &sys_vlynq_ref_clk),
242 CLK(
NULL,
"sys_tsc_clk", &sys_tsc_clk),
243 CLK(
NULL,
"sys_half_clk", &sys_half_clk),
244 CLK(
NULL,
"eth_5mhz_clk", ð_5mhz_clk),
245 CLK(
NULL,
"eth_50mhz_clk", ð_50mhz_clk),
246 CLK(
NULL,
"eth_125mhz_clk", ð_125mhz_clk),
247 CLK(
NULL,
"eth_250mhz_clk", ð_250mhz_clk),
248 CLK(
NULL,
"eth_25mhz_clk", ð_25mhz_clk),
249 CLK(
NULL,
"tdm_0_clk", &tdm_0_clk),
250 CLK(
NULL,
"tdm_extra_clk", &tdm_extra_clk),
251 CLK(
NULL,
"tdm_1_clk", &tdm_1_clk),
253 CLK(
NULL,
"clk_gem", &clk_gem),
254 CLK(
NULL,
"clk_ddr2_phy", &clk_ddr2_phy),
255 CLK(
NULL,
"clk_tpcc", &clk_tpcc),
256 CLK(
NULL,
"clk_tptc0", &clk_tptc0),
257 CLK(
NULL,
"clk_tptc1", &clk_tptc1),
258 CLK(
NULL,
"clk_ram", &clk_ram),
259 CLK(
NULL,
"clk_mbx_lite", &clk_mbx_lite),
260 CLK(
"tnetv107x-fb.0",
NULL, &clk_lcd),
261 CLK(
NULL,
"clk_ethss", &clk_ethss),
262 CLK(
NULL,
"aemif", &clk_aemif),
263 CLK(
NULL,
"clk_chipcfg", &clk_chipcfg),
264 CLK(
"tnetv107x-ts.0",
NULL, &clk_tsc),
265 CLK(
NULL,
"clk_rom", &clk_rom),
266 CLK(
NULL,
"uart2", &clk_uart2),
267 CLK(
NULL,
"clk_pktsec", &clk_pktsec),
268 CLK(
"tnetv107x-rng.0",
NULL, &clk_rng),
269 CLK(
"tnetv107x-pka.0",
NULL, &clk_pka),
270 CLK(
NULL,
"clk_secctl", &clk_secctl),
271 CLK(
NULL,
"clk_keymgr", &clk_keymgr),
272 CLK(
"tnetv107x-keypad.0",
NULL, &clk_keypad),
273 CLK(
NULL,
"clk_gpio", &clk_gpio),
274 CLK(
NULL,
"clk_mdio", &clk_mdio),
275 CLK(
"davinci_mmc.0",
NULL, &clk_sdio0),
276 CLK(
NULL,
"uart0", &clk_uart0),
277 CLK(
NULL,
"uart1", &clk_uart1),
278 CLK(
NULL,
"timer0", &clk_timer0),
279 CLK(
NULL,
"timer1", &clk_timer1),
280 CLK(
"tnetv107x_wdt.0",
NULL, &clk_wdt_arm),
281 CLK(
NULL,
"clk_wdt_dsp", &clk_wdt_dsp),
283 CLK(
NULL,
"clk_tdm0", &clk_tdm0),
284 CLK(
NULL,
"clk_vlynq", &clk_vlynq),
285 CLK(
NULL,
"clk_mcdma", &clk_mcdma),
286 CLK(
NULL,
"clk_usbss", &clk_usbss),
287 CLK(
NULL,
"clk_usb0", &clk_usb0),
288 CLK(
NULL,
"clk_usb1", &clk_usb1),
289 CLK(
NULL,
"clk_tdm1", &clk_tdm1),
290 CLK(
NULL,
"clk_debugss", &clk_debugss),
291 CLK(
NULL,
"clk_ethss_rgmii", &clk_ethss_rgmii),
292 CLK(
NULL,
"clk_system", &clk_system),
293 CLK(
NULL,
"clk_imcop", &clk_imcop),
294 CLK(
NULL,
"clk_spare", &clk_spare),
295 CLK(
"davinci_mmc.1",
NULL, &clk_sdio1),
296 CLK(
NULL,
"clk_ddr2_vrst", &clk_ddr2_vrst),
297 CLK(
NULL,
"clk_ddr2_vctl_rst", &clk_ddr2_vctl_rst),
302 #ifdef CONFIG_DAVINCI_MUX
303 MUX_CFG(TNETV107X, ASR_A00, 0, 0, 0x1f, 0x00,
false)
326 MUX_CFG(TNETV107X, BOOT_STRP_0, 1, 25, 0x1f, 0x04,
false)
328 MUX_CFG(TNETV107X, BOOT_STRP_1, 2, 0, 0x1f, 0x04,
false)
341 MUX_CFG(TNETV107X, SDIO1_DATA3_0, 3, 0, 0x1f, 0x1c,
false)
344 MUX_CFG(TNETV107X, SDIO1_DATA2_0, 3, 5, 0x1f, 0x1c,
false)
347 MUX_CFG(TNETV107X, SDIO1_DATA1_0, 3, 10, 0x1f, 0x1c,
false)
350 MUX_CFG(TNETV107X, SDIO1_DATA0_0, 3, 15, 0x1f, 0x1c,
false)
353 MUX_CFG(TNETV107X, SDIO1_CMD_0, 3, 20, 0x1f, 0x1c,
false)
356 MUX_CFG(TNETV107X, SDIO1_CLK_0, 3, 25, 0x1f, 0x1c,
false)
359 MUX_CFG(TNETV107X, SYS_PLL_CLK, 4, 0, 0x1f, 0x1c,
false)
363 MUX_CFG(TNETV107X, TDM_PLL_CLK, 4, 15, 0x1f, 0x1c,
false)
365 MUX_CFG(TNETV107X, ETH_PHY_CLK, 4, 20, 0x1f, 0x0c,
false)
387 MUX_CFG(TNETV107X, SDIO1_DATA3_1, 6, 15, 0x1f, 0x1c,
false)
389 MUX_CFG(TNETV107X, SDIO1_DATA2_1, 6, 20, 0x1f, 0x1c,
false)
391 MUX_CFG(TNETV107X, SDIO1_DATA1_1, 6, 25, 0x1f, 0x1c,
false)
393 MUX_CFG(TNETV107X, SDIO1_DATA0_1, 7, 0, 0x1f, 0x1c,
false)
395 MUX_CFG(TNETV107X, SDIO1_CMD_1, 7, 5, 0x1f, 0x1c,
false)
397 MUX_CFG(TNETV107X, SDIO1_CLK_1, 7, 10, 0x1f, 0x1c,
false)
399 MUX_CFG(TNETV107X, BOOT_STRP_2, 7, 15, 0x1f, 0x04,
false)
405 MUX_CFG(TNETV107X, BOOT_STRP_3, 8, 0, 0x1f, 0x04,
false)
406 MUX_CFG(TNETV107X, ASR_WE_DQM0, 8, 5, 0x1f, 0x00,
false)
409 MUX_CFG(TNETV107X, ASR_WE_DQM1, 8, 10, 0x1f, 0x00,
false)
417 MUX_CFG(TNETV107X, VLYNQ_RXD1, 9, 10, 0x1f, 0x00,
false)
419 MUX_CFG(TNETV107X, LCD_PD21_0, 9, 10, 0x1f, 0x1c,
false)
420 MUX_CFG(TNETV107X, VLYNQ_TXD0, 9, 15, 0x1f, 0x00,
false)
422 MUX_CFG(TNETV107X, LCD_PD22_0, 9, 15, 0x1f, 0x1c,
false)
423 MUX_CFG(TNETV107X, VLYNQ_TXD1, 9, 20, 0x1f, 0x00,
false)
425 MUX_CFG(TNETV107X, LCD_PD23_0, 9, 20, 0x1f, 0x1c,
false)
430 MUX_CFG(TNETV107X, SDIO0_DATA0, 10, 10, 0x1f, 0x00,
false)
432 MUX_CFG(TNETV107X, SDIO0_DATA1, 10, 15, 0x1f, 0x00,
false)
434 MUX_CFG(TNETV107X, SDIO0_DATA2, 10, 20, 0x1f, 0x00,
false)
436 MUX_CFG(TNETV107X, SDIO0_DATA3, 10, 25, 0x1f, 0x00,
false)
452 MUX_CFG(TNETV107X, KEYPAD_R2, 14, 10, 0x1f, 0x00,
false)
453 MUX_CFG(TNETV107X, KEYPAD_R3, 14, 15, 0x1f, 0x00,
false)
454 MUX_CFG(TNETV107X, KEYPAD_R4, 14, 20, 0x1f, 0x00,
false)
455 MUX_CFG(TNETV107X, KEYPAD_R5, 14, 25, 0x1f, 0x00,
false)
460 MUX_CFG(TNETV107X, KEYPAD_C0, 15, 10, 0x1f, 0x00,
false)
461 MUX_CFG(TNETV107X, KEYPAD_C1, 15, 15, 0x1f, 0x00,
false)
462 MUX_CFG(TNETV107X, KEYPAD_C2, 15, 20, 0x1f, 0x00,
false)
463 MUX_CFG(TNETV107X, KEYPAD_C3, 15, 25, 0x1f, 0x00,
false)
466 MUX_CFG(TNETV107X, KEYPAD_C6, 16, 10, 0x1f, 0x00,
false)
468 MUX_CFG(TNETV107X, TEST_CLK_IN, 16, 10, 0x1f, 0x0c,
false)
469 MUX_CFG(TNETV107X, KEYPAD_C7, 16, 15, 0x1f, 0x00,
false)
473 MUX_CFG(TNETV107X, LCD_PD20_1, 17, 0, 0x1f, 0x0c,
false)
476 MUX_CFG(TNETV107X, LCD_PD21_1, 17, 5, 0x1f, 0x0c,
false)
479 MUX_CFG(TNETV107X, LCD_PD22_1, 17, 10, 0x1f, 0x0c,
false)
481 MUX_CFG(TNETV107X, SCC_RESETN, 17, 15, 0x1f, 0x04,
false)
482 MUX_CFG(TNETV107X, LCD_PD23_1, 17, 15, 0x1f, 0x0c,
false)
497 MUX_CFG(TNETV107X, UART0_RTS, 19, 10, 0x1f, 0x00,
false)
501 MUX_CFG(TNETV107X, LCD_AC_NCS, 20, 0, 0x1f, 0x00,
false)
502 MUX_CFG(TNETV107X, LCD_HSYNC_RNW, 20, 5, 0x1f, 0x00,
false)
503 MUX_CFG(TNETV107X, LCD_VSYNC_A0, 20, 10, 0x1f, 0x00,
false)
505 MUX_CFG(TNETV107X, LCD_PD16_0, 20, 15, 0x1f, 0x0c,
false)
506 MUX_CFG(TNETV107X, LCD_PCLK_E, 20, 20, 0x1f, 0x00,
false)
520 MUX_CFG(TNETV107X, ASR_BA0_1, 22, 15, 0x1f, 0x04,
false)
537 MUX_CFG(TNETV107X, LCD_PD20_2, 24, 10, 0x1f, 0x04,
false)
538 MUX_CFG(TNETV107X, TDM_CLK_IN_2, 24, 10, 0x1f, 0x0c,
false)
540 MUX_CFG(TNETV107X, LCD_PD21_2, 24, 15, 0x1f, 0x04,
false)
541 MUX_CFG(TNETV107X, 24M_CLK_OUT_1, 24, 15, 0x1f, 0x0c,
false)
543 MUX_CFG(TNETV107X, LCD_PD22_2, 24, 20, 0x1f, 0x04,
false)
545 MUX_CFG(TNETV107X, LCD_PD23_2, 24, 25, 0x1f, 0x04,
false)
547 MUX_CFG(TNETV107X, LCD_PD16_1, 25, 0, 0x1f, 0x04,
false)
548 MUX_CFG(TNETV107X, USB0_RXERR, 25, 0, 0x1f, 0x0c,
false)
550 MUX_CFG(TNETV107X, LCD_PD17_1, 25, 5, 0x1f, 0x04,
false)
551 MUX_CFG(TNETV107X, TDM_CLK_IN_1, 25, 5, 0x1f, 0x0c,
false)
554 MUX_CFG(TNETV107X, 24M_CLK_OUT_2, 25, 10, 0x1f, 0x0c,
false)
556 MUX_CFG(TNETV107X, LCD_PD19_1, 25, 15, 0x1f, 0x04,
false)
557 MUX_CFG(TNETV107X, USB1_RXERR, 25, 15, 0x1f, 0x0c,
false)
558 MUX_CFG(TNETV107X, ETH_PLL_CLK, 25, 15, 0x1f, 0x1c,
false)
561 MUX_CFG(TNETV107X, AIC_MUTE_STAT_N, 26, 10, 0x1f, 0x00,
false)
563 MUX_CFG(TNETV107X, AIC_HNS_EN_N, 26, 15, 0x1f, 0x00,
false)
565 MUX_CFG(TNETV107X, AIC_HDS_EN_STAT_N, 26, 20, 0x1f, 0x00,
false)
567 MUX_CFG(TNETV107X, AIC_HNF_EN_STAT_N, 26, 25, 0x1f, 0x00,
false)
584 .manufacturer = 0x017,
586 .name =
"tnetv107x rev 1.0",
591 .manufacturer = 0x017,
593 .name =
"tnetv107x rev 1.1/1.2",
611 .timers = timer_instance,
632 static struct map_desc io_desc[] = {
647 static unsigned long clk_sspll_recalc(
struct clk *
clk)
650 unsigned long mult = 0, prediv = 1, postdiv = 1;
657 if (!clk_ctrl_regs) {
662 if (
WARN(!tmp,
"failed ioremap for clock control regs\n"))
665 for (pll = 0; pll <
N_PLLS; pll++)
666 sspll_regs[pll] = tmp + sspll_regs_base[pll];
674 if (!(tmp & bypass_mask[pll])) {
676 prediv =
__raw_readl(&sspll_regs[pll]->pre_div) + 1;
677 postdiv =
__raw_readl(&sspll_regs[pll]->post_div) + 1;
682 ref = pll_ext_freq[
pll];
692 ret += ((
unsigned long long)ref * mult) / 256;
694 ret /= (prediv * postdiv);
745 .psc_bases = psc_regs,
752 .intc_irq_prios = irq_prios,