board-zoom-debugboard.c 3.3 KB

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