netxbig_v2-setup.c 11.5 KB
Newer Older
1
/*
2
 * arch/arm/mach-kirkwood/netxbig_v2-setup.c
3
 *
4
 * LaCie 2Big and 5Big Network v2 board setup
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
 *
 * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/mtd/physmap.h>
#include <linux/spi/flash.h>
#include <linux/spi/spi.h>
#include <linux/ata_platform.h>
#include <linux/mv643xx_eth.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/input.h>
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/leds.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/time.h>
#include <mach/kirkwood.h>
#include <plat/time.h>
#include "common.h"
#include "mpp.h"

/*****************************************************************************
 * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
 ****************************************************************************/

49
static struct mtd_partition netxbig_v2_flash_parts[] = {
50 51 52 53 54 55 56 57
	{
		.name = "u-boot",
		.size = MTDPART_SIZ_FULL,
		.offset = 0,
		.mask_flags = MTD_WRITEABLE, /* force read-only */
	},
};

58
static const struct flash_platform_data netxbig_v2_flash = {
59 60
	.type		= "mx25l4005a",
	.name		= "spi_flash",
61 62
	.parts		= netxbig_v2_flash_parts,
	.nr_parts	= ARRAY_SIZE(netxbig_v2_flash_parts),
63 64
};

65
static struct spi_board_info __initdata netxbig_v2_spi_slave_info[] = {
66 67
	{
		.modalias	= "m25p80",
68
		.platform_data	= &netxbig_v2_flash,
69 70 71 72 73 74 75 76 77 78 79
		.irq		= -1,
		.max_speed_hz	= 20000000,
		.bus_num	= 0,
		.chip_select	= 0,
	},
};

/*****************************************************************************
 * Ethernet
 ****************************************************************************/

80
static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = {
81 82 83
	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
};

84
static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
};

/*****************************************************************************
 * I2C devices
 ****************************************************************************/

static struct at24_platform_data at24c04 = {
	.byte_len	= SZ_4K / 8,
	.page_size	= 16,
};

/*
 * i2c addr | chip         | description
 * 0x50     | HT24LC04     | eeprom (512B)
 */

102
static struct i2c_board_info __initdata netxbig_v2_i2c_info[] = {
103 104 105 106 107 108 109 110 111 112
	{
		I2C_BOARD_INFO("24c04", 0x50),
		.platform_data  = &at24c04,
	}
};

/*****************************************************************************
 * SATA
 ****************************************************************************/

113
static struct mv_sata_platform_data netxbig_v2_sata_data = {
114 115 116
	.n_ports	= 2,
};

117
static int __initdata netxbig_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
118

119
static void __init netxbig_v2_sata_power_init(void)
120 121 122
{
	int i;
	int err;
123 124 125 126 127 128
	int hdd_nb;

	if (machine_is_net2big_v2())
		hdd_nb = 2;
	else
		hdd_nb = 5;
129 130

	/* Power up all hard disks. */
131 132
	for (i = 0; i < hdd_nb; i++) {
		err = gpio_request(netxbig_v2_gpio_hdd_power[i], NULL);
133 134
		if (err == 0) {
			err = gpio_direction_output(
135
					netxbig_v2_gpio_hdd_power[i], 1);
136 137
			/* Free the HDD power GPIOs. This allow user-space to
			 * configure them via the gpiolib sysfs interface. */
138
			gpio_free(netxbig_v2_gpio_hdd_power[i]);
139 140
		}
		if (err)
141
			pr_err("netxbig_v2: failed to power up HDD%d\n", i + 1);
142 143 144 145 146 147 148
	}
}

/*****************************************************************************
 * GPIO keys
 ****************************************************************************/

149 150 151
#define NETXBIG_V2_GPIO_SWITCH_POWER_ON		13
#define NETXBIG_V2_GPIO_SWITCH_POWER_OFF	15
#define NETXBIG_V2_GPIO_FUNC_BUTTON		34
152

153 154
#define NETXBIG_V2_SWITCH_POWER_ON		0x1
#define NETXBIG_V2_SWITCH_POWER_OFF		0x2
155

156
static struct gpio_keys_button netxbig_v2_buttons[] = {
157 158
	[0] = {
		.type           = EV_SW,
159 160
		.code           = NETXBIG_V2_SWITCH_POWER_ON,
		.gpio           = NETXBIG_V2_GPIO_SWITCH_POWER_ON,
161 162 163 164 165
		.desc           = "Back power switch (on|auto)",
		.active_low     = 1,
	},
	[1] = {
		.type           = EV_SW,
166 167
		.code           = NETXBIG_V2_SWITCH_POWER_OFF,
		.gpio           = NETXBIG_V2_GPIO_SWITCH_POWER_OFF,
168 169 170 171 172
		.desc           = "Back power switch (auto|off)",
		.active_low     = 1,
	},
	[2] = {
		.code		= KEY_OPTION,
173
		.gpio		= NETXBIG_V2_GPIO_FUNC_BUTTON,
174 175 176 177 178
		.desc		= "Function button",
		.active_low	= 1,
	},
};

