[adm5120] add 2.6.26 specific files
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / zyxel / p-33x.c
1 /*
2 * ZyXEL Prestige P-33x boards support
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 "p-33x.h"
13
14 #define P33X_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
15 #define P33X_GPIO_DEV_MASK (1 << P33X_GPIO_FLASH_A20)
16
17 #ifdef CONFIG_MTD_PARTITIONS
18 static struct mtd_partition p33x_partitions[] = {
19 {
20 .name = "bootbase",
21 .offset = 0,
22 .size = 16*1024,
23 .mask_flags = MTD_WRITEABLE,
24 } , {
25 .name = "rom",
26 .offset = MTDPART_OFS_APPEND,
27 .size = 16*1024,
28 } , {
29 .name = "bootext",
30 .offset = MTDPART_OFS_APPEND,
31 .size = 96*1024,
32 .mask_flags = MTD_WRITEABLE,
33 } , {
34 .name = "trx",
35 .offset = MTDPART_OFS_APPEND,
36 .size = MTDPART_SIZ_FULL,
37 } , {
38 .name = "firmware",
39 .offset = 32*1024,
40 .size = MTDPART_SIZ_FULL,
41 }
42 };
43 #endif /* CONFIG_MTD_PARTITIONS */
44
45 static struct adm5120_pci_irq p33x_pci_irqs[] __initdata = {
46 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
47 };
48
49 static u8 p33x_vlans[6] __initdata = {
50 /* FIXME: untested */
51 0x50, 0x48, 0x44, 0x42, 0x41, 0x00
52 };
53
54 static void switch_bank_gpio5(unsigned bank)
55 {
56 switch (bank) {
57 case 0:
58 gpio_set_value(P33X_GPIO_FLASH_A20, 0);
59 break;
60 case 1:
61 gpio_set_value(P33X_GPIO_FLASH_A20, 1);
62 break;
63 }
64 }
65
66 void __init p33x_generic_setup(void)
67 {
68 /* setup data for flash0 device */
69 gpio_request(P33X_GPIO_FLASH_A20, NULL); /* for flash A20 line */
70 gpio_direction_output(P33X_GPIO_FLASH_A20, 0);
71 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
72 #ifdef CONFIG_MTD_PARTITIONS
73 adm5120_flash0_data.nr_parts = ARRAY_SIZE(p33x_partitions);
74 adm5120_flash0_data.parts = p33x_partitions;
75 #endif /* CONFIG_MTD_PARTITIONS */
76 adm5120_add_device_flash(0);
77
78 adm5120_add_device_gpio(P33X_GPIO_DEV_MASK);
79 adm5120_add_device_switch(5, p33x_vlans);
80
81 adm5120_pci_set_irq_map(ARRAY_SIZE(p33x_pci_irqs), p33x_pci_irqs);
82 }