board-zoom-debugboard.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Inc.
  3. * Mikkel Christensen <mlc@ti.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/gpio.h>
  12. #include <linux/serial_8250.h>
  13. #include <linux/smsc911x.h>
  14. #include <linux/interrupt.h>
  15. #include <mach/gpmc.h>
  16. #define ZOOM2_SMSC911X_CS 7
  17. #define ZOOM2_SMSC911X_GPIO 158
  18. #define ZOOM2_QUADUART_CS 3
  19. #define ZOOM2_QUADUART_GPIO 102
  20. #define QUART_CLK 1843200
  21. #define DEBUG_BASE 0x08000000
  22. #define ZOOM2_ETHR_START DEBUG_BASE
  23. static struct resource zoom2_smsc911x_resources[] = {
  24. [0] = {
  25. .start = ZOOM2_ETHR_START,
  26. .end = ZOOM2_ETHR_START + SZ_4K,
  27. .flags = IORESOURCE_MEM,
  28. },
  29. [1] = {
  30. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  31. },
  32. };
  33. static struct smsc911x_platform_config zoom2_smsc911x_config = {
  34. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  35. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  36. .flags = SMSC911X_USE_32BIT,
  37. .phy_interface = PHY_INTERFACE_MODE_MII,
  38. };
  39. static struct platform_device zoom2_smsc911x_device = {
  40. .name = "smsc911x",
  41. .id = -1,
  42. .num_resources = ARRAY_SIZE(zoom2_smsc911x_resources),
  43. .resource = zoom2_smsc911x_resources,
  44. .dev = {
  45. .platform_data = &zoom2_smsc911x_config,
  46. },
  47. };
  48. static inline void __init zoom2_init_smsc911x(void)
  49. {
  50. int eth_cs;
  51. unsigned long cs_mem_base;
  52. int eth_gpio = 0;
  53. eth_cs = ZOOM2_SMSC911X_CS;
  54. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  55. printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
  56. return;
  57. }
  58. zoom2_smsc911x_resources[0].start = cs_mem_base + 0x0;
  59. zoom2_smsc911x_resources[0].end = cs_mem_base + 0xff;
  60. eth_gpio = ZOOM2_SMSC911X_GPIO;
  61. zoom2_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
  62. if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
  63. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  64. eth_gpio);
  65. return;
  66. }
  67. gpio_direction_input(eth_gpio);
  68. }
  69. static struct plat_serial8250_port serial_platform_data[] = {
  70. {
  71. .mapbase = 0x10000000,
  72. .irq = OMAP_GPIO_IRQ(102),
  73. .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
  74. .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
  75. .iotype = UPIO_MEM,
  76. .regshift = 1,
  77. .uartclk = QUART_CLK,
  78. }, {
  79. .flags = 0
  80. }
  81. };
  82. static struct platform_device zoom2_debugboard_serial_device = {
  83. .name = "serial8250",
  84. .id = 3,
  85. .dev = {
  86. .platform_data = serial_platform_data,
  87. },
  88. };
  89. static inline void __init zoom2_init_quaduart(void)
  90. {
  91. int quart_cs;
  92. unsigned long cs_mem_base;
  93. int quart_gpio = 0;
  94. quart_cs = ZOOM2_QUADUART_CS;
  95. if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
  96. printk(KERN_ERR "Failed to request GPMC mem"
  97. "for Quad UART(TL16CP754C)\n");
  98. return;
  99. }
  100. quart_gpio = ZOOM2_QUADUART_GPIO;
  101. if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) {
  102. printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
  103. quart_gpio);
  104. return;
  105. }
  106. gpio_direction_input(quart_gpio);
  107. }
  108. static inline int omap_zoom2_debugboard_detect(void)
  109. {
  110. int debug_board_detect = 0;
  111. int ret = 1;
  112. debug_board_detect = ZOOM2_SMSC911X_GPIO;
  113. if (gpio_request(debug_board_detect, "Zoom2 debug board detect") < 0) {
  114. printk(KERN_ERR "Failed to request GPIO%d for Zoom2 debug"
  115. "board detect\n", debug_board_detect);
  116. return 0;
  117. }
  118. gpio_direction_input(debug_board_detect);
  119. if (!gpio_get_value(debug_board_detect)) {
  120. ret = 0;
  121. }
  122. gpio_free(debug_board_detect);
  123. return ret;
  124. }
  125. static struct platform_device *zoom2_devices[] __initdata = {
  126. &zoom2_smsc911x_device,
  127. &zoom2_debugboard_serial_device,
  128. };
  129. int __init omap_zoom2_debugboard_init(void)
  130. {
  131. if (!omap_zoom2_debugboard_detect())
  132. return 0;
  133. zoom2_init_smsc911x();
  134. zoom2_init_quaduart();
  135. return platform_add_devices(zoom2_devices, ARRAY_SIZE(zoom2_devices));
  136. }