// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) /* * platform.c - DesignWare HS OTG Controller platform driver * * Copyright (C) Matthijs Kooijman <[email protected]> */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/clk.h> #include <linux/device.h> #include <linux/dma-mapping.h> #include <linux/of.h> #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/phy/phy.h> #include <linux/platform_data/s3c-hsotg.h> #include <linux/reset.h> #include <linux/usb/of.h> #include "core.h" #include "hcd.h" #include "debug.h" static const char dwc2_driver_name[] = …; /* * Check the dr_mode against the module configuration and hardware * capabilities. * * The hardware, module, and dr_mode, can each be set to host, device, * or otg. Check that all these values are compatible and adjust the * value of dr_mode if possible. * * actual * HW MOD dr_mode dr_mode * ------------------------------ * HST HST any : HST * HST DEV any : --- * HST OTG any : HST * * DEV HST any : --- * DEV DEV any : DEV * DEV OTG any : DEV * * OTG HST any : HST * OTG DEV any : DEV * OTG OTG any : dr_mode */ static int dwc2_get_dr_mode(struct dwc2_hsotg *hsotg) { … } static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) { … } /** * dwc2_lowlevel_hw_enable - enable platform lowlevel hw resources * @hsotg: The driver state * * A wrapper for platform code responsible for controlling * low-level USB platform resources (phy, clock, regulators) */ int dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) { … } static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg) { … } /** * dwc2_lowlevel_hw_disable - disable platform lowlevel hw resources * @hsotg: The driver state * * A wrapper for platform code responsible for controlling * low-level USB platform resources (phy, clock, regulators) */ int dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg) { … } static void dwc2_reset_control_assert(void *data) { … } static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) { … } /** * dwc2_driver_remove() - Called when the DWC_otg core is unregistered with the * DWC_otg driver * * @dev: Platform device * * This routine is called, for example, when the rmmod command is executed. The * device may or may not be electrically present. If it is present, the driver * stops device processing. Any resources used on behalf of this device are * freed. */ static void dwc2_driver_remove(struct platform_device *dev) { … } /** * dwc2_driver_shutdown() - Called on device shutdown * * @dev: Platform device * * In specific conditions (involving usb hubs) dwc2 devices can create a * lot of interrupts, even to the point of overwhelming devices running * at low frequencies. Some devices need to do special clock handling * at shutdown-time which may bring the system clock below the threshold * of being able to handle the dwc2 interrupts. Disabling dwc2-irqs * prevents reboots/poweroffs from getting stuck in such cases. */ static void dwc2_driver_shutdown(struct platform_device *dev) { … } /** * dwc2_check_core_endianness() - Returns true if core and AHB have * opposite endianness. * @hsotg: Programming view of the DWC_otg controller. */ static bool dwc2_check_core_endianness(struct dwc2_hsotg *hsotg) { … } /** * dwc2_check_core_version() - Check core version * * @hsotg: Programming view of the DWC_otg controller * */ int dwc2_check_core_version(struct dwc2_hsotg *hsotg) { … } /** * dwc2_driver_probe() - Called when the DWC_otg core is bound to the DWC_otg * driver * * @dev: Platform device * * This routine creates the driver components required to control the device * (core, HCD, and PCD) and initializes the device. The driver components are * stored in a dwc2_hsotg structure. A reference to the dwc2_hsotg is saved * in the device private data. This allows the driver to access the dwc2_hsotg * structure on subsequent calls to driver methods for this device. */ static int dwc2_driver_probe(struct platform_device *dev) { … } static int __maybe_unused dwc2_suspend(struct device *dev) { … } static int __maybe_unused dwc2_resume(struct device *dev) { … } static const struct dev_pm_ops dwc2_dev_pm_ops = …; static struct platform_driver dwc2_platform_driver = …; module_platform_driver(…) …;