4 * ADM5120 generic board code
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 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 LIST_HEAD(adm5120_boards
);
32 static char adm5120_board_name
[ADM5120_BOARD_NAMELEN
];
34 const char *get_system_type(void)
36 return adm5120_board_name
;
39 static struct adm5120_board
* __init
adm5120_board_find(unsigned long machtype
)
41 struct list_head
*this;
42 struct adm5120_board
*board
;
46 list_for_each(this, &adm5120_boards
) {
47 board
= list_entry(this, struct adm5120_board
, list
);
48 if (board
->mach_type
== machtype
) {
57 static int __init
adm5120_board_setup(void)
59 struct adm5120_board
*board
;
62 board
= adm5120_board_find(mips_machtype
);
64 printk(KERN_ALERT PFX
"no board registered for "
65 "machtype %lu, trying generic\n", mips_machtype
);
66 board
= adm5120_board_find(MACH_ADM5120_GENERIC
);
68 panic(PFX
"unsupported board\n");
71 printk(KERN_INFO PFX
"setting up board '%s'\n", board
->name
);
73 memcpy(&adm5120_board_name
, board
->name
, ADM5120_BOARD_NAMELEN
);
77 adm5120_board_reset
= board
->board_reset
;
78 if (board
->eth_num_ports
> 0)
79 adm5120_eth_num_ports
= board
->eth_num_ports
;
82 memcpy(adm5120_eth_vlans
, board
->eth_vlans
,
83 sizeof(adm5120_eth_vlans
));
85 if (board
->board_setup
)
89 amba_device_register(&adm5120_uart0_device
, &iomem_resource
);
90 amba_device_register(&adm5120_uart1_device
, &iomem_resource
);
92 /* register built-in ethernet switch */
93 platform_device_register(&adm5120_switch_device
);
95 /* setup PCI irq map */
96 adm5120_pci_set_irq_map(board
->pci_nr_irqs
, board
->pci_irq_map
);
98 /* register board devices */
99 if (board
->num_devices
> 0 && board
->devices
!= NULL
) {
100 err
= platform_add_devices(board
->devices
, board
->num_devices
);
102 printk(KERN_ALERT PFX
"adding board devices failed\n");
107 arch_initcall(adm5120_board_setup
);
109 void __init
adm5120_board_register(struct adm5120_board
*board
)
111 list_add_tail(&board
->list
, &adm5120_boards
);
112 printk(KERN_INFO PFX
"registered board '%s'\n", board
->name
);
This page took 0.05396 seconds and 5 git commands to generate.