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 <asm/bootinfo.h>
23 #include <asm/txx9/generic.h>
24 #ifdef CONFIG_CPU_TX49XX
25 #include <asm/txx9/tx4938.h>
28 /* EBUSC settings of TX4927, etc. */
29 struct resource txx9_ce_res
[8];
30 static char txx9_ce_res_name
[8][4]; /* "CEn" */
32 /* pcode, internal register */
33 char txx9_pcode_str
[8];
34 static struct resource txx9_reg_res
= {
35 .name
= txx9_pcode_str
,
36 .flags
= IORESOURCE_MEM
,
39 txx9_reg_res_init(unsigned int pcode
, unsigned long base
, unsigned long size
)
43 for (i
= 0; i
< ARRAY_SIZE(txx9_ce_res
); i
++) {
44 sprintf(txx9_ce_res_name
[i
], "CE%d", i
);
45 txx9_ce_res
[i
].flags
= IORESOURCE_MEM
;
46 txx9_ce_res
[i
].name
= txx9_ce_res_name
[i
];
49 sprintf(txx9_pcode_str
, "TX%x", pcode
);
51 txx9_reg_res
.start
= base
& 0xfffffffffULL
;
52 txx9_reg_res
.end
= (base
& 0xfffffffffULL
) + (size
- 1);
53 request_resource(&iomem_resource
, &txx9_reg_res
);
58 unsigned int txx9_master_clock
;
59 unsigned int txx9_cpu_clock
;
60 unsigned int txx9_gbus_clock
;
63 /* Minimum CLK support */
65 struct clk
*clk_get(struct device
*dev
, const char *id
)
67 if (!strcmp(id
, "spi-baseclk"))
68 return (struct clk
*)(txx9_gbus_clock
/ 2 / 4);
69 if (!strcmp(id
, "imbus_clk"))
70 return (struct clk
*)(txx9_gbus_clock
/ 2);
71 return ERR_PTR(-ENOENT
);
73 EXPORT_SYMBOL(clk_get
);
75 int clk_enable(struct clk
*clk
)
79 EXPORT_SYMBOL(clk_enable
);
81 void clk_disable(struct clk
*clk
)
84 EXPORT_SYMBOL(clk_disable
);
86 unsigned long clk_get_rate(struct clk
*clk
)
88 return (unsigned long)clk
;
90 EXPORT_SYMBOL(clk_get_rate
);
92 void clk_put(struct clk
*clk
)
95 EXPORT_SYMBOL(clk_put
);
99 #ifdef CONFIG_GENERIC_GPIO
100 int gpio_to_irq(unsigned gpio
)
104 EXPORT_SYMBOL(gpio_to_irq
);
106 int irq_to_gpio(unsigned irq
)
110 EXPORT_SYMBOL(irq_to_gpio
);
113 extern struct txx9_board_vec jmr3927_vec
;
114 extern struct txx9_board_vec rbtx4927_vec
;
115 extern struct txx9_board_vec rbtx4937_vec
;
116 extern struct txx9_board_vec rbtx4938_vec
;
118 struct txx9_board_vec
*txx9_board_vec __initdata
;
119 static char txx9_system_type
[32];
121 void __init
prom_init_cmdline(void)
123 int argc
= (int)fw_arg0
;
124 char **argv
= (char **)fw_arg1
;
125 int i
; /* Always ignore the "-c" at argv[0] */
127 /* ignore all built-in args if any f/w args given */
129 *arcs_cmdline
= '\0';
131 for (i
= 1; i
< argc
; i
++) {
133 strcat(arcs_cmdline
, " ");
134 strcat(arcs_cmdline
, argv
[i
]);
138 void __init
prom_init(void)
140 #ifdef CONFIG_CPU_TX39XX
141 txx9_board_vec
= &jmr3927_vec
;
143 #ifdef CONFIG_CPU_TX49XX
144 switch (TX4938_REV_PCODE()) {
145 #ifdef CONFIG_TOSHIBA_RBTX4927
147 txx9_board_vec
= &rbtx4927_vec
;
150 txx9_board_vec
= &rbtx4937_vec
;
153 #ifdef CONFIG_TOSHIBA_RBTX4938
155 txx9_board_vec
= &rbtx4938_vec
;
161 strcpy(txx9_system_type
, txx9_board_vec
->system
);
163 txx9_board_vec
->prom_init();
166 void __init
prom_free_prom_memory(void)
170 const char *get_system_type(void)
172 return txx9_system_type
;
175 char * __init
prom_getcmdline(void)
177 return &(arcs_cmdline
[0]);
181 void __init
plat_mem_setup(void)
183 txx9_board_vec
->mem_setup();
186 void __init
arch_init_irq(void)
188 txx9_board_vec
->irq_setup();
191 void __init
plat_time_init(void)
193 txx9_board_vec
->time_init();
196 static int __init
_txx9_arch_init(void)
198 if (txx9_board_vec
->arch_init
)
199 txx9_board_vec
->arch_init();
202 arch_initcall(_txx9_arch_init
);
204 static int __init
_txx9_device_init(void)
206 if (txx9_board_vec
->device_init
)
207 txx9_board_vec
->device_init();
210 device_initcall(_txx9_device_init
);
212 int (*txx9_irq_dispatch
)(int pending
);
213 asmlinkage
void plat_irq_dispatch(void)
215 int pending
= read_c0_status() & read_c0_cause() & ST0_IM
;
216 int irq
= txx9_irq_dispatch(pending
);
218 if (likely(irq
>= 0))
221 spurious_interrupt();
224 /* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
225 #ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
226 static unsigned long __swizzle_addr_none(unsigned long port
)
230 unsigned long (*__swizzle_addr_b
)(unsigned long port
) = __swizzle_addr_none
;
231 EXPORT_SYMBOL(__swizzle_addr_b
);