colibri_pxa270.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Toradex Colibri PXA270 Support
  4. *
  5. * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
  6. * Copyright (C) 2016-2019 Marcel Ziswiler <marcel.ziswiler@toradex.com>
  7. */
  8. #include <common.h>
  9. #include <cpu_func.h>
  10. #include <dm.h>
  11. #include <init.h>
  12. #include <net.h>
  13. #include <asm/arch/hardware.h>
  14. #include <asm/arch/pxa.h>
  15. #include <asm/arch/regs-mmc.h>
  16. #include <asm/arch/regs-uart.h>
  17. #include <asm/io.h>
  18. #include <dm/platdata.h>
  19. #include <dm/platform_data/pxa_mmc_gen.h>
  20. #include <dm/platform_data/serial_pxa.h>
  21. #include <netdev.h>
  22. #include <serial.h>
  23. #include <usb.h>
  24. #include <asm/mach-types.h>
  25. #include <linux/delay.h>
  26. #include "../common/tdx-common.h"
  27. DECLARE_GLOBAL_DATA_PTR;
  28. int board_init(void)
  29. {
  30. /* We have RAM, disable cache */
  31. dcache_disable();
  32. icache_disable();
  33. /* arch number of Toradex Colibri PXA270 */
  34. gd->bd->bi_arch_number = MACH_TYPE_COLIBRI;
  35. /* address of boot parameters */
  36. gd->bd->bi_boot_params = 0xa0000100;
  37. return 0;
  38. }
  39. int checkboard(void)
  40. {
  41. puts("Model: Toradex Colibri PXA270\n");
  42. return 0;
  43. }
  44. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  45. int ft_board_setup(void *blob, struct bd_info *bd)
  46. {
  47. return ft_common_board_setup(blob, bd);
  48. }
  49. #endif
  50. int dram_init(void)
  51. {
  52. pxa2xx_dram_init();
  53. gd->ram_size = PHYS_SDRAM_1_SIZE;
  54. return 0;
  55. }
  56. #ifdef CONFIG_CMD_USB
  57. int board_usb_init(int index, enum usb_init_type init)
  58. {
  59. writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) &
  60. ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
  61. UHCHR);
  62. writel(readl(UHCHR) | UHCHR_FSBIR, UHCHR);
  63. while (UHCHR & UHCHR_FSBIR)
  64. ;
  65. writel(readl(UHCHR) & ~UHCHR_SSE, UHCHR);
  66. writel((UHCHIE_UPRIE | UHCHIE_RWIE), UHCHIE);
  67. /* Clear any OTG Pin Hold */
  68. if (readl(PSSR) & PSSR_OTGPH)
  69. writel(readl(PSSR) | PSSR_OTGPH, PSSR);
  70. writel(readl(UHCRHDA) & ~(0x200), UHCRHDA);
  71. writel(readl(UHCRHDA) | 0x100, UHCRHDA);
  72. /* Set port power control mask bits, only 3 ports. */
  73. writel(readl(UHCRHDB) | (0x7 << 17), UHCRHDB);
  74. /* enable port 2 */
  75. writel(readl(UP2OCR) | UP2OCR_HXOE | UP2OCR_HXS |
  76. UP2OCR_DMPDE | UP2OCR_DPPDE, UP2OCR);
  77. return 0;
  78. }
  79. int board_usb_cleanup(int index, enum usb_init_type init)
  80. {
  81. return 0;
  82. }
  83. void usb_board_stop(void)
  84. {
  85. writel(readl(UHCHR) | UHCHR_FHR, UHCHR);
  86. udelay(11);
  87. writel(readl(UHCHR) & ~UHCHR_FHR, UHCHR);
  88. writel(readl(UHCCOMS) | 1, UHCCOMS);
  89. udelay(10);
  90. writel(readl(CKEN) & ~CKEN10_USBHOST, CKEN);
  91. }
  92. #endif
  93. #ifdef CONFIG_DRIVER_DM9000
  94. int board_eth_init(struct bd_info *bis)
  95. {
  96. return dm9000_initialize(bis);
  97. }
  98. #endif
  99. #ifdef CONFIG_CMD_MMC
  100. #if !CONFIG_IS_ENABLED(DM_MMC)
  101. int board_mmc_init(struct bd_info *bis)
  102. {
  103. pxa_mmc_register(0);
  104. return 0;
  105. }
  106. #else /* !CONFIG_IS_ENABLED(DM_MMC) */
  107. static const struct pxa_mmc_plat mmc_platdata = {
  108. .base = (struct pxa_mmc_regs *)MMC0_BASE,
  109. };
  110. U_BOOT_DEVICE(pxa_mmcs) = {
  111. .name = "pxa_mmc",
  112. .plat = &mmc_platdata,
  113. };
  114. #endif /* !CONFIG_IS_ENABLED(DM_MMC) */
  115. #endif
  116. static const struct pxa_serial_platdata serial_platdata = {
  117. .base = (struct pxa_uart_regs *)FFUART_BASE,
  118. .port = FFUART_INDEX,
  119. .baudrate = CONFIG_BAUDRATE,
  120. };
  121. U_BOOT_DEVICE(pxa_serials) = {
  122. .name = "serial_pxa",
  123. .plat = &serial_platdata,
  124. };