sandbox.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/u-boot-sandbox.h>
  10. /*
  11. * Pointer to initial global data area
  12. *
  13. * Here we initialize it.
  14. */
  15. gd_t *gd;
  16. /* Add a simple GPIO device */
  17. U_BOOT_DEVICE(gpio_sandbox) = {
  18. .name = "gpio_sandbox",
  19. };
  20. void flush_cache(unsigned long start, unsigned long size)
  21. {
  22. }
  23. unsigned long timer_read_counter(void)
  24. {
  25. return os_get_nsec() / 1000;
  26. }
  27. int dram_init(void)
  28. {
  29. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  30. return 0;
  31. }
  32. #ifdef CONFIG_BOARD_EARLY_INIT_F
  33. int board_early_init_f(void)
  34. {
  35. #ifdef CONFIG_VIDEO_SANDBOX_SDL
  36. int ret;
  37. ret = sandbox_lcd_sdl_early_init();
  38. if (ret) {
  39. puts("Could not init sandbox LCD emulation\n");
  40. return ret;
  41. }
  42. #endif
  43. return 0;
  44. }
  45. #endif
  46. int arch_early_init_r(void)
  47. {
  48. #ifdef CONFIG_CROS_EC
  49. if (cros_ec_board_init()) {
  50. printf("%s: Failed to init EC\n", __func__);
  51. return 0;
  52. }
  53. #endif
  54. return 0;
  55. }
  56. #ifdef CONFIG_BOARD_LATE_INIT
  57. int board_late_init(void)
  58. {
  59. if (cros_ec_get_error()) {
  60. /* Force console on */
  61. gd->flags &= ~GD_FLG_SILENT;
  62. printf("cros-ec communications failure %d\n",
  63. cros_ec_get_error());
  64. puts("\nPlease reset with Power+Refresh\n\n");
  65. panic("Cannot init cros-ec device");
  66. return -1;
  67. }
  68. return 0;
  69. }
  70. #endif