179 180 181
static struct gpio_keys_platform_data netxbig_v2_button_data = {
	.buttons	= netxbig_v2_buttons,
	.nbuttons	= ARRAY_SIZE(netxbig_v2_buttons),
182 183
};

184
static struct platform_device netxbig_v2_gpio_buttons = {
185 186 187
	.name		= "gpio-keys",
	.id		= -1,
	.dev		= {
188
		.platform_data	= &netxbig_v2_button_data,
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
	},
};

/*****************************************************************************
 * GPIO LEDs
 ****************************************************************************/

/*
 * The LEDs are controlled by a CPLD and can be configured through a GPIO
 * extension bus:
 *
 * - address register : bit [0-2] -> GPIO [47-49]
 * - data register    : bit [0-2] -> GPIO [44-46]
 * - enable register  : GPIO 29
 *
 * Address register selection:
 *
 * addr | register
 * ----------------------------
 *   0  | front LED
 *   1  | front LED brightness
 *   2  | HDD LED brightness
 *   3  | HDD1 LED
 *   4  | HDD2 LED
 *   5  | HDD3 LED
 *   6  | HDD4 LED
 *   7  | HDD5 LED
 *
 * Data register configuration:
 *
 * data | LED brightness
 * -------------------------------------------------
 *   0  | min (off)
 *   -  | -
 *   7  | max
 *
 * data | front LED mode
 * -------------------------------------------------
 *   0  | fix off
 *   1  | fix blue on
 *   2  | fix red on
 *   3  | blink blue on=1 sec and blue off=1 sec
 *   4  | blink red on=1 sec and red off=1 sec
 *   5  | blink blue on=2.5 sec and red on=0.5 sec
 *   6  | blink blue on=1 sec and red on=1 sec
 *   7  | blink blue on=0.5 sec and blue off=2.5 sec
 *
 * data | HDD LED mode
 * -------------------------------------------------
 *   0  | fix blue on
 *   1  | SATA activity blink
 *   2  | fix red on
 *   3  | blink blue on=1 sec and blue off=1 sec
 *   4  | blink red on=1 sec and red off=1 sec
 *   5  | blink blue on=2.5 sec and red on=0.5 sec
 *   6  | blink blue on=1 sec and red on=1 sec
 *   7  | blink blue on=0.5 sec and blue off=2.5 sec
 */

/*****************************************************************************
 * Timer
 ****************************************************************************/

252
static void netxbig_v2_timer_init(void)
253 254 255 256 257
{
	kirkwood_tclk = 166666667;
	orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
}

258 259
struct sys_timer netxbig_v2_timer = {
	.init = netxbig_v2_timer_init,
260 261 262 263 264 265
};

/*****************************************************************************
 * General Setup
 ****************************************************************************/

266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
static unsigned int net2big_v2_mpp_config[] __initdata = {
	MPP0_SPI_SCn,
	MPP1_SPI_MOSI,
	MPP2_SPI_SCK,
	MPP3_SPI_MISO,
	MPP6_SYSRST_OUTn,
	MPP7_GPO,		/* Request power-off */
	MPP8_TW_SDA,
	MPP9_TW_SCK,
	MPP10_UART0_TXD,
	MPP11_UART0_RXD,
	MPP13_GPIO,		/* Rear power switch (on|auto) */
	MPP14_GPIO,		/* USB fuse alarm */
	MPP15_GPIO,		/* Rear power switch (auto|off) */
	MPP16_GPIO,		/* SATA HDD1 power */
	MPP17_GPIO,		/* SATA HDD2 power */
	MPP20_SATA1_ACTn,
	MPP21_SATA0_ACTn,
	MPP24_GPIO,		/* USB mode select */
	MPP26_GPIO,		/* USB device vbus */
	MPP28_GPIO,		/* USB enable host vbus */
	MPP29_GPIO,		/* CPLD extension ALE */
	MPP34_GPIO,		/* Rear Push button */
	MPP35_GPIO,		/* Inhibit switch power-off */
	MPP36_GPIO,		/* SATA HDD1 presence */
	MPP37_GPIO,		/* SATA HDD2 presence */
	MPP40_GPIO,		/* eSATA presence */
	MPP44_GPIO,		/* CPLD extension (data 0) */
	MPP45_GPIO,		/* CPLD extension (data 1) */
	MPP46_GPIO,		/* CPLD extension (data 2) */
	MPP47_GPIO,		/* CPLD extension (addr 0) */
	MPP48_GPIO,		/* CPLD extension (addr 1) */
	MPP49_GPIO,		/* CPLD extension (addr 2) */
	0
};

