^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * arch/arm/mach-ixp4xx/nslu2-setup.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * NSLU2 board-setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * based on ixdp425-setup.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 2003-2004 MontaVista Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * based on nslu2-power.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (C) 2005 Tower Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Author: Mark Rakes <mrakes at mac.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Author: Rod Whitby <rod@whitby.id.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Author: Alessandro Zummo <a.zummo@towertech.it>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Maintainers: http://www.nslu2-linux.org/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <asm/mach/flash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <asm/mach/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include "irqs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define NSLU2_SDA_PIN 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define NSLU2_SCL_PIN 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* NSLU2 Timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define NSLU2_FREQ 66000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Buttons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define NSLU2_PB_GPIO 5 /* power button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define NSLU2_PO_GPIO 8 /* power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define NSLU2_RB_GPIO 12 /* reset button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /* Buzzer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define NSLU2_GPIO_BUZZ 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /* LEDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define NSLU2_LED_RED_GPIO 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define NSLU2_LED_GRN_GPIO 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define NSLU2_LED_DISK1_GPIO 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define NSLU2_LED_DISK2_GPIO 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static struct flash_platform_data nslu2_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) .map_name = "cfi_probe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) .width = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static struct resource nslu2_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static struct platform_device nslu2_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .name = "IXP4XX-Flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .dev.platform_data = &nslu2_flash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .num_resources = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .resource = &nslu2_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static struct gpiod_lookup_table nslu2_i2c_gpiod_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .dev_id = "i2c-gpio.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", NSLU2_SDA_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", NSLU2_SCL_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static struct i2c_board_info __initdata nslu2_i2c_board_info [] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) I2C_BOARD_INFO("x1205", 0x6f),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static struct gpio_led nslu2_led_pins[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .name = "nslu2:green:ready",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .gpio = NSLU2_LED_GRN_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .name = "nslu2:red:status",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .gpio = NSLU2_LED_RED_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .name = "nslu2:green:disk-1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .gpio = NSLU2_LED_DISK1_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .active_low = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .name = "nslu2:green:disk-2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .gpio = NSLU2_LED_DISK2_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .active_low = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static struct gpio_led_platform_data nslu2_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .num_leds = ARRAY_SIZE(nslu2_led_pins),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .leds = nslu2_led_pins,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static struct platform_device nslu2_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .name = "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) .dev.platform_data = &nslu2_led_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static struct platform_device nslu2_i2c_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) .name = "i2c-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .platform_data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static struct resource nslu2_beeper_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) .start = IRQ_IXP4XX_TIMER2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .flags = IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static struct platform_device nslu2_beeper = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) .name = "ixp4xx-beeper",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) .id = NSLU2_GPIO_BUZZ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .resource = nslu2_beeper_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .num_resources = ARRAY_SIZE(nslu2_beeper_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static struct resource nslu2_uart_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) .start = IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) .start = IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static struct plat_serial8250_port nslu2_uart_data[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) .mapbase = IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) .irq = IRQ_IXP4XX_UART1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) .flags = UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .iotype = UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) .regshift = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) .uartclk = IXP4XX_UART_XTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) .mapbase = IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) .irq = IRQ_IXP4XX_UART2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) .flags = UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) .iotype = UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) .regshift = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) .uartclk = IXP4XX_UART_XTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static struct platform_device nslu2_uart = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .name = "serial8250",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) .id = PLAT8250_DEV_PLATFORM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) .dev.platform_data = nslu2_uart_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) .num_resources = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .resource = nslu2_uart_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) /* Built-in 10/100 Ethernet MAC interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static struct resource nslu2_eth_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) .start = IXP4XX_EthB_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) .end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static struct eth_plat_info nslu2_plat_eth[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) .phy = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) .rxq = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .txreadyq = 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) static struct platform_device nslu2_eth[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .name = "ixp4xx_eth",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .id = IXP4XX_ETH_NPEB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) .dev.platform_data = nslu2_plat_eth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) .num_resources = ARRAY_SIZE(nslu2_eth_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) .resource = nslu2_eth_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static struct platform_device *nslu2_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) &nslu2_i2c_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) &nslu2_flash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) &nslu2_beeper,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) &nslu2_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) &nslu2_eth[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static void nslu2_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /* This causes the box to drop the power and go dead. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /* enable the pwr cntl gpio and assert power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) gpio_direction_output(NSLU2_PO_GPIO, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /* Signal init to do the ctrlaltdel action, this will bypass init if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * it hasn't started and do a kernel_restart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) ctrl_alt_del();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* This is the paper-clip reset, it shuts the machine down directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) machine_power_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static int __init nslu2_gpio_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (!machine_is_nslu2())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* Request the power off GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return gpio_request(NSLU2_PO_GPIO, "power off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) device_initcall(nslu2_gpio_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static void __init nslu2_timer_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /* The xtal on this machine is non-standard. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) ixp4xx_timer_freq = NSLU2_FREQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) /* Call standard timer_init function. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ixp4xx_timer_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static void __init nslu2_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) uint8_t __iomem *f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) ixp4xx_sys_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) nslu2_flash_resource.end =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) gpiod_add_lookup_table(&nslu2_i2c_gpiod_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) i2c_register_board_info(0, nslu2_i2c_board_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) ARRAY_SIZE(nslu2_i2c_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * This is only useful on a modified machine, but it is valuable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * to have it first in order to see debug messages, and so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * it does *not* get removed if platform_add_devices fails!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) (void)platform_device_register(&nslu2_uart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) pm_power_off = nslu2_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) IRQF_TRIGGER_LOW, "NSLU2 reset button", NULL) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) gpio_to_irq(NSLU2_RB_GPIO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) IRQF_TRIGGER_HIGH, "NSLU2 power button", NULL) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) printk(KERN_DEBUG "Power Button IRQ %d not available\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) gpio_to_irq(NSLU2_PB_GPIO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * Map in a portion of the flash and read the MAC address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * Since it is stored in BE in the flash itself, we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * byteswap it if we're in LE mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) if (f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) for (i = 0; i < 6; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #ifdef __ARMEB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) iounmap(f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) printk(KERN_INFO "NSLU2: Using MAC address %pM for port 0\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) nslu2_plat_eth[0].hwaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) MACHINE_START(NSLU2, "Linksys NSLU2")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* Maintainer: www.nslu2-linux.org */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) .map_io = ixp4xx_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) .init_early = ixp4xx_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) .init_irq = ixp4xx_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .init_time = nslu2_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) .init_machine = nslu2_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) #if defined(CONFIG_PCI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) .dma_zone_size = SZ_64M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) .restart = ixp4xx_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) MACHINE_END