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