Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 2 | #include <linux/kernel.h> |
| 3 | #include <linux/init.h> |
Sergey Ryazanov | 1ac91b1 | 2014-10-29 03:18:43 +0400 | [diff] [blame] | 4 | #include <linux/serial_8250.h> |
Sergey Ryazanov | d6a4c72 | 2014-10-29 03:18:50 +0400 | [diff] [blame] | 5 | #include <linux/platform_device.h> |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 6 | #include <asm/bootinfo.h> |
| 7 | |
Sergey Ryazanov | a747371 | 2014-10-29 03:18:44 +0400 | [diff] [blame] | 8 | #include <ath25_platform.h> |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 9 | #include "devices.h" |
Sergey Ryazanov | 1ac91b1 | 2014-10-29 03:18:43 +0400 | [diff] [blame] | 10 | #include "ar5312.h" |
| 11 | #include "ar2315.h" |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 12 | |
Sergey Ryazanov | a747371 | 2014-10-29 03:18:44 +0400 | [diff] [blame] | 13 | struct ar231x_board_config ath25_board; |
Sergey Ryazanov | 1654861 | 2014-10-29 03:18:45 +0400 | [diff] [blame] | 14 | enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN; |
| 15 | |
Sergey Ryazanov | d6a4c72 | 2014-10-29 03:18:50 +0400 | [diff] [blame] | 16 | static struct resource ath25_wmac0_res[] = { |
| 17 | { |
| 18 | .name = "wmac0_membase", |
| 19 | .flags = IORESOURCE_MEM, |
| 20 | }, |
| 21 | { |
| 22 | .name = "wmac0_irq", |
| 23 | .flags = IORESOURCE_IRQ, |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | static struct resource ath25_wmac1_res[] = { |
| 28 | { |
| 29 | .name = "wmac1_membase", |
| 30 | .flags = IORESOURCE_MEM, |
| 31 | }, |
| 32 | { |
| 33 | .name = "wmac1_irq", |
| 34 | .flags = IORESOURCE_IRQ, |
| 35 | } |
| 36 | }; |
| 37 | |
| 38 | static struct platform_device ath25_wmac[] = { |
| 39 | { |
| 40 | .id = 0, |
| 41 | .name = "ar231x-wmac", |
| 42 | .resource = ath25_wmac0_res, |
| 43 | .num_resources = ARRAY_SIZE(ath25_wmac0_res), |
| 44 | .dev.platform_data = &ath25_board, |
| 45 | }, |
| 46 | { |
| 47 | .id = 1, |
| 48 | .name = "ar231x-wmac", |
| 49 | .resource = ath25_wmac1_res, |
| 50 | .num_resources = ARRAY_SIZE(ath25_wmac1_res), |
| 51 | .dev.platform_data = &ath25_board, |
| 52 | }, |
| 53 | }; |
| 54 | |
Sergey Ryazanov | 1654861 | 2014-10-29 03:18:45 +0400 | [diff] [blame] | 55 | static const char * const soc_type_strings[] = { |
| 56 | [ATH25_SOC_AR5312] = "Atheros AR5312", |
| 57 | [ATH25_SOC_AR2312] = "Atheros AR2312", |
| 58 | [ATH25_SOC_AR2313] = "Atheros AR2313", |
| 59 | [ATH25_SOC_AR2315] = "Atheros AR2315", |
| 60 | [ATH25_SOC_AR2316] = "Atheros AR2316", |
| 61 | [ATH25_SOC_AR2317] = "Atheros AR2317", |
| 62 | [ATH25_SOC_AR2318] = "Atheros AR2318", |
| 63 | [ATH25_SOC_UNKNOWN] = "Atheros (unknown)", |
| 64 | }; |
Sergey Ryazanov | a747371 | 2014-10-29 03:18:44 +0400 | [diff] [blame] | 65 | |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 66 | const char *get_system_type(void) |
| 67 | { |
Sergey Ryazanov | 1654861 | 2014-10-29 03:18:45 +0400 | [diff] [blame] | 68 | if ((ath25_soc >= ARRAY_SIZE(soc_type_strings)) || |
| 69 | !soc_type_strings[ath25_soc]) |
| 70 | return soc_type_strings[ATH25_SOC_UNKNOWN]; |
| 71 | return soc_type_strings[ath25_soc]; |
Sergey Ryazanov | 43cc739 | 2014-10-29 03:18:38 +0400 | [diff] [blame] | 72 | } |
Sergey Ryazanov | 1ac91b1 | 2014-10-29 03:18:43 +0400 | [diff] [blame] | 73 | |
| 74 | void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk) |
| 75 | { |
| 76 | struct uart_port s; |
| 77 | |
| 78 | memset(&s, 0, sizeof(s)); |
| 79 | |
| 80 | s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP; |
| 81 | s.iotype = UPIO_MEM32; |
| 82 | s.irq = irq; |
| 83 | s.regshift = 2; |
| 84 | s.mapbase = mapbase; |
| 85 | s.uartclk = uartclk; |
| 86 | |
| 87 | early_serial_setup(&s); |
| 88 | } |
| 89 | |
Sergey Ryazanov | d6a4c72 | 2014-10-29 03:18:50 +0400 | [diff] [blame] | 90 | int __init ath25_add_wmac(int nr, u32 base, int irq) |
| 91 | { |
| 92 | struct resource *res; |
| 93 | |
| 94 | ath25_wmac[nr].dev.platform_data = &ath25_board; |
| 95 | res = &ath25_wmac[nr].resource[0]; |
| 96 | res->start = base; |
| 97 | res->end = base + 0x10000 - 1; |
| 98 | res++; |
| 99 | res->start = irq; |
| 100 | res->end = irq; |
| 101 | return platform_device_register(&ath25_wmac[nr]); |
| 102 | } |
| 103 | |
Sergey Ryazanov | a747371 | 2014-10-29 03:18:44 +0400 | [diff] [blame] | 104 | static int __init ath25_register_devices(void) |
| 105 | { |
| 106 | if (is_ar5312()) |
| 107 | ar5312_init_devices(); |
| 108 | else |
| 109 | ar2315_init_devices(); |
| 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | device_initcall(ath25_register_devices); |
| 115 | |
Sergey Ryazanov | 1ac91b1 | 2014-10-29 03:18:43 +0400 | [diff] [blame] | 116 | static int __init ath25_arch_init(void) |
| 117 | { |
| 118 | if (is_ar5312()) |
| 119 | ar5312_arch_init(); |
| 120 | else |
| 121 | ar2315_arch_init(); |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | arch_initcall(ath25_arch_init); |