blob: d675e727803d214f49320db72f5b059e54d076b2 [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>
Albert Aribaud3d014b02008-09-19 21:06:25 +020028#include <linux/leds.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
Christopher Moore0eb66972008-07-18 00:25:10 +020031#include <linux/i2c.h>
32#include <linux/ata_platform.h>
33#include <linux/gpio.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/pci.h>
37#include <mach/orion5x.h>
38#include "common.h"
39#include "mpp.h"
40
41/*****************************************************************************
42 * EDMINI_V2 Info
43 ****************************************************************************/
44
45/*
46 * 512KB NOR flash Device bus boot chip select
47 */
48
49#define EDMINI_V2_NOR_BOOT_BASE 0xfff80000
50#define EDMINI_V2_NOR_BOOT_SIZE SZ_512K
51
52/*****************************************************************************
53 * 512KB NOR Flash on BOOT Device
54 ****************************************************************************/
55
56/*
57 * Currently the MTD code does not recognize the MX29LV400CBCT as a bottom
58 * -type device. This could cause risks of accidentally erasing critical
59 * flash sectors. We thus define a single, write-protected partition covering
60 * the whole flash.
61 * TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD
62 * code, break this into at least three partitions: 'u-boot code', 'u-boot
63 * environment' and 'whatever is left'.
64 */
65
66static struct mtd_partition edmini_v2_partitions[] = {
67 {
68 .name = "Full512kb",
69 .size = 0x00080000,
70 .offset = 0x00000000,
71 .mask_flags = MTD_WRITEABLE,
72 },
73};
74
75static struct physmap_flash_data edmini_v2_nor_flash_data = {
76 .width = 1,
77 .parts = edmini_v2_partitions,
78 .nr_parts = ARRAY_SIZE(edmini_v2_partitions),
79};
80
81static struct resource edmini_v2_nor_flash_resource = {
82 .flags = IORESOURCE_MEM,
83 .start = EDMINI_V2_NOR_BOOT_BASE,
84 .end = EDMINI_V2_NOR_BOOT_BASE
85 + EDMINI_V2_NOR_BOOT_SIZE - 1,
86};
87
88static struct platform_device edmini_v2_nor_flash = {
89 .name = "physmap-flash",
90 .id = 0,
91 .dev = {
92 .platform_data = &edmini_v2_nor_flash_data,
93 },
94 .num_resources = 1,
95 .resource = &edmini_v2_nor_flash_resource,
96};
97
98/*****************************************************************************
99 * Ethernet
100 ****************************************************************************/
101
102static struct mv643xx_eth_platform_data edmini_v2_eth_data = {
103 .phy_addr = 8,
104};
105
106/*****************************************************************************
107 * RTC 5C372a on I2C bus
108 ****************************************************************************/
109
110#define EDMINIV2_RTC_GPIO 3
111
112static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {
113 I2C_BOARD_INFO("rs5c372a", 0x32),
114 .irq = 0,
115};
116
117/*****************************************************************************
Christopher Moore0eb66972008-07-18 00:25:10 +0200118 * General Setup
119 ****************************************************************************/
Andrew Lunn554cdae2011-05-15 13:32:53 +0200120static unsigned int edminiv2_mpp_modes[] __initdata = {
121 MPP0_UNUSED,
122 MPP1_UNUSED,
123 MPP2_UNUSED,
124 MPP3_GPIO, /* RTC interrupt */
125 MPP4_UNUSED,
126 MPP5_UNUSED,
127 MPP6_UNUSED,
128 MPP7_UNUSED,
129 MPP8_UNUSED,
130 MPP9_UNUSED,
131 MPP10_UNUSED,
132 MPP11_UNUSED,
133 MPP12_SATA_LED, /* SATA 0 presence */
134 MPP13_SATA_LED, /* SATA 1 presence */
135 MPP14_SATA_LED, /* SATA 0 active */
136 MPP15_SATA_LED, /* SATA 1 active */
Christopher Moore0eb66972008-07-18 00:25:10 +0200137 /* 16: Power LED control (0 = On, 1 = Off) */
Andrew Lunn554cdae2011-05-15 13:32:53 +0200138 MPP16_GPIO,
Christopher Moore0eb66972008-07-18 00:25:10 +0200139 /* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */
Andrew Lunn554cdae2011-05-15 13:32:53 +0200140 MPP17_GPIO,
Christopher Moore0eb66972008-07-18 00:25:10 +0200141 /* 18: Power button status (0 = Released, 1 = Pressed) */
Andrew Lunn554cdae2011-05-15 13:32:53 +0200142 MPP18_GPIO,
143 MPP19_UNUSED,
144 0,
Christopher Moore0eb66972008-07-18 00:25:10 +0200145};
146
Thomas Petazzoni07f645d2012-11-16 16:39:46 +0100147void __init edmini_v2_init(void)
Christopher Moore0eb66972008-07-18 00:25:10 +0200148{
Christopher Moore0eb66972008-07-18 00:25:10 +0200149 orion5x_mpp_conf(edminiv2_mpp_modes);
150
151 /*
152 * Configure peripherals.
153 */
154 orion5x_ehci0_init();
155 orion5x_eth_init(&edmini_v2_eth_data);
Christopher Moore0eb66972008-07-18 00:25:10 +0200156
157 orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,
158 EDMINI_V2_NOR_BOOT_SIZE);
159 platform_device_register(&edmini_v2_nor_flash);
Christopher Moore0eb66972008-07-18 00:25:10 +0200160
161 pr_notice("edmini_v2: USB device port, flash write and power-off "
162 "are not yet supported.\n");
163
164 /* Get RTC IRQ and register the chip */
165 if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {
166 if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)
167 edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);
168 else
169 gpio_free(EDMINIV2_RTC_GPIO);
170 }
171
172 if (edmini_v2_i2c_rtc.irq == 0)
173 pr_warning("edmini_v2: failed to get RTC IRQ\n");
174
175 i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);
176}