Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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)  * DSM-G600 board-setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2006 Tower Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * based on ixdp425-setup.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *      Copyright (C) 2003-2004 MontaVista Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * based on nslu2-power.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *	Copyright (C) 2005 Tower Technologies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * based on nslu2-io.c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *	Copyright (C) 2004 Karen Spearel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  * Author: Alessandro Zummo <a.zummo@towertech.it>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Author: Michael Westerhof <mwester@dls.net>
^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) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/serial.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/reboot.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/gpio/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^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) #include <asm/mach/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include "irqs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define DSMG600_SDA_PIN		5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define DSMG600_SCL_PIN		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /* DSM-G600 Timer Setting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #define DSMG600_FREQ		66000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) /* Buttons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define DSMG600_PB_GPIO		15	/* power button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) #define DSMG600_RB_GPIO		3	/* reset button */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) /* Power control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define DSMG600_PO_GPIO		2	/* power off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /* LEDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define DSMG600_LED_PWR_GPIO	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define DSMG600_LED_WLAN_GPIO	14
^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 dsmg600_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 dsmg600_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 dsmg600_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	= &dsmg600_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		= &dsmg600_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 dsmg600_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", DSMG600_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", DSMG600_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 platform_device dsmg600_i2c_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.name			= "i2c-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.id			= 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.dev	 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		.platform_data	= NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		I2C_BOARD_INFO("pcf8563", 0x51),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static struct gpio_led dsmg600_led_pins[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		.name		= "dsmg600:green:power",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		.gpio		= DSMG600_LED_PWR_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		.name		= "dsmg600:green:wlan",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		.gpio		= DSMG600_LED_WLAN_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		.active_low	= true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	},
^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) static struct gpio_led_platform_data dsmg600_led_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	.num_leds		= ARRAY_SIZE(dsmg600_led_pins),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.leds			= dsmg600_led_pins,
^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) static struct platform_device dsmg600_leds = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.name			= "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.id			= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.dev.platform_data	= &dsmg600_led_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static struct resource dsmg600_uart_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		.start		= IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		.end		= IXP4XX_UART1_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		.flags		= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		.start		= IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		.end		= IXP4XX_UART2_BASE_PHYS + 0x0fff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		.flags		= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) static struct plat_serial8250_port dsmg600_uart_data[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		.mapbase	= IXP4XX_UART1_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		.membase	= (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		.irq		= IRQ_IXP4XX_UART1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		.flags		= UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.iotype		= UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		.regshift	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		.uartclk	= IXP4XX_UART_XTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		.mapbase	= IXP4XX_UART2_BASE_PHYS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		.membase	= (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		.irq		= IRQ_IXP4XX_UART2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		.flags		= UPF_BOOT_AUTOCONF,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		.iotype		= UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		.regshift	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		.uartclk	= IXP4XX_UART_XTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	{ }
^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) static struct platform_device dsmg600_uart = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	.name			= "serial8250",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	.id			= PLAT8250_DEV_PLATFORM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.dev.platform_data	= dsmg600_uart_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.num_resources		= ARRAY_SIZE(dsmg600_uart_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.resource		= dsmg600_uart_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) static struct platform_device *dsmg600_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	&dsmg600_i2c_gpio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	&dsmg600_flash,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	&dsmg600_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static void dsmg600_power_off(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	/* enable the pwr cntl and drive it high */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	gpio_direction_output(DSMG600_PO_GPIO, 1);
^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) /* This is used to make sure the power-button pusher is serious.  The button
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * must be held until the value of this counter reaches zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static int power_button_countdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* Must hold the button down for at least this many counts to be processed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static void dsmg600_power_handler(struct timer_list *unused);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) static void dsmg600_power_handler(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	/* This routine is called twice per second to check the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 * state of the power button.
^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) 	if (gpio_get_value(DSMG600_PB_GPIO)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		/* IO Pin is 1 (button pushed) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		if (power_button_countdown > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			power_button_countdown--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		/* Done on button release, to allow for auto-power-on mods. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (power_button_countdown == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			/* Signal init to do the ctrlaltdel action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			 * this will bypass init if it hasn't started
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 			 * and do a kernel_restart.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			ctrl_alt_del();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			/* Change the state of the power LED to "blink" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			gpio_set_value(DSMG600_LED_PWR_GPIO, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	/* This is the paper-clip reset, it shuts the machine down directly. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	machine_power_off();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static void __init dsmg600_timer_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)     /* The xtal on this machine is non-standard. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)     ixp4xx_timer_freq = DSMG600_FREQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)     /* Call standard timer_init function. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)     ixp4xx_timer_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static int __init dsmg600_gpio_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	if (!machine_is_dsmg600())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	gpio_request(DSMG600_RB_GPIO, "reset button");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		IRQF_TRIGGER_LOW, "DSM-G600 reset button", NULL) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			gpio_to_irq(DSMG600_RB_GPIO));
^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) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	 * The power button on the D-Link DSM-G600 is on GPIO 15, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	 * it cannot handle interrupts on that GPIO line.  So we'll
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	 * have to poll it with a kernel timer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	/* Make sure that the power button GPIO is set up as an input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	gpio_request(DSMG600_PB_GPIO, "power button");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	gpio_direction_input(DSMG600_PB_GPIO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	/* Request poweroff GPIO line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	gpio_request(DSMG600_PO_GPIO, "power off button");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	/* Set the initial value for the power button IRQ handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) device_initcall(dsmg600_gpio_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static void __init dsmg600_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	ixp4xx_sys_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	dsmg600_flash_resource.end =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	gpiod_add_lookup_table(&dsmg600_i2c_gpiod_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	i2c_register_board_info(0, dsmg600_i2c_board_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 				ARRAY_SIZE(dsmg600_i2c_board_info));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	/* The UART is required on the DSM-G600 (Redboot cannot use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	 * NIC) -- do it here so that it does *not* get removed if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 * platform_add_devices fails!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)         (void)platform_device_register(&dsmg600_uart);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	pm_power_off = dsmg600_power_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	/* Maintainer: www.nslu2-linux.org */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	.atag_offset	= 0x100,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	.map_io		= ixp4xx_map_io,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	.init_early	= ixp4xx_init_early,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	.init_irq	= ixp4xx_init_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	.init_time	= dsmg600_timer_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	.init_machine	= dsmg600_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) #if defined(CONFIG_PCI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	.dma_zone_size	= SZ_64M,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	.restart	= ixp4xx_restart,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) MACHINE_END