devices.c 2.6 KB

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