linux/drivers/usb/chipidea/otg_fsm.c

// SPDX-License-Identifier: GPL-2.0
/*
 * otg_fsm.c - ChipIdea USB IP core OTG FSM driver
 *
 * Copyright (C) 2014 Freescale Semiconductor, Inc.
 *
 * Author: Jun Li
 */

/*
 * This file mainly handles OTG fsm, it includes OTG fsm operations
 * for HNP and SRP.
 *
 * TODO List
 * - ADP
 * - OTG test device
 */

#include <linux/usb/otg.h>
#include <linux/usb/gadget.h>
#include <linux/usb/hcd.h>
#include <linux/usb/chipidea.h>
#include <linux/regulator/consumer.h>

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

/* Add for otg: interact with user space app */
static ssize_t
a_bus_req_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

static ssize_t
a_bus_req_store(struct device *dev, struct device_attribute *attr,
					const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(a_bus_req);

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

static ssize_t
a_bus_drop_store(struct device *dev, struct device_attribute *attr,
					const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(a_bus_drop);

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

static ssize_t
b_bus_req_store(struct device *dev, struct device_attribute *attr,
					const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(b_bus_req);

static ssize_t
a_clr_err_store(struct device *dev, struct device_attribute *attr,
					const char *buf, size_t count)
{}
static DEVICE_ATTR_WO(a_clr_err);

static struct attribute *inputs_attrs[] =;

static const struct attribute_group inputs_attr_group =;

/*
 * Keep this list in the same order as timers indexed
 * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h
 */
static unsigned otg_timer_ms[] =;

/*
 * Add timer to active timer list
 */
static void ci_otg_add_timer(struct ci_hdrc *ci, enum otg_fsm_timer t)
{}

/*
 * Remove timer from active timer list
 */
static void ci_otg_del_timer(struct ci_hdrc *ci, enum otg_fsm_timer t)
{}

/* OTG FSM timer handlers */
static int a_wait_vrise_tmout(struct ci_hdrc *ci)
{}

static int a_wait_vfall_tmout(struct ci_hdrc *ci)
{}

static int a_wait_bcon_tmout(struct ci_hdrc *ci)
{}

static int a_aidl_bdis_tmout(struct ci_hdrc *ci)
{}

static int b_ase0_brst_tmout(struct ci_hdrc *ci)
{}

static int a_bidl_adis_tmout(struct ci_hdrc *ci)
{}

static int b_aidl_bdis_tmout(struct ci_hdrc *ci)
{}

static int b_se0_srp_tmout(struct ci_hdrc *ci)
{}

static int b_srp_fail_tmout(struct ci_hdrc *ci)
{}

static int b_data_pls_tmout(struct ci_hdrc *ci)
{}

static int b_ssend_srp_tmout(struct ci_hdrc *ci)
{}

/*
 * Keep this list in the same order as timers indexed
 * by enum otg_fsm_timer in include/linux/usb/otg-fsm.h
 */
static int (*otg_timer_handlers[])(struct ci_hdrc *) =;

/*
 * Enable the next nearest enabled timer if have
 */
static enum hrtimer_restart ci_otg_hrtimer_func(struct hrtimer *t)
{}

/* Initialize timers */
static int ci_otg_init_timers(struct ci_hdrc *ci)
{}

/* -------------------------------------------------------------*/
/* Operations that will be called from OTG Finite State Machine */
/* -------------------------------------------------------------*/
static void ci_otg_fsm_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
{}

static void ci_otg_fsm_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer t)
{}

/*
 * A-device drive vbus: turn on vbus regulator and enable port power
 * Data pulse irq should be disabled while vbus is on.
 */
static void ci_otg_drv_vbus(struct otg_fsm *fsm, int on)
{}

/*
 * Control data line by Run Stop bit.
 */
static void ci_otg_loc_conn(struct otg_fsm *fsm, int on)
{}

/*
 * Generate SOF by host.
 * In host mode, controller will automatically send SOF.
 * Suspend will block the data on the port.
 *
 * This is controlled through usbcore by usb autosuspend,
 * so the usb device class driver need support autosuspend,
 * otherwise the bus suspend will not happen.
 */
static void ci_otg_loc_sof(struct otg_fsm *fsm, int on)
{}

/*
 * Start SRP pulsing by data-line pulsing,
 * no v-bus pulsing followed
 */
static void ci_otg_start_pulse(struct otg_fsm *fsm)
{}

static int ci_otg_start_host(struct otg_fsm *fsm, int on)
{}

static int ci_otg_start_gadget(struct otg_fsm *fsm, int on)
{}

static struct otg_fsm_ops ci_otg_ops =;

int ci_otg_fsm_work(struct ci_hdrc *ci)
{}

/*
 * Update fsm variables in each state if catching expected interrupts,
 * called by otg fsm isr.
 */
static void ci_otg_fsm_event(struct ci_hdrc *ci)
{}

/*
 * ci_otg_irq - otg fsm related irq handling
 * and also update otg fsm variable by monitoring usb host and udc
 * state change interrupts.
 * @ci: ci_hdrc
 */
irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
{}

void ci_hdrc_otg_fsm_start(struct ci_hdrc *ci)
{}

int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
{}

void ci_hdrc_otg_fsm_remove(struct ci_hdrc *ci)
{}