2 * Cellvision/SparkLAN boards
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
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.
12 #include "cellvision.h"
14 #include <prom/admboot.h>
16 #define CELLVISION_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
17 #define CELLVISION_GPIO_DEV_MASK (1 << CELLVISION_GPIO_FLASH_A20)
19 #define CELLVISION_CONFIG_OFFSET 0x8000
20 #define CELLVISION_CONFIG_SIZE 0x1000
22 #ifdef CONFIG_MTD_PARTITIONS
23 static struct mtd_partition cas6xx_partitions[] = {
28 .mask_flags = MTD_WRITEABLE,
31 .offset = MTDPART_OFS_APPEND,
35 .offset = MTDPART_OFS_APPEND,
39 .offset = MTDPART_OFS_APPEND,
43 .offset = MTDPART_OFS_APPEND,
44 .size = MTDPART_SIZ_FULL,
48 static struct mtd_partition cas7xx_partitions[] = {
53 .mask_flags = MTD_WRITEABLE,
56 .offset = MTDPART_OFS_APPEND,
60 .offset = MTDPART_OFS_APPEND,
64 .offset = MTDPART_OFS_APPEND,
65 .size = MTDPART_SIZ_FULL,
68 #endif /* CONFIG_MTD_PARTITIONS */
70 static void switch_bank_gpio5(unsigned bank)
74 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 0);
77 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 1);
82 static void __init cellvision_flash_setup(void)
84 /* setup flash A20 line */
85 gpio_request(CELLVISION_GPIO_FLASH_A20, NULL);
86 gpio_direction_output(CELLVISION_GPIO_FLASH_A20, 0);
88 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
89 adm5120_add_device_flash(0);
92 void __init cellvision_mac_setup(void)
97 err = admboot_get_mac_base(CELLVISION_CONFIG_OFFSET,
98 CELLVISION_CONFIG_SIZE, mac_base);
100 if ((err) || !is_valid_ether_addr(mac_base))
101 random_ether_addr(mac_base);
103 adm5120_setup_eth_macs(mac_base);
106 void __init cas6xx_flash_setup(void)
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 */
113 cellvision_flash_setup();
116 void __init cas7xx_flash_setup(void)
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 */
123 cellvision_flash_setup();
126 void __init cas6xx_setup(void)
128 cas6xx_flash_setup();
129 adm5120_add_device_uart(0);
130 adm5120_add_device_uart(1);
131 adm5120_add_device_switch(1, NULL);
134 MIPS_MACHINE(MACH_ADM5120_CAS630, "Cellvision CAS-630/630W", cas6xx_setup);
135 MIPS_MACHINE(MACH_ADM5120_CAS670, "Cellvision CAS-670/670W", cas6xx_setup);
137 void __init cas7xx_setup(void)
139 cas7xx_flash_setup();
140 cellvision_mac_setup();
141 adm5120_add_device_uart(0);
142 adm5120_add_device_uart(1);
143 adm5120_add_device_switch(1, NULL);
147 MIPS_MACHINE(MACH_ADM5120_CAS700, "Cellvision CAS-700/700W", cas7xx_setup);
148 MIPS_MACHINE(MACH_ADM5120_CAS790, "Cellvision CAS-790", cas7xx_setup);
149 MIPS_MACHINE(MACH_ADM5120_CAS861, "Cellvision CAS-861/861W", cas7xx_setup);