Root/target/linux/lantiq/files/arch/mips/lantiq/xway/mach-fritz_vr9.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/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
13#include <linux/mtd/physmap.h>
14#include <linux/input.h>
15#include <linux/phy.h>
16#include <linux/spi/spi_gpio.h>
17#include <linux/spi/flash.h>
18
19#include <lantiq_soc.h>
20#include <irq.h>
21
22#include "../machtypes.h"
23#include "devices.h"
24#include "dev-ifxhcd.h"
25#include "dev-gpio-leds.h"
26#include "dev-gpio-buttons.h"
27
28static struct mtd_partition fritz3370_partitions[] = {
29    {
30        .name = "linux",
31        .offset = 0x0,
32        .size = 0x400000,
33    },
34    {
35        .name = "filesystem",
36        .offset = 0x400000,
37        .size = 0x3000000,
38    },
39    {
40        .name = "reserved-kernel",
41        .offset = 0x3400000,
42        .size = 0x400000,
43    },
44    {
45        .name = "reserved",
46        .offset = 0x3800000,
47        .size = 0x3000000,
48    },
49    {
50        .name = "config",
51        .offset = 0x6800000,
52        .size = 0x200000,
53    },
54    {
55        .name = "nand-filesystem",
56        .offset = 0x6a00000,
57        .size = 0x1600000,
58    },
59};
60
61static struct mtd_partition spi_flash_partitions[] = {
62    {
63        .name = "urlader",
64        .offset = 0x0,
65        .size = 0x20000,
66    },
67    {
68        .name = "tffs",
69        .offset = 0x20000,
70        .size = 0x10000,
71    },
72    {
73        .name = "tffs",
74        .offset = 0x30000,
75        .size = 0x10000,
76    },
77};
78
79static struct gpio_led
80fritz3370_gpio_leds[] __initdata = {
81    { .name = "soc:green:1", .gpio = 32, .active_low = 1, .default_trigger = "default-on" },
82    { .name = "soc:red:2", .gpio = 33, .active_low = 1, .default_trigger = "default-on" },
83    { .name = "soc:red:3", .gpio = 34, .active_low = 1, .default_trigger = "default-on" },
84    { .name = "soc:green:4", .gpio = 35, .active_low = 1, .default_trigger = "default-on" },
85    { .name = "soc:green:5", .gpio = 36, .active_low = 1, .default_trigger = "default-on" },
86    { .name = "soc:green:6", .gpio = 47, .active_low = 1, .default_trigger = "default-on" },
87};
88
89static struct gpio_keys_button
90fritz3370_gpio_keys[] __initdata = {
91    {
92        .desc = "wifi",
93        .type = EV_KEY,
94        .code = BTN_0,
95        .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
96        .gpio = 29,
97        .active_low = 1,
98    },
99};
100
101static struct ltq_eth_data ltq_eth_data = {
102    .mii_mode = PHY_INTERFACE_MODE_RMII,
103};
104
105static int usb_pins[2] = { 5, 14 };
106
107#define SPI_GPIO_MRST 16
108#define SPI_GPIO_MTSR 17
109#define SPI_GPIO_CLK 18
110#define SPI_GPIO_CS0 10
111
112static struct spi_gpio_platform_data spi_gpio_data = {
113    .sck = SPI_GPIO_CLK,
114    .mosi = SPI_GPIO_MTSR,
115    .miso = SPI_GPIO_MRST,
116    .num_chipselect = 2,
117};
118
119static struct platform_device spi_gpio_device = {
120    .name = "spi_gpio",
121    .dev.platform_data = &spi_gpio_data,
122};
123
124static struct flash_platform_data spi_flash_data = {
125    .name = "SPL",
126    .parts = spi_flash_partitions,
127    .nr_parts = ARRAY_SIZE(spi_flash_partitions),
128};
129
130static struct spi_board_info spi_flash __initdata = {
131    .modalias = "m25p80",
132    .bus_num = 0,
133    .chip_select = 0,
134    .max_speed_hz = 10 * 1000 * 1000,
135    .mode = SPI_MODE_3,
136    .chip_select = 0,
137    .controller_data = (void *) SPI_GPIO_CS0,
138    .platform_data = &spi_flash_data
139};
140
141static void __init
142spi_gpio_init(void)
143{
144    spi_register_board_info(&spi_flash, 1);
145    platform_device_register(&spi_gpio_device);
146}
147
148static void __init
149fritz3370_init(void)
150{
151    spi_gpio_init();
152    platform_device_register_simple("pcie-xway", 0, NULL, 0);
153    xway_register_nand(fritz3370_partitions, ARRAY_SIZE(fritz3370_partitions));
154    xway_register_hcd(usb_pins);
155    ltq_add_device_gpio_leds(-1, ARRAY_SIZE(fritz3370_gpio_leds), fritz3370_gpio_leds);
156    ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
157        ARRAY_SIZE(fritz3370_gpio_keys), fritz3370_gpio_keys);
158    ltq_register_vrx200(&ltq_eth_data);
159}
160
161MIPS_MACHINE(LANTIQ_MACH_FRITZ3370,
162            "FRITZ3370",
163            "FRITZ!BOX 3370",
164            fritz3370_init);
165

Archive Download this file



interactive