143cc739fSSergey Ryazanov #include <linux/kernel.h> 243cc739fSSergey Ryazanov #include <linux/init.h> 31ac91b1fSSergey Ryazanov #include <linux/serial_8250.h> 4*d6a4c72aSSergey Ryazanov #include <linux/platform_device.h> 543cc739fSSergey Ryazanov #include <asm/bootinfo.h> 643cc739fSSergey Ryazanov 7a7473717SSergey Ryazanov #include <ath25_platform.h> 843cc739fSSergey Ryazanov #include "devices.h" 91ac91b1fSSergey Ryazanov #include "ar5312.h" 101ac91b1fSSergey Ryazanov #include "ar2315.h" 1143cc739fSSergey Ryazanov 12a7473717SSergey Ryazanov struct ar231x_board_config ath25_board; 131654861fSSergey Ryazanov enum ath25_soc_type ath25_soc = ATH25_SOC_UNKNOWN; 141654861fSSergey Ryazanov 15*d6a4c72aSSergey Ryazanov static struct resource ath25_wmac0_res[] = { 16*d6a4c72aSSergey Ryazanov { 17*d6a4c72aSSergey Ryazanov .name = "wmac0_membase", 18*d6a4c72aSSergey Ryazanov .flags = IORESOURCE_MEM, 19*d6a4c72aSSergey Ryazanov }, 20*d6a4c72aSSergey Ryazanov { 21*d6a4c72aSSergey Ryazanov .name = "wmac0_irq", 22*d6a4c72aSSergey Ryazanov .flags = IORESOURCE_IRQ, 23*d6a4c72aSSergey Ryazanov } 24*d6a4c72aSSergey Ryazanov }; 25*d6a4c72aSSergey Ryazanov 26*d6a4c72aSSergey Ryazanov static struct resource ath25_wmac1_res[] = { 27*d6a4c72aSSergey Ryazanov { 28*d6a4c72aSSergey Ryazanov .name = "wmac1_membase", 29*d6a4c72aSSergey Ryazanov .flags = IORESOURCE_MEM, 30*d6a4c72aSSergey Ryazanov }, 31*d6a4c72aSSergey Ryazanov { 32*d6a4c72aSSergey Ryazanov .name = "wmac1_irq", 33*d6a4c72aSSergey Ryazanov .flags = IORESOURCE_IRQ, 34*d6a4c72aSSergey Ryazanov } 35*d6a4c72aSSergey Ryazanov }; 36*d6a4c72aSSergey Ryazanov 37*d6a4c72aSSergey Ryazanov static struct platform_device ath25_wmac[] = { 38*d6a4c72aSSergey Ryazanov { 39*d6a4c72aSSergey Ryazanov .id = 0, 40*d6a4c72aSSergey Ryazanov .name = "ar231x-wmac", 41*d6a4c72aSSergey Ryazanov .resource = ath25_wmac0_res, 42*d6a4c72aSSergey Ryazanov .num_resources = ARRAY_SIZE(ath25_wmac0_res), 43*d6a4c72aSSergey Ryazanov .dev.platform_data = &ath25_board, 44*d6a4c72aSSergey Ryazanov }, 45*d6a4c72aSSergey Ryazanov { 46*d6a4c72aSSergey Ryazanov .id = 1, 47*d6a4c72aSSergey Ryazanov .name = "ar231x-wmac", 48*d6a4c72aSSergey Ryazanov .resource = ath25_wmac1_res, 49*d6a4c72aSSergey Ryazanov .num_resources = ARRAY_SIZE(ath25_wmac1_res), 50*d6a4c72aSSergey Ryazanov .dev.platform_data = &ath25_board, 51*d6a4c72aSSergey Ryazanov }, 52*d6a4c72aSSergey Ryazanov }; 53*d6a4c72aSSergey Ryazanov 541654861fSSergey Ryazanov static const char * const soc_type_strings[] = { 551654861fSSergey Ryazanov [ATH25_SOC_AR5312] = "Atheros AR5312", 561654861fSSergey Ryazanov [ATH25_SOC_AR2312] = "Atheros AR2312", 571654861fSSergey Ryazanov [ATH25_SOC_AR2313] = "Atheros AR2313", 581654861fSSergey Ryazanov [ATH25_SOC_AR2315] = "Atheros AR2315", 591654861fSSergey Ryazanov [ATH25_SOC_AR2316] = "Atheros AR2316", 601654861fSSergey Ryazanov [ATH25_SOC_AR2317] = "Atheros AR2317", 611654861fSSergey Ryazanov [ATH25_SOC_AR2318] = "Atheros AR2318", 621654861fSSergey Ryazanov [ATH25_SOC_UNKNOWN] = "Atheros (unknown)", 631654861fSSergey Ryazanov }; 64a7473717SSergey Ryazanov 6543cc739fSSergey Ryazanov const char *get_system_type(void) 6643cc739fSSergey Ryazanov { 671654861fSSergey Ryazanov if ((ath25_soc >= ARRAY_SIZE(soc_type_strings)) || 681654861fSSergey Ryazanov !soc_type_strings[ath25_soc]) 691654861fSSergey Ryazanov return soc_type_strings[ATH25_SOC_UNKNOWN]; 701654861fSSergey Ryazanov return soc_type_strings[ath25_soc]; 7143cc739fSSergey Ryazanov } 721ac91b1fSSergey Ryazanov 731ac91b1fSSergey Ryazanov void __init ath25_serial_setup(u32 mapbase, int irq, unsigned int uartclk) 741ac91b1fSSergey Ryazanov { 751ac91b1fSSergey Ryazanov struct uart_port s; 761ac91b1fSSergey Ryazanov 771ac91b1fSSergey Ryazanov memset(&s, 0, sizeof(s)); 781ac91b1fSSergey Ryazanov 791ac91b1fSSergey Ryazanov s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP; 801ac91b1fSSergey Ryazanov s.iotype = UPIO_MEM32; 811ac91b1fSSergey Ryazanov s.irq = irq; 821ac91b1fSSergey Ryazanov s.regshift = 2; 831ac91b1fSSergey Ryazanov s.mapbase = mapbase; 841ac91b1fSSergey Ryazanov s.uartclk = uartclk; 851ac91b1fSSergey Ryazanov 861ac91b1fSSergey Ryazanov early_serial_setup(&s); 871ac91b1fSSergey Ryazanov } 881ac91b1fSSergey Ryazanov 89*d6a4c72aSSergey Ryazanov int __init ath25_add_wmac(int nr, u32 base, int irq) 90*d6a4c72aSSergey Ryazanov { 91*d6a4c72aSSergey Ryazanov struct resource *res; 92*d6a4c72aSSergey Ryazanov 93*d6a4c72aSSergey Ryazanov ath25_wmac[nr].dev.platform_data = &ath25_board; 94*d6a4c72aSSergey Ryazanov res = &ath25_wmac[nr].resource[0]; 95*d6a4c72aSSergey Ryazanov res->start = base; 96*d6a4c72aSSergey Ryazanov res->end = base + 0x10000 - 1; 97*d6a4c72aSSergey Ryazanov res++; 98*d6a4c72aSSergey Ryazanov res->start = irq; 99*d6a4c72aSSergey Ryazanov res->end = irq; 100*d6a4c72aSSergey Ryazanov return platform_device_register(&ath25_wmac[nr]); 101*d6a4c72aSSergey Ryazanov } 102*d6a4c72aSSergey Ryazanov 103a7473717SSergey Ryazanov static int __init ath25_register_devices(void) 104a7473717SSergey Ryazanov { 105a7473717SSergey Ryazanov if (is_ar5312()) 106a7473717SSergey Ryazanov ar5312_init_devices(); 107a7473717SSergey Ryazanov else 108a7473717SSergey Ryazanov ar2315_init_devices(); 109a7473717SSergey Ryazanov 110a7473717SSergey Ryazanov return 0; 111a7473717SSergey Ryazanov } 112a7473717SSergey Ryazanov 113a7473717SSergey Ryazanov device_initcall(ath25_register_devices); 114a7473717SSergey Ryazanov 1151ac91b1fSSergey Ryazanov static int __init ath25_arch_init(void) 1161ac91b1fSSergey Ryazanov { 1171ac91b1fSSergey Ryazanov if (is_ar5312()) 1181ac91b1fSSergey Ryazanov ar5312_arch_init(); 1191ac91b1fSSergey Ryazanov else 1201ac91b1fSSergey Ryazanov ar2315_arch_init(); 1211ac91b1fSSergey Ryazanov 1221ac91b1fSSergey Ryazanov return 0; 1231ac91b1fSSergey Ryazanov } 1241ac91b1fSSergey Ryazanov 1251ac91b1fSSergey Ryazanov arch_initcall(ath25_arch_init); 126