colibri-evalboard.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/colibri-evalboard.c
  4. *
  5. * Support for Toradex Colibri Evaluation Carrier Board
  6. * Daniel Mack <[email protected]>
  7. * Marek Vasut <[email protected]>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/kernel.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/gpio/machine.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/mach/arch.h>
  16. #include <linux/i2c.h>
  17. #include <linux/platform_data/i2c-pxa.h>
  18. #include <asm/io.h>
  19. #include "pxa27x.h"
  20. #include "colibri.h"
  21. #include <linux/platform_data/mmc-pxamci.h>
  22. #include <linux/platform_data/usb-ohci-pxa27x.h>
  23. #include "pxa27x-udc.h"
  24. #include "generic.h"
  25. #include "devices.h"
  26. /******************************************************************************
  27. * SD/MMC card controller
  28. ******************************************************************************/
  29. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  30. static struct pxamci_platform_data colibri_mci_platform_data = {
  31. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  32. .detect_delay_ms = 200,
  33. };
  34. static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = {
  35. .dev_id = "pxa2xx-mci.0",
  36. .table = {
  37. GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT,
  38. "cd", GPIO_ACTIVE_LOW),
  39. { },
  40. },
  41. };
  42. static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = {
  43. .dev_id = "pxa2xx-mci.0",
  44. .table = {
  45. GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT,
  46. "cd", GPIO_ACTIVE_LOW),
  47. { },
  48. },
  49. };
  50. static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = {
  51. .dev_id = "pxa2xx-mci.0",
  52. .table = {
  53. GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT,
  54. "cd", GPIO_ACTIVE_LOW),
  55. { },
  56. },
  57. };
  58. static void __init colibri_mmc_init(void)
  59. {
  60. if (machine_is_colibri()) /* PXA270 Colibri */
  61. gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table);
  62. if (machine_is_colibri300()) /* PXA300 Colibri */
  63. gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table);
  64. else /* PXA320 Colibri */
  65. gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table);
  66. pxa_set_mci_info(&colibri_mci_platform_data);
  67. }
  68. #else
  69. static inline void colibri_mmc_init(void) {}
  70. #endif
  71. /******************************************************************************
  72. * USB Host
  73. ******************************************************************************/
  74. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  75. static int colibri_ohci_init(struct device *dev)
  76. {
  77. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  78. return 0;
  79. }
  80. static struct pxaohci_platform_data colibri_ohci_info = {
  81. .port_mode = PMM_PERPORT_MODE,
  82. .flags = ENABLE_PORT1 |
  83. POWER_CONTROL_LOW | POWER_SENSE_LOW,
  84. .init = colibri_ohci_init,
  85. };
  86. static void __init colibri_uhc_init(void)
  87. {
  88. /* Colibri PXA270 has two usb ports, TBA for 320 */
  89. if (machine_is_colibri())
  90. colibri_ohci_info.flags |= ENABLE_PORT2;
  91. pxa_set_ohci_info(&colibri_ohci_info);
  92. }
  93. #else
  94. static inline void colibri_uhc_init(void) {}
  95. #endif
  96. /******************************************************************************
  97. * I2C RTC
  98. ******************************************************************************/
  99. #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
  100. static struct i2c_board_info __initdata colibri_i2c_devs[] = {
  101. {
  102. I2C_BOARD_INFO("m41t00", 0x68),
  103. },
  104. };
  105. static void __init colibri_rtc_init(void)
  106. {
  107. pxa_set_i2c_info(NULL);
  108. i2c_register_board_info(0, ARRAY_AND_SIZE(colibri_i2c_devs));
  109. }
  110. #else
  111. static inline void colibri_rtc_init(void) {}
  112. #endif
  113. void __init colibri_evalboard_init(void)
  114. {
  115. pxa_set_ffuart_info(NULL);
  116. pxa_set_btuart_info(NULL);
  117. pxa_set_stuart_info(NULL);
  118. colibri_mmc_init();
  119. colibri_uhc_init();
  120. colibri_rtc_init();
  121. }