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.
 
 
 
 
 
 

45 lines
1.1 KiB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007
  4. * Sascha Hauer, Pengutronix
  5. */
  6. #include <common.h>
  7. #include <asm/arch/imx-regs.h>
  8. #include <asm/io.h>
  9. #define TIMER_BASE 0x53f90000 /* General purpose timer 1 */
  10. /* General purpose timers registers */
  11. #define GPTCR __REG(TIMER_BASE) /* Control register */
  12. #define GPTPR __REG(TIMER_BASE + 0x4) /* Prescaler register */
  13. #define GPTSR __REG(TIMER_BASE + 0x8) /* Status register */
  14. #define GPTCNT __REG(TIMER_BASE + 0x24) /* Counter register */
  15. /* General purpose timers bitfields */
  16. #define GPTCR_SWR (1 << 15) /* Software reset */
  17. #define GPTCR_FRR (1 << 9) /* Freerun / restart */
  18. #define GPTCR_CLKSOURCE_32 (4 << 6) /* Clock source */
  19. #define GPTCR_TEN 1 /* Timer enable */
  20. /* The 32768Hz 32-bit timer overruns in 131072 seconds */
  21. int timer_init(void)
  22. {
  23. int i;
  24. /* setup GP Timer 1 */
  25. GPTCR = GPTCR_SWR;
  26. for (i = 0; i < 100; i++)
  27. GPTCR = 0; /* We have no udelay by now */
  28. GPTPR = 0; /* 32Khz */
  29. /* Freerun Mode, PERCLK1 input */
  30. GPTCR |= GPTCR_CLKSOURCE_32 | GPTCR_TEN;
  31. return 0;
  32. }
  33. unsigned long timer_read_counter(void)
  34. {
  35. return GPTCNT;
  36. }