sandbox.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2011 The Chromium OS Authors.
  3. * SPDX-License-Identifier: GPL-2.0+
  4. */
  5. #include <common.h>
  6. #include <cros_ec.h>
  7. #include <dm.h>
  8. #include <os.h>
  9. #include <asm/test.h>
  10. #include <asm/u-boot-sandbox.h>
  11. /*
  12. * Pointer to initial global data area
  13. *
  14. * Here we initialize it.
  15. */
  16. gd_t *gd;
  17. /* Add a simple GPIO device */
  18. U_BOOT_DEVICE(gpio_sandbox) = {
  19. .name = "gpio_sandbox",
  20. };
  21. void flush_cache(unsigned long start, unsigned long size)
  22. {
  23. }
  24. #ifndef CONFIG_TIMER
  25. /* system timer offset in ms */
  26. static unsigned long sandbox_timer_offset;
  27. void sandbox_timer_add_offset(unsigned long offset)
  28. {
  29. sandbox_timer_offset += offset;
  30. }
  31. unsigned long timer_read_counter(void)
  32. {
  33. return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
  34. }
  35. #endif
  36. int dram_init(void)
  37. {
  38. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  39. return 0;
  40. }
  41. #ifdef CONFIG_BOARD_EARLY_INIT_F
  42. int board_early_init_f(void)
  43. {
  44. #ifdef CONFIG_VIDEO_SANDBOX_SDL
  45. int ret;
  46. ret = sandbox_lcd_sdl_early_init();
  47. if (ret) {
  48. puts("Could not init sandbox LCD emulation\n");
  49. return ret;
  50. }
  51. #endif
  52. return 0;
  53. }
  54. #endif
  55. #ifdef CONFIG_BOARD_LATE_INIT
  56. int board_late_init(void)
  57. {
  58. if (cros_ec_get_error()) {
  59. /* Force console on */
  60. gd->flags &= ~GD_FLG_SILENT;
  61. printf("cros-ec communications failure %d\n",
  62. cros_ec_get_error());
  63. puts("\nPlease reset with Power+Refresh\n\n");
  64. panic("Cannot init cros-ec device");
  65. return -1;
  66. }
  67. return 0;
  68. }
  69. #endif