1*90fbb282SAlexey Brodkin /* 2*90fbb282SAlexey Brodkin * Copyright (C) 2015 Alexey Brodkin <abrodkin@synopsys.com> 3*90fbb282SAlexey Brodkin * 4*90fbb282SAlexey Brodkin * SPDX-License-Identifier: GPL-2.0+ 5*90fbb282SAlexey Brodkin */ 6*90fbb282SAlexey Brodkin 7*90fbb282SAlexey Brodkin #include <common.h> 8*90fbb282SAlexey Brodkin #include <dm.h> 9*90fbb282SAlexey Brodkin #include "ehci.h" 10*90fbb282SAlexey Brodkin 11*90fbb282SAlexey Brodkin /* 12*90fbb282SAlexey Brodkin * Even though here we don't explicitly use "struct ehci_ctrl" 13*90fbb282SAlexey Brodkin * ehci_register() expects it to be the first thing that resides in 14*90fbb282SAlexey Brodkin * device's private data. 15*90fbb282SAlexey Brodkin */ 16*90fbb282SAlexey Brodkin struct generic_ehci { 17*90fbb282SAlexey Brodkin struct ehci_ctrl ctrl; 18*90fbb282SAlexey Brodkin }; 19*90fbb282SAlexey Brodkin 20*90fbb282SAlexey Brodkin static int ehci_usb_probe(struct udevice *dev) 21*90fbb282SAlexey Brodkin { 22*90fbb282SAlexey Brodkin struct ehci_hccr *hccr = (struct ehci_hccr *)dev_get_addr(dev); 23*90fbb282SAlexey Brodkin struct ehci_hcor *hcor; 24*90fbb282SAlexey Brodkin 25*90fbb282SAlexey Brodkin hcor = (struct ehci_hcor *)((uintptr_t)hccr + 26*90fbb282SAlexey Brodkin HC_LENGTH(ehci_readl(&hccr->cr_capbase))); 27*90fbb282SAlexey Brodkin 28*90fbb282SAlexey Brodkin return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST); 29*90fbb282SAlexey Brodkin } 30*90fbb282SAlexey Brodkin 31*90fbb282SAlexey Brodkin static int ehci_usb_remove(struct udevice *dev) 32*90fbb282SAlexey Brodkin { 33*90fbb282SAlexey Brodkin return ehci_deregister(dev); 34*90fbb282SAlexey Brodkin } 35*90fbb282SAlexey Brodkin 36*90fbb282SAlexey Brodkin static const struct udevice_id ehci_usb_ids[] = { 37*90fbb282SAlexey Brodkin { .compatible = "generic-ehci" }, 38*90fbb282SAlexey Brodkin { } 39*90fbb282SAlexey Brodkin }; 40*90fbb282SAlexey Brodkin 41*90fbb282SAlexey Brodkin U_BOOT_DRIVER(ehci_generic) = { 42*90fbb282SAlexey Brodkin .name = "ehci_generic", 43*90fbb282SAlexey Brodkin .id = UCLASS_USB, 44*90fbb282SAlexey Brodkin .of_match = ehci_usb_ids, 45*90fbb282SAlexey Brodkin .probe = ehci_usb_probe, 46*90fbb282SAlexey Brodkin .remove = ehci_usb_remove, 47*90fbb282SAlexey Brodkin .ops = &ehci_usb_ops, 48*90fbb282SAlexey Brodkin .priv_auto_alloc_size = sizeof(struct generic_ehci), 49*90fbb282SAlexey Brodkin .flags = DM_FLAG_ALLOC_PRIV_DMA, 50*90fbb282SAlexey Brodkin }; 51