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 #ifdef CONFIG_CPU_TX49XX
27 #include <asm/txx9/tx4938.h>
30 /* EBUSC settings of TX4927, etc. */
31 struct resource txx9_ce_res[8];
32 static char txx9_ce_res_name[8][4]; /* "CEn" */
34 /* pcode, internal register */
35 unsigned int txx9_pcode;
36 char txx9_pcode_str[8];
37 static struct resource txx9_reg_res = {
38 .name = txx9_pcode_str,
39 .flags = IORESOURCE_MEM,
42 txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
46 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
47 sprintf(txx9_ce_res_name[i], "CE%d", i);
48 txx9_ce_res[i].flags = IORESOURCE_MEM;
49 txx9_ce_res[i].name = txx9_ce_res_name[i];
52 sprintf(txx9_pcode_str, "TX%x", pcode);
54 txx9_reg_res.start = base & 0xfffffffffULL;
55 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
56 request_resource(&iomem_resource, &txx9_reg_res);
61 unsigned int txx9_master_clock;
62 unsigned int txx9_cpu_clock;
63 unsigned int txx9_gbus_clock;
65 int txx9_ccfg_toeon __initdata = 1;
67 /* Minimum CLK support */
69 struct clk *clk_get(struct device *dev, const char *id)
71 if (!strcmp(id, "spi-baseclk"))
72 return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
73 if (!strcmp(id, "imbus_clk"))
74 return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
75 return ERR_PTR(-ENOENT);
77 EXPORT_SYMBOL(clk_get);
79 int clk_enable(struct clk *clk)
83 EXPORT_SYMBOL(clk_enable);
85 void clk_disable(struct clk *clk)
88 EXPORT_SYMBOL(clk_disable);
90 unsigned long clk_get_rate(struct clk *clk)
92 return (unsigned long)clk;
94 EXPORT_SYMBOL(clk_get_rate);
96 void clk_put(struct clk *clk)
99 EXPORT_SYMBOL(clk_put);
103 #ifdef CONFIG_GENERIC_GPIO
104 int gpio_to_irq(unsigned gpio)
108 EXPORT_SYMBOL(gpio_to_irq);
110 int irq_to_gpio(unsigned irq)
114 EXPORT_SYMBOL(irq_to_gpio);
117 extern struct txx9_board_vec jmr3927_vec;
118 extern struct txx9_board_vec rbtx4927_vec;
119 extern struct txx9_board_vec rbtx4937_vec;
120 extern struct txx9_board_vec rbtx4938_vec;
122 struct txx9_board_vec *txx9_board_vec __initdata;
123 static char txx9_system_type[32];
125 void __init prom_init_cmdline(void)
127 int argc = (int)fw_arg0;
128 char **argv = (char **)fw_arg1;
129 int i; /* Always ignore the "-c" at argv[0] */
131 char *fixed_argv[32];
132 for (i = 0; i < argc; i++)
133 fixed_argv[i] = (char *)(long)(*((__s32 *)argv + i));
137 /* ignore all built-in args if any f/w args given */
139 *arcs_cmdline = '\0';
141 for (i = 1; i < argc; i++) {
143 strcat(arcs_cmdline, " ");
144 strcat(arcs_cmdline, argv[i]);
148 void __init prom_init(void)
150 #ifdef CONFIG_CPU_TX39XX
151 txx9_board_vec = &jmr3927_vec;
153 #ifdef CONFIG_CPU_TX49XX
154 switch (TX4938_REV_PCODE()) {
155 #ifdef CONFIG_TOSHIBA_RBTX4927
157 txx9_board_vec = &rbtx4927_vec;
160 txx9_board_vec = &rbtx4937_vec;
163 #ifdef CONFIG_TOSHIBA_RBTX4938
165 txx9_board_vec = &rbtx4938_vec;
171 strcpy(txx9_system_type, txx9_board_vec->system);
173 txx9_board_vec->prom_init();
176 void __init prom_free_prom_memory(void)
180 const char *get_system_type(void)
182 return txx9_system_type;
185 char * __init prom_getcmdline(void)
187 return &(arcs_cmdline[0]);
191 void __init plat_mem_setup(void)
193 ioport_resource.start = 0;
194 ioport_resource.end = ~0UL; /* no limit */
195 iomem_resource.start = 0;
196 iomem_resource.end = ~0UL; /* no limit */
197 txx9_board_vec->mem_setup();
200 void __init arch_init_irq(void)
202 txx9_board_vec->irq_setup();
205 void __init plat_time_init(void)
207 txx9_board_vec->time_init();
210 static int __init _txx9_arch_init(void)
212 if (txx9_board_vec->arch_init)
213 txx9_board_vec->arch_init();
216 arch_initcall(_txx9_arch_init);
218 static int __init _txx9_device_init(void)
220 if (txx9_board_vec->device_init)
221 txx9_board_vec->device_init();
224 device_initcall(_txx9_device_init);
226 int (*txx9_irq_dispatch)(int pending);
227 asmlinkage void plat_irq_dispatch(void)
229 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
230 int irq = txx9_irq_dispatch(pending);
232 if (likely(irq >= 0))
235 spurious_interrupt();
238 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
239 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
240 static unsigned long __swizzle_addr_none(unsigned long port)
244 unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
245 EXPORT_SYMBOL(__swizzle_addr_b);