302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
static unsigned int net5big_v2_mpp_config[] __initdata = {
	MPP0_SPI_SCn,
	MPP1_SPI_MOSI,
	MPP2_SPI_SCK,
	MPP3_SPI_MISO,
	MPP6_SYSRST_OUTn,
	MPP7_GPO,		/* Request power-off */
	MPP8_TW_SDA,
	MPP9_TW_SCK,
	MPP10_UART0_TXD,
	MPP11_UART0_RXD,
	MPP13_GPIO,		/* Rear power switch (on|auto) */
	MPP14_GPIO,		/* USB fuse alarm */
	MPP15_GPIO,		/* Rear power switch (auto|off) */
	MPP16_GPIO,		/* SATA HDD1 power */
	MPP17_GPIO,		/* SATA HDD2 power */
	MPP20_GE1_0,
	MPP21_GE1_1,
	MPP22_GE1_2,
	MPP23_GE1_3,
	MPP24_GE1_4,
	MPP25_GE1_5,
	MPP26_GE1_6,
	MPP27_GE1_7,
	MPP28_GPIO,		/* USB enable host vbus */
	MPP29_GPIO,		/* CPLD extension ALE */
	MPP30_GE1_10,
	MPP31_GE1_11,
	MPP32_GE1_12,
	MPP33_GE1_13,
	MPP34_GPIO,		/* Rear Push button */
	MPP35_GPIO,		/* Inhibit switch power-off */
	MPP36_GPIO,		/* SATA HDD1 presence */
	MPP37_GPIO,		/* SATA HDD2 presence */
	MPP38_GPIO,		/* SATA HDD3 presence */
	MPP39_GPIO,		/* SATA HDD4 presence */
	MPP40_GPIO,		/* SATA HDD5 presence */
	MPP41_GPIO,		/* SATA HDD3 power */
	MPP42_GPIO,		/* SATA HDD4 power */
	MPP43_GPIO,		/* SATA HDD5 power */
	MPP44_GPIO,		/* CPLD extension (data 0) */
	MPP45_GPIO,		/* CPLD extension (data 1) */
	MPP46_GPIO,		/* CPLD extension (data 2) */
	MPP47_GPIO,		/* CPLD extension (addr 0) */
	MPP48_GPIO,		/* CPLD extension (addr 1) */
	MPP49_GPIO,		/* CPLD extension (addr 2) */
	0
};

351
#define NETXBIG_V2_GPIO_POWER_OFF		7
352

353
static void netxbig_v2_power_off(void)
354
{
355
	gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1);
356 357
}

358
static void __init netxbig_v2_init(void)
359 360 361 362 363
{
	/*
	 * Basic setup. Needs to be called early.
	 */
	kirkwood_init();
364 365 366 367
	if (machine_is_net2big_v2())
		kirkwood_mpp_conf(net2big_v2_mpp_config);
	else
		kirkwood_mpp_conf(net5big_v2_mpp_config);
368

369
	netxbig_v2_sata_power_init();
370 371

	kirkwood_ehci_init();
372 373 374 375
	kirkwood_ge00_init(&netxbig_v2_ge00_data);
	if (machine_is_net5big_v2())
		kirkwood_ge01_init(&netxbig_v2_ge01_data);
	kirkwood_sata_init(&netxbig_v2_sata_data);
376
	kirkwood_uart0_init();
377 378
	spi_register_board_info(netxbig_v2_spi_slave_info,
				ARRAY_SIZE(netxbig_v2_spi_slave_info));
379 380
	kirkwood_spi_init();
	kirkwood_i2c_init();
381 382
	i2c_register_board_info(0, netxbig_v2_i2c_info,
				ARRAY_SIZE(netxbig_v2_i2c_info));
383

384
	platform_device_register(&netxbig_v2_gpio_buttons);
385

386 387 388
	if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&
	    gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF, 0) == 0)
		pm_power_off = netxbig_v2_power_off;
389
	else
390
		pr_err("netxbig_v2: failed to configure power-off GPIO\n");
391 392
}

393 394 395 396 397 398 399 400 401 402 403 404 405
#ifdef CONFIG_MACH_NET2BIG_V2
MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")
	.phys_io	= KIRKWOOD_REGS_PHYS_BASE,
	.io_pg_offst	= ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
	.boot_params	= 0x00000100,
	.init_machine	= netxbig_v2_init,
	.map_io		= kirkwood_map_io,
	.init_irq	= kirkwood_init_irq,
	.timer		= &netxbig_v2_timer,
MACHINE_END
#endif

#ifdef CONFIG_MACH_NET5BIG_V2
406 407 408 409
MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")
	.phys_io	= KIRKWOOD_REGS_PHYS_BASE,
	.io_pg_offst	= ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
	.boot_params	= 0x00000100,
410
	.init_machine	= netxbig_v2_init,
411 412
	.map_io		= kirkwood_map_io,
	.init_irq	= kirkwood_init_irq,
413
	.timer		= &netxbig_v2_timer,
414
MACHINE_END
415
#endif