^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/nas100d-setup.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * NAS 100d 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 nas100d-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) * based on nas100d-io.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (C) 2004 Karen Spearel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^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) * Author: Rod Whitby <rod@whitby.id.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Maintainers: http://www.nslu2-linux.org/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/if_ether.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <asm/mach/arch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <asm/mach/flash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include "irqs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define NAS100D_SDA_PIN 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define NAS100D_SCL_PIN 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* Buttons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define NAS100D_PB_GPIO 14 /* power button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define NAS100D_RB_GPIO 4 /* reset button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* Power control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define NAS100D_PO_GPIO 12 /* power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* LEDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define NAS100D_LED_WLAN_GPIO 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define NAS100D_LED_DISK_GPIO 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define NAS100D_LED_PWR_GPIO 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static struct flash_platform_data nas100d_flash_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) .map_name = "cfi_probe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) .width = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static struct resource nas100d_flash_resource = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static struct platform_device nas100d_flash = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) .name = "IXP4XX-Flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .dev.platform_data = &nas100d_flash_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) .num_resources = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .resource = &nas100d_flash_resource,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static struct i2c_board_info __initdata nas100d_i2c_board_info [] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) I2C_BOARD_INFO("pcf8563", 0x51),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static struct gpio_led nas100d_led_pins[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .name = "nas100d:green:wlan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .gpio = NAS100D_LED_WLAN_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .active_low = true,
^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) .name = "nas100d:blue:power", /* (off=flashing) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .gpio = NAS100D_LED_PWR_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .active_low = true,
^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) .name = "nas100d:yellow:disk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .gpio = NAS100D_LED_DISK_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .active_low = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static struct gpio_led_platform_data nas100d_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .num_leds = ARRAY_SIZE(nas100d_led_pins),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .leds = nas100d_led_pins,
^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) static struct platform_device nas100d_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .name = "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .id = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .dev.platform_data = &nas100d_led_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static struct gpiod_lookup_table nas100d_i2c_gpiod_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .dev_id = "i2c-gpio.0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) .table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", NAS100D_SDA_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) GPIO_LOOKUP_IDX("IXP4XX_GPIO_CHIP", NAS100D_SCL_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) },
^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 nas100d_i2c_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .name = "i2c-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) .dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .platform_data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static struct resource nas100d_uart_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .start = IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) .start = IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .flags = IORESOURCE_MEM,
^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 plat_serial8250_port nas100d_uart_data[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) .mapbase = IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .irq = IRQ_IXP4XX_UART1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .flags = UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) .iotype = UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) .regshift = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) .uartclk = IXP4XX_UART_XTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) .mapbase = IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) .irq = IRQ_IXP4XX_UART2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) .flags = UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .iotype = UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .regshift = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .uartclk = IXP4XX_UART_XTAL,
^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) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static struct platform_device nas100d_uart = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) .name = "serial8250",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) .id = PLAT8250_DEV_PLATFORM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) .dev.platform_data = nas100d_uart_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .num_resources = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) .resource = nas100d_uart_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) /* Built-in 10/100 Ethernet MAC interfaces */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static struct resource nas100d_eth_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) .start = IXP4XX_EthB_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) .end = IXP4XX_EthB_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) .flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static struct eth_plat_info nas100d_plat_eth[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) .phy = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) .rxq = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) .txreadyq = 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static struct platform_device nas100d_eth[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) .name = "ixp4xx_eth",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) .id = IXP4XX_ETH_NPEB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) .dev.platform_data = nas100d_plat_eth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) .num_resources = ARRAY_SIZE(nas100d_eth_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) .resource = nas100d_eth_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static struct platform_device *nas100d_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) &nas100d_i2c_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) &nas100d_flash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) &nas100d_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) &nas100d_eth[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void nas100d_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* This causes the box to drop the power and go dead. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) /* enable the pwr cntl gpio and assert power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) gpio_direction_output(NAS100D_PO_GPIO, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* This is used to make sure the power-button pusher is serious. The button
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * must be held until the value of this counter reaches zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static int power_button_countdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* Must hold the button down for at least this many counts to be processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static void nas100d_power_handler(struct timer_list *unused);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static void nas100d_power_handler(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* This routine is called twice per second to check the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * state of the power button.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (gpio_get_value(NAS100D_PB_GPIO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /* IO Pin is 1 (button pushed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (power_button_countdown > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) power_button_countdown--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* Done on button release, to allow for auto-power-on mods. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (power_button_countdown == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /* Signal init to do the ctrlaltdel action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * this will bypass init if it hasn't started
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * and do a kernel_restart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) ctrl_alt_del();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /* Change the state of the power LED to "blink" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) gpio_set_value(NAS100D_LED_PWR_GPIO, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^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) mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) /* This is the paper-clip reset, it shuts the machine down directly. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) machine_power_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static int __init nas100d_gpio_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if (!machine_is_nas100d())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) * The power button on the Iomega NAS100d is on GPIO 14, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * it cannot handle interrupts on that GPIO line. So we'll
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * have to poll it with a kernel timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /* Request the power off GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) gpio_request(NAS100D_PO_GPIO, "power off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) /* Make sure that the power button GPIO is set up as an input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) gpio_request(NAS100D_PB_GPIO, "power button");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) gpio_direction_input(NAS100D_PB_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /* Set the initial value for the power button IRQ handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) device_initcall(nas100d_gpio_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) static void __init nas100d_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) uint8_t __iomem *f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ixp4xx_sys_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) nas100d_flash_resource.end =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) gpiod_add_lookup_table(&nas100d_i2c_gpiod_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) i2c_register_board_info(0, nas100d_i2c_board_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ARRAY_SIZE(nas100d_i2c_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * This is only useful on a modified machine, but it is valuable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * to have it first in order to see debug messages, and so that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * it does *not* get removed if platform_add_devices fails!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) (void)platform_device_register(&nas100d_uart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) pm_power_off = nas100d_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) IRQF_TRIGGER_LOW, "NAS100D reset button", NULL) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) gpio_to_irq(NAS100D_RB_GPIO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * Map in a portion of the flash and read the MAC address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * Since it is stored in BE in the flash itself, we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * byteswap it if we're in LE mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) if (f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) for (i = 0; i < 6; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) #ifdef __ARMEB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + (i^3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) iounmap(f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) printk(KERN_INFO "NAS100D: Using MAC address %pM for port 0\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) nas100d_plat_eth[0].hwaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) MACHINE_START(NAS100D, "Iomega NAS 100d")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) /* Maintainer: www.nslu2-linux.org */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) .atag_offset = 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) .map_io = ixp4xx_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) .init_early = ixp4xx_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) .init_irq = ixp4xx_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) .init_time = ixp4xx_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) .init_machine = nas100d_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) #if defined(CONFIG_PCI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) .dma_zone_size = SZ_64M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) .restart = ixp4xx_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) MACHINE_END