adm5120: move files to files-3.8
[15.05/openwrt.git] / target / linux / adm5120 / files-3.8 / arch / mips / adm5120 / infineon / infineon.c
1 /*
2  *  Infineon Reference 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 "infineon.h"
13
14 #include <prom/admboot.h>
15
16 #define EASY_CONFIG_OFFSET      0x10000
17 #define EASY_CONFIG_SIZE        0x1000
18
19 static struct mtd_partition easy_partitions[] = {
20         {
21                 .name   = "admboot",
22                 .offset = 0,
23                 .size   = 64*1024,
24                 .mask_flags = MTD_WRITEABLE,
25         } , {
26                 .name   = "boardcfg",
27                 .offset = MTDPART_OFS_APPEND,
28                 .size   = 64*1024,
29         } , {
30                 .name   = "firmware",
31                 .offset = MTDPART_OFS_APPEND,
32                 .size   = MTDPART_SIZ_FULL,
33         }
34 };
35
36 static __init void easy_setup_mac(void)
37 {
38         u8 mac_base[6];
39         int err;
40
41         err = admboot_get_mac_base(EASY_CONFIG_OFFSET,
42                                    EASY_CONFIG_SIZE, mac_base);
43
44         if ((err) || !is_valid_ether_addr(mac_base))
45                 random_ether_addr(mac_base);
46
47         adm5120_setup_eth_macs(mac_base);
48 }
49
50 static void switch_bank_gpio3(unsigned bank)
51 {
52         switch (bank) {
53         case 0:
54                 gpio_set_value(ADM5120_GPIO_PIN3, 0);
55                 break;
56         case 1:
57                 gpio_set_value(ADM5120_GPIO_PIN3, 1);
58                 break;
59         }
60 }
61
62 void __init easy_setup_pqfp(void)
63 {
64         /* setup flash A20 line */
65         gpio_request(ADM5120_GPIO_PIN3, NULL);
66         gpio_direction_output(ADM5120_GPIO_PIN3, 0);
67         adm5120_flash0_data.switch_bank = switch_bank_gpio3;
68
69         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
70         adm5120_flash0_data.parts = easy_partitions;
71
72         adm5120_add_device_uart(0);
73         adm5120_add_device_uart(1);
74
75         adm5120_add_device_flash(0);
76
77         easy_setup_mac();
78 }
79
80 static void switch_bank_gpio5(unsigned bank)
81 {
82         switch (bank) {
83         case 0:
84                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
85                 break;
86         case 1:
87                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
88                 break;
89         }
90 }
91
92 void __init easy_setup_bga(void)
93 {
94         /* setup flash A20 line */
95         gpio_request(ADM5120_GPIO_PIN5, NULL);
96         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
97         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
98
99         adm5120_flash0_data.nr_parts = ARRAY_SIZE(easy_partitions);
100         adm5120_flash0_data.parts = easy_partitions;
101
102         adm5120_add_device_uart(0);
103         adm5120_add_device_uart(1);
104
105         adm5120_add_device_flash(0);
106
107         easy_setup_mac();
108 }