be1fc9ab032197217dc02ceed0af387adae0d500
[openwrt/staging/wigyori.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / common / board.c
1 /*
2 * ADM5120 generic board code
3 *
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 *
10 */
11
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/list.h>
15 #include <linux/string.h>
16 #include <linux/device.h>
17 #include <linux/platform_device.h>
18
19 #include <asm/bootinfo.h>
20
21 #include <asm/mach-adm5120/adm5120_info.h>
22 #include <asm/mach-adm5120/adm5120_defs.h>
23 #include <asm/mach-adm5120/adm5120_board.h>
24 #include <asm/mach-adm5120/adm5120_platform.h>
25
26 #define PFX "ADM5120: "
27
28 static struct list_head adm5120_boards __initdata =
29 LIST_HEAD_INIT(adm5120_boards);
30
31 static char adm5120_board_name[ADM5120_BOARD_NAMELEN] = "Unknown board";
32
33 const char *get_system_type(void)
34 {
35 return adm5120_board_name;
36 }
37
38 static struct adm5120_board * __init adm5120_board_find(unsigned long machtype)
39 {
40 struct list_head *this;
41
42 list_for_each(this, &adm5120_boards) {
43 struct adm5120_board *board;
44
45 board = list_entry(this, struct adm5120_board, list);
46 if (board->mach_type == machtype)
47 return board;
48 }
49
50 return NULL;
51 }
52
53 static int __init adm5120_board_setup(void)
54 {
55 struct adm5120_board *board;
56
57 board = adm5120_board_find(mips_machtype);
58 if (board == NULL)
59 panic(PFX "no board registered for machtype %lu\n",
60 mips_machtype);
61
62 if (board->name[0])
63 strlcpy(adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
64
65 printk(KERN_INFO PFX "board is '%s'\n", adm5120_board_name);
66
67 adm5120_gpio_init();
68
69 if (board->board_setup)
70 board->board_setup();
71
72 return 0;
73 }
74 arch_initcall(adm5120_board_setup);
75
76 void __init adm5120_board_register(struct adm5120_board *board)
77 {
78 list_add_tail(&board->list, &adm5120_boards);
79 }
80
81 static void __init adm5120_generic_board_setup(void)
82 {
83 adm5120_add_device_uart(0);
84 adm5120_add_device_uart(1);
85
86 adm5120_add_device_flash(0);
87 adm5120_add_device_switch(6, NULL);
88 }
89
90 ADM5120_BOARD(MACH_ADM5120_GENERIC, "Generic ADM5120 board",
91 adm5120_generic_board_setup);