devices.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/kernel.h>
  13. #include <linux/reboot.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/leds.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/reboot.h>
  18. #include <linux/time.h>
  19. #include <linux/io.h>
  20. #include <linux/gpio.h>
  21. #include <linux/leds.h>
  22. #include <asm/bootinfo.h>
  23. #include <asm/irq.h>
  24. #include <lantiq_soc.h>
  25. #include "devices.h"
  26. /* nor flash */
  27. static struct resource ltq_nor_resource = {
  28. .name = "nor",
  29. .start = LTQ_FLASH_START,
  30. .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
  31. .flags = IORESOURCE_MEM,
  32. };
  33. static struct platform_device ltq_nor = {
  34. .name = "ltq_nor",
  35. .resource = &ltq_nor_resource,
  36. .num_resources = 1,
  37. };
  38. void __init ltq_register_nor(struct physmap_flash_data *data)
  39. {
  40. ltq_nor.dev.platform_data = data;
  41. platform_device_register(&ltq_nor);
  42. }
  43. /* watchdog */
  44. static struct resource ltq_wdt_resource = {
  45. .name = "watchdog",
  46. .start = LTQ_WDT_BASE_ADDR,
  47. .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
  48. .flags = IORESOURCE_MEM,
  49. };
  50. void __init ltq_register_wdt(void)
  51. {
  52. platform_device_register_simple("ltq_wdt", 0, &ltq_wdt_resource, 1);
  53. }
  54. /* asc ports */
  55. static struct resource ltq_asc0_resources[] = {
  56. {
  57. .name = "asc0",
  58. .start = LTQ_ASC0_BASE_ADDR,
  59. .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
  60. .flags = IORESOURCE_MEM,
  61. },
  62. IRQ_RES(tx, LTQ_ASC_TIR(0)),
  63. IRQ_RES(rx, LTQ_ASC_RIR(0)),
  64. IRQ_RES(err, LTQ_ASC_EIR(0)),
  65. };
  66. static struct resource ltq_asc1_resources[] = {
  67. {
  68. .name = "asc1",
  69. .start = LTQ_ASC1_BASE_ADDR,
  70. .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. IRQ_RES(tx, LTQ_ASC_TIR(1)),
  74. IRQ_RES(rx, LTQ_ASC_RIR(1)),
  75. IRQ_RES(err, LTQ_ASC_EIR(1)),
  76. };
  77. void __init ltq_register_asc(int port)
  78. {
  79. switch (port) {
  80. case 0:
  81. platform_device_register_simple("ltq_asc", 0,
  82. ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
  83. break;
  84. case 1:
  85. platform_device_register_simple("ltq_asc", 1,
  86. ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
  87. break;
  88. default:
  89. break;
  90. }
  91. }
  92. #ifdef CONFIG_PCI
  93. /* pci */
  94. static struct platform_device ltq_pci = {
  95. .name = "ltq_pci",
  96. .num_resources = 0,
  97. };
  98. void __init ltq_register_pci(struct ltq_pci_data *data)
  99. {
  100. ltq_pci.dev.platform_data = data;
  101. platform_device_register(&ltq_pci);
  102. }
  103. #else
  104. void __init ltq_register_pci(struct ltq_pci_data *data)
  105. {
  106. pr_err("kernel is compiled without PCI support\n");
  107. }
  108. #endif