sandbox.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_LATE_INIT
  42. int board_late_init(void)
  43. {
  44. if (cros_ec_get_error()) {
  45. /* Force console on */
  46. gd->flags &= ~GD_FLG_SILENT;
  47. printf("cros-ec communications failure %d\n",
  48. cros_ec_get_error());
  49. puts("\nPlease reset with Power+Refresh\n\n");
  50. panic("Cannot init cros-ec device");
  51. return -1;
  52. }
  53. return 0;
  54. }
  55. #endif