linux/drivers/usb/chipidea/core.c

// SPDX-License-Identifier: GPL-2.0
/*
 * core.c - ChipIdea USB IP core family device controller
 *
 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
 * Copyright (C) 2020 NXP
 *
 * Author: David Lopo
 *	   Peter Chen <[email protected]>
 *
 * Main Features:
 * - Four transfers are supported, usbtest is passed
 * - USB Certification for gadget: CH9 and Mass Storage are passed
 * - Low power mode
 * - USB wakeup
 */
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/extcon.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/idr.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/consumer.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/usb/otg.h>
#include <linux/usb/chipidea.h>
#include <linux/usb/of.h>
#include <linux/of.h>
#include <linux/regulator/consumer.h>
#include <linux/usb/ehci_def.h>

#include "ci.h"
#include "udc.h"
#include "bits.h"
#include "host.h"
#include "otg.h"
#include "otg_fsm.h"

/* Controller register map */
static const u8 ci_regs_nolpm[] =;

static const u8 ci_regs_lpm[] =;

static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
{}

static enum ci_revision ci_get_revision(struct ci_hdrc *ci)
{}

/**
 * hw_read_intr_enable: returns interrupt enable register
 *
 * @ci: the controller
 *
 * This function returns register data
 */
u32 hw_read_intr_enable(struct ci_hdrc *ci)
{}

/**
 * hw_read_intr_status: returns interrupt status register
 *
 * @ci: the controller
 *
 * This function returns register data
 */
u32 hw_read_intr_status(struct ci_hdrc *ci)
{}

/**
 * hw_port_test_set: writes port test mode (execute without interruption)
 * @ci: the controller
 * @mode: new value
 *
 * This function returns an error code
 */
int hw_port_test_set(struct ci_hdrc *ci, u8 mode)
{}

/**
 * hw_port_test_get: reads port test mode value
 *
 * @ci: the controller
 *
 * This function returns port test mode value
 */
u8 hw_port_test_get(struct ci_hdrc *ci)
{}

static void hw_wait_phy_stable(void)
{}

/* The PHY enters/leaves low power mode */
static void ci_hdrc_enter_lpm_common(struct ci_hdrc *ci, bool enable)
{}

static void ci_hdrc_enter_lpm(struct ci_hdrc *ci, bool enable)
{}

static int hw_device_init(struct ci_hdrc *ci, void __iomem *base)
{}

void hw_phymode_configure(struct ci_hdrc *ci)
{}
EXPORT_SYMBOL_GPL();

/**
 * _ci_usb_phy_init: initialize phy taking in account both phy and usb_phy
 * interfaces
 * @ci: the controller
 *
 * This function returns an error code if the phy failed to init
 */
static int _ci_usb_phy_init(struct ci_hdrc *ci)
{}

/**
 * ci_usb_phy_exit: deinitialize phy taking in account both phy and usb_phy
 * interfaces
 * @ci: the controller
 */
static void ci_usb_phy_exit(struct ci_hdrc *ci)
{}

/**
 * ci_usb_phy_init: initialize phy according to different phy type
 * @ci: the controller
 *
 * This function returns an error code if usb_phy_init has failed
 */
static int ci_usb_phy_init(struct ci_hdrc *ci)
{}


/**
 * ci_platform_configure: do controller configure
 * @ci: the controller
 *
 */
void ci_platform_configure(struct ci_hdrc *ci)
{}

/**
 * hw_controller_reset: do controller reset
 * @ci: the controller
  *
 * This function returns an error code
 */
static int hw_controller_reset(struct ci_hdrc *ci)
{}

/**
 * hw_device_reset: resets chip (execute without interruption)
 * @ci: the controller
 *
 * This function returns an error code
 */
int hw_device_reset(struct ci_hdrc *ci)
{}

static irqreturn_t ci_irq_handler(int irq, void *data)
{}

static void ci_irq(struct ci_hdrc *ci)
{}

static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
			     void *ptr)
{}

static enum usb_role ci_usb_role_switch_get(struct usb_role_switch *sw)
{}

static int ci_usb_role_switch_set(struct usb_role_switch *sw,
				  enum usb_role role)
{}

static enum ci_role ci_get_role(struct ci_hdrc *ci)
{}

static struct usb_role_switch_desc ci_role_switch =;

static int ci_get_platdata(struct device *dev,
		struct ci_hdrc_platform_data *platdata)
{}

static int ci_extcon_register(struct ci_hdrc *ci)
{}

static void ci_power_lost_work(struct work_struct *work)
{}

static DEFINE_IDA(ci_ida);

struct platform_device *ci_hdrc_add_device(struct device *dev,
			struct resource *res, int nres,
			struct ci_hdrc_platform_data *platdata)
{}
EXPORT_SYMBOL_GPL();

void ci_hdrc_remove_device(struct platform_device *pdev)
{}
EXPORT_SYMBOL_GPL();

/**
 * ci_hdrc_query_available_role: get runtime available operation mode
 *
 * The glue layer can get current operation mode (host/peripheral/otg)
 * This function should be called after ci core device has created.
 *
 * @pdev: the platform device of ci core.
 *
 * Return runtime usb_dr_mode.
 */
enum usb_dr_mode ci_hdrc_query_available_role(struct platform_device *pdev)
{}
EXPORT_SYMBOL_GPL();

static inline void ci_role_destroy(struct ci_hdrc *ci)
{}

static void ci_get_otg_capable(struct ci_hdrc *ci)
{}

static ssize_t role_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}

static ssize_t role_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t n)
{}
static DEVICE_ATTR_RW(role);

static struct attribute *ci_attrs[] =;
ATTRIBUTE_GROUPS();

static int ci_hdrc_probe(struct platform_device *pdev)
{}

static void ci_hdrc_remove(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
/* Prepare wakeup by SRP before suspend */
static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci)
{}

/* Handle SRP when wakeup by data pulse */
static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci)
{}

static void ci_controller_suspend(struct ci_hdrc *ci)
{}

/*
 * Handle the wakeup interrupt triggered by extcon connector
 * We need to call ci_irq again for extcon since the first
 * interrupt (wakeup int) only let the controller be out of
 * low power mode, but not handle any interrupts.
 */
static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
{}

static int ci_controller_resume(struct device *dev)
{}

#ifdef CONFIG_PM_SLEEP
static int ci_suspend(struct device *dev)
{}

static int ci_resume(struct device *dev)
{}
#endif /* CONFIG_PM_SLEEP */

static int ci_runtime_suspend(struct device *dev)
{}

static int ci_runtime_resume(struct device *dev)
{}

#endif /* CONFIG_PM */
static const struct dev_pm_ops ci_pm_ops =;

static struct platform_driver ci_hdrc_driver =;

static int __init ci_hdrc_platform_register(void)
{}
module_init();

static void __exit ci_hdrc_platform_unregister(void)
{}
module_exit(ci_hdrc_platform_unregister);

MODULE_ALIAS();
MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();