aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/files/arch/mips/lantiq/xway/mach-fritz_vr9.c
blob: 293c7b750ab36146f4f5c0cb7f371f9db4506450 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License version 2 as published
 *  by the Free Software Foundation.
 *
 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
 */

#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <linux/input.h>
#include <linux/phy.h>
#include <linux/spi/spi_gpio.h>
#include <linux/spi/flash.h>

#include <lantiq_soc.h>
#include <irq.h>

#include "../machtypes.h"
#include "devices.h"
#include "dev-ifxhcd.h"
#include "dev-gpio-leds.h"
#include "dev-gpio-buttons.h"

static struct mtd_partition fritz3370_partitions[] = {
	{
		.name	= "linux",
		.offset	= 0x0,
		.size	= 0x400000,
	},
	{
		.name	= "filesystem",
		.offset	= 0x400000,
		.size	= 0x3000000,
	},
	{
		.name	= "reserved-kernel",
		.offset	= 0x3400000,
		.size	= 0x400000,
	},
	{
		.name	= "reserved",
		.offset	= 0x3800000,
		.size	= 0x3000000,
	},
	{
		.name	= "config",
		.offset	= 0x6800000,
		.size	= 0x200000,
	},
	{
		.name	= "nand-filesystem",
		.offset	= 0x6a00000,
		.size	= 0x1600000,
	},
};

static struct mtd_partition spi_flash_partitions[] = {
	{
		.name	= "urlader",
		.offset	= 0x0,
		.size	= 0x20000,
	},
	{
		.name	= "tffs",
		.offset	= 0x20000,
		.size	= 0x10000,
	},
	{
		.name	= "tffs",
		.offset	= 0x30000,
		.size	= 0x10000,
	},
};

static struct gpio_led
fritz3370_gpio_leds[] __initdata = {
	{ .name = "soc:green:1", .gpio = 32, .active_low = 1, .default_trigger = "default-on" },
	{ .name = "soc:red:2", .gpio = 33, .active_low = 1, .default_trigger = "default-on" },
	{ .name = "soc:red:3", .gpio = 34, .active_low = 1, .default_trigger = "default-on" },
	{ .name = "soc:green:4", .gpio = 35, .active_low = 1, .default_trigger = "default-on" },
	{ .name = "soc:green:5", .gpio = 36, .active_low = 1, .default_trigger = "default-on" },
	{ .name = "soc:green:6", .gpio = 47, .active_low = 1, .default_trigger = "default-on" },
};

static struct gpio_keys_button
fritz3370_gpio_keys[] __initdata = {
	{
		.desc = "wifi",
		.type = EV_KEY,
		.code = BTN_0,
		.debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL,
		.gpio = 29,
		.active_low = 1,
	},
};

static struct ltq_eth_data ltq_eth_data = {
	.mii_mode	= PHY_INTERFACE_MODE_RMII,
};

static int usb_pins[2] = { 5, 14 };

#define SPI_GPIO_MRST	16
#define SPI_GPIO_MTSR	17
#define SPI_GPIO_CLK	18
#define SPI_GPIO_CS0	10

static struct spi_gpio_platform_data spi_gpio_data = {
	.sck		= SPI_GPIO_CLK,
	.mosi		= SPI_GPIO_MTSR,
	.miso		= SPI_GPIO_MRST,
	.num_chipselect	= 2,
};

static struct platform_device spi_gpio_device = {
	.name			= "spi_gpio",
	.dev.platform_data	= &spi_gpio_data,
};

static struct flash_platform_data spi_flash_data = {
	.name		= "SPL",
	.parts		= spi_flash_partitions,
	.nr_parts	= ARRAY_SIZE(spi_flash_partitions),
};

static struct spi_board_info spi_flash __initdata = {
	.modalias		= "m25p80",
	.bus_num		= 0,
	.chip_select		= 0,
	.max_speed_hz		= 10 * 1000 * 1000,
	.mode			= SPI_MODE_3,
	.chip_select		= 0,
	.controller_data	= (void *) SPI_GPIO_CS0,
	.platform_data		= &spi_flash_data
};

static void __init
spi_gpio_init(void)
{
	spi_register_board_info(&spi_flash, 1);
	platform_device_register(&spi_gpio_device);
}

static void __init
fritz3370_init(void)
{
	spi_gpio_init();
	platform_device_register_simple("pcie-xway", 0, NULL, 0);
	xway_register_nand(fritz3370_partitions, ARRAY_SIZE(fritz3370_partitions));
	xway_register_hcd(usb_pins);
	ltq_add_device_gpio_leds(-1, ARRAY_SIZE(fritz3370_gpio_leds), fritz3370_gpio_leds);
	ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL,
		ARRAY_SIZE(fritz3370_gpio_keys), fritz3370_gpio_keys);
	ltq_register_vrx200(&ltq_eth_data);
}

MIPS_MACHINE(LANTIQ_MACH_FRITZ3370,
			"FRITZ3370",
			"FRITZ!BOX 3370",
			fritz3370_init);