10120d6226d4b7e41edc6ab3b59e45e377a5c6ce
[librecmc/librecmc.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 <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/gpio.h>
15
16 #include <asm/bootinfo.h>
17
18 #include <asm/mach-adm5120/adm5120_info.h>
19 #include <asm/mach-adm5120/adm5120_board.h>
20 #include <asm/mach-adm5120/adm5120_platform.h>
21 #include <asm/mach-adm5120/adm5120_irq.h>
22
23 #include <asm/mach-adm5120/prom/myloader.h>
24
25 #include "compex.h"
26
27 #define COMPEX_GPIO_DEV_MASK    (1 << ADM5120_GPIO_PIN5)
28
29 static void switch_bank_gpio5(unsigned bank)
30 {
31         switch (bank) {
32         case 0:
33                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
34                 break;
35         case 1:
36                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
37                 break;
38         }
39 }
40
41 void __init compex_mac_setup(void)
42 {
43         int i, j;
44
45         if (!myloader_present())
46                 return;
47
48         for (i = 0; i < 6; i++)
49                 for (j = 0; j < 6; j++)
50                         adm5120_eth_macs[i][j] = myloader_info.macs[i][j];
51 }
52
53 void __init compex_generic_setup(void)
54 {
55         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
56         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
57
58         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
59         adm5120_add_device_flash(0);
60
61         adm5120_add_device_gpio(COMPEX_GPIO_DEV_MASK);
62
63         compex_mac_setup();
64 }