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) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/serial_8250.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <asm/bootinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <ath25_platform.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include "devices.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "ar5312.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "ar2315.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) struct ar231x_board_config ath25_board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static struct resource ath25_wmac0_res[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		.name = "wmac0_membase",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		.flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		.name = "wmac0_irq",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		.flags = IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	}
^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 ath25_wmac1_res[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		.name = "wmac1_membase",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		.flags = IORESOURCE_MEM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		.name = "wmac1_irq",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		.flags = IORESOURCE_IRQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	}
^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) static struct platform_device ath25_wmac[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		.id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		.name = "ar231x-wmac",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		.resource = ath25_wmac0_res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		.num_resources = ARRAY_SIZE(ath25_wmac0_res),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		.dev.platform_data = &ath25_board,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		.id = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		.name = "ar231x-wmac",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		.resource = ath25_wmac1_res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		.num_resources = ARRAY_SIZE(ath25_wmac1_res),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		.dev.platform_data = &ath25_board,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static const char * const soc_type_strings[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	[ATH25_SOC_AR5312] = "Atheros AR5312",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	[ATH25_SOC_AR2312] = "Atheros AR2312",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	[ATH25_SOC_AR2313] = "Atheros AR2313",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	[ATH25_SOC_AR2315] = "Atheros AR2315",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	[ATH25_SOC_AR2316] = "Atheros AR2316",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	[ATH25_SOC_AR2317] = "Atheros AR2317",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	[ATH25_SOC_AR2318] = "Atheros AR2318",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	[ATH25_SOC_UNKNOWN] = "Atheros (unknown)",
^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) const char *get_system_type(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if ((ath25_soc >= ARRAY_SIZE(soc_type_strings)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	    !soc_type_strings[ath25_soc])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return soc_type_strings[ATH25_SOC_UNKNOWN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	return soc_type_strings[ath25_soc];
^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) void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) #ifdef CONFIG_SERIAL_8250_CONSOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	struct uart_port s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	memset(&s, 0, sizeof(s));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	s.iotype = UPIO_MEM32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	s.irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	s.regshift = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	s.mapbase = mapbase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	s.uartclk = uartclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	early_serial_setup(&s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) #endif /* CONFIG_SERIAL_8250_CONSOLE */
^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) int __init ath25_add_wmac(int nr, u32 base, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ath25_wmac[nr].dev.platform_data = &ath25_board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	res = &ath25_wmac[nr].resource[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	res->start = base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	res->end = base + 0x10000 - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	res++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	res->start = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	res->end = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return platform_device_register(&ath25_wmac[nr]);
^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 int __init ath25_register_devices(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	if (is_ar5312())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		ar5312_init_devices();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		ar2315_init_devices();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return 0;
^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) device_initcall(ath25_register_devices);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static int __init ath25_arch_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (is_ar5312())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		ar5312_arch_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		ar2315_arch_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return 0;
^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) arch_initcall(ath25_arch_init);