minnowmax.c 1.2 KB

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