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-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  Registration of Cobalt UART platform device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <cobalt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static struct resource cobalt_uart_resource[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		.start	= 0x1c800000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 		.end	= 0x1c800007,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		.flags	= IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		.start	= SERIAL_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		.end	= SERIAL_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		.flags	= IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static struct plat_serial8250_port cobalt_serial8250_port[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		.irq		= SERIAL_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		.uartclk	= 18432000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		.iotype		= UPIO_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		.flags		= UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		.mapbase	= 0x1c800000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	},
^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 __init int cobalt_uart_add(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	struct platform_device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	 * Cobalt Qube1 has no UART.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	if (cobalt_board_id == COBALT_BRD_ID_QUBE1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	pdev = platform_device_alloc("serial8250", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (!pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	pdev->id = PLAT8250_DEV_PLATFORM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	pdev->dev.platform_data = cobalt_serial8250_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		goto err_free_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	retval = platform_device_add(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	if (retval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 		goto err_free_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) err_free_device:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	platform_device_put(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) device_initcall(cobalt_uart_add);