board-zoom-debugboard.c 3.0 KB

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