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