board-zoom-debugboard.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 <mach/gpmc.h>
  15. #define ZOOM2_SMSC911X_CS 7
  16. #define ZOOM2_SMSC911X_GPIO 158
  17. #define ZOOM2_QUADUART_CS 3
  18. #define ZOOM2_QUADUART_GPIO 102
  19. #define QUART_CLK 1843200
  20. #define DEBUG_BASE 0x08000000
  21. #define ZOOM2_ETHR_START DEBUG_BASE
  22. static struct resource zoom2_smsc911x_resources[] = {
  23. [0] = {
  24. .start = ZOOM2_ETHR_START,
  25. .end = ZOOM2_ETHR_START + SZ_4K,
  26. .flags = IORESOURCE_MEM,
  27. },
  28. [1] = {
  29. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
  30. },
  31. };
  32. static struct smsc911x_platform_config zoom2_smsc911x_config = {
  33. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  34. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  35. .flags = SMSC911X_USE_32BIT,
  36. .phy_interface = PHY_INTERFACE_MODE_MII,
  37. };
  38. static struct platform_device zoom2_smsc911x_device = {
  39. .name = "smsc911x",
  40. .id = -1,
  41. .num_resources = ARRAY_SIZE(zoom2_smsc911x_resources),
  42. .resource = zoom2_smsc911x_resources,
  43. .dev = {
  44. .platform_data = &zoom2_smsc911x_config,
  45. },
  46. };
  47. static inline void __init zoom2_init_smsc911x(void)
  48. {
  49. int eth_cs;
  50. unsigned long cs_mem_base;
  51. int eth_gpio = 0;
  52. eth_cs = ZOOM2_SMSC911X_CS;
  53. if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
  54. printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
  55. return;
  56. }
  57. zoom2_smsc911x_resources[0].start = cs_mem_base + 0x0;
  58. zoom2_smsc911x_resources[0].end = cs_mem_base + 0xff;
  59. eth_gpio = ZOOM2_SMSC911X_GPIO;
  60. zoom2_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
  61. if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
  62. printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
  63. eth_gpio);
  64. return;
  65. }
  66. gpio_direction_input(eth_gpio);
  67. }
  68. static struct plat_serial8250_port serial_platform_data[] = {
  69. {
  70. .mapbase = 0x10000000,
  71. .irq = OMAP_GPIO_IRQ(102),
  72. .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
  73. .iotype = UPIO_MEM,
  74. .regshift = 1,
  75. .uartclk = QUART_CLK,
  76. }, {
  77. .flags = 0
  78. }
  79. };
  80. static struct platform_device zoom2_debugboard_serial_device = {
  81. .name = "serial8250",
  82. .id = PLAT8250_DEV_PLATFORM1,
  83. .dev = {
  84. .platform_data = serial_platform_data,
  85. },
  86. };
  87. static inline void __init zoom2_init_quaduart(void)
  88. {
  89. int quart_cs;
  90. unsigned long cs_mem_base;
  91. int quart_gpio = 0;
  92. quart_cs = ZOOM2_QUADUART_CS;
  93. if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
  94. printk(KERN_ERR "Failed to request GPMC mem"
  95. "for Quad UART(TL16CP754C)\n");
  96. return;
  97. }
  98. quart_gpio = ZOOM2_QUADUART_GPIO;
  99. if (gpio_request(quart_gpio, "TL16CP754C GPIO") < 0) {
  100. printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
  101. quart_gpio);
  102. return;
  103. }
  104. gpio_direction_input(quart_gpio);
  105. }
  106. static inline int omap_zoom2_debugboard_detect(void)
  107. {
  108. int debug_board_detect = 0;
  109. debug_board_detect = ZOOM2_SMSC911X_GPIO;
  110. if (gpio_request(debug_board_detect, "Zoom2 debug board detect") < 0) {
  111. printk(KERN_ERR "Failed to request GPIO%d for Zoom2 debug"
  112. "board detect\n", debug_board_detect);
  113. return 0;
  114. }
  115. gpio_direction_input(debug_board_detect);
  116. if (!gpio_get_value(debug_board_detect)) {
  117. gpio_free(debug_board_detect);
  118. return 0;
  119. }
  120. return 1;
  121. }
  122. static struct platform_device *zoom2_devices[] __initdata = {
  123. &zoom2_smsc911x_device,
  124. &zoom2_debugboard_serial_device,
  125. };
  126. int __init omap_zoom2_debugboard_init(void)
  127. {
  128. if (!omap_zoom2_debugboard_detect())
  129. return 0;
  130. zoom2_init_smsc911x();
  131. zoom2_init_quaduart();
  132. return platform_add_devices(zoom2_devices, ARRAY_SIZE(zoom2_devices));
  133. }