Ejemplo n.º 1
0
Archivo: ltp_tpci.c Proyecto: 1587/ltp
static int pci_disable(void)
{
	struct pci_dev *dev = ltp_pci.dev;

	prk_info("disable pci device");

	/* check if device pointer exists */
	if (!dev) {
		prk_err("dev is NULL");
		return TFAIL;
	}

	prk_info("is pci enabled '%d', is managed '%d'",
		pci_is_enabled(dev), pci_is_managed(dev));

	pci_release_regions(dev);
	pci_disable_device(dev);

	if (dev->current_state == PCI_D3hot ||
		dev->current_state == PCI_D3cold) {

		prk_info("disabled pci device, state '%s'",
			pci_power_name(dev->current_state));
		return TPASS;

	}

	prk_err("failed to disable pci device, state '%s'",
		pci_power_name(dev->current_state));
	return TFAIL;
}
Ejemplo n.º 2
0
static int hcd_pci_suspend_noirq(struct device *dev)
{
	struct pci_dev		*pci_dev = to_pci_dev(dev);
	struct usb_hcd		*hcd = pci_get_drvdata(pci_dev);
	int			retval;

	retval = check_root_hub_suspended(dev);
	if (retval)
		return retval;

	pci_save_state(pci_dev);

	/* If the root hub is HALTed rather than SUSPENDed,
	 * disallow remote wakeup.
	 */
	if (hcd->state == HC_STATE_HALT)
		device_set_wakeup_enable(dev, 0);
	dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));

	/* Possibly enable remote wakeup,
	 * choose the appropriate low-power state, and go to that state.
	 */
	retval = pci_prepare_to_sleep(pci_dev);
	if (retval == -EIO) {		/* Low-power not supported */
		dev_dbg(dev, "--> PCI D0 legacy\n");
		retval = 0;
	} else if (retval == 0) {
		dev_dbg(dev, "--> PCI %s\n",
				pci_power_name(pci_dev->current_state));
	} else {
		suspend_report_result(pci_prepare_to_sleep, retval);
		return retval;
	}

#ifdef CONFIG_PPC_PMAC
	/* Disable ASIC clocks for USB */
	if (machine_is(powermac)) {
		struct device_node	*of_node;

		of_node = pci_device_to_OF_node(pci_dev);
		if (of_node)
			pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
	}
#endif
	return retval;
}