devices.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/module.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/reboot.h>
  19. #include <linux/time.h>
  20. #include <linux/io.h>
  21. #include <linux/gpio.h>
  22. #include <linux/leds.h>
  23. #include <asm/bootinfo.h>
  24. #include <asm/irq.h>
  25. #include <lantiq_soc.h>
  26. #include <lantiq_irq.h>
  27. #include <lantiq_platform.h>
  28. #include "devices.h"
  29. /* gpio */
  30. static struct resource ltq_gpio_resource[] = {
  31. {
  32. .name = "gpio0",
  33. .start = LTQ_GPIO0_BASE_ADDR,
  34. .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  35. .flags = IORESOURCE_MEM,
  36. }, {
  37. .name = "gpio1",
  38. .start = LTQ_GPIO1_BASE_ADDR,
  39. .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  40. .flags = IORESOURCE_MEM,
  41. }, {
  42. .name = "gpio2",
  43. .start = LTQ_GPIO2_BASE_ADDR,
  44. .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
  45. .flags = IORESOURCE_MEM,
  46. }
  47. };
  48. void __init ltq_register_gpio(void)
  49. {
  50. platform_device_register_simple("ltq_gpio", 0,
  51. &ltq_gpio_resource[0], 1);
  52. platform_device_register_simple("ltq_gpio", 1,
  53. &ltq_gpio_resource[1], 1);
  54. /* AR9 and VR9 have an extra gpio block */
  55. if (ltq_is_ar9() || ltq_is_vr9()) {
  56. platform_device_register_simple("ltq_gpio", 2,
  57. &ltq_gpio_resource[2], 1);
  58. }
  59. }
  60. /* serial to parallel conversion */
  61. static struct resource ltq_stp_resource = {
  62. .name = "stp",
  63. .start = LTQ_STP_BASE_ADDR,
  64. .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
  65. .flags = IORESOURCE_MEM,
  66. };
  67. void __init ltq_register_gpio_stp(void)
  68. {
  69. platform_device_register_simple("ltq_stp", 0, &ltq_stp_resource, 1);
  70. }
  71. /* asc ports - amazon se has its own serial mapping */
  72. static struct resource ltq_ase_asc_resources[] = {
  73. {
  74. .name = "asc0",
  75. .start = LTQ_ASC1_BASE_ADDR,
  76. .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
  77. .flags = IORESOURCE_MEM,
  78. },
  79. IRQ_RES(tx, LTQ_ASC_ASE_TIR),
  80. IRQ_RES(rx, LTQ_ASC_ASE_RIR),
  81. IRQ_RES(err, LTQ_ASC_ASE_EIR),
  82. };
  83. void __init ltq_register_ase_asc(void)
  84. {
  85. platform_device_register_simple("ltq_asc", 0,
  86. ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources));
  87. }
  88. /* ethernet */
  89. static struct resource ltq_etop_resources = {
  90. .name = "etop",
  91. .start = LTQ_ETOP_BASE_ADDR,
  92. .end = LTQ_ETOP_BASE_ADDR + LTQ_ETOP_SIZE - 1,
  93. .flags = IORESOURCE_MEM,
  94. };
  95. static struct platform_device ltq_etop = {
  96. .name = "ltq_etop",
  97. .resource = &ltq_etop_resources,
  98. .num_resources = 1,
  99. };
  100. void __init
  101. ltq_register_etop(struct ltq_eth_data *eth)
  102. {
  103. if (eth) {
  104. ltq_etop.dev.platform_data = eth;
  105. platform_device_register(&ltq_etop);
  106. }
  107. }