minnowmax.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2015, Google, Inc
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <asm/gpio.h>
  8. #include <dm/device-internal.h>
  9. #include <dm/uclass-internal.h>
  10. #define GPIO_BANKE_NAME "gpioe"
  11. int misc_init_r(void)
  12. {
  13. struct udevice *dev;
  14. struct gpio_desc desc;
  15. int ret;
  16. /*
  17. * Turn on USB VBUS for the two USB ports on the board.
  18. * Each port's VBUS is controlled by a GPIO pin.
  19. */
  20. ret = uclass_find_device_by_name(UCLASS_GPIO, GPIO_BANKE_NAME, &dev);
  21. if (ret) {
  22. debug("%s: GPIO %s device cannot be not found (ret=%d)\n",
  23. __func__, GPIO_BANKE_NAME, ret);
  24. return ret;
  25. }
  26. ret = device_probe(dev);
  27. if (ret) {
  28. debug("%s: GPIO %s device probe failed (ret=%d)\n",
  29. __func__, GPIO_BANKE_NAME, ret);
  30. return ret;
  31. }
  32. desc.dev = dev;
  33. desc.flags = GPIOD_IS_OUT;
  34. /* GPIO E8 controls the bottom port */
  35. desc.offset = 8;
  36. ret = dm_gpio_request(&desc, "usb_host_en0");
  37. if (ret)
  38. return ret;
  39. dm_gpio_set_value(&desc, 1);
  40. /* GPIO E9 controls the upper port */
  41. desc.offset = 9;
  42. ret = dm_gpio_request(&desc, "usb_host_en1");
  43. if (ret)
  44. return ret;
  45. dm_gpio_set_value(&desc, 1);
  46. return 0;
  47. }