sandbox.c 1.4 KB

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