sandbox.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. int ft_board_setup(void *fdt, bd_t *bd)
  51. {
  52. /* Create an arbitrary reservation to allow testing OF_BOARD_SETUP.*/
  53. return fdt_add_mem_rsv(fdt, 0x00d02000, 0x4000);
  54. }
  55. #ifdef CONFIG_BOARD_LATE_INIT
  56. int board_late_init(void)
  57. {
  58. struct udevice *dev;
  59. int ret;
  60. ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
  61. if (ret && ret != -ENODEV) {
  62. /* Force console on */
  63. gd->flags &= ~GD_FLG_SILENT;
  64. printf("cros-ec communications failure %d\n", ret);
  65. puts("\nPlease reset with Power+Refresh\n\n");
  66. panic("Cannot init cros-ec device");
  67. return -1;
  68. }
  69. return 0;
  70. }
  71. #endif