cpu.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011-2015 by Vladimir Zapolskiy <vz@mleia.com>
  4. */
  5. #include <common.h>
  6. #include <netdev.h>
  7. #include <asm/arch/cpu.h>
  8. #include <asm/arch/clk.h>
  9. #include <asm/arch/wdt.h>
  10. #include <asm/arch/sys_proto.h>
  11. #include <asm/io.h>
  12. static struct clk_pm_regs *clk = (struct clk_pm_regs *)CLK_PM_BASE;
  13. static struct wdt_regs *wdt = (struct wdt_regs *)WDT_BASE;
  14. void reset_cpu(ulong addr)
  15. {
  16. /* Enable watchdog clock */
  17. setbits_le32(&clk->timclk_ctrl, CLK_TIMCLK_WATCHDOG);
  18. /* To be compatible with the original U-Boot code:
  19. * addr: - 0: perform hard reset.
  20. * - !=0: perform a soft reset; i.e. "RESOUT_N" not asserted). */
  21. if (addr == 0) {
  22. /* Reset pulse length is 13005 peripheral clock frames */
  23. writel(13000, &wdt->pulse);
  24. /* Force WDOG_RESET2 and RESOUT_N signal active */
  25. writel(WDTIM_MCTRL_RESFRC2 | WDTIM_MCTRL_RESFRC1
  26. | WDTIM_MCTRL_M_RES2, &wdt->mctrl);
  27. } else {
  28. /* Force match output active */
  29. writel(0x01, &wdt->emr);
  30. /* Internal reset on match output (no pulse on "RESOUT_N") */
  31. writel(WDTIM_MCTRL_M_RES1, &wdt->mctrl);
  32. }
  33. while (1)
  34. /* NOP */;
  35. }
  36. #if defined(CONFIG_ARCH_CPU_INIT)
  37. int arch_cpu_init(void)
  38. {
  39. /*
  40. * It might be necessary to flush data cache, if U-Boot is loaded
  41. * from kickstart bootloader, e.g. from S1L loader
  42. */
  43. flush_dcache_all();
  44. return 0;
  45. }
  46. #else
  47. #error "You have to select CONFIG_ARCH_CPU_INIT"
  48. #endif
  49. #if defined(CONFIG_DISPLAY_CPUINFO)
  50. int print_cpuinfo(void)
  51. {
  52. printf("CPU: NXP LPC32XX\n");
  53. printf("CPU clock: %uMHz\n", get_hclk_pll_rate() / 1000000);
  54. printf("AHB bus clock: %uMHz\n", get_hclk_clk_rate() / 1000000);
  55. printf("Peripheral clock: %uMHz\n", get_periph_clk_rate() / 1000000);
  56. return 0;
  57. }
  58. #endif
  59. #ifdef CONFIG_LPC32XX_ETH
  60. int cpu_eth_init(bd_t *bis)
  61. {
  62. lpc32xx_eth_initialize(bis);
  63. return 0;
  64. }
  65. #endif