4 * ADM5120 generic board code
6 * Copyright (C) 2007,2008 OpenWrt.org
7 * Copyright (C) 2007,2008 Gabor Juhos <juhosg at openwrt.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/list.h>
18 #include <linux/device.h>
19 #include <linux/platform_device.h>
21 #include <asm/bootinfo.h>
23 #include <adm5120_info.h>
24 #include <adm5120_defs.h>
25 #include <adm5120_irq.h>
26 #include <adm5120_board.h>
27 #include <adm5120_platform.h>
29 #define PFX "adm5120: "
31 static struct list_head adm5120_boards __initdata =
32 LIST_HEAD_INIT(adm5120_boards);
33 static char adm5120_board_name[ADM5120_BOARD_NAMELEN];
35 const char *get_system_type(void)
37 return adm5120_board_name;
40 static struct adm5120_board * __init adm5120_board_find(unsigned long machtype)
42 struct list_head *this;
43 struct adm5120_board *board;
47 list_for_each(this, &adm5120_boards) {
48 board = list_entry(this, struct adm5120_board, list);
49 if (board->mach_type == machtype) {
58 static int __init adm5120_board_setup(void)
60 struct adm5120_board *board;
63 board = adm5120_board_find(mips_machtype);
65 printk(KERN_ALERT PFX "no board registered for "
66 "machtype %lu, trying generic\n", mips_machtype);
67 board = adm5120_board_find(MACH_ADM5120_GENERIC);
69 panic(PFX "unsupported board\n");
72 printk(KERN_INFO PFX "board is '%s'\n", board->name);
74 memcpy(&adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
78 adm5120_board_reset = board->board_reset;
79 if (board->eth_num_ports > 0)
80 adm5120_eth_num_ports = board->eth_num_ports;
83 memcpy(adm5120_eth_vlans, board->eth_vlans,
84 sizeof(adm5120_eth_vlans));
86 if (board->board_setup)
90 amba_device_register(&adm5120_uart0_device, &iomem_resource);
91 amba_device_register(&adm5120_uart1_device, &iomem_resource);
93 /* register built-in ethernet switch */
94 platform_device_register(&adm5120_switch_device);
96 /* setup PCI irq map */
97 adm5120_pci_set_irq_map(board->pci_nr_irqs, board->pci_irq_map);
99 /* register board devices */
100 if (board->num_devices > 0 && board->devices != NULL) {
101 err = platform_add_devices(board->devices, board->num_devices);
103 printk(KERN_ALERT PFX "adding board devices failed\n");
108 arch_initcall(adm5120_board_setup);
110 void __init adm5120_board_register(struct adm5120_board *board)
112 list_add_tail(&board->list, &adm5120_boards);