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/reboot.h>
26 #include <asm/txx9/generic.h>
27 #include <asm/txx9/pci.h>
28 #ifdef CONFIG_CPU_TX49XX
29 #include <asm/txx9/tx4938.h>
32 /* EBUSC settings of TX4927, etc. */
33 struct resource txx9_ce_res
[8];
34 static char txx9_ce_res_name
[8][4]; /* "CEn" */
36 /* pcode, internal register */
37 unsigned int txx9_pcode
;
38 char txx9_pcode_str
[8];
39 static struct resource txx9_reg_res
= {
40 .name
= txx9_pcode_str
,
41 .flags
= IORESOURCE_MEM
,
44 txx9_reg_res_init(unsigned int pcode
, unsigned long base
, unsigned long size
)
48 for (i
= 0; i
< ARRAY_SIZE(txx9_ce_res
); i
++) {
49 sprintf(txx9_ce_res_name
[i
], "CE%d", i
);
50 txx9_ce_res
[i
].flags
= IORESOURCE_MEM
;
51 txx9_ce_res
[i
].name
= txx9_ce_res_name
[i
];
54 sprintf(txx9_pcode_str
, "TX%x", pcode
);
56 txx9_reg_res
.start
= base
& 0xfffffffffULL
;
57 txx9_reg_res
.end
= (base
& 0xfffffffffULL
) + (size
- 1);
58 request_resource(&iomem_resource
, &txx9_reg_res
);
63 unsigned int txx9_master_clock
;
64 unsigned int txx9_cpu_clock
;
65 unsigned int txx9_gbus_clock
;
67 int txx9_ccfg_toeon __initdata
= 1;
69 /* Minimum CLK support */
71 struct clk
*clk_get(struct device
*dev
, const char *id
)
73 if (!strcmp(id
, "spi-baseclk"))
74 return (struct clk
*)((unsigned long)txx9_gbus_clock
/ 2 / 4);
75 if (!strcmp(id
, "imbus_clk"))
76 return (struct clk
*)((unsigned long)txx9_gbus_clock
/ 2);
77 return ERR_PTR(-ENOENT
);
79 EXPORT_SYMBOL(clk_get
);
81 int clk_enable(struct clk
*clk
)
85 EXPORT_SYMBOL(clk_enable
);
87 void clk_disable(struct clk
*clk
)
90 EXPORT_SYMBOL(clk_disable
);
92 unsigned long clk_get_rate(struct clk
*clk
)
94 return (unsigned long)clk
;
96 EXPORT_SYMBOL(clk_get_rate
);
98 void clk_put(struct clk
*clk
)
101 EXPORT_SYMBOL(clk_put
);
105 #ifdef CONFIG_GENERIC_GPIO
106 int gpio_to_irq(unsigned gpio
)
110 EXPORT_SYMBOL(gpio_to_irq
);
112 int irq_to_gpio(unsigned irq
)
116 EXPORT_SYMBOL(irq_to_gpio
);
119 extern struct txx9_board_vec jmr3927_vec
;
120 extern struct txx9_board_vec rbtx4927_vec
;
121 extern struct txx9_board_vec rbtx4937_vec
;
122 extern struct txx9_board_vec rbtx4938_vec
;
124 struct txx9_board_vec
*txx9_board_vec __initdata
;
125 static char txx9_system_type
[32];
127 void __init
prom_init_cmdline(void)
129 int argc
= (int)fw_arg0
;
130 char **argv
= (char **)fw_arg1
;
131 int i
; /* Always ignore the "-c" at argv[0] */
133 char *fixed_argv
[32];
134 for (i
= 0; i
< argc
; i
++)
135 fixed_argv
[i
] = (char *)(long)(*((__s32
*)argv
+ i
));
139 /* ignore all built-in args if any f/w args given */
141 *arcs_cmdline
= '\0';
143 for (i
= 1; i
< argc
; i
++) {
145 strcat(arcs_cmdline
, " ");
146 strcat(arcs_cmdline
, argv
[i
]);
150 void __init
prom_init(void)
152 #ifdef CONFIG_CPU_TX39XX
153 txx9_board_vec
= &jmr3927_vec
;
155 #ifdef CONFIG_CPU_TX49XX
156 switch (TX4938_REV_PCODE()) {
157 #ifdef CONFIG_TOSHIBA_RBTX4927
159 txx9_board_vec
= &rbtx4927_vec
;
162 txx9_board_vec
= &rbtx4937_vec
;
165 #ifdef CONFIG_TOSHIBA_RBTX4938
167 txx9_board_vec
= &rbtx4938_vec
;
173 strcpy(txx9_system_type
, txx9_board_vec
->system
);
175 txx9_board_vec
->prom_init();
178 void __init
prom_free_prom_memory(void)
182 const char *get_system_type(void)
184 return txx9_system_type
;
187 char * __init
prom_getcmdline(void)
189 return &(arcs_cmdline
[0]);
192 static void __noreturn
txx9_machine_halt(void)
195 clear_c0_status(ST0_IM
);
199 if (cpu_has_counter
) {
201 * Clear counter interrupt while it
202 * breaks WAIT instruction even if
212 void __init
plat_mem_setup(void)
214 ioport_resource
.start
= 0;
215 ioport_resource
.end
= ~0UL; /* no limit */
216 iomem_resource
.start
= 0;
217 iomem_resource
.end
= ~0UL; /* no limit */
219 /* fallback restart/halt routines */
220 _machine_restart
= (void (*)(char *))txx9_machine_halt
;
221 _machine_halt
= txx9_machine_halt
;
222 pm_power_off
= txx9_machine_halt
;
225 pcibios_plat_setup
= txx9_pcibios_setup
;
227 txx9_board_vec
->mem_setup();
230 void __init
arch_init_irq(void)
232 txx9_board_vec
->irq_setup();
235 void __init
plat_time_init(void)
237 txx9_board_vec
->time_init();
240 static int __init
_txx9_arch_init(void)
242 if (txx9_board_vec
->arch_init
)
243 txx9_board_vec
->arch_init();
246 arch_initcall(_txx9_arch_init
);
248 static int __init
_txx9_device_init(void)
250 if (txx9_board_vec
->device_init
)
251 txx9_board_vec
->device_init();
254 device_initcall(_txx9_device_init
);
256 int (*txx9_irq_dispatch
)(int pending
);
257 asmlinkage
void plat_irq_dispatch(void)
259 int pending
= read_c0_status() & read_c0_cause() & ST0_IM
;
260 int irq
= txx9_irq_dispatch(pending
);
262 if (likely(irq
>= 0))
265 spurious_interrupt();
268 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
269 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
270 static unsigned long __swizzle_addr_none(unsigned long port
)
274 unsigned long (*__swizzle_addr_b
)(unsigned long port
) = __swizzle_addr_none
;
275 EXPORT_SYMBOL(__swizzle_addr_b
);