dev-common.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Atheros AR71XX/AR724X/AR913X common devices
  3. *
  4. * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * Parts of this file are based on Atheros' 2.6.15 BSP
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/serial_8250.h>
  17. #include <linux/clk.h>
  18. #include <linux/err.h>
  19. #include <asm/mach-ath79/ath79.h>
  20. #include <asm/mach-ath79/ar71xx_regs.h>
  21. #include "common.h"
  22. #include "dev-common.h"
  23. static struct resource ath79_uart_resources[] = {
  24. {
  25. .start = AR71XX_UART_BASE,
  26. .end = AR71XX_UART_BASE + AR71XX_UART_SIZE - 1,
  27. .flags = IORESOURCE_MEM,
  28. },
  29. };
  30. #define AR71XX_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
  31. static struct plat_serial8250_port ath79_uart_data[] = {
  32. {
  33. .mapbase = AR71XX_UART_BASE,
  34. .irq = ATH79_MISC_IRQ_UART,
  35. .flags = AR71XX_UART_FLAGS,
  36. .iotype = UPIO_MEM32,
  37. .regshift = 2,
  38. }, {
  39. /* terminating entry */
  40. }
  41. };
  42. static struct platform_device ath79_uart_device = {
  43. .name = "serial8250",
  44. .id = PLAT8250_DEV_PLATFORM,
  45. .resource = ath79_uart_resources,
  46. .num_resources = ARRAY_SIZE(ath79_uart_resources),
  47. .dev = {
  48. .platform_data = ath79_uart_data
  49. },
  50. };
  51. void __init ath79_register_uart(void)
  52. {
  53. struct clk *clk;
  54. clk = clk_get(NULL, "uart");
  55. if (IS_ERR(clk))
  56. panic("unable to get UART clock, err=%ld", PTR_ERR(clk));
  57. ath79_uart_data[0].uartclk = clk_get_rate(clk);
  58. platform_device_register(&ath79_uart_device);
  59. }
  60. static struct platform_device ath79_wdt_device = {
  61. .name = "ath79-wdt",
  62. .id = -1,
  63. };
  64. void __init ath79_register_wdt(void)
  65. {
  66. platform_device_register(&ath79_wdt_device);
  67. }