palmtreo680.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Palm Treo 680 Support
  3. *
  4. * Copyright (C) 2013 Mike Dunn <mikedunn@newsguy.com>
  5. *
  6. * This file is released under the terms of GPL v2 and any later version.
  7. * See the file COPYING in the root directory of the source tree for details.
  8. *
  9. */
  10. #include <common.h>
  11. #include <command.h>
  12. #include <serial.h>
  13. #include <nand.h>
  14. #include <malloc.h>
  15. #include <asm/arch/pxa-regs.h>
  16. #include <asm/arch-pxa/pxa.h>
  17. #include <asm/arch-pxa/regs-mmc.h>
  18. #include <asm/io.h>
  19. #include <asm/global_data.h>
  20. #include <u-boot/crc.h>
  21. #include <linux/mtd/docg4.h>
  22. DECLARE_GLOBAL_DATA_PTR;
  23. static struct nand_chip docg4_nand_chip;
  24. int board_init(void)
  25. {
  26. /* We have RAM, disable cache */
  27. dcache_disable();
  28. icache_disable();
  29. gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
  30. gd->bd->bi_boot_params = CONFIG_SYS_DRAM_BASE + 0x100;
  31. return 0;
  32. }
  33. int dram_init(void)
  34. {
  35. /* IPL initializes SDRAM (we're already running from it) */
  36. gd->ram_size = PHYS_SDRAM_1_SIZE;
  37. return 0;
  38. }
  39. #ifdef CONFIG_LCD
  40. void lcd_enable(void)
  41. {
  42. /*
  43. * Undo the L_BIAS / gpio77 pin configuration performed by the pxa lcd
  44. * driver code. We need it as an output gpio.
  45. */
  46. writel((readl(GAFR2_L) & ~(0xc << 24)), GAFR2_L);
  47. /* power-up and enable the lcd */
  48. writel(0x00400000, GPSR(86)); /* enable; drive high */
  49. writel(0x00002000, GPSR(77)); /* power; drive high */
  50. writel(0x02000000, GPCR(25)); /* enable_n; drive low */
  51. /* turn on LCD backlight and configure PWM for reasonable brightness */
  52. writel(0x00, PWM_CTRL0);
  53. writel(0x1b1, PWM_PERVAL0);
  54. writel(0xfd, PWM_PWDUTY0);
  55. writel(0x00000040, GPSR(38)); /* backlight power on */
  56. }
  57. #endif
  58. #ifdef CONFIG_MMC
  59. int board_mmc_init(bd_t *bis)
  60. {
  61. writel(1 << 10, GPSR(42)); /* power on */
  62. return pxa_mmc_register(0);
  63. }
  64. #endif
  65. void board_nand_init(void)
  66. {
  67. /* we have one 128M diskonchip G4 */
  68. struct mtd_info *mtd = &nand_info[0];
  69. struct nand_chip *nand = &docg4_nand_chip;
  70. if (docg4_nand_init(mtd, nand, 0))
  71. hang();
  72. }
  73. #ifdef CONFIG_SPL_BUILD
  74. void nand_boot(void)
  75. {
  76. __attribute__((noreturn)) void (*uboot)(void);
  77. extern const void *_start, *_end; /* boundaries of spl in memory */
  78. /* size of spl; ipl loads this, and then a portion of u-boot */
  79. const size_t spl_image_size = ((size_t)&_end - (size_t)&_start);
  80. /* the flash offset of the blocks that are loaded by the spl */
  81. const uint32_t spl_load_offset = CONFIG_SYS_NAND_U_BOOT_OFFS +
  82. DOCG4_IPL_LOAD_BLOCK_COUNT * DOCG4_BLOCK_SIZE;
  83. /* total number of bytes loaded by IPL */
  84. const size_t ipl_load_size =
  85. DOCG4_IPL_LOAD_BLOCK_COUNT * DOCG4_BLOCK_CAPACITY_SPL;
  86. /* number of bytes of u-boot proper that was loaded by the IPL */
  87. const size_t ipl_uboot_load_size = ipl_load_size - spl_image_size;
  88. /* number of remaining bytes of u-boot that the SPL must load */
  89. const size_t spl_load_size =
  90. CONFIG_SYS_NAND_U_BOOT_SIZE - ipl_load_size;
  91. /* memory address where we resume loading u-boot */
  92. void *const load_addr =
  93. (void *)(CONFIG_SYS_NAND_U_BOOT_DST + ipl_uboot_load_size);
  94. /*
  95. * Copy the portion of u-boot already read from flash by the IPL to its
  96. * correct load address.
  97. */
  98. memcpy((void *)CONFIG_SYS_NAND_U_BOOT_DST, &_end, ipl_uboot_load_size);
  99. /*
  100. * Resume loading u-boot where the IPL left off.
  101. */
  102. nand_spl_load_image(spl_load_offset, spl_load_size, load_addr);
  103. #ifdef CONFIG_NAND_ENV_DST
  104. nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
  105. (void *)CONFIG_NAND_ENV_DST);
  106. #ifdef CONFIG_ENV_OFFSET_REDUND
  107. nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE,
  108. (void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE);
  109. #endif
  110. #endif
  111. /*
  112. * Jump to U-Boot image
  113. */
  114. uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
  115. (*uboot)();
  116. }
  117. void board_init_f(ulong bootflag)
  118. {
  119. nand_boot();
  120. }
  121. #endif /* CONFIG_SPL_BUILD */