devices.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/export.h>
  10. #include <linux/types.h>
  11. #include <linux/string.h>
  12. #include <linux/mtd/physmap.h>
  13. #include <linux/kernel.h>
  14. #include <linux/reboot.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/leds.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/time.h>
  19. #include <linux/io.h>
  20. #include <linux/gpio.h>
  21. #include <asm/bootinfo.h>
  22. #include <asm/irq.h>
  23. #include <lantiq_soc.h>
  24. #include <lantiq_irq.h>
  25. #include <lantiq_platform.h>
  26. #include "devices.h"
  27. /* gpio */
  28. static struct resource ltq_gpio_resource[] = {
  29. {
  30. .name = "gpio0",
  31. .start = LTQ_GPIO0_BASE_ADDR,
  32. .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  33. .flags = IORESOURCE_MEM,
  34. }, {
  35. .name = "gpio1",
  36. .start = LTQ_GPIO1_BASE_ADDR,
  37. .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  38. .flags = IORESOURCE_MEM,
  39. }, {
  40. .name = "gpio2",
  41. .start = LTQ_GPIO2_BASE_ADDR,
  42. .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  43. .flags = IORESOURCE_MEM,
  44. }
  45. };
  46. void __init ltq_register_gpio(void)
  47. {
  48. platform_device_register_simple("ltq_gpio", 0,
  49. &ltq_gpio_resource[0], 1);
  50. platform_device_register_simple("ltq_gpio", 1,
  51. &ltq_gpio_resource[1], 1);
  52. /* AR9 and VR9 have an extra gpio block */
  53. if (ltq_is_ar9() || ltq_is_vr9()) {
  54. platform_device_register_simple("ltq_gpio", 2,
  55. &ltq_gpio_resource[2], 1);
  56. }
  57. }
  58. /* serial to parallel conversion */
  59. static struct resource ltq_stp_resource = {
  60. .name = "stp",
  61. .start = LTQ_STP_BASE_ADDR,
  62. .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
  63. .flags = IORESOURCE_MEM,
  64. };
  65. void __init ltq_register_gpio_stp(void)
  66. {
  67. platform_device_register_simple("ltq_stp", 0, &ltq_stp_resource, 1);
  68. }
  69. /* asc ports - amazon se has its own serial mapping */
  70. static struct resource ltq_ase_asc_resources[] = {
  71. {
  72. .name = "asc0",
  73. .start = LTQ_ASC1_BASE_ADDR,
  74. .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
  75. .flags = IORESOURCE_MEM,
  76. },
  77. IRQ_RES(tx, LTQ_ASC_ASE_TIR),
  78. IRQ_RES(rx, LTQ_ASC_ASE_RIR),
  79. IRQ_RES(err, LTQ_ASC_ASE_EIR),
  80. };
  81. void __init ltq_register_ase_asc(void)
  82. {
  83. platform_device_register_simple("ltq_asc", 0,
  84. ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources));
  85. }
  86. /* ethernet */
  87. static struct resource ltq_etop_resources = {
  88. .name = "etop",
  89. .start = LTQ_ETOP_BASE_ADDR,
  90. .end = LTQ_ETOP_BASE_ADDR + LTQ_ETOP_SIZE - 1,
  91. .flags = IORESOURCE_MEM,
  92. };
  93. static struct platform_device ltq_etop = {
  94. .name = "ltq_etop",
  95. .resource = &ltq_etop_resources,
  96. .num_resources = 1,
  97. };
  98. void __init
  99. ltq_register_etop(struct ltq_eth_data *eth)
  100. {
  101. if (eth) {
  102. ltq_etop.dev.platform_data = eth;
  103. platform_device_register(&ltq_etop);
  104. }
  105. }