add preliminary Marvell Orion support
[openwrt.git] / target / linux / orion / patches / 018-add_hp_media_vault_mv2120_support.patch
1 From: Martin Michlmayr <tbm@cyrius.com>
2
3 Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
4 ---
5 arch/arm/mach-orion5x/Kconfig | 6 +
6 arch/arm/mach-orion5x/Makefile | 1 +
7 arch/arm/mach-orion5x/mv2120-setup.c | 228 ++++++++++++++++++++++++++++++++++
8 3 files changed, 235 insertions(+), 0 deletions(-)
9 create mode 100644 arch/arm/mach-orion5x/mv2120-setup.c
10
11 --- a/arch/arm/mach-orion5x/Kconfig
12 +++ b/arch/arm/mach-orion5x/Kconfig
13 @@ -56,6 +56,12 @@
14 Say 'Y' here if you want your kernel to support the
15 Linksys WRT350N v2 platform.
16
17 +config MACH_MV2120
18 + bool "HP Media Vault mv2120"
19 + help
20 + Say 'Y' here if you want your kernel to support the
21 + HP Media Vault mv2120 or mv5100.
22 +
23 endmenu
24
25 endif
26 --- a/arch/arm/mach-orion5x/Makefile
27 +++ b/arch/arm/mach-orion5x/Makefile
28 @@ -7,3 +7,4 @@
29 obj-$(CONFIG_MACH_TS209) += ts209-setup.o
30 obj-$(CONFIG_MACH_TS409) += ts409-setup.o
31 obj-$(CONFIG_MACH_WRT350N_V2) += wrt350n-v2-setup.o
32 +obj-$(CONFIG_MACH_MV2120) += mv2120-setup.o
33 --- /dev/null
34 +++ b/arch/arm/mach-orion5x/mv2120-setup.c
35 @@ -0,0 +1,228 @@
36 +/*
37 + * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
38 + * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
39 + *
40 + * This program is free software; you can redistribute it and/or modify
41 + * it under the terms of the GNU Lesser General Public License as
42 + * published by the Free Software Foundation; either version 2 of the
43 + * License, or (at your option) any later version.
44 + */
45 +
46 +#include <linux/kernel.h>
47 +#include <linux/init.h>
48 +#include <linux/platform_device.h>
49 +#include <linux/pci.h>
50 +#include <linux/irq.h>
51 +#include <linux/mtd/physmap.h>
52 +#include <linux/mv643xx_eth.h>
53 +#include <linux/leds.h>
54 +#include <linux/gpio_keys.h>
55 +#include <linux/input.h>
56 +#include <linux/i2c.h>
57 +#include <linux/ata_platform.h>
58 +#include <asm/mach-types.h>
59 +#include <asm/gpio.h>
60 +#include <asm/mach/arch.h>
61 +#include <asm/mach/pci.h>
62 +#include <asm/arch/orion5x.h>
63 +#include "common.h"
64 +#include "mpp.h"
65 +
66 +#define MV2120_NOR_BOOT_BASE 0xf4000000
67 +#define MV2120_NOR_BOOT_SIZE SZ_512K
68 +
69 +#define MV2120_GPIO_RTC_IRQ 3
70 +#define MV2120_GPIO_KEY_RESET 17
71 +#define MV2120_GPIO_KEY_POWER 18
72 +#define MV2120_GPIO_POWER_OFF 19
73 +
74 +
75 +/****************************************************************************
76 + * PCI setup
77 + ****************************************************************************/
78 +static int __init mv2120_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
79 +{
80 + int irq;
81 +
82 + /*
83 + * Check for devices with hard-wired IRQs.
84 + */
85 + irq = orion5x_pci_map_irq(dev, slot, pin);
86 + if (irq != -1)
87 + return irq;
88 +
89 + pr_err("%s: requested mapping for unknown bus\n", __func__);
90 +
91 + return -1;
92 +}
93 +
94 +static struct hw_pci mv2120_pci __initdata = {
95 + .nr_controllers = 2,
96 + .swizzle = pci_std_swizzle,
97 + .setup = orion5x_pci_sys_setup,
98 + .scan = orion5x_pci_sys_scan_bus,
99 + .map_irq = mv2120_pci_map_irq,
100 +};
101 +
102 +static int __init mv2120_pci_init(void)
103 +{
104 + if (machine_is_mv2120())
105 + pci_common_init(&mv2120_pci);
106 +
107 + return 0;
108 +}
109 +subsys_initcall(mv2120_pci_init);
110 +
111 +
112 +/*****************************************************************************
113 + * Ethernet
114 + ****************************************************************************/
115 +static struct mv643xx_eth_platform_data mv2120_eth_data = {
116 + .phy_addr = 8,
117 +};
118 +
119 +static struct mv_sata_platform_data mv2120_sata_data = {
120 + .n_ports = 2,
121 +};
122 +
123 +static struct mtd_partition mv2120_partitions[] = {
124 + {
125 + .name = "firmware",
126 + .size = 0x00080000,
127 + .offset = 0,
128 + },
129 +};
130 +
131 +static struct physmap_flash_data mv2120_nor_flash_data = {
132 + .width = 1,
133 + .parts = mv2120_partitions,
134 + .nr_parts = ARRAY_SIZE(mv2120_partitions)
135 +};
136 +
137 +static struct resource mv2120_nor_flash_resource = {
138 + .flags = IORESOURCE_MEM,
139 + .start = MV2120_NOR_BOOT_BASE,
140 + .end = MV2120_NOR_BOOT_BASE + MV2120_NOR_BOOT_SIZE - 1,
141 +};
142 +
143 +static struct platform_device mv2120_nor_flash = {
144 + .name = "physmap-flash",
145 + .id = 0,
146 + .dev = {
147 + .platform_data = &mv2120_nor_flash_data,
148 + },
149 + .resource = &mv2120_nor_flash_resource,
150 + .num_resources = 1,
151 +};
152 +
153 +static struct gpio_keys_button mv2120_buttons[] = {
154 + {
155 + .code = KEY_RESTART,
156 + .gpio = MV2120_GPIO_KEY_RESET,
157 + .desc = "Reset Button",
158 + .active_low = 1,
159 + }, {
160 + .code = KEY_POWER,
161 + .gpio = MV2120_GPIO_KEY_POWER,
162 + .desc = "Power Button",
163 + .active_low = 1,
164 + },
165 +};
166 +
167 +static struct gpio_keys_platform_data mv2120_button_data = {
168 + .buttons = mv2120_buttons,
169 + .nbuttons = ARRAY_SIZE(mv2120_buttons),
170 +};
171 +
172 +static struct platform_device mv2120_button_device = {
173 + .name = "gpio-keys",
174 + .id = -1,
175 + .num_resources = 0,
176 + .dev = {
177 + .platform_data = &mv2120_button_data,
178 + },
179 +};
180 +
181 +
182 +/****************************************************************************
183 + * General Setup
184 + ****************************************************************************/
185 +static struct i2c_board_info __initdata mv2120_i2c_rtc = {
186 + I2C_BOARD_INFO("rtc-pcf8563", 0x51),
187 + .irq = 0,
188 +};
189 +
190 +static void mv2120_power_off(void)
191 +{
192 + pr_info("%s: triggering power-off...\n", __func__);
193 + gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
194 +}
195 +
196 +static void __init mv2120_init(void)
197 +{
198 + /* Setup basic Orion functions. Need to be called early. */
199 + orion5x_init();
200 +
201 + orion5x_mpp_conf(0, MPP_GPIO); /* Sys status LED */
202 + orion5x_mpp_conf(1, MPP_GPIO); /* Sys error LED */
203 + orion5x_mpp_conf(2, MPP_GPIO); /* OverTemp interrupt */
204 + orion5x_mpp_conf(3, MPP_GPIO); /* RTC interrupt */
205 + orion5x_mpp_conf(4, MPP_GPIO); /* V_LED 5V */
206 + orion5x_mpp_conf(5, MPP_GPIO); /* V_LED 3.3V */
207 + orion5x_mpp_conf(6, MPP_UNUSED);
208 + orion5x_mpp_conf(7, MPP_UNUSED);
209 + orion5x_mpp_conf(8, MPP_GPIO); /* SATA 0 fail LED */
210 + orion5x_mpp_conf(9, MPP_GPIO); /* SATA 1 fail LED */
211 + orion5x_mpp_conf(10, MPP_UNUSED);
212 + orion5x_mpp_conf(11, MPP_UNUSED);
213 + orion5x_mpp_conf(12, MPP_SATA_LED); /* SATA 0 presence */
214 + orion5x_mpp_conf(13, MPP_SATA_LED); /* SATA 1 presence */
215 + orion5x_mpp_conf(14, MPP_SATA_LED); /* SATA 0 active */
216 + orion5x_mpp_conf(15, MPP_SATA_LED); /* SATA 1 active */
217 + orion5x_mpp_conf(16, MPP_UNUSED);
218 + orion5x_mpp_conf(17, MPP_GPIO); /* Reset button */
219 + orion5x_mpp_conf(18, MPP_GPIO); /* Power button */
220 + orion5x_mpp_conf(19, MPP_GPIO); /* Power off */
221 +
222 + /*
223 + * Configure peripherals.
224 + */
225 + orion5x_ehci0_init();
226 + orion5x_ehci1_init();
227 + orion5x_eth_init(&mv2120_eth_data);
228 + orion5x_i2c_init();
229 + orion5x_sata_init(&mv2120_sata_data);
230 + orion5x_uart0_init();
231 +
232 + orion5x_setup_dev_boot_win(MV2120_NOR_BOOT_BASE, MV2120_NOR_BOOT_SIZE);
233 + platform_device_register(&mv2120_nor_flash);
234 +
235 + platform_device_register(&mv2120_button_device);
236 +
237 + if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
238 + if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
239 + mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
240 + else
241 + gpio_free(MV2120_GPIO_RTC_IRQ);
242 + }
243 + i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
244 +
245 + /* register mv2120 specific power-off method */
246 + if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
247 + gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
248 + pr_err("mv2120: failed to setup power-off GPIO\n");
249 + pm_power_off = mv2120_power_off;
250 +}
251 +
252 +/* Warning: HP uses a wrong mach-type (=526) in their bootloader */
253 +MACHINE_START(MV2120, "HP Media Vault mv2120")
254 + /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
255 + .phys_io = ORION5X_REGS_PHYS_BASE,
256 + .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
257 + .boot_params = 0x00000100,
258 + .init_machine = mv2120_init,
259 + .map_io = orion5x_map_io,
260 + .init_irq = orion5x_init_irq,
261 + .timer = &orion5x_timer,
262 + .fixup = tag_fixup_mem32
263 +MACHINE_END
This page took 0.081981 seconds and 5 git commands to generate.