mx31lilly-db.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * LILLY-1131 development board support
  3. *
  4. * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
  5. *
  6. * based on code for other MX31 boards,
  7. *
  8. * Copyright 2005-2007 Freescale Semiconductor
  9. * Copyright (c) 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
  10. * Copyright (C) 2009 Valentin Longchamp, EPFL Mobots group
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/kernel.h>
  27. #include <linux/types.h>
  28. #include <linux/init.h>
  29. #include <linux/gpio.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <mach/hardware.h>
  34. #include <mach/common.h>
  35. #include <mach/imx-uart.h>
  36. #include <mach/iomux-mx3.h>
  37. #include <mach/board-mx31lilly.h>
  38. #include <mach/mmc.h>
  39. #include "devices.h"
  40. /*
  41. * This file contains board-specific initialization routines for the
  42. * LILLY-1131 development board. If you design an own baseboard for the
  43. * module, use this file as base for support code.
  44. */
  45. static unsigned int lilly_db_board_pins[] __initdata = {
  46. MX31_PIN_CTS1__CTS1,
  47. MX31_PIN_RTS1__RTS1,
  48. MX31_PIN_TXD1__TXD1,
  49. MX31_PIN_RXD1__RXD1,
  50. MX31_PIN_SD1_DATA3__SD1_DATA3,
  51. MX31_PIN_SD1_DATA2__SD1_DATA2,
  52. MX31_PIN_SD1_DATA1__SD1_DATA1,
  53. MX31_PIN_SD1_DATA0__SD1_DATA0,
  54. MX31_PIN_SD1_CLK__SD1_CLK,
  55. MX31_PIN_SD1_CMD__SD1_CMD,
  56. };
  57. /* UART */
  58. static struct imxuart_platform_data uart_pdata __initdata = {
  59. .flags = IMXUART_HAVE_RTSCTS,
  60. };
  61. /* MMC support */
  62. static int mxc_mmc1_get_ro(struct device *dev)
  63. {
  64. return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_LCS0));
  65. }
  66. static int gpio_det, gpio_wp;
  67. static int mxc_mmc1_init(struct device *dev,
  68. irq_handler_t detect_irq, void *data)
  69. {
  70. int ret;
  71. gpio_det = IOMUX_TO_GPIO(MX31_PIN_GPIO1_1);
  72. gpio_wp = IOMUX_TO_GPIO(MX31_PIN_LCS0);
  73. ret = gpio_request(gpio_det, "MMC detect");
  74. if (ret)
  75. return ret;
  76. ret = gpio_request(gpio_wp, "MMC w/p");
  77. if (ret)
  78. goto exit_free_det;
  79. gpio_direction_input(gpio_det);
  80. gpio_direction_input(gpio_wp);
  81. ret = request_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), detect_irq,
  82. IRQF_DISABLED | IRQF_TRIGGER_FALLING,
  83. "MMC detect", data);
  84. if (ret)
  85. goto exit_free_wp;
  86. return 0;
  87. exit_free_wp:
  88. gpio_free(gpio_wp);
  89. exit_free_det:
  90. gpio_free(gpio_det);
  91. return ret;
  92. }
  93. static void mxc_mmc1_exit(struct device *dev, void *data)
  94. {
  95. gpio_free(gpio_det);
  96. gpio_free(gpio_wp);
  97. free_irq(IOMUX_TO_IRQ(MX31_PIN_GPIO1_1), data);
  98. }
  99. static struct imxmmc_platform_data mmc_pdata = {
  100. .get_ro = mxc_mmc1_get_ro,
  101. .init = mxc_mmc1_init,
  102. .exit = mxc_mmc1_exit,
  103. };
  104. void __init mx31lilly_db_init(void)
  105. {
  106. mxc_iomux_setup_multiple_pins(lilly_db_board_pins,
  107. ARRAY_SIZE(lilly_db_board_pins),
  108. "development board pins");
  109. mxc_register_device(&mxc_uart_device0, &uart_pdata);
  110. mxc_register_device(&mxcsdhc_device0, &mmc_pdata);
  111. }