minnowmax.c 1.1 KB

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