board-zoom-debugboard.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 <linux/regulator/fixed.h>
  16. #include <linux/regulator/machine.h>
  17. #include "gpmc.h"
  18. #include "gpmc-smsc911x.h"
  19. #include "board-zoom.h"
  20. #include "soc.h"
  21. #include "common.h"
  22. #define ZOOM_SMSC911X_CS 7
  23. #define ZOOM_SMSC911X_GPIO 158
  24. #define ZOOM_QUADUART_CS 3
  25. #define ZOOM_QUADUART_GPIO 102
  26. #define ZOOM_QUADUART_RST_GPIO 152
  27. #define QUART_CLK 1843200
  28. #define DEBUG_BASE 0x08000000
  29. #define ZOOM_ETHR_START DEBUG_BASE
  30. static struct omap_smsc911x_platform_data zoom_smsc911x_cfg = {
  31. .cs = ZOOM_SMSC911X_CS,
  32. .gpio_irq = ZOOM_SMSC911X_GPIO,
  33. .gpio_reset = -EINVAL,
  34. .flags = SMSC911X_USE_32BIT,
  35. };
  36. static inline void __init zoom_init_smsc911x(void)
  37. {
  38. gpmc_smsc911x_init(&zoom_smsc911x_cfg);
  39. }
  40. static struct plat_serial8250_port serial_platform_data[] = {
  41. {
  42. .mapbase = ZOOM_UART_BASE,
  43. .flags = UPF_BOOT_AUTOCONF|UPF_IOREMAP|UPF_SHARE_IRQ,
  44. .irqflags = IRQF_SHARED | IRQF_TRIGGER_RISING,
  45. .iotype = UPIO_MEM,
  46. .regshift = 1,
  47. .uartclk = QUART_CLK,
  48. }, {
  49. .flags = 0
  50. }
  51. };
  52. static struct platform_device zoom_debugboard_serial_device = {
  53. .name = "serial8250",
  54. .id = PLAT8250_DEV_PLATFORM,
  55. .dev = {
  56. .platform_data = serial_platform_data,
  57. },
  58. };
  59. static inline void __init zoom_init_quaduart(void)
  60. {
  61. int quart_cs;
  62. unsigned long cs_mem_base;
  63. int quart_gpio = 0;
  64. if (gpio_request_one(ZOOM_QUADUART_RST_GPIO,
  65. GPIOF_OUT_INIT_LOW,
  66. "TL16CP754C GPIO") < 0) {
  67. pr_err("Failed to request GPIO%d for TL16CP754C\n",
  68. ZOOM_QUADUART_RST_GPIO);
  69. return;
  70. }
  71. quart_cs = ZOOM_QUADUART_CS;
  72. if (gpmc_cs_request(quart_cs, SZ_1M, &cs_mem_base) < 0) {
  73. pr_err("Failed to request GPMC mem for Quad UART(TL16CP754C)\n");
  74. return;
  75. }
  76. quart_gpio = ZOOM_QUADUART_GPIO;
  77. if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
  78. printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
  79. quart_gpio);
  80. serial_platform_data[0].irq = gpio_to_irq(102);
  81. }
  82. static inline int omap_zoom_debugboard_detect(void)
  83. {
  84. int debug_board_detect = 0;
  85. int ret = 1;
  86. debug_board_detect = ZOOM_SMSC911X_GPIO;
  87. if (gpio_request_one(debug_board_detect, GPIOF_IN,
  88. "Zoom debug board detect") < 0) {
  89. pr_err("Failed to request GPIO%d for Zoom debug board detect\n",
  90. debug_board_detect);
  91. return 0;
  92. }
  93. if (!gpio_get_value(debug_board_detect)) {
  94. ret = 0;
  95. }
  96. gpio_free(debug_board_detect);
  97. return ret;
  98. }
  99. static struct platform_device *zoom_devices[] __initdata = {
  100. &zoom_debugboard_serial_device,
  101. };
  102. static struct regulator_consumer_supply dummy_supplies[] = {
  103. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  104. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  105. };
  106. int __init zoom_debugboard_init(void)
  107. {
  108. if (!omap_zoom_debugboard_detect())
  109. return 0;
  110. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  111. zoom_init_smsc911x();
  112. zoom_init_quaduart();
  113. return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
  114. }