Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/kernel.h>
0003 #include <linux/init.h>
0004 #include <linux/serial_8250.h>
0005 #include <linux/platform_device.h>
0006 #include <asm/bootinfo.h>
0007 
0008 #include <ath25_platform.h>
0009 #include "devices.h"
0010 #include "ar5312.h"
0011 #include "ar2315.h"
0012 
0013 struct ar231x_board_config ath25_board;
0014 enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN;
0015 
0016 static struct resource ath25_wmac0_res[] = {
0017     {
0018         .name = "wmac0_membase",
0019         .flags = IORESOURCE_MEM,
0020     },
0021     {
0022         .name = "wmac0_irq",
0023         .flags = IORESOURCE_IRQ,
0024     }
0025 };
0026 
0027 static struct resource ath25_wmac1_res[] = {
0028     {
0029         .name = "wmac1_membase",
0030         .flags = IORESOURCE_MEM,
0031     },
0032     {
0033         .name = "wmac1_irq",
0034         .flags = IORESOURCE_IRQ,
0035     }
0036 };
0037 
0038 static struct platform_device ath25_wmac[] = {
0039     {
0040         .id = 0,
0041         .name = "ar231x-wmac",
0042         .resource = ath25_wmac0_res,
0043         .num_resources = ARRAY_SIZE(ath25_wmac0_res),
0044         .dev.platform_data = &ath25_board,
0045     },
0046     {
0047         .id = 1,
0048         .name = "ar231x-wmac",
0049         .resource = ath25_wmac1_res,
0050         .num_resources = ARRAY_SIZE(ath25_wmac1_res),
0051         .dev.platform_data = &ath25_board,
0052     },
0053 };
0054 
0055 static const char * const soc_type_strings[] = {
0056     [ATH25_SOC_AR5312] = "Atheros AR5312",
0057     [ATH25_SOC_AR2312] = "Atheros AR2312",
0058     [ATH25_SOC_AR2313] = "Atheros AR2313",
0059     [ATH25_SOC_AR2315] = "Atheros AR2315",
0060     [ATH25_SOC_AR2316] = "Atheros AR2316",
0061     [ATH25_SOC_AR2317] = "Atheros AR2317",
0062     [ATH25_SOC_AR2318] = "Atheros AR2318",
0063     [ATH25_SOC_UNKNOWN] = "Atheros (unknown)",
0064 };
0065 
0066 const char *get_system_type(void)
0067 {
0068     if ((ath25_soc >= ARRAY_SIZE(soc_type_strings)) ||
0069         !soc_type_strings[ath25_soc])
0070         return soc_type_strings[ATH25_SOC_UNKNOWN];
0071     return soc_type_strings[ath25_soc];
0072 }
0073 
0074 void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk)
0075 {
0076 #ifdef CONFIG_SERIAL_8250_CONSOLE
0077     struct uart_port s;
0078 
0079     memset(&s, 0, sizeof(s));
0080 
0081     s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP;
0082     s.iotype = UPIO_MEM32;
0083     s.irq = irq;
0084     s.regshift = 2;
0085     s.mapbase = mapbase;
0086     s.uartclk = uartclk;
0087 
0088     early_serial_setup(&s);
0089 #endif /* CONFIG_SERIAL_8250_CONSOLE */
0090 }
0091 
0092 int __init ath25_add_wmac(int nr, u32 base, int irq)
0093 {
0094     struct resource *res;
0095 
0096     ath25_wmac[nr].dev.platform_data = &ath25_board;
0097     res = &ath25_wmac[nr].resource[0];
0098     res->start = base;
0099     res->end = base + 0x10000 - 1;
0100     res++;
0101     res->start = irq;
0102     res->end = irq;
0103     return platform_device_register(&ath25_wmac[nr]);
0104 }
0105 
0106 static int __init ath25_register_devices(void)
0107 {
0108     if (is_ar5312())
0109         ar5312_init_devices();
0110     else
0111         ar2315_init_devices();
0112 
0113     return 0;
0114 }
0115 
0116 device_initcall(ath25_register_devices);
0117 
0118 static int __init ath25_arch_init(void)
0119 {
0120     if (is_ar5312())
0121         ar5312_arch_init();
0122     else
0123         ar2315_arch_init();
0124 
0125     return 0;
0126 }
0127 
0128 arch_initcall(ath25_arch_init);