2 * linux/arch/mips/txx9/generic/setup.c
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
7 * 2003-2005 (c) MontaVista Software, Inc.
8 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/interrupt.h>
18 #include <linux/string.h>
19 #include <linux/module.h>
20 #include <linux/clk.h>
21 #include <linux/err.h>
22 #include <linux/gpio.h>
23 #include <asm/bootinfo.h>
25 #include <asm/txx9/generic.h>
26 #include <asm/txx9/pci.h>
27 #ifdef CONFIG_CPU_TX49XX
28 #include <asm/txx9/tx4938.h>
31 /* EBUSC settings of TX4927, etc. */
32 struct resource txx9_ce_res[8];
33 static char txx9_ce_res_name[8][4]; /* "CEn" */
35 /* pcode, internal register */
36 unsigned int txx9_pcode;
37 char txx9_pcode_str[8];
38 static struct resource txx9_reg_res = {
39 .name = txx9_pcode_str,
40 .flags = IORESOURCE_MEM,
43 txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
47 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
48 sprintf(txx9_ce_res_name[i], "CE%d", i);
49 txx9_ce_res[i].flags = IORESOURCE_MEM;
50 txx9_ce_res[i].name = txx9_ce_res_name[i];
53 sprintf(txx9_pcode_str, "TX%x", pcode);
55 txx9_reg_res.start = base & 0xfffffffffULL;
56 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
57 request_resource(&iomem_resource, &txx9_reg_res);
62 unsigned int txx9_master_clock;
63 unsigned int txx9_cpu_clock;
64 unsigned int txx9_gbus_clock;
66 int txx9_ccfg_toeon __initdata = 1;
68 /* Minimum CLK support */
70 struct clk *clk_get(struct device *dev, const char *id)
72 if (!strcmp(id, "spi-baseclk"))
73 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
74 if (!strcmp(id, "imbus_clk"))
75 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
76 return ERR_PTR(-ENOENT);
78 EXPORT_SYMBOL(clk_get);
80 int clk_enable(struct clk *clk)
84 EXPORT_SYMBOL(clk_enable);
86 void clk_disable(struct clk *clk)
89 EXPORT_SYMBOL(clk_disable);
91 unsigned long clk_get_rate(struct clk *clk)
93 return (unsigned long)clk;
95 EXPORT_SYMBOL(clk_get_rate);
97 void clk_put(struct clk *clk)
100 EXPORT_SYMBOL(clk_put);
104 #ifdef CONFIG_GENERIC_GPIO
105 int gpio_to_irq(unsigned gpio)
109 EXPORT_SYMBOL(gpio_to_irq);
111 int irq_to_gpio(unsigned irq)
115 EXPORT_SYMBOL(irq_to_gpio);
118 extern struct txx9_board_vec jmr3927_vec;
119 extern struct txx9_board_vec rbtx4927_vec;
120 extern struct txx9_board_vec rbtx4937_vec;
121 extern struct txx9_board_vec rbtx4938_vec;
123 struct txx9_board_vec *txx9_board_vec __initdata;
124 static char txx9_system_type[32];
126 void __init prom_init_cmdline(void)
128 int argc = (int)fw_arg0;
129 char **argv = (char **)fw_arg1;
130 int i; /* Always ignore the "-c" at argv[0] */
132 char *fixed_argv[32];
133 for (i = 0; i < argc; i++)
134 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
138 /* ignore all built-in args if any f/w args given */
140 *arcs_cmdline = '\0';
142 for (i = 1; i < argc; i++) {
144 strcat(arcs_cmdline, " ");
145 strcat(arcs_cmdline, argv[i]);
149 void __init prom_init(void)
151 #ifdef CONFIG_CPU_TX39XX
152 txx9_board_vec = &jmr3927_vec;
154 #ifdef CONFIG_CPU_TX49XX
155 switch (TX4938_REV_PCODE()) {
156 #ifdef CONFIG_TOSHIBA_RBTX4927
158 txx9_board_vec = &rbtx4927_vec;
161 txx9_board_vec = &rbtx4937_vec;
164 #ifdef CONFIG_TOSHIBA_RBTX4938
166 txx9_board_vec = &rbtx4938_vec;
172 strcpy(txx9_system_type, txx9_board_vec->system);
174 txx9_board_vec->prom_init();
177 void __init prom_free_prom_memory(void)
181 const char *get_system_type(void)
183 return txx9_system_type;
186 char * __init prom_getcmdline(void)
188 return &(arcs_cmdline[0]);
192 void __init plat_mem_setup(void)
194 ioport_resource.start = 0;
195 ioport_resource.end = ~0UL; /* no limit */
196 iomem_resource.start = 0;
197 iomem_resource.end = ~0UL; /* no limit */
199 pcibios_plat_setup = txx9_pcibios_setup;
201 txx9_board_vec->mem_setup();
204 void __init arch_init_irq(void)
206 txx9_board_vec->irq_setup();
209 void __init plat_time_init(void)
211 txx9_board_vec->time_init();
214 static int __init _txx9_arch_init(void)
216 if (txx9_board_vec->arch_init)
217 txx9_board_vec->arch_init();
220 arch_initcall(_txx9_arch_init);
222 static int __init _txx9_device_init(void)
224 if (txx9_board_vec->device_init)
225 txx9_board_vec->device_init();
228 device_initcall(_txx9_device_init);
230 int (*txx9_irq_dispatch)(int pending);
231 asmlinkage void plat_irq_dispatch(void)
233 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
234 int irq = txx9_irq_dispatch(pending);
236 if (likely(irq >= 0))
239 spurious_interrupt();
242 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
243 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
244 static unsigned long __swizzle_addr_none(unsigned long port)
248 unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
249 EXPORT_SYMBOL(__swizzle_addr_b);