Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
0003  * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Lesser General Public License as
0007  * published by the Free Software Foundation; either version 2 of the
0008  * License, or (at your option) any later version.
0009  */
0010 #include <linux/gpio.h>
0011 #include <linux/kernel.h>
0012 #include <linux/init.h>
0013 #include <linux/platform_device.h>
0014 #include <linux/irq.h>
0015 #include <linux/mtd/physmap.h>
0016 #include <linux/mv643xx_eth.h>
0017 #include <linux/leds.h>
0018 #include <linux/gpio_keys.h>
0019 #include <linux/input.h>
0020 #include <linux/i2c.h>
0021 #include <linux/ata_platform.h>
0022 #include <asm/mach-types.h>
0023 #include <asm/mach/arch.h>
0024 #include "common.h"
0025 #include "mpp.h"
0026 #include "orion5x.h"
0027 
0028 #define MV2120_NOR_BOOT_BASE    0xf4000000
0029 #define MV2120_NOR_BOOT_SIZE    SZ_512K
0030 
0031 #define MV2120_GPIO_RTC_IRQ 3
0032 #define MV2120_GPIO_KEY_RESET   17
0033 #define MV2120_GPIO_KEY_POWER   18
0034 #define MV2120_GPIO_POWER_OFF   19
0035 
0036 
0037 /*****************************************************************************
0038  * Ethernet
0039  ****************************************************************************/
0040 static struct mv643xx_eth_platform_data mv2120_eth_data = {
0041     .phy_addr   = MV643XX_ETH_PHY_ADDR(8),
0042 };
0043 
0044 static struct mv_sata_platform_data mv2120_sata_data = {
0045     .n_ports    = 2,
0046 };
0047 
0048 static struct mtd_partition mv2120_partitions[] = {
0049     {
0050         .name   = "firmware",
0051         .size   = 0x00080000,
0052         .offset = 0,
0053     },
0054 };
0055 
0056 static struct physmap_flash_data mv2120_nor_flash_data = {
0057     .width      = 1,
0058     .parts      = mv2120_partitions,
0059     .nr_parts   = ARRAY_SIZE(mv2120_partitions)
0060 };
0061 
0062 static struct resource mv2120_nor_flash_resource = {
0063     .flags      = IORESOURCE_MEM,
0064     .start      = MV2120_NOR_BOOT_BASE,
0065     .end        = MV2120_NOR_BOOT_BASE + MV2120_NOR_BOOT_SIZE - 1,
0066 };
0067 
0068 static struct platform_device mv2120_nor_flash = {
0069     .name       = "physmap-flash",
0070     .id     = 0,
0071     .dev        = {
0072         .platform_data  = &mv2120_nor_flash_data,
0073     },
0074     .resource   = &mv2120_nor_flash_resource,
0075     .num_resources  = 1,
0076 };
0077 
0078 static struct gpio_keys_button mv2120_buttons[] = {
0079     {
0080         .code       = KEY_RESTART,
0081         .gpio       = MV2120_GPIO_KEY_RESET,
0082         .desc       = "reset",
0083         .active_low = 1,
0084     }, {
0085         .code       = KEY_POWER,
0086         .gpio       = MV2120_GPIO_KEY_POWER,
0087         .desc       = "power",
0088         .active_low = 1,
0089     },
0090 };
0091 
0092 static struct gpio_keys_platform_data mv2120_button_data = {
0093     .buttons    = mv2120_buttons,
0094     .nbuttons   = ARRAY_SIZE(mv2120_buttons),
0095 };
0096 
0097 static struct platform_device mv2120_button_device = {
0098     .name       = "gpio-keys",
0099     .id     = -1,
0100     .num_resources  = 0,
0101     .dev        = {
0102         .platform_data  = &mv2120_button_data,
0103     },
0104 };
0105 
0106 
0107 /****************************************************************************
0108  * General Setup
0109  ****************************************************************************/
0110 static unsigned int mv2120_mpp_modes[] __initdata = {
0111     MPP0_GPIO,      /* Sys status LED */
0112     MPP1_GPIO,      /* Sys error LED */
0113     MPP2_GPIO,      /* OverTemp interrupt */
0114     MPP3_GPIO,      /* RTC interrupt */
0115     MPP4_GPIO,      /* V_LED 5V */
0116     MPP5_GPIO,      /* V_LED 3.3V */
0117     MPP6_UNUSED,
0118     MPP7_UNUSED,
0119     MPP8_GPIO,      /* SATA 0 fail LED */
0120     MPP9_GPIO,      /* SATA 1 fail LED */
0121     MPP10_UNUSED,
0122     MPP11_UNUSED,
0123     MPP12_SATA_LED,     /* SATA 0 presence */
0124     MPP13_SATA_LED,     /* SATA 1 presence */
0125     MPP14_SATA_LED,     /* SATA 0 active */
0126     MPP15_SATA_LED,     /* SATA 1 active */
0127     MPP16_UNUSED,
0128     MPP17_GPIO,     /* Reset button */
0129     MPP18_GPIO,     /* Power button */
0130     MPP19_GPIO,     /* Power off */
0131     0,
0132 };
0133 
0134 static struct i2c_board_info __initdata mv2120_i2c_rtc = {
0135     I2C_BOARD_INFO("pcf8563", 0x51),
0136     .irq    = 0,
0137 };
0138 
0139 static struct gpio_led mv2120_led_pins[] = {
0140     {
0141         .name           = "mv2120:blue:health",
0142         .gpio           = 0,
0143     },
0144     {
0145         .name           = "mv2120:red:health",
0146         .gpio           = 1,
0147     },
0148     {
0149         .name           = "mv2120:led:bright",
0150         .gpio           = 4,
0151         .default_trigger    = "default-on",
0152     },
0153     {
0154         .name           = "mv2120:led:dimmed",
0155         .gpio           = 5,
0156     },
0157     {
0158         .name           = "mv2120:red:sata0",
0159         .gpio           = 8,
0160         .active_low     = 1,
0161     },
0162     {
0163         .name           = "mv2120:red:sata1",
0164         .gpio           = 9,
0165         .active_low     = 1,
0166     },
0167 
0168 };
0169 
0170 static struct gpio_led_platform_data mv2120_led_data = {
0171     .leds       = mv2120_led_pins,
0172     .num_leds   = ARRAY_SIZE(mv2120_led_pins),
0173 };
0174 
0175 static struct platform_device mv2120_leds = {
0176     .name   = "leds-gpio",
0177     .id = -1,
0178     .dev    = {
0179         .platform_data  = &mv2120_led_data,
0180     }
0181 };
0182 
0183 static void mv2120_power_off(void)
0184 {
0185     pr_info("%s: triggering power-off...\n", __func__);
0186     gpio_set_value(MV2120_GPIO_POWER_OFF, 0);
0187 }
0188 
0189 static void __init mv2120_init(void)
0190 {
0191     /* Setup basic Orion functions. Need to be called early. */
0192     orion5x_init();
0193 
0194     orion5x_mpp_conf(mv2120_mpp_modes);
0195 
0196     /*
0197      * Configure peripherals.
0198      */
0199     orion5x_ehci0_init();
0200     orion5x_ehci1_init();
0201     orion5x_eth_init(&mv2120_eth_data);
0202     orion5x_i2c_init();
0203     orion5x_sata_init(&mv2120_sata_data);
0204     orion5x_uart0_init();
0205     orion5x_xor_init();
0206 
0207     mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
0208                     ORION_MBUS_DEVBUS_BOOT_ATTR,
0209                     MV2120_NOR_BOOT_BASE,
0210                     MV2120_NOR_BOOT_SIZE);
0211     platform_device_register(&mv2120_nor_flash);
0212 
0213     platform_device_register(&mv2120_button_device);
0214 
0215     if (gpio_request(MV2120_GPIO_RTC_IRQ, "rtc") == 0) {
0216         if (gpio_direction_input(MV2120_GPIO_RTC_IRQ) == 0)
0217             mv2120_i2c_rtc.irq = gpio_to_irq(MV2120_GPIO_RTC_IRQ);
0218         else
0219             gpio_free(MV2120_GPIO_RTC_IRQ);
0220     }
0221     i2c_register_board_info(0, &mv2120_i2c_rtc, 1);
0222     platform_device_register(&mv2120_leds);
0223 
0224     /* register mv2120 specific power-off method */
0225     if (gpio_request(MV2120_GPIO_POWER_OFF, "POWEROFF") != 0 ||
0226         gpio_direction_output(MV2120_GPIO_POWER_OFF, 1) != 0)
0227         pr_err("mv2120: failed to setup power-off GPIO\n");
0228     pm_power_off = mv2120_power_off;
0229 }
0230 
0231 /* Warning: HP uses a wrong mach-type (=526) in their bootloader */
0232 MACHINE_START(MV2120, "HP Media Vault mv2120")
0233     /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
0234     .atag_offset    = 0x100,
0235     .nr_irqs    = ORION5X_NR_IRQS,
0236     .init_machine   = mv2120_init,
0237     .map_io     = orion5x_map_io,
0238     .init_early = orion5x_init_early,
0239     .init_irq   = orion5x_init_irq,
0240     .init_time  = orion5x_timer_init,
0241     .fixup      = tag_fixup_mem32,
0242     .restart    = orion5x_restart,
0243 MACHINE_END