devices.c 2.5 KB

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