linux/drivers/usb/core/hcd-pci.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * (C) Copyright David Brownell 2000-2002
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>

#include <asm/io.h>
#include <asm/irq.h>

#ifdef CONFIG_PPC_PMAC
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#endif

#include "usb.h"


/* PCI-based HCs are common, but plenty of non-PCI HCs are used too */

/*
 * Coordinate handoffs between EHCI and companion controllers
 * during EHCI probing and system resume.
 */

static DECLARE_RWSEM(companions_rwsem);

#define CL_UHCI
#define CL_OHCI
#define CL_EHCI

static inline int is_ohci_or_uhci(struct pci_dev *pdev)
{}

companion_fn;

/* Iterate over PCI devices in the same slot as pdev and call fn for each */
static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
		companion_fn fn)
{}

/*
 * We're about to add an EHCI controller, which will unceremoniously grab
 * all the port connections away from its companions.  To prevent annoying
 * error messages, lock the companion's root hub and gracefully unconfigure
 * it beforehand.  Leave it locked until the EHCI controller is all set.
 */
static void ehci_pre_add(struct pci_dev *pdev, struct usb_hcd *hcd,
		struct pci_dev *companion, struct usb_hcd *companion_hcd)
{}

/*
 * Adding the EHCI controller has either succeeded or failed.  Set the
 * companion pointer accordingly, and in either case, reconfigure and
 * unlock the root hub.
 */
static void ehci_post_add(struct pci_dev *pdev, struct usb_hcd *hcd,
		struct pci_dev *companion, struct usb_hcd *companion_hcd)
{}

/*
 * We just added a non-EHCI controller.  Find the EHCI controller to
 * which it is a companion, and store a pointer to the bus structure.
 */
static void non_ehci_add(struct pci_dev *pdev, struct usb_hcd *hcd,
		struct pci_dev *companion, struct usb_hcd *companion_hcd)
{}

/* We are removing an EHCI controller.  Clear the companions' pointers. */
static void ehci_remove(struct pci_dev *pdev, struct usb_hcd *hcd,
		struct pci_dev *companion, struct usb_hcd *companion_hcd)
{}

#ifdef	CONFIG_PM

/* An EHCI controller must wait for its companions before resuming. */
static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
		struct pci_dev *companion, struct usb_hcd *companion_hcd)
{}

#endif	/* CONFIG_PM */

/*-------------------------------------------------------------------------*/

/* configure so an HC device and id are always provided */
/* always called with process context; sleeping is OK */

/**
 * usb_hcd_pci_probe - initialize PCI-based HCDs
 * @dev: USB Host Controller being probed
 * @driver: USB HC driver handle
 *
 * Context: task context, might sleep
 *
 * Allocates basic PCI resources for this USB host controller, and
 * then invokes the start() method for the HCD associated with it
 * through the hotplug entry's driver_data.
 *
 * Store this function in the HCD's struct pci_driver as probe().
 *
 * Return: 0 if successful.
 */
int usb_hcd_pci_probe(struct pci_dev *dev, const struct hc_driver *driver)
{}
EXPORT_SYMBOL_GPL();


/* may be called without controller electrically present */
/* may be called with controller, bus, and devices active */

/**
 * usb_hcd_pci_remove - shutdown processing for PCI-based HCDs
 * @dev: USB Host Controller being removed
 *
 * Context: task context, might sleep
 *
 * Reverses the effect of usb_hcd_pci_probe(), first invoking
 * the HCD's stop() method.  It is always called from a thread
 * context, normally "rmmod", "apmd", or something similar.
 *
 * Store this function in the HCD's struct pci_driver as remove().
 */
void usb_hcd_pci_remove(struct pci_dev *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_hcd_pci_shutdown - shutdown host controller
 * @dev: USB Host Controller being shutdown
 */
void usb_hcd_pci_shutdown(struct pci_dev *dev)
{}
EXPORT_SYMBOL_GPL();

#ifdef	CONFIG_PM

#ifdef	CONFIG_PPC_PMAC
static void powermac_set_asic(struct pci_dev *pci_dev, int enable)
{
	/* Enanble or 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, enable);
	}
}

#else

static inline void powermac_set_asic(struct pci_dev *pci_dev, int enable)
{}

#endif	/* CONFIG_PPC_PMAC */

static int check_root_hub_suspended(struct device *dev)
{}

static int suspend_common(struct device *dev, pm_message_t msg)
{}

static int resume_common(struct device *dev, pm_message_t msg)
{}

#ifdef	CONFIG_PM_SLEEP

static int hcd_pci_suspend(struct device *dev)
{}

static int hcd_pci_suspend_noirq(struct device *dev)
{}

static int hcd_pci_poweroff_late(struct device *dev)
{}

static int hcd_pci_resume_noirq(struct device *dev)
{}

static int hcd_pci_resume(struct device *dev)
{}

static int hcd_pci_restore(struct device *dev)
{}

#else

#define hcd_pci_suspend
#define hcd_pci_suspend_noirq
#define hcd_pci_poweroff_late
#define hcd_pci_resume_noirq
#define hcd_pci_resume
#define hcd_pci_restore

#endif	/* CONFIG_PM_SLEEP */

static int hcd_pci_runtime_suspend(struct device *dev)
{}

static int hcd_pci_runtime_resume(struct device *dev)
{}

const struct dev_pm_ops usb_hcd_pci_pm_ops =;
EXPORT_SYMBOL_GPL();

#endif	/* CONFIG_PM */