Path: blob/master/arch/arm/mach-orion5x/edmini_v2-setup.c
10817 views
/*1* arch/arm/mach-orion5x/edmini_v2-setup.c2*3* LaCie Ethernet Disk mini V2 Setup4*5* Copyright (C) 2008 Christopher Moore <[email protected]>6* Copyright (C) 2008 Albert Aribaud <[email protected]>7*8* This file is licensed under the terms of the GNU General Public9* License version 2. This program is licensed "as is" without any10* warranty of any kind, whether express or implied.11*/1213/*14* TODO: add Orion USB device port init when kernel.org support is added.15* TODO: add flash write support: see below.16* TODO: add power-off support.17* TODO: add I2C EEPROM support.18*/1920#include <linux/kernel.h>21#include <linux/init.h>22#include <linux/platform_device.h>23#include <linux/pci.h>24#include <linux/irq.h>25#include <linux/mtd/physmap.h>26#include <linux/mv643xx_eth.h>27#include <linux/leds.h>28#include <linux/gpio_keys.h>29#include <linux/input.h>30#include <linux/i2c.h>31#include <linux/ata_platform.h>32#include <linux/gpio.h>33#include <asm/mach-types.h>34#include <asm/mach/arch.h>35#include <asm/mach/pci.h>36#include <mach/orion5x.h>37#include "common.h"38#include "mpp.h"3940/*****************************************************************************41* EDMINI_V2 Info42****************************************************************************/4344/*45* 512KB NOR flash Device bus boot chip select46*/4748#define EDMINI_V2_NOR_BOOT_BASE 0xfff8000049#define EDMINI_V2_NOR_BOOT_SIZE SZ_512K5051/*****************************************************************************52* 512KB NOR Flash on BOOT Device53****************************************************************************/5455/*56* Currently the MTD code does not recognize the MX29LV400CBCT as a bottom57* -type device. This could cause risks of accidentally erasing critical58* flash sectors. We thus define a single, write-protected partition covering59* the whole flash.60* TODO: once the flash part TOP/BOTTOM detection issue is sorted out in the MTD61* code, break this into at least three partitions: 'u-boot code', 'u-boot62* environment' and 'whatever is left'.63*/6465static struct mtd_partition edmini_v2_partitions[] = {66{67.name = "Full512kb",68.size = 0x00080000,69.offset = 0x00000000,70.mask_flags = MTD_WRITEABLE,71},72};7374static struct physmap_flash_data edmini_v2_nor_flash_data = {75.width = 1,76.parts = edmini_v2_partitions,77.nr_parts = ARRAY_SIZE(edmini_v2_partitions),78};7980static struct resource edmini_v2_nor_flash_resource = {81.flags = IORESOURCE_MEM,82.start = EDMINI_V2_NOR_BOOT_BASE,83.end = EDMINI_V2_NOR_BOOT_BASE84+ EDMINI_V2_NOR_BOOT_SIZE - 1,85};8687static struct platform_device edmini_v2_nor_flash = {88.name = "physmap-flash",89.id = 0,90.dev = {91.platform_data = &edmini_v2_nor_flash_data,92},93.num_resources = 1,94.resource = &edmini_v2_nor_flash_resource,95};9697/*****************************************************************************98* Ethernet99****************************************************************************/100101static struct mv643xx_eth_platform_data edmini_v2_eth_data = {102.phy_addr = 8,103};104105/*****************************************************************************106* RTC 5C372a on I2C bus107****************************************************************************/108109#define EDMINIV2_RTC_GPIO 3110111static struct i2c_board_info __initdata edmini_v2_i2c_rtc = {112I2C_BOARD_INFO("rs5c372a", 0x32),113.irq = 0,114};115116/*****************************************************************************117* Sata118****************************************************************************/119120static struct mv_sata_platform_data edmini_v2_sata_data = {121.n_ports = 2,122};123124/*****************************************************************************125* GPIO LED (simple - doesn't use hardware blinking support)126****************************************************************************/127128#define EDMINI_V2_GPIO_LED_POWER 16129130static struct gpio_led edmini_v2_leds[] = {131{132.name = "power:blue",133.gpio = EDMINI_V2_GPIO_LED_POWER,134.active_low = 1,135},136};137138static struct gpio_led_platform_data edmini_v2_led_data = {139.num_leds = ARRAY_SIZE(edmini_v2_leds),140.leds = edmini_v2_leds,141};142143static struct platform_device edmini_v2_gpio_leds = {144.name = "leds-gpio",145.id = -1,146.dev = {147.platform_data = &edmini_v2_led_data,148},149};150151/****************************************************************************152* GPIO key153****************************************************************************/154155#define EDMINI_V2_GPIO_KEY_POWER 18156157static struct gpio_keys_button edmini_v2_buttons[] = {158{159.code = KEY_POWER,160.gpio = EDMINI_V2_GPIO_KEY_POWER,161.desc = "Power Button",162.active_low = 0,163},164};165166static struct gpio_keys_platform_data edmini_v2_button_data = {167.buttons = edmini_v2_buttons,168.nbuttons = ARRAY_SIZE(edmini_v2_buttons),169};170171static struct platform_device edmini_v2_gpio_buttons = {172.name = "gpio-keys",173.id = -1,174.dev = {175.platform_data = &edmini_v2_button_data,176},177};178179/*****************************************************************************180* General Setup181****************************************************************************/182static unsigned int edminiv2_mpp_modes[] __initdata = {183MPP0_UNUSED,184MPP1_UNUSED,185MPP2_UNUSED,186MPP3_GPIO, /* RTC interrupt */187MPP4_UNUSED,188MPP5_UNUSED,189MPP6_UNUSED,190MPP7_UNUSED,191MPP8_UNUSED,192MPP9_UNUSED,193MPP10_UNUSED,194MPP11_UNUSED,195MPP12_SATA_LED, /* SATA 0 presence */196MPP13_SATA_LED, /* SATA 1 presence */197MPP14_SATA_LED, /* SATA 0 active */198MPP15_SATA_LED, /* SATA 1 active */199/* 16: Power LED control (0 = On, 1 = Off) */200MPP16_GPIO,201/* 17: Power LED control select (0 = CPLD, 1 = GPIO16) */202MPP17_GPIO,203/* 18: Power button status (0 = Released, 1 = Pressed) */204MPP18_GPIO,205MPP19_UNUSED,2060,207};208209static void __init edmini_v2_init(void)210{211/*212* Setup basic Orion functions. Need to be called early.213*/214orion5x_init();215216orion5x_mpp_conf(edminiv2_mpp_modes);217218/*219* Configure peripherals.220*/221orion5x_ehci0_init();222orion5x_eth_init(&edmini_v2_eth_data);223orion5x_i2c_init();224orion5x_sata_init(&edmini_v2_sata_data);225orion5x_uart0_init();226227orion5x_setup_dev_boot_win(EDMINI_V2_NOR_BOOT_BASE,228EDMINI_V2_NOR_BOOT_SIZE);229platform_device_register(&edmini_v2_nor_flash);230platform_device_register(&edmini_v2_gpio_leds);231platform_device_register(&edmini_v2_gpio_buttons);232233pr_notice("edmini_v2: USB device port, flash write and power-off "234"are not yet supported.\n");235236/* Get RTC IRQ and register the chip */237if (gpio_request(EDMINIV2_RTC_GPIO, "rtc") == 0) {238if (gpio_direction_input(EDMINIV2_RTC_GPIO) == 0)239edmini_v2_i2c_rtc.irq = gpio_to_irq(EDMINIV2_RTC_GPIO);240else241gpio_free(EDMINIV2_RTC_GPIO);242}243244if (edmini_v2_i2c_rtc.irq == 0)245pr_warning("edmini_v2: failed to get RTC IRQ\n");246247i2c_register_board_info(0, &edmini_v2_i2c_rtc, 1);248}249250/* Warning: LaCie use a wrong mach-type (0x20e=526) in their bootloader. */251MACHINE_START(EDMINI_V2, "LaCie Ethernet Disk mini V2")252/* Maintainer: Christopher Moore <[email protected]> */253.boot_params = 0x00000100,254.init_machine = edmini_v2_init,255.map_io = orion5x_map_io,256.init_early = orion5x_init_early,257.init_irq = orion5x_init_irq,258.timer = &orion5x_timer,259.fixup = tag_fixup_mem32,260MACHINE_END261262263