sandbox.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /* system timer offset in ms */
  25. static unsigned long sandbox_timer_offset;
  26. void sandbox_timer_add_offset(unsigned long offset)
  27. {
  28. sandbox_timer_offset += offset;
  29. }
  30. unsigned long timer_read_counter(void)
  31. {
  32. return os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
  33. }
  34. int dram_init(void)
  35. {
  36. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  37. return 0;
  38. }
  39. #ifdef CONFIG_BOARD_EARLY_INIT_F
  40. int board_early_init_f(void)
  41. {
  42. #ifdef CONFIG_VIDEO_SANDBOX_SDL
  43. int ret;
  44. ret = sandbox_lcd_sdl_early_init();
  45. if (ret) {
  46. puts("Could not init sandbox LCD emulation\n");
  47. return ret;
  48. }
  49. #endif
  50. return 0;
  51. }
  52. #endif
  53. #ifdef CONFIG_BOARD_LATE_INIT
  54. int board_late_init(void)
  55. {
  56. if (cros_ec_get_error()) {
  57. /* Force console on */
  58. gd->flags &= ~GD_FLG_SILENT;
  59. printf("cros-ec communications failure %d\n",
  60. cros_ec_get_error());
  61. puts("\nPlease reset with Power+Refresh\n\n");
  62. panic("Cannot init cros-ec device");
  63. return -1;
  64. }
  65. return 0;
  66. }
  67. #endif