您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ HCD_HW_ACCESSIBLE函数代码示例

51自学网 2021-06-01 21:22:37
  C++
这篇教程C++ HCD_HW_ACCESSIBLE函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中HCD_HW_ACCESSIBLE函数的典型用法代码示例。如果您正苦于以下问题:C++ HCD_HW_ACCESSIBLE函数的具体用法?C++ HCD_HW_ACCESSIBLE怎么用?C++ HCD_HW_ACCESSIBLE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了HCD_HW_ACCESSIBLE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: c67x00_hcd_irq

/** * c67x00_hcd_irq * * This function is called from the interrupt handler in c67x00-drv.c */static void c67x00_hcd_irq(struct c67x00_sie *sie, u16 int_status, u16 msg){	struct c67x00_hcd *c67x00 = sie->private_data;	struct usb_hcd *hcd = c67x00_hcd_to_hcd(c67x00);	/* Handle sie message flags */	if (msg) {		if (msg & HUSB_TDListDone)			c67x00_sched_kick(c67x00);		else			dev_warn(c67x00_hcd_dev(c67x00),				 "Unknown SIE msg flag(s): 0x%04x/n", msg);	}	if (unlikely(hcd->state == HC_STATE_HALT))		return;	if (!HCD_HW_ACCESSIBLE(hcd))		return;	/* Handle Start of frame events */	if (int_status & SOFEOP_FLG(sie->sie_num)) {		c67x00_ll_usb_clear_status(sie, SOF_EOP_IRQ_FLG);		c67x00_sched_kick(c67x00);	}}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:31,


示例2: xhci_hub_status_data

/* * Returns 0 if the status hasn't changed, or the number of bytes in buf. * Ports are 0-indexed from the HCD point of view, * and 1-indexed from the USB core pointer of view. * * Note that the status change bits will be cleared as soon as a port status * change event is generated, so we use the saved status from that event. */int xhci_hub_status_data(struct usb_hcd *hcd, char *buf){	unsigned long flags;	u32 temp, status;	u32 mask;	int i, retval;	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	bool reset_change = false;	/* Forbid to access register if controller in suspneded */	if (!HCD_HW_ACCESSIBLE(hcd))		return -ESHUTDOWN;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	/* Initial status is no changes */	retval = (max_ports + 8) / 8;	memset(buf, 0, retval);	/*	 * Inform the usbcore about resume-in-progress by returning	 * a non-zero value even if there are no status changes.	 */	status = bus_state->resuming_ports;	mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC;	spin_lock_irqsave(&xhci->lock, flags);	/* For each port, did anything change?  If so, set that bit in buf. */	for (i = 0; i < max_ports; i++) {		temp = xhci_readl(xhci, port_array[i]);		if (temp == 0xffffffff) {			retval = -ENODEV;			break;		}		if ((temp & mask) != 0 ||			(bus_state->port_c_suspend & 1 << i) ||			(bus_state->resume_done[i] && time_after_eq(			    jiffies, bus_state->resume_done[i]))) {			buf[(i + 1) / 8] |= 1 << (i + 1) % 8;			status = 1;		}		if ((temp & PORT_RC))			reset_change = true;	}	if (!status && !reset_change) {		xhci_dbg(xhci, "%s: stopping port polling./n", __func__);		clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);	}	spin_unlock_irqrestore(&xhci->lock, flags);	return status ? retval : 0;}
开发者ID:BitOBSessiOn,项目名称:android_kernel_asus_P01M,代码行数:64,


示例3: uhci_hub_status_data

static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf){	struct uhci_hcd *uhci = hcd_to_uhci(hcd);	unsigned long flags;	int status = 0;	spin_lock_irqsave(&uhci->lock, flags);	uhci_scan_schedule(uhci);	if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)		goto done;	uhci_check_ports(uhci);	status = get_hub_status_data(uhci, buf);	switch (uhci->rh_state) {	    case UHCI_RH_SUSPENDED:				if (status || uhci->resuming_ports) {			status = 1;			usb_hcd_resume_root_hub(hcd);		}		break;	    case UHCI_RH_AUTO_STOPPED:				if (status)			wakeup_rh(uhci);		break;	    case UHCI_RH_RUNNING:				if (!any_ports_active(uhci)) {			uhci->rh_state = UHCI_RH_RUNNING_NODEVS;			uhci->auto_stop_time = jiffies + HZ;		}		break;	    case UHCI_RH_RUNNING_NODEVS:				if (any_ports_active(uhci))			uhci->rh_state = UHCI_RH_RUNNING;		else if (time_after_eq(jiffies, uhci->auto_stop_time) &&				!uhci->wait_for_hp)			suspend_rh(uhci, UHCI_RH_AUTO_STOPPED);		break;	    default:		break;	}done:	spin_unlock_irqrestore(&uhci->lock, flags);	return status;}
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:55,


示例4: uhci_hub_status_data

static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf){    struct uhci_hcd *uhci = hcd_to_uhci(hcd);    unsigned long flags;    int status = 0;    spin_lock_irqsave(&uhci->lock, flags);    uhci_scan_schedule(uhci);    if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)        goto done;    uhci_check_ports(uhci);    status = get_hub_status_data(uhci, buf);    switch (uhci->rh_state) {    case UHCI_RH_SUSPENDING:    case UHCI_RH_SUSPENDED:        /* if port change, ask to be resumed */        if (status || uhci->resuming_ports)            usb_hcd_resume_root_hub(hcd);        break;    case UHCI_RH_AUTO_STOPPED:        /* if port change, auto start */        if (status)            wakeup_rh(uhci);        break;    case UHCI_RH_RUNNING:        /* are any devices attached? */        if (!any_ports_active(uhci)) {            uhci->rh_state = UHCI_RH_RUNNING_NODEVS;            uhci->auto_stop_time = jiffies + HZ;        }        break;    case UHCI_RH_RUNNING_NODEVS:        /* auto-stop if nothing connected for 1 second */        if (any_ports_active(uhci))            uhci->rh_state = UHCI_RH_RUNNING;        else if (time_after_eq(jiffies, uhci->auto_stop_time))            suspend_rh(uhci, UHCI_RH_AUTO_STOPPED);        break;    default:        break;    }done:    spin_unlock_irqrestore(&uhci->lock, flags);    return status;}
开发者ID:daodaoliang,项目名称:miwifi,代码行数:53,


示例5: admhc_hub_status_data

