dev-ar913x-wmac.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Atheros AR913X SoC built-in WMAC device support
  3. *
  4. * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/delay.h>
  13. #include <linux/irq.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/ath9k_platform.h>
  16. #include <asm/mach-ath79/ath79.h>
  17. #include <asm/mach-ath79/ar71xx_regs.h>
  18. #include "dev-ar913x-wmac.h"
  19. static struct ath9k_platform_data ath79_wmac_data;
  20. static struct resource ath79_wmac_resources[] = {
  21. {
  22. /* .start and .end fields are filled dynamically */
  23. .flags = IORESOURCE_MEM,
  24. }, {
  25. .start = ATH79_CPU_IRQ_IP2,
  26. .end = ATH79_CPU_IRQ_IP2,
  27. .flags = IORESOURCE_IRQ,
  28. },
  29. };
  30. static struct platform_device ath79_wmac_device = {
  31. .name = "ath9k",
  32. .id = -1,
  33. .resource = ath79_wmac_resources,
  34. .num_resources = ARRAY_SIZE(ath79_wmac_resources),
  35. .dev = {
  36. .platform_data = &ath79_wmac_data,
  37. },
  38. };
  39. static void __init ar913x_wmac_setup(void)
  40. {
  41. /* reset the WMAC */
  42. ath79_device_reset_set(AR913X_RESET_AMBA2WMAC);
  43. mdelay(10);
  44. ath79_device_reset_clear(AR913X_RESET_AMBA2WMAC);
  45. mdelay(10);
  46. ath79_wmac_resources[0].start = AR913X_WMAC_BASE;
  47. ath79_wmac_resources[0].end = AR913X_WMAC_BASE + AR913X_WMAC_SIZE - 1;
  48. }
  49. void __init ath79_register_wmac(u8 *cal_data)
  50. {
  51. if (soc_is_ar913x())
  52. ar913x_wmac_setup();
  53. else
  54. BUG();
  55. if (cal_data)
  56. memcpy(ath79_wmac_data.eeprom_data, cal_data,
  57. sizeof(ath79_wmac_data.eeprom_data));
  58. platform_device_register(&ath79_wmac_device);
  59. }