Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-1.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * OHCI HCD (Host Controller Driver) for USB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * (C) Copyright 2002 Hewlett-Packard Company
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * SA1111 Bus Glue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Written by Christopher Hoover <ch@hpl.hp.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Based on fragments of previous driver by Russell King et al.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * This file is licenced under the GPL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/hardware/sa1111.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #ifndef CONFIG_SA1111
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #error "This file is SA-1111 bus glue.  CONFIG_SA1111 must be defined."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define USB_STATUS	0x0118
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define USB_RESET	0x011c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define USB_IRQTEST	0x0120
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define USB_RESET_FORCEIFRESET	(1 << 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define USB_RESET_FORCEHCRESET	(1 << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define USB_RESET_CLKGENRESET	(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define USB_RESET_SIMSCALEDOWN	(1 << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define USB_RESET_USBINTTEST	(1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define USB_RESET_SLEEPSTBYEN	(1 << 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define USB_RESET_PWRSENSELOW	(1 << 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define USB_RESET_PWRCTRLLOW	(1 << 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define USB_STATUS_IRQHCIRMTWKUP  (1 <<  7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define USB_STATUS_IRQHCIBUFFACC  (1 <<  8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define USB_STATUS_NIRQHCIM       (1 <<  9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define USB_STATUS_NHCIMFCLR      (1 << 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define USB_STATUS_USBPWRSENSE    (1 << 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static void dump_hci_status(struct usb_hcd *hcd, const char *label)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	unsigned long status = readl_relaxed(hcd->regs + USB_STATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	printk(KERN_DEBUG "%s USB_STATUS = { %s%s%s%s%s}\n", label,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	     ((status & USB_STATUS_IRQHCIRMTWKUP) ? "IRQHCIRMTWKUP " : ""),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	     ((status & USB_STATUS_IRQHCIBUFFACC) ? "IRQHCIBUFFACC " : ""),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	     ((status & USB_STATUS_NIRQHCIM) ? "" : "IRQHCIM "),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	     ((status & USB_STATUS_NHCIMFCLR) ? "" : "HCIMFCLR "),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	     ((status & USB_STATUS_USBPWRSENSE) ? "USBPWRSENSE " : ""));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static int ohci_sa1111_reset(struct usb_hcd *hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	ohci_hcd_init(ohci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	return ohci_init(ohci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) static int ohci_sa1111_start(struct usb_hcd *hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct ohci_hcd	*ohci = hcd_to_ohci(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	ret = ohci_run(ohci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		ohci_err(ohci, "can't start\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		ohci_stop(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static const struct hc_driver ohci_sa1111_hc_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.description =		hcd_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	.product_desc =		"SA-1111 OHCI",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	.hcd_priv_size =	sizeof(struct ohci_hcd),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 * generic hardware linkage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.irq =			ohci_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.flags =		HCD_USB11 | HCD_DMA | HCD_MEMORY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 * basic lifecycle operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	.reset =		ohci_sa1111_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	.start =		ohci_sa1111_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	.stop =			ohci_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	.shutdown =		ohci_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 * managing i/o requests and associated device resources
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	.urb_enqueue =		ohci_urb_enqueue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	.urb_dequeue =		ohci_urb_dequeue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	.endpoint_disable =	ohci_endpoint_disable,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	 * scheduling support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.get_frame_number =	ohci_get_frame,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 * root hub support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	.hub_status_data =	ohci_hub_status_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	.hub_control =		ohci_hub_control,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #ifdef	CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	.bus_suspend =		ohci_bus_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.bus_resume =		ohci_bus_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.start_port_reset =	ohci_start_port_reset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static int sa1111_start_hc(struct sa1111_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	unsigned int usb_rst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	dev_dbg(&dev->dev, "starting SA-1111 OHCI USB Controller\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	if (machine_is_xp860() ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	    machine_is_assabet() ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	    machine_is_pfs168() ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	    machine_is_badge4())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		usb_rst = USB_RESET_PWRSENSELOW | USB_RESET_PWRCTRLLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 * Configure the power sense and control lines.  Place the USB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	 * host controller in reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	writel_relaxed(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		      dev->mapbase + USB_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	 * Now, carefully enable the USB clock, and take
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	 * the USB host controller out of reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	ret = sa1111_enable_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		udelay(11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		writel_relaxed(usb_rst, dev->mapbase + USB_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) static void sa1111_stop_hc(struct sa1111_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	unsigned int usb_rst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	dev_dbg(&dev->dev, "stopping SA-1111 OHCI USB Controller\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	 * Put the USB host controller into reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	usb_rst = readl_relaxed(dev->mapbase + USB_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	writel_relaxed(usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		      dev->mapbase + USB_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	 * Stop the USB clock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	sa1111_disable_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * ohci_hcd_sa1111_probe - initialize SA-1111-based HCDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  * Allocates basic resources for this USB host controller, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  * then invokes the start() method for the HCD associated with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) static int ohci_hcd_sa1111_probe(struct sa1111_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	struct usb_hcd *hcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	int ret, irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (usb_disabled())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	 * We don't call dma_set_mask_and_coherent() here because the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 * DMA mask has already been appropraitely setup by the core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 * SA-1111 bus code (which includes bug workarounds.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	hcd = usb_create_hcd(&ohci_sa1111_hc_driver, &dev->dev, "sa1111");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	hcd->rsrc_start = dev->res.start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	hcd->rsrc_len = resource_size(&dev->res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	irq = sa1111_get_irq(dev, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (irq <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		ret = irq ? : -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		goto err1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		dev_dbg(&dev->dev, "request_mem_region failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		ret = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		goto err1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	hcd->regs = dev->mapbase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	ret = sa1111_start_hc(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		goto err2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	ret = usb_add_hcd(hcd, irq, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (ret == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		device_wakeup_enable(hcd->self.controller);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	sa1111_stop_hc(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  err2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  err1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	usb_put_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * ohci_hcd_sa1111_remove - shutdown processing for SA-1111-based HCDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * @dev: USB Host Controller being removed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * Reverses the effect of ohci_hcd_sa1111_probe(), first invoking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * the HCD's stop() method.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int ohci_hcd_sa1111_remove(struct sa1111_dev *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct usb_hcd *hcd = sa1111_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	usb_remove_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	sa1111_stop_hc(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	usb_put_hcd(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) static void ohci_hcd_sa1111_shutdown(struct device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	struct sa1111_dev *dev = to_sa1111_device(_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	struct usb_hcd *hcd = sa1111_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		hcd->driver->shutdown(hcd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		sa1111_stop_hc(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) static struct sa1111_driver ohci_hcd_sa1111_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	.drv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		.name	= "sa1111-ohci",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		.owner	= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		.shutdown = ohci_hcd_sa1111_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	.devid		= SA1111_DEVID_USB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	.probe		= ohci_hcd_sa1111_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	.remove		= ohci_hcd_sa1111_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };