// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2015, Google, Inc
 */

#include <dm.h>
#include <init.h>
#include <log.h>
#include <asm/gpio.h>
#include <dm/device-internal.h>
#include <dm/uclass-internal.h>

#define GPIO_BANKE_NAME		"gpioe"

int misc_init_r(void)
{
	struct udevice *dev;
	struct gpio_desc desc;
	int ret;

	/*
	 * Turn on USB VBUS for the two USB ports on the board.
	 * Each port's VBUS is controlled by a GPIO pin.
	 */

	ret = uclass_find_device_by_name(UCLASS_GPIO, GPIO_BANKE_NAME, &dev);
	if (ret) {
		debug("%s: GPIO %s device cannot be not found (ret=%d)\n",
		      __func__, GPIO_BANKE_NAME, ret);
		return ret;
	}

	ret = device_probe(dev);
	if (ret) {
		debug("%s: GPIO %s device probe failed (ret=%d)\n",
		      __func__, GPIO_BANKE_NAME, ret);
		return ret;
	}

	desc.dev = dev;
	desc.flags = GPIOD_IS_OUT;

	/* GPIO E8 controls the bottom port */
	desc.offset = 8;

	ret = dm_gpio_request(&desc, "usb_host_en0");
	if (ret)
		return ret;
	dm_gpio_set_value(&desc, 1);

	/* GPIO E9 controls the upper port */
	desc.offset = 9;

	ret = dm_gpio_request(&desc, "usb_host_en1");
	if (ret)
		return ret;

	dm_gpio_set_value(&desc, 1);

	return 0;
}
