sandbox.c 1.3 KB

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