bfd4bf8befe7c738b7fc285e002093bf2ab0034d
[openwrt.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/device.h>
16 #include <linux/platform_device.h>
17
18 #include <asm/bootinfo.h>
19
20 #include <asm/mach-adm5120/adm5120_info.h>
21 #include <asm/mach-adm5120/adm5120_defs.h>
22 #include <asm/mach-adm5120/adm5120_irq.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 memcpy(adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
64
65 printk(KERN_INFO PFX "board is '%s'\n", board->name);
66
67 adm5120_gpio_init();
68
69 adm5120_add_device_uart(0);
70 adm5120_add_device_uart(1);
71
72 if (board->board_setup)
73 board->board_setup();
74
75 return 0;
76 }
77 arch_initcall(adm5120_board_setup);
78
79 void __init adm5120_board_register(struct adm5120_board *board)
80 {
81 list_add_tail(&board->list, &adm5120_boards);
82 }
83
84 static void __init adm5120_generic_board_setup(void)
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);
This page took 0.043865 seconds and 3 git commands to generate.