board-zoom-debugboard.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 <plat/gpmc.h>
  18. #include <plat/gpmc-smsc911x.h>
  19. #include <mach/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. printk(KERN_ERR "Failed to request GPMC mem"
  74. "for Quad UART(TL16CP754C)\n");
  75. return;
  76. }
  77. quart_gpio = ZOOM_QUADUART_GPIO;
  78. if (gpio_request_one(quart_gpio, GPIOF_IN, "TL16CP754C GPIO") < 0)
  79. printk(KERN_ERR "Failed to request GPIO%d for TL16CP754C\n",
  80. quart_gpio);
  81. serial_platform_data[0].irq = gpio_to_irq(102);
  82. }
  83. static inline int omap_zoom_debugboard_detect(void)
  84. {
  85. int debug_board_detect = 0;
  86. int ret = 1;
  87. debug_board_detect = ZOOM_SMSC911X_GPIO;
  88. if (gpio_request_one(debug_board_detect, GPIOF_IN,
  89. "Zoom debug board detect") < 0) {
  90. printk(KERN_ERR "Failed to request GPIO%d for Zoom debug"
  91. "board detect\n", debug_board_detect);
  92. return 0;
  93. }
  94. if (!gpio_get_value(debug_board_detect)) {
  95. ret = 0;
  96. }
  97. gpio_free(debug_board_detect);
  98. return ret;
  99. }
  100. static struct platform_device *zoom_devices[] __initdata = {
  101. &zoom_debugboard_serial_device,
  102. };
  103. static struct regulator_consumer_supply dummy_supplies[] = {
  104. REGULATOR_SUPPLY("vddvario", "smsc911x.0"),
  105. REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
  106. };
  107. int __init zoom_debugboard_init(void)
  108. {
  109. if (!omap_zoom_debugboard_detect())
  110. return 0;
  111. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  112. zoom_init_smsc911x();
  113. zoom_init_quaduart();
  114. return platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
  115. }