board-zoom-debugboard.c 2.8 KB

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