247dfb572ce56043cc9288782ddaf080acc203bb
[openwrt/svn-archive/archive.git] / target / linux / lantiq / files-3.3 / arch / mips / lantiq / xway / mach-p2601hnfx.c
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
5 *
6 * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7 */
8
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <linux/leds.h>
12 #include <linux/gpio.h>
13 #include <linux/gpio_buttons.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.h>
17 #include <linux/input.h>
18 #include <linux/etherdevice.h>
19 #include <linux/mdio-gpio.h>
20 #include <linux/kernel.h>
21 #include <linux/delay.h>
22
23 #include <lantiq_soc.h>
24 #include <lantiq_platform.h>
25 #include <dev-gpio-leds.h>
26 #include <dev-gpio-buttons.h>
27
28 #include "../machtypes.h"
29 #include "devices.h"
30 #include "dev-dwc_otg.h"
31
32 static struct mtd_partition p2601hnfx_partitions[] __initdata =
33 {
34 {
35 .name = "uboot",
36 .offset = 0x0,
37 .size = 0x20000,
38 },
39 {
40 .name = "uboot_env",
41 .offset = 0x20000,
42 .size = 0x20000,
43 },
44 {
45 .name = "linux",
46 .offset = 0x40000,
47 .size = 0xfc0000,
48 },
49 };
50
51 static struct physmap_flash_data p2601hnfx_flash_data __initdata = {
52 .nr_parts = ARRAY_SIZE(p2601hnfx_partitions),
53 .parts = p2601hnfx_partitions,
54 };
55
56 static struct gpio_led
57 p2601hnfx_leds_gpio[] __initdata = {
58 { .name = "soc:yellow:phone", .gpio = 216, .active_low = 1 },
59 { .name = "soc:green:phone", .gpio = 217, .active_low = 1 },
60 { .name = "soc:yellow:wifi", .gpio = 218, .active_low = 1 },
61 { .name = "soc:green:power", .gpio = 219, .active_low = 1 },
62 { .name = "soc:red:internet", .gpio = 220, .active_low = 1 },
63 { .name = "soc:green:internet", .gpio = 221, .active_low = 1 },
64 { .name = "soc:green:dsl", .gpio = 222, .active_low = 1 },
65 { .name = "soc:green:wifi", .gpio = 223, .active_low = 1 },
66 };
67
68 static struct gpio_keys_button
69 p2601hnfx_gpio_keys[] __initdata = {
70 {
71 .desc = "reset",
72 .type = EV_KEY,
73 .code = BTN_0,
74 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = 53,
76 .active_low = 1,
77 },
78 {
79 .desc = "wifi",
80 .type = EV_KEY,
81 .code = BTN_1,
82 .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
83 .gpio = 54,
84 .active_low = 1,
85 },
86 };
87
88 static struct ltq_eth_data ltq_eth_data = {
89 .mii_mode = PHY_INTERFACE_MODE_RMII,
90 };
91
92 static void __init
93 p2601hnfx_init(void)
94 {
95 #define P2601HNFX_USB 9
96
97 ltq_register_gpio_stp();
98 ltq_register_nor(&p2601hnfx_flash_data);
99 ltq_add_device_gpio_leds(-1, ARRAY_SIZE(p2601hnfx_leds_gpio), p2601hnfx_leds_gpio);
100 ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, ARRAY_SIZE(p2601hnfx_gpio_keys), p2601hnfx_gpio_keys);
101 ltq_register_etop(&ltq_eth_data);
102 xway_register_dwc(P2601HNFX_USB);
103
104 // enable the ethernet ports on the SoC
105 // ltq_w32((ltq_r32(LTQ_GPORT_P0_CTL) & ~(1 << 17)) | (1 << 18), LTQ_GPORT_P0_CTL);
106 // ltq_w32((ltq_r32(LTQ_GPORT_P1_CTL) & ~(1 << 17)) | (1 << 18), LTQ_GPORT_P1_CTL);
107 // ltq_w32((ltq_r32(LTQ_GPORT_P2_CTL) & ~(1 << 17)) | (1 << 18), LTQ_GPORT_P2_CTL);
108 }
109
110 MIPS_MACHINE(LANTIQ_MACH_P2601HNFX,
111 "P2601HNFX",
112 "ZyXEL P-2601HN-Fx",
113 p2601hnfx_init);