static intadmhc_hub_status_data(struct usb_hcd *hcd, char *buf){	struct admhcd	*ahcd = hcd_to_admhcd(hcd);	int		i, changed = 0, length = 1;	int		any_connected = 0;	unsigned long	flags;	u32		status;	spin_lock_irqsave(&ahcd->lock, flags);	if (!HCD_HW_ACCESSIBLE(hcd))		goto done;	/* init status */	status = admhc_read_rhdesc(ahcd);	if (status & (ADMHC_RH_LPSC | ADMHC_RH_OCIC))		buf[0] = changed = 1;	else		buf[0] = 0;	if (ahcd->num_ports > 7) {		buf[1] = 0;		length++;	}	/* look at each port */	for (i = 0; i < ahcd->num_ports; i++) {		status = admhc_read_portstatus(ahcd, i);		/* can't autostop if ports are connected */		any_connected |= (status & ADMHC_PS_CCS);		if (status & (ADMHC_PS_CSC | ADMHC_PS_PESC | ADMHC_PS_PSSC				| ADMHC_PS_OCIC | ADMHC_PS_PRSC)) {			changed = 1;			if (i < 7)				buf[0] |= 1 << (i + 1);			else				buf[1] |= 1 << (i - 7);		}	}	if (admhc_root_hub_state_changes(ahcd, changed,			any_connected))		set_bit(HCD_FLAG_POLL_RH, &hcd->flags);	else		clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);done:	spin_unlock_irqrestore(&ahcd->lock, flags);	return changed ? length : 0;}
开发者ID:020gzh,项目名称:openwrt-mirror,代码行数:52,


示例6: uhci_pci_suspend

static int uhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup){	struct uhci_hcd *uhci = hcd_to_uhci(hcd);	struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci));	int rc = 0;	u16 pmc_enable = 0;	dev_dbg(uhci_dev(uhci), "%s/n", __func__);	spin_lock_irq(&uhci->lock);	if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)		goto done_okay;		/* Already suspended or dead */	if (uhci->rh_state > UHCI_RH_SUSPENDED) {		dev_warn(uhci_dev(uhci), "Root hub isn't suspended!/n");		rc = -EBUSY;		goto done;	};	/* All PCI host controllers are required to disable IRQ generation	 * at the source, so we must turn off PIRQ.	 */	pci_write_config_word(pdev, USBLEGSUP, 0);	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);	/* Enable platform-specific non-PME# wakeup */	if (do_wakeup) {		if (pdev->vendor == PCI_VENDOR_ID_INTEL)			pci_write_config_byte(pdev, USBRES_INTEL,					USBPORT1EN | USBPORT2EN);	}  //CharlesTu, for PM	if (((hcd->self.busnum == 2) && enable_uhci0_wake) || ((hcd->self.busnum == 3) && enable_uhci1_wake)){		pci_read_config_word(to_pci_dev(uhci_dev(uhci)), 0x84, &pmc_enable);		pmc_enable |= 0x103;		pci_write_config_word(to_pci_dev(uhci_dev(uhci)), 0x84, pmc_enable);	}done_okay:	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);done:	spin_unlock_irq(&uhci->lock);	return rc;}
开发者ID:manishj-patel,项目名称:netbook_kernel_3.4.5,代码行数:44,


示例7: uhci_pci_suspend

static int uhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup){	struct uhci_hcd *uhci = hcd_to_uhci(hcd);	struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci));	int rc = 0;	dev_dbg(uhci_dev(uhci), "%s/n", __func__);	spin_lock_irq(&uhci->lock);	if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)		goto done_okay;		/* Already suspended or dead */	/* All PCI host controllers are required to disable IRQ generation	 * at the source, so we must turn off PIRQ.	 */	pci_write_config_word(pdev, USBLEGSUP, 0);	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);	/* Enable platform-specific non-PME# wakeup */	if (do_wakeup) {		if (pdev->vendor == PCI_VENDOR_ID_INTEL)			pci_write_config_byte(pdev, USBRES_INTEL,					USBPORT1EN | USBPORT2EN);	}done_okay:	clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);	spin_unlock_irq(&uhci->lock);	synchronize_irq(hcd->irq);	/* Check for race with a wakeup request */	if (do_wakeup && HCD_WAKEUP_PENDING(hcd)) {		uhci_pci_resume(hcd, false);		rc = -EBUSY;	}	return rc;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:38,


示例8: xhci_bus_resume

int xhci_bus_resume(struct usb_hcd *hcd){	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports, port_index;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	u32 temp;	unsigned long flags;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	if (time_before(jiffies, bus_state->next_statechange))		msleep(5);	spin_lock_irqsave(&xhci->lock, flags);	if (!HCD_HW_ACCESSIBLE(hcd)) {		spin_unlock_irqrestore(&xhci->lock, flags);		return -ESHUTDOWN;	}	/* delay the irqs */	temp = xhci_readl(xhci, &xhci->op_regs->command);	temp &= ~CMD_EIE;	xhci_writel(xhci, temp, &xhci->op_regs->command);	port_index = max_ports;	while (port_index--) {		/* Check whether need resume ports. If needed		   resume port and disable remote wakeup */		u32 temp;		int slot_id;		temp = xhci_readl(xhci, port_array[port_index]);		if (DEV_SUPERSPEED(temp))			temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);		else			temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);		if (test_bit(port_index, &bus_state->bus_suspended) &&		    (temp & PORT_PLS_MASK)) {			if (DEV_SUPERSPEED(temp)) {				temp = xhci_port_state_to_neutral(temp);				temp &= ~PORT_PLS_MASK;				temp |= PORT_LINK_STROBE | XDEV_U0;				xhci_writel(xhci, temp, port_array[port_index]);			} else {				temp = xhci_port_state_to_neutral(temp);				temp &= ~PORT_PLS_MASK;				temp |= PORT_LINK_STROBE | XDEV_RESUME;				xhci_writel(xhci, temp, port_array[port_index]);				spin_unlock_irqrestore(&xhci->lock, flags);				msleep(20);				spin_lock_irqsave(&xhci->lock, flags);				temp = xhci_readl(xhci, port_array[port_index]);				temp = xhci_port_state_to_neutral(temp);				temp &= ~PORT_PLS_MASK;				temp |= PORT_LINK_STROBE | XDEV_U0;				xhci_writel(xhci, temp, port_array[port_index]);			}			/* wait for the port to enter U0 and report port link			 * state change.			 */			spin_unlock_irqrestore(&xhci->lock, flags);			msleep(20);			spin_lock_irqsave(&xhci->lock, flags);			/* Clear PLC */			xhci_test_and_clear_bit(xhci, port_array, port_index,						PORT_PLC);			slot_id = xhci_find_slot_id_by_port(hcd,					xhci, port_index + 1);			if (slot_id)				xhci_ring_device(xhci, slot_id);		} else			xhci_writel(xhci, temp, port_array[port_index]);		if (hcd->speed != HCD_USB3) {			/* disable remote wake up for USB 2.0 */			__le32 __iomem *addr;			u32 tmp;			/* Add one to the port status register address to get			 * the port power control register address.			 */			addr = port_array[port_index] + 1;			tmp = xhci_readl(xhci, addr);			tmp &= ~PORT_RWE;			xhci_writel(xhci, tmp, addr);		}	}	(void) xhci_readl(xhci, &xhci->op_regs->command);	bus_state->next_statechange = jiffies + msecs_to_jiffies(5);	/* re-enable irqs */	temp = xhci_readl(xhci, &xhci->op_regs->command);	temp |= CMD_EIE;//.........这里部分代码省略.........
开发者ID:303750856,项目名称:linux-3.1,代码行数:101,


