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

Archive Download this file



interactive