sys_proto.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * (C) Copyright 2010
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef _SYS_PROTO_H_
  8. #define _SYS_PROTO_H_
  9. #include <asm/arch/omap.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/clock.h>
  12. #include <asm/omap_common.h>
  13. #include <asm/arch/clock.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. struct pad_conf_entry {
  16. u32 offset;
  17. u32 val;
  18. };
  19. struct omap_sysinfo {
  20. char *board_string;
  21. };
  22. extern const struct omap_sysinfo sysinfo;
  23. void gpmc_init(void);
  24. void watchdog_init(void);
  25. u32 get_device_type(void);
  26. void do_set_mux(u32 base, struct pad_conf_entry const *array, int size);
  27. void set_muxconf_regs_essential(void);
  28. void sr32(void *, u32, u32, u32);
  29. u32 wait_on_value(u32, u32, void *, u32);
  30. void sdelay(unsigned long);
  31. void setup_clocks_for_console(void);
  32. void prcm_init(void);
  33. void bypass_dpll(u32 const base);
  34. void freq_update_core(void);
  35. u32 get_sys_clk_freq(void);
  36. u32 omap5_ddr_clk(void);
  37. void cancel_out(u32 *num, u32 *den, u32 den_limit);
  38. void sdram_init(void);
  39. u32 omap_sdram_size(void);
  40. u32 cortex_rev(void);
  41. void save_omap_boot_params(void);
  42. void init_omap_revision(void);
  43. void do_io_settings(void);
  44. void sri2c_init(void);
  45. void gpi2c_init(void);
  46. int omap_vc_bypass_send_value(u8 sa, u8 reg_addr, u8 reg_data);
  47. u32 warm_reset(void);
  48. void force_emif_self_refresh(void);
  49. void get_ioregs(const struct ctrl_ioregs **regs);
  50. void srcomp_enable(void);
  51. void setup_warmreset_time(void);
  52. static inline u32 running_from_sdram(void)
  53. {
  54. u32 pc;
  55. asm volatile ("mov %0, pc" : "=r" (pc));
  56. return ((pc >= OMAP54XX_DRAM_ADDR_SPACE_START) &&
  57. (pc < OMAP54XX_DRAM_ADDR_SPACE_END));
  58. }
  59. static inline u8 uboot_loaded_by_spl(void)
  60. {
  61. /*
  62. * u-boot can be running from sdram either because of configuration
  63. * Header or by SPL. If because of CH, then the romcode sets the
  64. * CHSETTINGS executed bit to true in the boot parameter structure that
  65. * it passes to the bootloader.This parameter is stored in the ch_flags
  66. * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
  67. * mandatory section if CH is present.
  68. */
  69. if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
  70. return 0;
  71. else
  72. return running_from_sdram();
  73. }
  74. /*
  75. * The basic hardware init of OMAP(s_init()) can happen in 4
  76. * different contexts:
  77. * 1. SPL running from SRAM
  78. * 2. U-Boot running from FLASH
  79. * 3. Non-XIP U-Boot loaded to SDRAM by SPL
  80. * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
  81. * Configuration Header feature
  82. *
  83. * This function finds this context.
  84. * Defining as inline may help in compiling out unused functions in SPL
  85. */
  86. static inline u32 omap_hw_init_context(void)
  87. {
  88. #ifdef CONFIG_SPL_BUILD
  89. return OMAP_INIT_CONTEXT_SPL;
  90. #else
  91. if (uboot_loaded_by_spl())
  92. return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
  93. else if (running_from_sdram())
  94. return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
  95. else
  96. return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
  97. #endif
  98. }
  99. static inline u32 div_round_up(u32 num, u32 den)
  100. {
  101. return (num + den - 1)/den;
  102. }
  103. static inline u32 usec_to_32k(u32 usec)
  104. {
  105. return div_round_up(32768 * usec, 1000000);
  106. }
  107. #endif