示例9: musb_hub_control

int musb_hub_control(	struct usb_hcd	*hcd,	u16		typeReq,	u16		wValue,	u16		wIndex,	char		*buf,	u16		wLength){	struct musb	*musb = hcd_to_musb(hcd);	u32		temp;	int		retval = 0;	unsigned long	flags;	spin_lock_irqsave(&musb->lock, flags);	if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) {		spin_unlock_irqrestore(&musb->lock, flags);		return -ESHUTDOWN;	}	/* hub features:  always zero, setting is a NOP	 * port features: reported, sometimes updated when host is active	 * no indicators	 */	switch (typeReq) {	case ClearHubFeature:	case SetHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:		case C_HUB_LOCAL_POWER:			break;		default:			goto error;		}		break;	case ClearPortFeature:		if ((wIndex & 0xff) != 1)			goto error;		switch (wValue) {		case USB_PORT_FEAT_ENABLE:			break;		case USB_PORT_FEAT_SUSPEND:			musb_port_suspend(musb, false);			break;		case USB_PORT_FEAT_POWER:			if (!(is_otg_enabled(musb) && hcd->self.is_b_host))				musb_set_vbus(musb, 0);			break;		case USB_PORT_FEAT_C_CONNECTION:		case USB_PORT_FEAT_C_ENABLE:		case USB_PORT_FEAT_C_OVER_CURRENT:		case USB_PORT_FEAT_C_RESET:		case USB_PORT_FEAT_C_SUSPEND:			break;		default:			goto error;		}		DBG(5, "clear feature %d/n", wValue);		musb->port1_status &= ~(1 << wValue);		break;	case GetHubDescriptor:		{		struct usb_hub_descriptor *desc = (void *)buf;		desc->bDescLength = 9;		desc->bDescriptorType = 0x29;		desc->bNbrPorts = 1;		desc->wHubCharacteristics = cpu_to_le16(				  0x0001	/* per-port power switching */				| 0x0010	/* no overcurrent reporting */				);		desc->bPwrOn2PwrGood = 5;	/* msec/2 */		desc->bHubContrCurrent = 0;		/* workaround bogus struct definition */		desc->DeviceRemovable[0] = 0x02;	/* port 1 */		desc->DeviceRemovable[1] = 0xff;		}		break;	case GetHubStatus:		temp = 0;		*(__le32 *) buf = cpu_to_le32(temp);		break;	case GetPortStatus:		if (wIndex != 1)			goto error;		/* finish RESET signaling? */		if ((musb->port1_status & USB_PORT_STAT_RESET)				&& time_after_eq(jiffies, musb->rh_timer))			musb_port_reset(musb, false);		/* finish RESUME signaling? */		if ((musb->port1_status & MUSB_PORT_STAT_RESUME)				&& time_after_eq(jiffies, musb->rh_timer)) {			u8		power;			power = musb_readb(musb->mregs, MUSB_POWER);			power &= ~MUSB_POWER_RESUME;//.........这里部分代码省略.........
开发者ID:SunRain,项目名称:kernel_mapphone_kexec,代码行数:101,


示例10: musbfsh_hub_control

int musbfsh_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,			u16 wIndex, char *buf, u16 wLength){	struct musbfsh *musbfsh = hcd_to_musbfsh(hcd);	u32 temp;	int retval = 0;	unsigned long flags;	INFO("%s++, typeReq=0x%x, wValue=0x%x, wIndex=0x%x/r/n",	     __func__, typeReq, wValue, wIndex);	spin_lock_irqsave(&musbfsh->lock, flags);	if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) {		spin_unlock_irqrestore(&musbfsh->lock, flags);		return -ESHUTDOWN;	}	/* hub features:  always zero, setting is a NOP	 * port features: reported, sometimes updated when host is active	 * no indicators	 */	switch (typeReq) {	case ClearHubFeature:	case SetHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:		case C_HUB_LOCAL_POWER:			break;		default:			goto error;		}		break;	case ClearPortFeature:		/* wIndex indicate the port number, here it is should be 1 */		if ((wIndex & 0xff) != 1)			goto error;		switch (wValue) {		case USB_PORT_FEAT_ENABLE:			break;		case USB_PORT_FEAT_SUSPEND:			/* here is clearing the suspend */			musbfsh_port_suspend(musbfsh, false);			break;		case USB_PORT_FEAT_POWER:#ifndef MTK_ALPS_BOX_SUPPORT			/* only power off the vbus */			musbfsh_set_vbus(musbfsh, 0);#else			/* only power off the vbus */			musbfsh_platform_set_vbus(musbfsh, 0);#endif			break;		case USB_PORT_FEAT_C_CONNECTION:		case USB_PORT_FEAT_C_ENABLE:		case USB_PORT_FEAT_C_OVER_CURRENT:		case USB_PORT_FEAT_C_RESET:		case USB_PORT_FEAT_C_SUSPEND:			break;		default:			goto error;		}		INFO("clear feature %d/n", wValue);		musbfsh->port1_status &= ~(1 << wValue);		break;	case GetHubDescriptor:		{			struct usb_hub_descriptor *desc = (void *)buf;			desc->bDescLength = 9;			desc->bDescriptorType = 0x29;			desc->bNbrPorts = 1;			/* 0x0001: per-port power switching */			/* 0x0010: no overcurrent reporting */			desc->wHubCharacteristics =				cpu_to_le16(0x0001 | 0x0010);			/* msec/2 */			desc->bPwrOn2PwrGood = 5;			desc->bHubContrCurrent = 0;			/* workaround bogus struct definition */			desc->u.hs.DeviceRemovable[0] = 0x02;	/* port 1 */			desc->u.hs.DeviceRemovable[1] = 0xff;		}		break;	case GetHubStatus:		temp = 0;		*(__le32 *)buf = cpu_to_le32(temp);		break;	case GetPortStatus:		if (wIndex != 1)			goto error;		/* finish RESET signaling? */		/* if FALSE: stop the reset because the timeout of reset. */		if ((musbfsh->port1_status & USB_PORT_STAT_RESET)		    && time_after_eq(jiffies, musbfsh->rh_timer))			musbfsh_port_reset(musbfsh, false);//.........这里部分代码省略.........
开发者ID:P-D-A,项目名称:android_kernel_lge_mt6753,代码行数:101,


示例11: msm_hsic_resume_thread

static int msm_hsic_resume_thread(void *data){	struct msm_hsic_hcd *mehci = data;	struct usb_hcd *hcd = hsic_to_hcd(mehci);	struct ehci_hcd		*ehci = hcd_to_ehci(hcd);	u32			temp;	unsigned long		resume_needed = 0;	int			retry_cnt = 0;	int			tight_resume = 0;	dbg_log_event(NULL, "Resume RH", 0);	/* keep delay between bus states */	if (time_before(jiffies, ehci->next_statechange))		usleep_range(5000, 5000);	spin_lock_irq(&ehci->lock);	if (!HCD_HW_ACCESSIBLE(hcd)) {		spin_unlock_irq(&ehci->lock);		mehci->resume_status = -ESHUTDOWN;		complete(&mehci->rt_completion);		return 0;	}	if (unlikely(ehci->debug)) {		if (!dbgp_reset_prep())			ehci->debug = NULL;		else			dbgp_external_startup();	}	/* at least some APM implementations will try to deliver	 * IRQs right away, so delay them until we're ready.	 */	ehci_writel(ehci, 0, &ehci->regs->intr_enable);	/* re-init operational registers */	ehci_writel(ehci, 0, &ehci->regs->segment);	ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);	ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);	/*CMD_RUN will be set after, PORT_RESUME gets cleared*/	if (ehci->resume_sof_bug)		ehci->command &= ~CMD_RUN;	/* restore CMD_RUN, framelist size, and irq threshold */	ehci_writel(ehci, ehci->command, &ehci->regs->command);	/* manually resume the ports we suspended during bus_suspend() */resume_again:	if (retry_cnt >= RESUME_RETRY_LIMIT) {		pr_info("retry count(%d) reached max, resume in tight loop/n",					retry_cnt);		tight_resume = 1;	}	temp = ehci_readl(ehci, &ehci->regs->port_status[0]);	temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);	if (test_bit(0, &ehci->bus_suspended) && (temp & PORT_SUSPEND)) {		temp |= PORT_RESUME;		set_bit(0, &resume_needed);	}	dbg_log_event(NULL, "FPR: Set", temp);	ehci_writel(ehci, temp, &ehci->regs->port_status[0]);	/* HSIC controller has a h/w bug due to which it can try to send SOFs	 * (start of frames) during port resume resulting in phy lockup. HSIC hw	 * controller in MSM clears FPR bit after driving the resume signal for	 * 20ms. Workaround is to stop SOFs before driving resume and then start	 * sending SOFs immediately. Need to send SOFs within 3ms of resume	 * completion otherwise peripheral may enter undefined state. As	 * usleep_range does not gurantee exact sleep time, GPTimer is used to	 * to time the resume sequence. If driver exceeds allowable time SOFs,	 * repeat the resume process.	 */	if (ehci->resume_sof_bug && resume_needed) {		if (!tight_resume) {			mehci->resume_again = 0;			ehci_writel(ehci, GPT_LD(RESUME_SIGNAL_TIME_MS),					&mehci->timer->gptimer0_ld);			ehci_writel(ehci, GPT_RESET | GPT_RUN,					&mehci->timer->gptimer0_ctrl);			ehci_writel(ehci, INTR_MASK | STS_GPTIMER0_INTERRUPT,					&ehci->regs->intr_enable);			ehci_writel(ehci, GPT_LD(RESUME_SIGNAL_TIME_SOF_MS),					&mehci->timer->gptimer1_ld);			ehci_writel(ehci, GPT_RESET | GPT_RUN,				&mehci->timer->gptimer1_ctrl);			spin_unlock_irq(&ehci->lock);			wait_for_completion(&mehci->gpt0_completion);			spin_lock_irq(&ehci->lock);		} else {			dbg_log_event(NULL, "FPR: Tightloop", 0);			/* do the resume in a tight loop */			handshake(ehci, &ehci->regs->port_status[0],				PORT_RESUME, 0, 22 * 1000);			ehci_writel(ehci, ehci_readl(ehci,//.........这里部分代码省略.........
开发者ID:x942,项目名称:GuardianKernel-Mako,代码行数:101,


示例12: xhci_bus_suspend

int xhci_bus_suspend(struct usb_hcd *hcd){	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports, port_index;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	unsigned long flags;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	spin_lock_irqsave(&xhci->lock, flags);	if (hcd->self.root_hub->do_remote_wakeup) {		if (bus_state->resuming_ports) {			spin_unlock_irqrestore(&xhci->lock, flags);			xhci_dbg(xhci, "suspend failed because "						"a port is resuming/n");			return -EBUSY;		}	}	port_index = max_ports;	bus_state->bus_suspended = 0;	while (port_index--) {		/* suspend the port if the port is not suspended */		u32 t1, t2;		int slot_id;		t1 = xhci_readl(xhci, port_array[port_index]);		t2 = xhci_port_state_to_neutral(t1);		if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {			xhci_dbg(xhci, "port %d not suspended/n", port_index);			slot_id = xhci_find_slot_id_by_port(hcd, xhci,					port_index + 1);			if (slot_id) {				spin_unlock_irqrestore(&xhci->lock, flags);				xhci_stop_device(xhci, slot_id, 1);				spin_lock_irqsave(&xhci->lock, flags);			}			t2 &= ~PORT_PLS_MASK;			t2 |= PORT_LINK_STROBE | XDEV_U3;			set_bit(port_index, &bus_state->bus_suspended);		}		/* USB core sets remote wake mask for USB 3.0 hubs,		 * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND		 * is enabled, so also enable remote wake here.		 */		if (hcd->self.root_hub->do_remote_wakeup) {			if (t1 & PORT_CONNECT) {				t2 |= PORT_WKOC_E | PORT_WKDISC_E;				t2 &= ~PORT_WKCONN_E;			} else {				t2 |= PORT_WKOC_E | PORT_WKCONN_E;				t2 &= ~PORT_WKDISC_E;			}		} else			t2 &= ~PORT_WAKE_BITS;		t1 = xhci_port_state_to_neutral(t1);		if (t1 != t2) {			xhci_writel(xhci, t2, port_array[port_index]);	}	hcd->state = HC_STATE_SUSPENDED;	bus_state->next_statechange = jiffies + msecs_to_jiffies(10);	spin_unlock_irqrestore(&xhci->lock, flags);	return 0;}int xhci_bus_resume(struct usb_hcd *hcd){	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports, port_index;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	u32 temp;	unsigned long flags;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	if (time_before(jiffies, bus_state->next_statechange))		msleep(5);	spin_lock_irqsave(&xhci->lock, flags);	if (!HCD_HW_ACCESSIBLE(hcd)) {		spin_unlock_irqrestore(&xhci->lock, flags);		return -ESHUTDOWN;	}	/* delay the irqs */	temp = xhci_readl(xhci, &xhci->op_regs->command);	temp &= ~CMD_EIE;	xhci_writel(xhci, temp, &xhci->op_regs->command);	port_index = max_ports;	while (port_index--) {		/* Check whether need resume ports. If needed		   resume port and disable remote wakeup *///.........这里部分代码省略.........
开发者ID:leezhenghui,项目名称:AGK-LOLLIPOP,代码行数:101,


示例13: admhc_hub_control

static int admhc_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,		u16 wIndex, char *buf, u16 wLength){	struct admhcd	*ahcd = hcd_to_admhcd(hcd);	int		ports = ahcd->num_ports;	int		ret = 0;	if (unlikely(!HCD_HW_ACCESSIBLE(hcd)))		return -ESHUTDOWN;	switch (typeReq) {	case ClearHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:#if 0			/* FIXME */			admhc_writel(ahcd, ADMHC_RH_OCIC,					&ahcd->regs->roothub.status);#endif		case C_HUB_LOCAL_POWER:			break;		default:			goto error;		}		break;	case ClearPortFeature:		if (!wIndex || wIndex > ports)			goto error;		wIndex--;		switch (wValue) {		case USB_PORT_FEAT_ENABLE:			ret = admhc_port_disable(ahcd, wIndex);			break;		case USB_PORT_FEAT_SUSPEND:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_CPS);			break;		case USB_PORT_FEAT_POWER:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_CPP);			break;		case USB_PORT_FEAT_C_CONNECTION:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_CSC);			break;		case USB_PORT_FEAT_C_ENABLE:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_PESC);			break;		case USB_PORT_FEAT_C_SUSPEND:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_PSSC);			break;		case USB_PORT_FEAT_C_OVER_CURRENT:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_OCIC);			break;		case USB_PORT_FEAT_C_RESET:			ret = admhc_port_write(ahcd, wIndex, ADMHC_PS_PRSC);			break;		default:			goto error;		}		break;	case GetHubDescriptor:		ret = admhc_get_hub_descriptor(ahcd, buf);		break;	case GetHubStatus:		ret = admhc_get_hub_status(ahcd, buf);		break;	case GetPortStatus:		if (!wIndex || wIndex > ports)			goto error;		wIndex--;		ret = admhc_get_port_status(ahcd, wIndex, buf);		break;	case SetHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:			/* FIXME:  this can be cleared, yes? */		case C_HUB_LOCAL_POWER:			break;		default:			goto error;		}		break;	case SetPortFeature:		if (!wIndex || wIndex > ports)			goto error;		wIndex--;		switch (wValue) {		case USB_PORT_FEAT_ENABLE:			ret = admhc_port_enable(ahcd, wIndex);			break;		case USB_PORT_FEAT_RESET:			ret = admhc_port_reset(ahcd, wIndex);			break;		case USB_PORT_FEAT_SUSPEND:#ifdef	CONFIG_USB_OTG			if (hcd->self.otg_port == (wIndex + 1)					&& hcd->self.b_hnp_enable)				start_hnp(ahcd);			else#endif//.........这里部分代码省略.........
开发者ID:020gzh,项目名称:openwrt-mirror,代码行数:101,


示例14: msm_ehci_bus_resume

static int msm_ehci_bus_resume(struct usb_hcd *hcd){	struct ehci_hcd		*ehci = hcd_to_ehci (hcd);	u32			temp;	u32			power_okay;	unsigned long		resume_needed = 0;	struct msm_hcd *mhcd = hcd_to_mhcd(hcd);	struct msm_usb_host_platform_data *pdata = mhcd->dev->platform_data;	if (mhcd->resume_gpio) 		gpio_direction_output(mhcd->resume_gpio, 1);		if(pdata && !pdata->sw_fpr_ctrl) {		ehci_bus_resume(hcd);	} else {		if (time_before (jiffies, ehci->next_statechange))			msleep(5);		spin_lock_irq (&ehci->lock);		if (!HCD_HW_ACCESSIBLE(hcd)) {			spin_unlock_irq(&ehci->lock);			return -ESHUTDOWN;		}		if (unlikely(ehci->debug)) {			if (!dbgp_reset_prep())				ehci->debug = NULL;			else				dbgp_external_startup();		}		/* Ideally and we've got a real resume here, and no port's power		 * was lost.  (For PCI, that means Vaux was maintained.)  But we		 * could instead be restoring a swsusp snapshot -- so that BIOS was		 * the last user of the controller, not reset/pm hardware keeping		 * state we gave to it.		 */		power_okay = ehci_readl(ehci, &ehci->regs->intr_enable);		ehci_dbg(ehci, "resume root hub%s/n",				power_okay ? "" : " after power loss");		/* at least some APM implementations will try to deliver		 * IRQs right away, so delay them until we're ready.		 */		ehci_writel(ehci, 0, &ehci->regs->intr_enable);		/* re-init operational registers */		ehci_writel(ehci, 0, &ehci->regs->segment);		ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);		ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);		/*CMD_RUN will be set after, PORT_RESUME gets cleared*/		if (ehci->resume_sof_bug){			temp = ehci_readl(ehci, &ehci->regs->port_status [0]);			if (temp & PORT_PE)				ehci->command &= ~CMD_RUN;		}		/* restore CMD_RUN, framelist size, and irq threshold */		ehci_writel(ehci, ehci->command, &ehci->regs->command);		ehci->rh_state = EHCI_RH_RUNNING;		temp = ehci_readl(ehci, &ehci->regs->port_status [0]);		temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);		if (test_bit(0, &ehci->bus_suspended) &&				(temp & PORT_SUSPEND)) {			temp |= PORT_RESUME;			set_bit(0, &resume_needed);		}		ehci_writel(ehci, temp, &ehci->regs->port_status [0]);				if (resume_needed && ehci->resume_sof_bug) {			spin_unlock_irq(&ehci->lock);			msleep(20);			spin_lock_irq(&ehci->lock);			temp = ehci_readl(ehci, &ehci->regs->port_status [0]);			temp &= ~(PORT_RWC_BITS | PORT_RESUME);			ehci_writel(ehci, temp, &ehci->regs->port_status [0]);			ehci_writel(ehci, ehci_readl(ehci,					&ehci->regs->command) | CMD_RUN,					&ehci->regs->command);			goto skip_clear_resume;				}		/* msleep for 20ms only if code is trying to resume port */		if (resume_needed) {			spin_unlock_irq(&ehci->lock);			msleep(20);			spin_lock_irq(&ehci->lock);		}		temp = ehci_readl(ehci, &ehci->regs->port_status [0]);		if (test_bit(0, &resume_needed)) {			temp &= ~(PORT_RWC_BITS | PORT_RESUME);			ehci_writel(ehci, temp, &ehci->regs->port_status [0]);//.........这里部分代码省略.........
开发者ID:upworkstar,项目名称:AndroidAmazon,代码行数:101,


示例15: xhci_urb_enqueue

/* * non-error returns are a promise to giveback() the urb later * we drop ownership so next owner (or urb unlink) can get it */int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags){	struct xhci_hcd *xhci = hcd_to_xhci(hcd);	struct xhci_td *buffer;	unsigned long flags;	int ret = 0;	unsigned int slot_id, ep_index;	struct urb_priv	*urb_priv;	int size, i;	if (!urb || xhci_check_args(hcd, urb->dev, urb->ep,					true, true, __func__) <= 0)		return -EINVAL;	slot_id = urb->dev->slot_id;	ep_index = xhci_get_endpoint_index(&urb->ep->desc);	if (!HCD_HW_ACCESSIBLE(hcd)) {		if (!in_interrupt())			xhci_dbg(xhci, "urb submitted during PCI suspend/n");		ret = -ESHUTDOWN;		goto exit;	}	if (usb_endpoint_xfer_isoc(&urb->ep->desc))		size = urb->number_of_packets;	else		size = 1;	urb_priv = kzalloc(sizeof(struct urb_priv) +				  size * sizeof(struct xhci_td *), mem_flags);	if (!urb_priv)		return -ENOMEM;	buffer = kzalloc(size * sizeof(struct xhci_td), mem_flags);	if (!buffer) {		kfree(urb_priv);		return -ENOMEM;	}	for (i = 0; i < size; i++) {		urb_priv->td[i] = buffer;		buffer++;	}	urb_priv->length = size;	urb_priv->td_cnt = 0;	urb->hcpriv = urb_priv;	if (usb_endpoint_xfer_control(&urb->ep->desc)) {		/* Check to see if the max packet size for the default control		 * endpoint changed during FS device enumeration		 */		if (urb->dev->speed == USB_SPEED_FULL) {			ret = xhci_check_maxpacket(xhci, slot_id,					ep_index, urb);			if (ret < 0) {				xhci_urb_free_priv(urb_priv);				urb->hcpriv = NULL;				return ret;			}		}		/* We have a spinlock and interrupts disabled, so we must pass		 * atomic context to this function, which may allocate memory.		 */		spin_lock_irqsave(&xhci->lock, flags);		if (xhci->xhc_state & XHCI_STATE_DYING)			goto dying;		ret = xhci_queue_ctrl_tx(xhci, GFP_ATOMIC, urb,				slot_id, ep_index);		if (ret)			goto free_priv;		spin_unlock_irqrestore(&xhci->lock, flags);	} else if (usb_endpoint_xfer_bulk(&urb->ep->desc)) {		spin_lock_irqsave(&xhci->lock, flags);		if (xhci->xhc_state & XHCI_STATE_DYING)			goto dying;		if (xhci->devs[slot_id]->eps[ep_index].ep_state &				EP_GETTING_STREAMS) {			xhci_warn(xhci, "WARN: Can't enqueue URB while bulk ep "					"is transitioning to using streams./n");			ret = -EINVAL;		} else if (xhci->devs[slot_id]->eps[ep_index].ep_state &				EP_GETTING_NO_STREAMS) {			xhci_warn(xhci, "WARN: Can't enqueue URB while bulk ep "					"is transitioning to "					"not having streams./n");			ret = -EINVAL;		} else {			ret = xhci_queue_bulk_tx(xhci, GFP_ATOMIC, urb,					slot_id, ep_index);		}		if (ret)			goto free_priv;		spin_unlock_irqrestore(&xhci->lock, flags);//.........这里部分代码省略.........
开发者ID:redareda9,项目名称:linux,代码行数:101,


示例16: uhci_hub_control

/* size of returned buffer is part of USB spec */static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,			u16 wIndex, char *buf, u16 wLength){	struct uhci_hcd *uhci = hcd_to_uhci(hcd);	int status, lstatus, retval = 0, len = 0;	unsigned int port = wIndex - 1;	unsigned long port_addr = USBPORTSC1 + 2 * port;	u16 wPortChange, wPortStatus;	unsigned long flags;	if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)		return -ETIMEDOUT;	spin_lock_irqsave(&uhci->lock, flags);	switch (typeReq) {	case GetHubStatus:		*(__le32 *)buf = cpu_to_le32(0);		OK(4);		/* hub power */	case GetPortStatus:		if (port >= uhci->rh_numports)			goto err;		uhci_check_ports(uhci);		status = uhci_readw(uhci, port_addr);		/* Intel controllers report the OverCurrent bit active on.		 * VIA controllers report it active off, so we'll adjust the		 * bit value.  (It's not standardized in the UHCI spec.)		 */		if (uhci->oc_low)			status ^= USBPORTSC_OC;		/* UHCI doesn't support C_RESET (always false) */		wPortChange = lstatus = 0;		if (status & USBPORTSC_CSC)			wPortChange |= USB_PORT_STAT_C_CONNECTION;		if (status & USBPORTSC_PEC)			wPortChange |= USB_PORT_STAT_C_ENABLE;		if ((status & USBPORTSC_OCC) && !ignore_oc)			wPortChange |= USB_PORT_STAT_C_OVERCURRENT;		if (test_bit(port, &uhci->port_c_suspend)) {			wPortChange |= USB_PORT_STAT_C_SUSPEND;			lstatus |= 1;		}		if (test_bit(port, &uhci->resuming_ports))			lstatus |= 4;		/* UHCI has no power switching (always on) */		wPortStatus = USB_PORT_STAT_POWER;		if (status & USBPORTSC_CCS)			wPortStatus |= USB_PORT_STAT_CONNECTION;		if (status & USBPORTSC_PE) {			wPortStatus |= USB_PORT_STAT_ENABLE;			if (status & SUSPEND_BITS)				wPortStatus |= USB_PORT_STAT_SUSPEND;		}		if (status & USBPORTSC_OC)			wPortStatus |= USB_PORT_STAT_OVERCURRENT;		if (status & USBPORTSC_PR)			wPortStatus |= USB_PORT_STAT_RESET;		if (status & USBPORTSC_LSDA)			wPortStatus |= USB_PORT_STAT_LOW_SPEED;		if (wPortChange)			dev_dbg(uhci_dev(uhci), "port %d portsc %04x,%02x/n",					wIndex, status, lstatus);		*(__le16 *)buf = cpu_to_le16(wPortStatus);		*(__le16 *)(buf + 2) = cpu_to_le16(wPortChange);		OK(4);	case SetHubFeature:		/* We don't implement these */	case ClearHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:		case C_HUB_LOCAL_POWER:			OK(0);		default:			goto err;		}		break;	case SetPortFeature:		if (port >= uhci->rh_numports)			goto err;		switch (wValue) {		case USB_PORT_FEAT_SUSPEND:			SET_RH_PORTSTAT(USBPORTSC_SUSP);			OK(0);		case USB_PORT_FEAT_RESET:			SET_RH_PORTSTAT(USBPORTSC_PR);			/* Reset terminates Resume signalling */			uhci_finish_suspend(uhci, port, port_addr);			/* USB v2.0 7.1.7.5 */			uhci->ports_timeout = jiffies + msecs_to_jiffies(50);			OK(0);//.........这里部分代码省略.........
开发者ID:404992361,项目名称:mi1_kernel,代码行数:101,


示例17: xhci_bus_resume

int xhci_bus_resume(struct usb_hcd *hcd){	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports, port_index;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	u32 temp;	unsigned long flags;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	if (time_before_eq(jiffies, bus_state->next_statechange))		usleep_range(10000, 11000);	spin_lock_irqsave(&xhci->lock, flags);	if (!HCD_HW_ACCESSIBLE(hcd)) {		spin_unlock_irqrestore(&xhci->lock, flags);		return -ESHUTDOWN;	}	/* delay the irqs */	temp = xhci_readl(xhci, &xhci->op_regs->command);	temp &= ~CMD_EIE;	xhci_writel(xhci, temp, &xhci->op_regs->command);	if ((xhci->quirks & XHCI_RESET_RS_ON_RESUME_QUIRK) &&			HC_IS_SUSPENDED(xhci->main_hcd->state) &&				HC_IS_SUSPENDED(xhci->shared_hcd->state)) {		xhci_halt(xhci);		if (!xhci_start(xhci))			xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;	}	port_index = max_ports;	while (port_index--) {		/* Check whether need resume ports. If needed		   resume port and disable remote wakeup */		u32 temp;		int slot_id;		temp = xhci_readl(xhci, port_array[port_index]);		if (DEV_SUPERSPEED(temp))			temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);		else			temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);		if (test_bit(port_index, &bus_state->bus_suspended) &&		    (temp & PORT_PLS_MASK)) {			if (DEV_SUPERSPEED(temp)) {				xhci_set_link_state(xhci, port_array,							port_index, XDEV_U0);			} else {				xhci_set_link_state(xhci, port_array,						port_index, XDEV_RESUME);				spin_unlock_irqrestore(&xhci->lock, flags);				usleep_range(20000, 21000);				spin_lock_irqsave(&xhci->lock, flags);				xhci_set_link_state(xhci, port_array,							port_index, XDEV_U0);			}			/* wait for the port to enter U0 and report port link			 * state change.			 */			spin_unlock_irqrestore(&xhci->lock, flags);			usleep_range(20000, 21000);			spin_lock_irqsave(&xhci->lock, flags);			/* Clear PLC */			xhci_test_and_clear_bit(xhci, port_array, port_index,						PORT_PLC);			slot_id = xhci_find_slot_id_by_port(hcd,					xhci, port_index + 1);			if (slot_id)				xhci_ring_device(xhci, slot_id);		} else {			xhci_writel(xhci, temp, port_array[port_index]);			if (xhci->quirks & XHCI_PORTSC_DELAY)				ndelay(100);		}		if (hcd->speed != HCD_USB3) {			/* disable remote wake up for USB 2.0 */			__le32 __iomem *addr;			u32 tmp;			/* Add one to the port status register address to get			 * the port power control register address.			 */			addr = port_array[port_index] + 1;			tmp = xhci_readl(xhci, addr);			tmp &= ~PORT_RWE;			xhci_writel(xhci, tmp, addr);			if (xhci->quirks & XHCI_PORTSC_DELAY)				ndelay(100);		}	}//.........这里部分代码省略.........
开发者ID:Pafcholini,项目名称:Beta_TW,代码行数:101,


示例18: uhci_hub_control

static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,			u16 wIndex, char *buf, u16 wLength){	struct uhci_hcd *uhci = hcd_to_uhci(hcd);	int status, lstatus, retval = 0, len = 0;	unsigned int port = wIndex - 1;	unsigned long port_addr = USBPORTSC1 + 2 * port;	u16 wPortChange, wPortStatus;	unsigned long flags;	if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)		return -ETIMEDOUT;	spin_lock_irqsave(&uhci->lock, flags);	switch (typeReq) {	case GetHubStatus:		*(__le32 *)buf = cpu_to_le32(0);		OK(4);			case GetPortStatus:		if (port >= uhci->rh_numports)			goto err;		uhci_check_ports(uhci);		status = uhci_readw(uhci, port_addr);		if (uhci->oc_low)			status ^= USBPORTSC_OC;				wPortChange = lstatus = 0;		if (status & USBPORTSC_CSC)			wPortChange |= USB_PORT_STAT_C_CONNECTION;		if (status & USBPORTSC_PEC)			wPortChange |= USB_PORT_STAT_C_ENABLE;		if ((status & USBPORTSC_OCC) && !ignore_oc)			wPortChange |= USB_PORT_STAT_C_OVERCURRENT;		if (test_bit(port, &uhci->port_c_suspend)) {			wPortChange |= USB_PORT_STAT_C_SUSPEND;			lstatus |= 1;		}		if (test_bit(port, &uhci->resuming_ports))			lstatus |= 4;				wPortStatus = USB_PORT_STAT_POWER;		if (status & USBPORTSC_CCS)			wPortStatus |= USB_PORT_STAT_CONNECTION;		if (status & USBPORTSC_PE) {			wPortStatus |= USB_PORT_STAT_ENABLE;			if (status & SUSPEND_BITS)				wPortStatus |= USB_PORT_STAT_SUSPEND;		}		if (status & USBPORTSC_OC)			wPortStatus |= USB_PORT_STAT_OVERCURRENT;		if (status & USBPORTSC_PR)			wPortStatus |= USB_PORT_STAT_RESET;		if (status & USBPORTSC_LSDA)			wPortStatus |= USB_PORT_STAT_LOW_SPEED;		if (wPortChange)			dev_dbg(uhci_dev(uhci), "port %d portsc %04x,%02x/n",					wIndex, status, lstatus);		*(__le16 *)buf = cpu_to_le16(wPortStatus);		*(__le16 *)(buf + 2) = cpu_to_le16(wPortChange);		OK(4);	case SetHubFeature:			case ClearHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:		case C_HUB_LOCAL_POWER:			OK(0);		default:			goto err;		}		break;	case SetPortFeature:		if (port >= uhci->rh_numports)			goto err;		switch (wValue) {		case USB_PORT_FEAT_SUSPEND:			SET_RH_PORTSTAT(USBPORTSC_SUSP);			OK(0);		case USB_PORT_FEAT_RESET:			SET_RH_PORTSTAT(USBPORTSC_PR);						uhci_finish_suspend(uhci, port, port_addr);						uhci->ports_timeout = jiffies + msecs_to_jiffies(50);			OK(0);		case USB_PORT_FEAT_POWER:						OK(0);		default:			goto err;//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,


示例19: musb_hub_control

int musb_hub_control(	struct usb_hcd	*hcd,	u16		typeReq,	u16		wValue,	u16		wIndex,	char		*buf,	u16		wLength){	struct musb	*musb = hcd_to_musb(hcd);	u32		temp;	int		retval = 0;	unsigned long	flags;	spin_lock_irqsave(&musb->lock, flags);	if (unlikely(!HCD_HW_ACCESSIBLE(hcd))) {		spin_unlock_irqrestore(&musb->lock, flags);		return -ESHUTDOWN;	}	/* hub features:  always zero, setting is a NOP	 * port features: reported, sometimes updated when host is active	 * no indicators	 */	switch (typeReq) {	case ClearHubFeature:	case SetHubFeature:		switch (wValue) {		case C_HUB_OVER_CURRENT:		case C_HUB_LOCAL_POWER:			break;		default:			goto error;		}		break;	case ClearPortFeature:		if ((wIndex & 0xff) != 1)			goto error;		switch (wValue) {		case USB_PORT_FEAT_ENABLE:			break;		case USB_PORT_FEAT_SUSPEND:			musb_port_suspend(musb, false);			break;		case USB_PORT_FEAT_POWER:			if (!hcd->self.is_b_host)				musb_platform_set_vbus(musb, 0);			break;		case USB_PORT_FEAT_C_CONNECTION:		case USB_PORT_FEAT_C_ENABLE:		case USB_PORT_FEAT_C_OVER_CURRENT:		case USB_PORT_FEAT_C_RESET:		case USB_PORT_FEAT_C_SUSPEND:			break;		default:			goto error;		}		dev_dbg(musb->controller, "clear feature %d/n", wValue);		musb->port1_status &= ~(1 << wValue);		break;	case GetHubDescriptor:		{		struct usb_hub_descriptor *desc = (void *)buf;		desc->bDescLength = 9;		desc->bDescriptorType = 0x29;		desc->bNbrPorts = 1;		desc->wHubCharacteristics = cpu_to_le16(				  0x0001	/* per-port power switching */				| 0x0010	/* no overcurrent reporting */				);		desc->bPwrOn2PwrGood = 5;	/* msec/2 */		desc->bHubContrCurrent = 0;		/* workaround bogus struct definition */		desc->u.hs.DeviceRemovable[0] = 0x02;	/* port 1 */		desc->u.hs.DeviceRemovable[1] = 0xff;		}		break;	case GetHubStatus:		temp = 0;		*(__le32 *) buf = cpu_to_le32(temp);		break;	case GetPortStatus:		if (wIndex != 1)			goto error;		put_unaligned(cpu_to_le32(musb->port1_status					& ~MUSB_PORT_STAT_RESUME),				(__le32 *) buf);		/* port change status is more interesting */		dev_dbg(musb->controller, "port status %08x/n",				musb->port1_status);		break;	case SetPortFeature:		if ((wIndex & 0xff) != 1)			goto error;//.........这里部分代码省略.........
开发者ID:jgroen,项目名称:rtt_tests,代码行数:101,


示例20: xhci_bus_resume

int xhci_bus_resume(struct usb_hcd *hcd){	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);	int max_ports, port_index;	__le32 __iomem **port_array;	struct xhci_bus_state *bus_state;	u32 temp;	unsigned long flags;	max_ports = xhci_get_ports(hcd, &port_array);	bus_state = &xhci->bus_state[hcd_index(hcd)];	if (time_before(jiffies, bus_state->next_statechange))		msleep(5);	spin_lock_irqsave(&xhci->lock, flags);	if (!HCD_HW_ACCESSIBLE(hcd)) {		spin_unlock_irqrestore(&xhci->lock, flags);		return -ESHUTDOWN;	}	/* delay the irqs */	temp = xhci_readl(xhci, &xhci->op_regs->command);	temp &= ~CMD_EIE;	xhci_writel(xhci, temp, &xhci->op_regs->command);	port_index = max_ports;	while (port_index--) {		/* Check whether need resume ports. If needed		   resume port and disable remote wakeup */		u32 temp;		int slot_id;		temp = xhci_readl(xhci, port_array[port_index]);		if (DEV_SUPERSPEED(temp))			temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);		else			temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);		if (test_bit(port_index, &bus_state->bus_suspended) &&		    (temp & PORT_PLS_MASK)) {			if (DEV_SUPERSPEED(temp)) {				xhci_set_link_state(xhci, port_array,							port_index, XDEV_U0);			} else {				xhci_set_link_state(xhci, port_array,						port_index, XDEV_RESUME);				/* need 1ms delay between access to USB2 PORTSC				 * and USB3 PORTSC to avoid Fabric Error.				 * */				mdelay(1);				spin_unlock_irqrestore(&xhci->lock, flags);				msleep(20);				spin_lock_irqsave(&xhci->lock, flags);				xhci_set_link_state(xhci, port_array,							port_index, XDEV_U0);			}			/* wait for the port to enter U0 and report port link			 * state change.			 */			spin_unlock_irqrestore(&xhci->lock, flags);			msleep(20);			spin_lock_irqsave(&xhci->lock, flags);			/* Clear PLC */			xhci_test_and_clear_bit(xhci, port_array, port_index,						PORT_PLC);			slot_id = xhci_find_slot_id_by_port(hcd,					xhci, port_index + 1);			if (slot_id)				xhci_ring_device(xhci, slot_id);		} else			xhci_writel(xhci, temp, port_array[port_index]);	}	(void) xhci_readl(xhci, &xhci->op_regs->command);	/* This is for wakeup IRQ case. For USB3 remote wakeup for S3 case,	 * the wakeup IRQ get immediately which before HCD set accessiable.	 * So the IRQ be disabled in usb_hcd_irq. For S3 case, after bus	 * resume done, the kernel will call their children directly. This	 * will cause children driver resume called before hcd_resume_work.	 *	 * The USB device corresponding port only be resume to U0/Enabled	 * state during xhci driver handle port change event. So this gap	 * will cause port haven't resumed when matched usb driver resume	 * callback be called. It will cause usb core try to disconnect the	 * usb device and cause some unexpected behavior.	 *	 * So we need to enable IRQ immediately at the end of bus_resume to	 * prevent above gap.	 **/	if (HCD_IRQ_DISABLED(hcd) && hcd->has_wakeup_irq) {		clear_bit(HCD_FLAG_IRQ_DISABLED, &hcd->flags);		enable_irq(hcd->irq);	}	bus_state->next_statechange = jiffies + msecs_to_jiffies(5);//.........这里部分代码省略.........
开发者ID:BitOBSessiOn,项目名称:android_kernel_asus_P01M,代码行数:101,



注:本文中的HCD_HW_ACCESSIBLE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ HCD_IsDeviceConnected函数代码示例
C++ HB_SYMBOL_UNUSED函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。