blob: 2d67591dbce638abcc75c52e8cbcd8c6d991b5a4 [file] [log] [blame]
Christopher Moore0eb66972008-07-18 00:25:10 +02001/*
2 * arch/arm/mach-orion5x/edmini_v2-setup.c
3 *
4 * LaCie Ethernet Disk mini V2 Setup
5 *
6 * Copyright (C) 2008 Christopher Moore <moore@free.fr>
7 * Copyright (C) 2008 Albert Aribaud <albert.aribaud@free.fr>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14/*
15 * TODO: add Orion USB device port init when kernel.org support is added.
16 * TODO: add flash write support: see below.
17 * TODO: add power-off support.
18 * TODO: add I2C EEPROM support.
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/platform_device.h>
24#include <linux/pci.h>
25#include <linux/irq.h>
26#include <linux/mtd/physmap.h>
27#include <linux/mv643xx_eth.h>
28#include <linux/i2c.h>
29#include <linux/ata_platform.h>
30#include <linux/gpio.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/pci.h>
34#include <mach/orion5x.h>
35#include "common.h"
36#include "mpp.h"
37
38/*****************************************************************************
39 * EDMINI_V2 Info
40 ****************************************************************************/
41
42/*
43 * 512KB NOR flash Device bus boot chip select
44 */
45
46#define EDMINI_V2_NOR_BOOT_BASE 0xfff80000
47#define EDMINI_V2_NOR_BOOT_SIZE SZ_512K
48
49/*****************************************************************************
50 * 512KB NOR Flash on BOOT Device
51 ****************************************************************************/
52
53/*
54 * Currently the MTD code does not recognize the MX29LV400CBCT as a bottom
55 * -type device. This could cause risks of accidentally erasing critical
56 * flash sectors. We thus define a single, write-protected partition covering
57 * the whole flash.
58 * TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD
59 * code, break this into at least three partitions: 'u-boot code', 'u-boot
60 * environment' and 'whatever is left'.
61 */
62
63static struct mtd_partition edmini_v2_partitions[] = {
64 {
65 .name = "Full512kb",
66 .size = 0x00080000,
67 .offset = 0x00000000,
68 .mask_flags = MTD_WRITEABLE,
69 },
70};
71
72static struct physmap_flash_data edmini_v2_nor_flash_data = {
73 .width = 1,
74 .parts = edmini_v2_partitions,
75 .nr_parts = ARRAY_SIZE(edmini_v2_partitions),
76};
77
78static struct resource edmini_v2_nor_flash_resource = {
79 .flags = IORESOURCE_MEM,
80 .start = EDMINI_V2_NOR_BOOT_BASE,
81 .end = EDMINI_V2_NOR_BOOT_BASE
82 + EDMINI_V2_NOR_BOOT_SIZE - 1,
83};
84
85static struct platform_device edmini_v2_nor_flash = {
86 .name = "physmap-flash",
87 .id = 0,
88 .dev = {
89 .platform_data = &edmini_v2_nor_flash_data,
90 },
91 .num_resources = 1,
92 .resource = &edmini_v2_nor_flash_resource,
93};
94
95/*****************************************************************************
96 * Ethernet
97 ****************************************************************************/
98
99static struct mv643xx_eth_platform_data edmini_v2_eth_data = {
100 .phy_addr = 8,
101};
102
103/*****************************************************************************
104 * RTC 5C372a on I2C bus
105 ****************************************************************************/
106
107#define EDMINIV2_RTC_GPIO 3
108
109static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {
110 I2C_BOARD_INFO("rs5c372a", 0x32),
111 .irq = 0,
112};
113
114/*****************************************************************************
115 * Sata
116 ****************************************************************************/
117
118static struct mv_sata_platform_data edmini_v2_sata_data = {
119 .n_ports = 2,
120};
121
122/*****************************************************************************
123 * General Setup
124 ****************************************************************************/
125static struct orion5x_mpp_mode edminiv2_mpp_modes[] __initdata = {
126 { 0, MPP_UNUSED },
127 { 1, MPP_UNUSED },
128 { 2, MPP_UNUSED },
129 { 3, MPP_GPIO }, /* RTC interrupt */
130 { 4, MPP_UNUSED },
131 { 5, MPP_UNUSED },
132 { 6, MPP_UNUSED },
133 { 7, MPP_UNUSED },
134 { 8, MPP_UNUSED },
135 { 9, MPP_UNUSED },
136 { 10, MPP_UNUSED },
137 { 11, MPP_UNUSED },
138 { 12, MPP_SATA_LED }, /* SATA 0 presence */
139 { 13, MPP_SATA_LED }, /* SATA 1 presence */
140 { 14, MPP_SATA_LED }, /* SATA 0 active */
141 { 15, MPP_SATA_LED }, /* SATA 1 active */
142 /* 16: Power LED control (0 = On, 1 = Off) */
143 { 16, MPP_GPIO },
144 /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
145 { 17, MPP_GPIO },
146 /* 18: Power button status (0 = Released, 1 = Pressed) */
147 { 18, MPP_GPIO },
148 { 19, MPP_UNUSED },
149 { -1 }
150};
151
152static void __init edmini_v2_init(void)
153{
154 /*
155 * Setup basic Orion functions. Need to be called early.
156 */
157 orion5x_init();
158
159 orion5x_mpp_conf(edminiv2_mpp_modes);
160
161 /*
162 * Configure peripherals.
163 */
164 orion5x_ehci0_init();
165 orion5x_eth_init(&edmini_v2_eth_data);
166 orion5x_i2c_init();
167 orion5x_sata_init(&edmini_v2_sata_data);
168 orion5x_uart0_init();
169
170 orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
171 EDMINI_V2_NOR_BOOT_SIZE);
172 platform_device_register(&edmini_v2_nor_flash);
173
174 pr_notice("edmini_v2: USB device port, flash write and power-off "
175 "are not yet supported.\n");
176
177 /* Get RTC IRQ and register the chip */
178 if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
179 if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
180 edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
181 else
182 gpio_free(EDMINIV2_RTC_GPIO);
183 }
184
185 if (edmini_v2_i2c_rtc.irq == 0)
186 pr_warning("edmini_v2: failed to get RTC IRQ\n");
187
188 i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
189}
190
191/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */
192MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2")
193 /* Maintainer: Christopher Moore <moore@free.fr> */
194 .phys_io = ORION5X_REGS_PHYS_BASE,
195 .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC,
196 .boot_params = 0x00000100,
197 .init_machine = edmini_v2_init,
198 .map_io = orion5x_map_io,
199 .init_irq = orion5x_init_irq,
200 .timer = &orion5x_timer,
201 .fixup = tag_fixup_mem32,
202MACHINE_END