Path: blob/master/arch/arm/mach-ixp4xx/nslu2-setup.c
10817 views
/*1* arch/arm/mach-ixp4xx/nslu2-setup.c2*3* NSLU2 board-setup4*5* Copyright (C) 2008 Rod Whitby <[email protected]>6*7* based on ixdp425-setup.c:8* Copyright (C) 2003-2004 MontaVista Software, Inc.9* based on nslu2-power.c:10* Copyright (C) 2005 Tower Technologies11*12* Author: Mark Rakes <mrakes at mac.com>13* Author: Rod Whitby <[email protected]>14* Author: Alessandro Zummo <[email protected]>15* Maintainers: http://www.nslu2-linux.org/16*17*/1819#include <linux/if_ether.h>20#include <linux/irq.h>21#include <linux/serial.h>22#include <linux/serial_8250.h>23#include <linux/leds.h>24#include <linux/reboot.h>25#include <linux/i2c.h>26#include <linux/i2c-gpio.h>27#include <linux/io.h>28#include <asm/mach-types.h>29#include <asm/mach/arch.h>30#include <asm/mach/flash.h>31#include <asm/mach/time.h>32#include <asm/gpio.h>3334#define NSLU2_SDA_PIN 735#define NSLU2_SCL_PIN 63637/* NSLU2 Timer */38#define NSLU2_FREQ 660000003940/* Buttons */41#define NSLU2_PB_GPIO 5 /* power button */42#define NSLU2_PO_GPIO 8 /* power off */43#define NSLU2_RB_GPIO 12 /* reset button */4445/* Buzzer */46#define NSLU2_GPIO_BUZZ 44748/* LEDs */49#define NSLU2_LED_RED_GPIO 050#define NSLU2_LED_GRN_GPIO 151#define NSLU2_LED_DISK1_GPIO 352#define NSLU2_LED_DISK2_GPIO 25354static struct flash_platform_data nslu2_flash_data = {55.map_name = "cfi_probe",56.width = 2,57};5859static struct resource nslu2_flash_resource = {60.flags = IORESOURCE_MEM,61};6263static struct platform_device nslu2_flash = {64.name = "IXP4XX-Flash",65.id = 0,66.dev.platform_data = &nslu2_flash_data,67.num_resources = 1,68.resource = &nslu2_flash_resource,69};7071static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = {72.sda_pin = NSLU2_SDA_PIN,73.scl_pin = NSLU2_SCL_PIN,74};7576static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {77{78I2C_BOARD_INFO("x1205", 0x6f),79},80};8182static struct gpio_led nslu2_led_pins[] = {83{84.name = "nslu2:green:ready",85.gpio = NSLU2_LED_GRN_GPIO,86},87{88.name = "nslu2:red:status",89.gpio = NSLU2_LED_RED_GPIO,90},91{92.name = "nslu2:green:disk-1",93.gpio = NSLU2_LED_DISK1_GPIO,94.active_low = true,95},96{97.name = "nslu2:green:disk-2",98.gpio = NSLU2_LED_DISK2_GPIO,99.active_low = true,100},101};102103static struct gpio_led_platform_data nslu2_led_data = {104.num_leds = ARRAY_SIZE(nslu2_led_pins),105.leds = nslu2_led_pins,106};107108static struct platform_device nslu2_leds = {109.name = "leds-gpio",110.id = -1,111.dev.platform_data = &nslu2_led_data,112};113114static struct platform_device nslu2_i2c_gpio = {115.name = "i2c-gpio",116.id = 0,117.dev = {118.platform_data = &nslu2_i2c_gpio_data,119},120};121122static struct platform_device nslu2_beeper = {123.name = "ixp4xx-beeper",124.id = NSLU2_GPIO_BUZZ,125.num_resources = 0,126};127128static struct resource nslu2_uart_resources[] = {129{130.start = IXP4XX_UART1_BASE_PHYS,131.end = IXP4XX_UART1_BASE_PHYS + 0x0fff,132.flags = IORESOURCE_MEM,133},134{135.start = IXP4XX_UART2_BASE_PHYS,136.end = IXP4XX_UART2_BASE_PHYS + 0x0fff,137.flags = IORESOURCE_MEM,138}139};140141static struct plat_serial8250_port nslu2_uart_data[] = {142{143.mapbase = IXP4XX_UART1_BASE_PHYS,144.membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,145.irq = IRQ_IXP4XX_UART1,146.flags = UPF_BOOT_AUTOCONF,147.iotype = UPIO_MEM,148.regshift = 2,149.uartclk = IXP4XX_UART_XTAL,150},151{152.mapbase = IXP4XX_UART2_BASE_PHYS,153.membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,154.irq = IRQ_IXP4XX_UART2,155.flags = UPF_BOOT_AUTOCONF,156.iotype = UPIO_MEM,157.regshift = 2,158.uartclk = IXP4XX_UART_XTAL,159},160{ }161};162163static struct platform_device nslu2_uart = {164.name = "serial8250",165.id = PLAT8250_DEV_PLATFORM,166.dev.platform_data = nslu2_uart_data,167.num_resources = 2,168.resource = nslu2_uart_resources,169};170171/* Built-in 10/100 Ethernet MAC interfaces */172static struct eth_plat_info nslu2_plat_eth[] = {173{174.phy = 1,175.rxq = 3,176.txreadyq = 20,177}178};179180static struct platform_device nslu2_eth[] = {181{182.name = "ixp4xx_eth",183.id = IXP4XX_ETH_NPEB,184.dev.platform_data = nslu2_plat_eth,185}186};187188static struct platform_device *nslu2_devices[] __initdata = {189&nslu2_i2c_gpio,190&nslu2_flash,191&nslu2_beeper,192&nslu2_leds,193&nslu2_eth[0],194};195196static void nslu2_power_off(void)197{198/* This causes the box to drop the power and go dead. */199200/* enable the pwr cntl gpio */201gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);202203/* do the deed */204gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);205}206207static irqreturn_t nslu2_power_handler(int irq, void *dev_id)208{209/* Signal init to do the ctrlaltdel action, this will bypass init if210* it hasn't started and do a kernel_restart.211*/212ctrl_alt_del();213214return IRQ_HANDLED;215}216217static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)218{219/* This is the paper-clip reset, it shuts the machine down directly.220*/221machine_power_off();222223return IRQ_HANDLED;224}225226static void __init nslu2_timer_init(void)227{228/* The xtal on this machine is non-standard. */229ixp4xx_timer_freq = NSLU2_FREQ;230231/* Call standard timer_init function. */232ixp4xx_timer_init();233}234235static struct sys_timer nslu2_timer = {236.init = nslu2_timer_init,237};238239static void __init nslu2_init(void)240{241uint8_t __iomem *f;242int i;243244ixp4xx_sys_init();245246nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);247nslu2_flash_resource.end =248IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;249250i2c_register_board_info(0, nslu2_i2c_board_info,251ARRAY_SIZE(nslu2_i2c_board_info));252253/*254* This is only useful on a modified machine, but it is valuable255* to have it first in order to see debug messages, and so that256* it does *not* get removed if platform_add_devices fails!257*/258(void)platform_device_register(&nslu2_uart);259260platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));261262pm_power_off = nslu2_power_off;263264if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,265IRQF_DISABLED | IRQF_TRIGGER_LOW,266"NSLU2 reset button", NULL) < 0) {267268printk(KERN_DEBUG "Reset Button IRQ %d not available\n",269gpio_to_irq(NSLU2_RB_GPIO));270}271272if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,273IRQF_DISABLED | IRQF_TRIGGER_HIGH,274"NSLU2 power button", NULL) < 0) {275276printk(KERN_DEBUG "Power Button IRQ %d not available\n",277gpio_to_irq(NSLU2_PB_GPIO));278}279280/*281* Map in a portion of the flash and read the MAC address.282* Since it is stored in BE in the flash itself, we need to283* byteswap it if we're in LE mode.284*/285f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);286if (f) {287for (i = 0; i < 6; i++)288#ifdef __ARMEB__289nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);290#else291nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3));292#endif293iounmap(f);294}295printk(KERN_INFO "NSLU2: Using MAC address %pM for port 0\n",296nslu2_plat_eth[0].hwaddr);297298}299300MACHINE_START(NSLU2, "Linksys NSLU2")301/* Maintainer: www.nslu2-linux.org */302.boot_params = 0x00000100,303.map_io = ixp4xx_map_io,304.init_irq = ixp4xx_init_irq,305.timer = &nslu2_timer,306.init_machine = nslu2_init,307MACHINE_END308309310