dev-ap9x-pci.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Atheros AP9X reference board PCI initialization
  3. *
  4. * Copyright (C) 2009-2012 Gabor Juhos <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/pci.h>
  11. #include <linux/ath9k_platform.h>
  12. #include <linux/delay.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include <asm/mach-ath79/pci.h>
  15. #include "dev-ap9x-pci.h"
  16. #include "pci-ath9k-fixup.h"
  17. #include "pci.h"
  18. static struct ath9k_platform_data ap9x_wmac0_data = {
  19. .led_pin = -1,
  20. };
  21. static struct ath9k_platform_data ap9x_wmac1_data = {
  22. .led_pin = -1,
  23. };
  24. static char ap9x_wmac0_mac[6];
  25. static char ap9x_wmac1_mac[6];
  26. __init void ap9x_pci_setup_wmac_led_pin(unsigned wmac, int pin)
  27. {
  28. switch (wmac) {
  29. case 0:
  30. ap9x_wmac0_data.led_pin = pin;
  31. break;
  32. case 1:
  33. ap9x_wmac1_data.led_pin = pin;
  34. break;
  35. }
  36. }
  37. __init void ap9x_pci_setup_wmac_gpio(unsigned wmac, u32 mask, u32 val)
  38. {
  39. switch (wmac) {
  40. case 0:
  41. ap9x_wmac0_data.gpio_mask = mask;
  42. ap9x_wmac0_data.gpio_val = val;
  43. break;
  44. case 1:
  45. ap9x_wmac1_data.gpio_mask = mask;
  46. ap9x_wmac1_data.gpio_val = val;
  47. break;
  48. }
  49. }
  50. __init void ap9x_pci_setup_wmac_leds(unsigned wmac, struct gpio_led *leds,
  51. int num_leds)
  52. {
  53. switch (wmac) {
  54. case 0:
  55. ap9x_wmac0_data.leds = leds;
  56. ap9x_wmac0_data.num_leds = num_leds;
  57. break;
  58. case 1:
  59. ap9x_wmac1_data.leds = leds;
  60. ap9x_wmac1_data.num_leds = num_leds;
  61. break;
  62. }
  63. }
  64. static int ap91_pci_plat_dev_init(struct pci_dev *dev)
  65. {
  66. switch (PCI_SLOT(dev->devfn)) {
  67. case 0:
  68. dev->dev.platform_data = &ap9x_wmac0_data;
  69. break;
  70. }
  71. return 0;
  72. }
  73. __init void ap91_pci_init(u8 *cal_data, u8 *mac_addr)
  74. {
  75. if (cal_data)
  76. memcpy(ap9x_wmac0_data.eeprom_data, cal_data,
  77. sizeof(ap9x_wmac0_data.eeprom_data));
  78. if (mac_addr) {
  79. memcpy(ap9x_wmac0_mac, mac_addr, sizeof(ap9x_wmac0_mac));
  80. ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
  81. }
  82. ath79_pci_set_plat_dev_init(ap91_pci_plat_dev_init);
  83. ath79_register_pci();
  84. pci_enable_ath9k_fixup(0, ap9x_wmac0_data.eeprom_data);
  85. }
  86. static int ap94_pci_plat_dev_init(struct pci_dev *dev)
  87. {
  88. switch (PCI_SLOT(dev->devfn)) {
  89. case 17:
  90. dev->dev.platform_data = &ap9x_wmac0_data;
  91. break;
  92. case 18:
  93. dev->dev.platform_data = &ap9x_wmac1_data;
  94. break;
  95. }
  96. return 0;
  97. }
  98. __init void ap94_pci_init(u8 *cal_data0, u8 *mac_addr0,
  99. u8 *cal_data1, u8 *mac_addr1)
  100. {
  101. if (cal_data0)
  102. memcpy(ap9x_wmac0_data.eeprom_data, cal_data0,
  103. sizeof(ap9x_wmac0_data.eeprom_data));
  104. if (cal_data1)
  105. memcpy(ap9x_wmac1_data.eeprom_data, cal_data1,
  106. sizeof(ap9x_wmac1_data.eeprom_data));
  107. if (mac_addr0) {
  108. memcpy(ap9x_wmac0_mac, mac_addr0, sizeof(ap9x_wmac0_mac));
  109. ap9x_wmac0_data.macaddr = ap9x_wmac0_mac;
  110. }
  111. if (mac_addr1) {
  112. memcpy(ap9x_wmac1_mac, mac_addr1, sizeof(ap9x_wmac1_mac));
  113. ap9x_wmac1_data.macaddr = ap9x_wmac1_mac;
  114. }
  115. ath79_pci_set_plat_dev_init(ap94_pci_plat_dev_init);
  116. ath79_register_pci();
  117. pci_enable_ath9k_fixup(17, ap9x_wmac0_data.eeprom_data);
  118. pci_enable_ath9k_fixup(18, ap9x_wmac1_data.eeprom_data);
  119. }