81157812bbbe6875781a7b66693fac5324688d89
[openwrt.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / compex / compex.c
1 /*
2 * Compex boards
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 "compex.h"
13
14 #include <asm/mach-adm5120/prom/myloader.h>
15
16 #define COMPEX_GPIO_DEV_MASK (1 << ADM5120_GPIO_PIN5)
17
18 static void switch_bank_gpio5(unsigned bank)
19 {
20 switch (bank) {
21 case 0:
22 gpio_set_value(ADM5120_GPIO_PIN5, 0);
23 break;
24 case 1:
25 gpio_set_value(ADM5120_GPIO_PIN5, 1);
26 break;
27 }
28 }
29
30 void __init compex_mac_setup(void)
31 {
32 if (myloader_present()) {
33 int i;
34
35 for (i = 0; i < 6; i++) {
36 if (is_valid_ether_addr(myloader_info.macs[i]))
37 memcpy(myloader_info.macs[i],
38 adm5120_eth_macs[i], ETH_ALEN);
39 else
40 random_ether_addr(adm5120_eth_macs[i]);
41 }
42 } else {
43 u8 mac[ETH_ALEN];
44
45 random_ether_addr(mac);
46 adm5120_setup_eth_macs(mac);
47 }
48 }
49
50 void __init compex_generic_setup(void)
51 {
52 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
53 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
54
55 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
56 adm5120_add_device_flash(0);
57
58 adm5120_add_device_gpio(COMPEX_GPIO_DEV_MASK);
59
60 compex_mac_setup();
61 }
This page took 0.050327 seconds and 3 git commands to generate.