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)  * Renesas Technology Europe RSK+ 7203 Support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2008 - 2010  Paul Mundt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/smsc911x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/gpio_keys.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/machvec.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <cpu/sh7203.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) static struct smsc911x_platform_config smsc911x_config = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	.phy_interface	= PHY_INTERFACE_MODE_MII,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	.flags		= SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static struct resource smsc911x_resources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	[0] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		.start		= 0x24000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		.end		= 0x240000ff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		.flags		= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		.start		= 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		.end		= 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		.flags		= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static struct platform_device smsc911x_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	.name		= "smsc911x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	.num_resources	= ARRAY_SIZE(smsc911x_resources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	.resource	= smsc911x_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		.platform_data = &smsc911x_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static struct gpio_led rsk7203_gpio_leds[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		.name			= "green",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		.gpio			= GPIO_PE10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		.active_low		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		.name			= "orange",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		.default_trigger	= "nand-disk",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		.gpio			= GPIO_PE12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		.active_low		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		.name			= "red:timer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		.default_trigger	= "timer",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		.gpio			= GPIO_PC14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		.active_low		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		.name			= "red:heartbeat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		.default_trigger	= "heartbeat",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		.gpio			= GPIO_PE11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		.active_low		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	.leds		= rsk7203_gpio_leds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	.num_leds	= ARRAY_SIZE(rsk7203_gpio_leds),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static struct platform_device led_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.name		= "leds-gpio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	.id		= -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		.platform_data	= &rsk7203_gpio_leds_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		.code		= BTN_0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		.gpio		= GPIO_PB0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		.desc		= "SW1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		.code		= BTN_1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		.gpio		= GPIO_PB1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		.desc		= "SW2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		.code		= BTN_2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		.gpio		= GPIO_PB2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		.active_low	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		.desc		= "SW3",
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.buttons	= rsk7203_gpio_keys_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.nbuttons	= ARRAY_SIZE(rsk7203_gpio_keys_table),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.poll_interval	= 50, /* default to 50ms */
^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 platform_device keys_device = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.name		= "gpio-keys-polled",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	.dev		= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		.platform_data	= &rsk7203_gpio_keys_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static struct platform_device *rsk7203_devices[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	&smsc911x_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	&led_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	&keys_device,
^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 int __init rsk7203_devices_setup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/* Select pins for SCIF0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	gpio_request(GPIO_FN_TXD0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	gpio_request(GPIO_FN_RXD0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	/* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	__raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	gpio_request(GPIO_FN_IRQ0_PB, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	return platform_add_devices(rsk7203_devices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 				    ARRAY_SIZE(rsk7203_devices));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) device_initcall(rsk7203_devices_setup);