mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-30 13:58:51 +09:00
![Tom Rini](/assets/img/avatar_default.png)
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
102 lines
2.4 KiB
C
102 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2015 Marvell International Ltd.
|
|
*
|
|
* MVEBU USB HOST xHCI Controller
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <fdtdec.h>
|
|
#include <usb.h>
|
|
#include <power/regulator.h>
|
|
#include <asm/gpio.h>
|
|
|
|
#include "xhci.h"
|
|
|
|
struct mvebu_xhci_platdata {
|
|
fdt_addr_t hcd_base;
|
|
};
|
|
|
|
/**
|
|
* Contains pointers to register base addresses
|
|
* for the usb controller.
|
|
*/
|
|
struct mvebu_xhci {
|
|
struct xhci_ctrl ctrl; /* Needs to come first in this struct! */
|
|
struct usb_platdata usb_plat;
|
|
struct xhci_hccr *hcd;
|
|
};
|
|
|
|
/*
|
|
* Dummy implementation that can be overwritten by a board
|
|
* specific function
|
|
*/
|
|
__weak int board_xhci_enable(fdt_addr_t base)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int xhci_usb_probe(struct udevice *dev)
|
|
{
|
|
struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
|
|
struct mvebu_xhci *ctx = dev_get_priv(dev);
|
|
struct xhci_hcor *hcor;
|
|
int len, ret;
|
|
struct udevice *regulator;
|
|
|
|
ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
|
|
len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
|
|
hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
|
|
|
|
ret = device_get_supply_regulator(dev, "vbus-supply", ®ulator);
|
|
if (!ret) {
|
|
ret = regulator_set_enable(regulator, true);
|
|
if (ret) {
|
|
printf("Failed to turn ON the VBUS regulator\n");
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
/* Enable USB xHCI (VBUS, reset etc) in board specific code */
|
|
board_xhci_enable(devfdt_get_addr_index(dev, 1));
|
|
|
|
return xhci_register(dev, ctx->hcd, hcor);
|
|
}
|
|
|
|
static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
|
|
{
|
|
struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
|
|
|
|
/*
|
|
* Get the base address for XHCI controller from the device node
|
|
*/
|
|
plat->hcd_base = devfdt_get_addr(dev);
|
|
if (plat->hcd_base == FDT_ADDR_T_NONE) {
|
|
debug("Can't get the XHCI register base address\n");
|
|
return -ENXIO;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct udevice_id xhci_usb_ids[] = {
|
|
{ .compatible = "marvell,armada3700-xhci" },
|
|
{ .compatible = "marvell,armada-380-xhci" },
|
|
{ .compatible = "marvell,armada-8k-xhci" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(usb_xhci) = {
|
|
.name = "xhci_mvebu",
|
|
.id = UCLASS_USB,
|
|
.of_match = xhci_usb_ids,
|
|
.ofdata_to_platdata = xhci_usb_ofdata_to_platdata,
|
|
.probe = xhci_usb_probe,
|
|
.remove = xhci_deregister,
|
|
.ops = &xhci_usb_ops,
|
|
.platdata_auto_alloc_size = sizeof(struct mvebu_xhci_platdata),
|
|
.priv_auto_alloc_size = sizeof(struct mvebu_xhci),
|
|
.flags = DM_FLAG_ALLOC_PRIV_DMA,
|
|
};
|