Root/target/linux/adm5120/files/arch/mips/adm5120/cellvision/cellvision.c

1/*
2 * Cellvision/SparkLAN 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 "cellvision.h"
13
14#include <prom/admboot.h>
15
16#define CELLVISION_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
17#define CELLVISION_GPIO_DEV_MASK (1 << CELLVISION_GPIO_FLASH_A20)
18
19#define CELLVISION_CONFIG_OFFSET 0x8000
20#define CELLVISION_CONFIG_SIZE 0x1000
21
22#ifdef CONFIG_MTD_PARTITIONS
23static struct mtd_partition cas6xx_partitions[] = {
24    {
25        .name = "admboot",
26        .offset = 0,
27        .size = 32*1024,
28        .mask_flags = MTD_WRITEABLE,
29    } , {
30        .name = "config",
31        .offset = MTDPART_OFS_APPEND,
32        .size = 32*1024,
33    } , {
34        .name = "nvfs1",
35        .offset = MTDPART_OFS_APPEND,
36        .size = 64*1024,
37    } , {
38        .name = "nvfs2",
39        .offset = MTDPART_OFS_APPEND,
40        .size = 64*1024,
41    } , {
42        .name = "firmware",
43        .offset = MTDPART_OFS_APPEND,
44        .size = MTDPART_SIZ_FULL,
45    }
46};
47
48static struct mtd_partition cas7xx_partitions[] = {
49    {
50        .name = "admboot",
51        .offset = 0,
52        .size = 32*1024,
53        .mask_flags = MTD_WRITEABLE,
54    } , {
55        .name = "config",
56        .offset = MTDPART_OFS_APPEND,
57        .size = 32*1024,
58    } , {
59        .name = "nvfs",
60        .offset = MTDPART_OFS_APPEND,
61        .size = 128*1024,
62    } , {
63        .name = "firmware",
64        .offset = MTDPART_OFS_APPEND,
65        .size = MTDPART_SIZ_FULL,
66    }
67};
68#endif /* CONFIG_MTD_PARTITIONS */
69
70static void switch_bank_gpio5(unsigned bank)
71{
72    switch (bank) {
73    case 0:
74        gpio_set_value(CELLVISION_GPIO_FLASH_A20, 0);
75        break;
76    case 1:
77        gpio_set_value(CELLVISION_GPIO_FLASH_A20, 1);
78        break;
79    }
80}
81
82static void __init cellvision_flash_setup(void)
83{
84    /* setup flash A20 line */
85    gpio_request(CELLVISION_GPIO_FLASH_A20, NULL);
86    gpio_direction_output(CELLVISION_GPIO_FLASH_A20, 0);
87
88    adm5120_flash0_data.switch_bank = switch_bank_gpio5;
89    adm5120_add_device_flash(0);
90}
91
92void __init cellvision_mac_setup(void)
93{
94    u8 mac_base[6];
95    int err;
96
97    err = admboot_get_mac_base(CELLVISION_CONFIG_OFFSET,
98                   CELLVISION_CONFIG_SIZE, mac_base);
99
100    if ((err) || !is_valid_ether_addr(mac_base))
101        random_ether_addr(mac_base);
102
103    adm5120_setup_eth_macs(mac_base);
104}
105
106void __init cas6xx_flash_setup(void)
107{
108#ifdef CONFIG_MTD_PARTITIONS
109    adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
110    adm5120_flash0_data.parts = cas6xx_partitions;
111#endif /* CONFIG_MTD_PARTITIONS */
112
113    cellvision_flash_setup();
114}
115
116void __init cas7xx_flash_setup(void)
117{
118#ifdef CONFIG_MTD_PARTITIONS
119    adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
120    adm5120_flash0_data.parts = cas7xx_partitions;
121#endif /* CONFIG_MTD_PARTITIONS */
122
123    cellvision_flash_setup();
124}
125
126void __init cas6xx_setup(void)
127{
128    cas6xx_flash_setup();
129    adm5120_add_device_uart(0);
130    adm5120_add_device_uart(1);
131    adm5120_add_device_switch(1, NULL);
132}
133
134MIPS_MACHINE(MACH_ADM5120_CAS630, "CAS-630", "Cellvision CAS-630/630W",
135         cas6xx_setup);
136MIPS_MACHINE(MACH_ADM5120_CAS670, "CAS-670", "Cellvision CAS-670/670W",
137         cas6xx_setup);
138
139void __init cas7xx_setup(void)
140{
141    cas7xx_flash_setup();
142    cellvision_mac_setup();
143    adm5120_add_device_uart(0);
144    adm5120_add_device_uart(1);
145    adm5120_add_device_switch(1, NULL);
146}
147
148MIPS_MACHINE(MACH_ADM5120_CAS700, "CAS-700", "Cellvision CAS-700/700W",
149         cas7xx_setup);
150MIPS_MACHINE(MACH_ADM5120_CAS790, "CAS-790", "Cellvision CAS-790",
151         cas7xx_setup);
152MIPS_MACHINE(MACH_ADM5120_CAS861, "CAS-861", "Cellvision CAS-861/861W",
153         cas7xx_setup);
154

Archive Download this file



interactive