Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

86 lines
1.8 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. *
  4. * (c) 2004 Sascha Hauer <sascha@saschahauer.de>
  5. */
  6. #include <common.h>
  7. #if defined (CONFIG_IMX)
  8. #include <asm/arch/imx-regs.h>
  9. /* ------------------------------------------------------------------------- */
  10. /* NOTE: This describes the proper use of this file.
  11. *
  12. * CONFIG_SYS_CLK_FREQ should be defined as the input frequency of the PLL.
  13. * SH FIXME: 16780000 in our case
  14. * get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of
  15. * the specified bus in HZ.
  16. */
  17. /* ------------------------------------------------------------------------- */
  18. ulong get_systemPLLCLK(void)
  19. {
  20. /* FIXME: We assume System_SEL = 0 here */
  21. u32 spctl0 = SPCTL0;
  22. u32 mfi = (spctl0 >> 10) & 0xf;
  23. u32 mfn = spctl0 & 0x3f;
  24. u32 mfd = (spctl0 >> 16) & 0x3f;
  25. u32 pd = (spctl0 >> 26) & 0xf;
  26. mfi = mfi<=5 ? 5 : mfi;
  27. return (2*(CONFIG_SYSPLL_CLK_FREQ>>10)*( (mfi<<10) + (mfn<<10)/(mfd+1)))/(pd+1);
  28. }
  29. ulong get_mcuPLLCLK(void)
  30. {
  31. /* FIXME: We assume System_SEL = 0 here */
  32. u32 mpctl0 = MPCTL0;
  33. u32 mfi = (mpctl0 >> 10) & 0xf;
  34. u32 mfn = mpctl0 & 0x3f;
  35. u32 mfd = (mpctl0 >> 16) & 0x3f;
  36. u32 pd = (mpctl0 >> 26) & 0xf;
  37. mfi = mfi<=5 ? 5 : mfi;
  38. return (2*(CONFIG_SYS_CLK_FREQ>>10)*( (mfi<<10) + (mfn<<10)/(mfd+1)))/(pd+1);
  39. }
  40. ulong get_FCLK(void)
  41. {
  42. return (( CSCR>>15)&1) ? get_mcuPLLCLK()>>1 : get_mcuPLLCLK();
  43. }
  44. /* return HCLK frequency */
  45. ulong get_HCLK(void)
  46. {
  47. u32 bclkdiv = (( CSCR >> 10 ) & 0xf) + 1;
  48. printf("bclkdiv: %d\n", bclkdiv);
  49. return get_systemPLLCLK() / bclkdiv;
  50. }
  51. /* return BCLK frequency */
  52. ulong get_BCLK(void)
  53. {
  54. return get_HCLK();
  55. }
  56. ulong get_PERCLK1(void)
  57. {
  58. return get_systemPLLCLK() / (((PCDR) & 0xf)+1);
  59. }
  60. ulong get_PERCLK2(void)
  61. {
  62. return get_systemPLLCLK() / (((PCDR>>4) & 0xf)+1);
  63. }
  64. ulong get_PERCLK3(void)
  65. {
  66. return get_systemPLLCLK() / (((PCDR>>16) & 0x7f)+1);
  67. }
  68. #endif /* defined (CONFIG_IMX) */