sh: Kill off machvec aliases.
[linux-2.6-block.git] / arch / sh / kernel / machvec.c
CommitLineData
9655ad03
PM
1/*
2 * arch/sh/kernel/machvec.c
3 *
4 * The SuperH machine vector setup handlers, yanked from setup.c
5 *
6 * Copyright (C) 1999 Niibe Yutaka
7 * Copyright (C) 2002 - 2007 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/string.h>
15#include <asm/machvec.h>
16#include <asm/sections.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19
20#define MV_NAME_SIZE 32
21
22#define for_each_mv(mv) \
23 for ((mv) = (struct sh_machine_vector *)&__machvec_start; \
24 (mv) && (unsigned long)(mv) < (unsigned long)&__machvec_end; \
25 (mv)++)
26
27static struct sh_machine_vector * __init get_mv_byname(const char *name)
28{
29 struct sh_machine_vector *mv;
30
31 for_each_mv(mv)
82f81f47 32 if (strcasecmp(name, mv->mv_name) == 0)
9655ad03
PM
33 return mv;
34
35 return NULL;
36}
37
38static int __init early_parse_mv(char *from)
39{
40 char mv_name[MV_NAME_SIZE] = "";
41 char *mv_end;
42 char *mv_comma;
43 int mv_len;
44 struct sh_machine_vector *mvp;
45
46 mv_end = strchr(from, ' ');
47 if (mv_end == NULL)
48 mv_end = from + strlen(from);
49
50 mv_comma = strchr(from, ',');
51 mv_len = mv_end - from;
52 if (mv_len > (MV_NAME_SIZE-1))
53 mv_len = MV_NAME_SIZE-1;
54 memcpy(mv_name, from, mv_len);
55 mv_name[mv_len] = '\0';
56 from = mv_end;
57
82f81f47
PM
58 mvp = get_mv_byname(mv_name);
59 if (unlikely(!mvp)) {
60 printk("Available vectors:\n\n\t");
61 for_each_mv(mvp)
62 printk("'%s', ", mvp->mv_name);
63 printk("\n\n");
64 panic("Failed to select machvec '%s' -- halting.\n",
65 mv_name);
66 } else
67 sh_mv = *mvp;
9655ad03 68
9655ad03
PM
69 return 0;
70}
71early_param("sh_mv", early_parse_mv);
72
73void __init sh_mv_setup(void)
74{
82f81f47
PM
75 /*
76 * Only overload the machvec if one hasn't been selected on
77 * the command line with sh_mv=
78 */
79 if (strcmp(sh_mv.mv_name, "Unknown") != 0) {
80 unsigned long machvec_size;
81
82 machvec_size = ((unsigned long)&__machvec_end -
83 (unsigned long)&__machvec_start);
84
85 /*
86 * If the machvec hasn't been preselected, use the first
87 * vector (usually the only one) from .machvec.init.
88 */
89 if (machvec_size >= sizeof(struct sh_machine_vector))
90 sh_mv = *(struct sh_machine_vector *)&__machvec_start;
91 }
92
93 printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type());
94
9655ad03
PM
95 /*
96 * Manually walk the vec, fill in anything that the board hasn't yet
97 * by hand, wrapping to the generic implementation.
98 */
99#define mv_set(elem) do { \
100 if (!sh_mv.mv_##elem) \
101 sh_mv.mv_##elem = generic_##elem; \
102} while (0)
103
104 mv_set(inb); mv_set(inw); mv_set(inl);
105 mv_set(outb); mv_set(outw); mv_set(outl);
106
107 mv_set(inb_p); mv_set(inw_p); mv_set(inl_p);
108 mv_set(outb_p); mv_set(outw_p); mv_set(outl_p);
109
110 mv_set(insb); mv_set(insw); mv_set(insl);
111 mv_set(outsb); mv_set(outsw); mv_set(outsl);
112
113 mv_set(readb); mv_set(readw); mv_set(readl);
114 mv_set(writeb); mv_set(writew); mv_set(writel);
115
116 mv_set(ioport_map);
117 mv_set(ioport_unmap);
118 mv_set(irq_demux);
119
120 if (!sh_mv.mv_nr_irqs)
121 sh_mv.mv_nr_irqs = NR_IRQS;
122}