2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
6 * Parts of this file are based on Ralink's 2.6.21 BSP
8 * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
9 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
10 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/module.h>
17 #include <asm/mipsregs.h>
18 #include <asm/mach-ralink/ralink_regs.h>
19 #include <asm/mach-ralink/rt288x.h>
23 static struct ralink_pinmux_grp mode_mux
[] = {
26 .mask
= RT2880_GPIO_MODE_I2C
,
31 .mask
= RT2880_GPIO_MODE_SPI
,
36 .mask
= RT2880_GPIO_MODE_UART0
,
41 .mask
= RT2880_GPIO_MODE_JTAG
,
46 .mask
= RT2880_GPIO_MODE_MDIO
,
51 .mask
= RT2880_GPIO_MODE_SDRAM
,
56 .mask
= RT2880_GPIO_MODE_PCI
,
62 static void rt288x_wdt_reset(void)
66 /* enable WDT reset output on pin SRAM_CS_N */
67 t
= rt_sysc_r32(SYSC_REG_CLKCFG
);
68 t
|= CLKCFG_SRAM_CS_N_WDT
;
69 rt_sysc_w32(t
, SYSC_REG_CLKCFG
);
72 struct ralink_pinmux rt_gpio_pinmux
= {
74 .wdt_reset
= rt288x_wdt_reset
,
77 void __init
ralink_clk_init(void)
79 unsigned long cpu_rate
;
80 u32 t
= rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG
);
81 t
= ((t
>> SYSTEM_CONFIG_CPUCLK_SHIFT
) & SYSTEM_CONFIG_CPUCLK_MASK
);
84 case SYSTEM_CONFIG_CPUCLK_250
:
87 case SYSTEM_CONFIG_CPUCLK_266
:
90 case SYSTEM_CONFIG_CPUCLK_280
:
93 case SYSTEM_CONFIG_CPUCLK_300
:
98 ralink_clk_add("cpu", cpu_rate
);
99 ralink_clk_add("300100.timer", cpu_rate
/ 2);
100 ralink_clk_add("300120.watchdog", cpu_rate
/ 2);
101 ralink_clk_add("300500.uart", cpu_rate
/ 2);
102 ralink_clk_add("300c00.uartlite", cpu_rate
/ 2);
103 ralink_clk_add("400000.ethernet", cpu_rate
/ 2);
106 void __init
ralink_of_remap(void)
108 rt_sysc_membase
= plat_of_remap_node("ralink,rt2880-sysc");
109 rt_memc_membase
= plat_of_remap_node("ralink,rt2880-memc");
111 if (!rt_sysc_membase
|| !rt_memc_membase
)
112 panic("Failed to remap core resources");
115 void prom_soc_init(struct ralink_soc_info
*soc_info
)
117 void __iomem
*sysc
= (void __iomem
*) KSEG1ADDR(RT2880_SYSC_BASE
);
123 n0
= __raw_readl(sysc
+ SYSC_REG_CHIP_NAME0
);
124 n1
= __raw_readl(sysc
+ SYSC_REG_CHIP_NAME1
);
125 id
= __raw_readl(sysc
+ SYSC_REG_CHIP_ID
);
127 if (n0
== RT2880_CHIP_NAME0
&& n1
== RT2880_CHIP_NAME1
) {
128 soc_info
->compatible
= "ralink,r2880-soc";
131 panic("rt288x: unknown SoC, n0:%08x n1:%08x", n0
, n1
);
134 snprintf(soc_info
->sys_type
, RAMIPS_SYS_TYPE_LEN
,
135 "Ralink %s id:%u rev:%u",
137 (id
>> CHIP_ID_ID_SHIFT
) & CHIP_ID_ID_MASK
,
138 (id
& CHIP_ID_REV_MASK
));
140 soc_info
->mem_base
= RT2880_SDRAM_BASE
;
141 soc_info
->mem_size_min
= RT2880_MEM_SIZE_MIN
;
142 soc_info
->mem_size_max
= RT2880_MEM_SIZE_MAX
;