linux/drivers/usb/gadget/udc/net2272.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Driver for PLX NET2272 USB device controller
 *
 * Copyright (C) 2005-2006 PLX Technology, Inc.
 * Copyright (C) 2006-2011 Analog Devices, Inc.
 */

#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/prefetch.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>

#include <asm/byteorder.h>
#include <asm/unaligned.h>

#include "net2272.h"

#define DRIVER_DESC

static const char driver_name[] =;
static const char driver_vers[] =;
static const char driver_desc[] =;

static const char ep0name[] =;
static const char * const ep_name[] =;

#ifdef CONFIG_USB_NET2272_DMA
/*
 * use_dma: the NET2272 can use an external DMA controller.
 * Note that since there is no generic DMA api, some functions,
 * notably request_dma, start_dma, and cancel_dma will need to be
 * modified for your platform's particular dma controller.
 *
 * If use_dma is disabled, pio will be used instead.
 */
static bool use_dma =;
module_param(use_dma, bool, 0644);

/*
 * dma_ep: selects the endpoint for use with dma (1=ep-a, 2=ep-b)
 * The NET2272 can only use dma for a single endpoint at a time.
 * At some point this could be modified to allow either endpoint
 * to take control of dma as it becomes available.
 *
 * Note that DMA should not be used on OUT endpoints unless it can
 * be guaranteed that no short packets will arrive on an IN endpoint
 * while the DMA operation is pending.  Otherwise the OUT DMA will
 * terminate prematurely (See NET2272 Errata 630-0213-0101)
 */
static ushort dma_ep =;
module_param(dma_ep, ushort, 0644);

/*
 * dma_mode: net2272 dma mode setting (see LOCCTL1 definition):
 *	mode 0 == Slow DREQ mode
 *	mode 1 == Fast DREQ mode
 *	mode 2 == Burst mode
 */
static ushort dma_mode =;
module_param(dma_mode, ushort, 0644);
#else
#define use_dma
#define dma_ep
#define dma_mode
#endif

/*
 * fifo_mode: net2272 buffer configuration:
 *      mode 0 == ep-{a,b,c} 512db each
 *      mode 1 == ep-a 1k, ep-{b,c} 512db
 *      mode 2 == ep-a 1k, ep-b 1k, ep-c 512db
 *      mode 3 == ep-a 1k, ep-b disabled, ep-c 512db
 */
static ushort fifo_mode;
module_param(fifo_mode, ushort, 0644);

/*
 * enable_suspend: When enabled, the driver will respond to
 * USB suspend requests by powering down the NET2272.  Otherwise,
 * USB suspend requests will be ignored.  This is acceptable for
 * self-powered devices.  For bus powered devices set this to 1.
 */
static ushort enable_suspend;
module_param(enable_suspend, ushort, 0644);

static void assert_out_naking(struct net2272_ep *ep, const char *where)
{}
#define ASSERT_OUT_NAKING(ep)

static void stop_out_naking(struct net2272_ep *ep)
{}

#define PIPEDIR(bAddress)

static char *type_string(u8 bmAttributes)
{}

static char *buf_state_string(unsigned state)
{}

static char *dma_mode_string(void)
{}

static void net2272_dequeue_all(struct net2272_ep *);
static int net2272_kick_dma(struct net2272_ep *, struct net2272_request *);
static int net2272_fifo_status(struct usb_ep *);

static const struct usb_ep_ops net2272_ep_ops;

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

static int
net2272_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
{}

static void net2272_ep_reset(struct net2272_ep *ep)
{}

static int net2272_disable(struct usb_ep *_ep)
{}

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

static struct usb_request *
net2272_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
{}

static void
net2272_free_request(struct usb_ep *_ep, struct usb_request *_req)
{}

static void
net2272_done(struct net2272_ep *ep, struct net2272_request *req, int status)
{}

static int
net2272_write_packet(struct net2272_ep *ep, u8 *buf,
	struct net2272_request *req, unsigned max)
{}

/* returns: 0: still running, 1: completed, negative: errno */
static int
net2272_write_fifo(struct net2272_ep *ep, struct net2272_request *req)
{}

static void
net2272_out_flush(struct net2272_ep *ep)
{}

static int
net2272_read_packet(struct net2272_ep *ep, u8 *buf,
	struct net2272_request *req, unsigned avail)
{}

static int
net2272_read_fifo(struct net2272_ep *ep, struct net2272_request *req)
{}

static void
net2272_pio_advance(struct net2272_ep *ep)
{}

/* returns 0 on success, else negative errno */
static int
net2272_request_dma(struct net2272 *dev, unsigned ep, u32 buf,
	unsigned len, unsigned dir)
{}

static void
net2272_start_dma(struct net2272 *dev)
{}

/* returns 0 on success, else negative errno */
static int
net2272_kick_dma(struct net2272_ep *ep, struct net2272_request *req)
{}

static void net2272_cancel_dma(struct net2272 *dev)
{}

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

static int
net2272_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
{}

/* dequeue ALL requests */
static void
net2272_dequeue_all(struct net2272_ep *ep)
{}

/* dequeue JUST ONE request */
static int
net2272_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{}

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

static int
net2272_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged)
{}

static int
net2272_set_halt(struct usb_ep *_ep, int value)
{}

static int
net2272_set_wedge(struct usb_ep *_ep)
{}

static int
net2272_fifo_status(struct usb_ep *_ep)
{}

static void
net2272_fifo_flush(struct usb_ep *_ep)
{}

static const struct usb_ep_ops net2272_ep_ops =;

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

static int
net2272_get_frame(struct usb_gadget *_gadget)
{}

static int
net2272_wakeup(struct usb_gadget *_gadget)
{}

static int
net2272_set_selfpowered(struct usb_gadget *_gadget, int value)
{}

static int
net2272_pullup(struct usb_gadget *_gadget, int is_on)
{}

static int net2272_start(struct usb_gadget *_gadget,
		struct usb_gadget_driver *driver);
static int net2272_stop(struct usb_gadget *_gadget);
static void net2272_async_callbacks(struct usb_gadget *_gadget, bool enable);

static const struct usb_gadget_ops net2272_ops =;

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

static ssize_t
registers_show(struct device *_dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(registers);

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

static void
net2272_set_fifo_mode(struct net2272 *dev, int mode)
{}

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

static void
net2272_usb_reset(struct net2272 *dev)
{}

static void
net2272_usb_reinit(struct net2272 *dev)
{}

static void
net2272_ep0_start(struct net2272 *dev)
{}

/* when a driver is successfully registered, it will receive
 * control requests including set_configuration(), which enables
 * non-control requests.  then usb traffic follows until a
 * disconnect is reported.  then a host may connect again, or
 * the driver might get unbound.
 */
static int net2272_start(struct usb_gadget *_gadget,
		struct usb_gadget_driver *driver)
{}

static void
stop_activity(struct net2272 *dev, struct usb_gadget_driver *driver)
{}

static int net2272_stop(struct usb_gadget *_gadget)
{}

static void net2272_async_callbacks(struct usb_gadget *_gadget, bool enable)
{}

/*---------------------------------------------------------------------------*/
/* handle ep-a/ep-b dma completions */
static void
net2272_handle_dma(struct net2272_ep *ep)
{}

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

static void
net2272_handle_ep(struct net2272_ep *ep)
{}

static struct net2272_ep *
net2272_get_ep_by_addr(struct net2272 *dev, u16 wIndex)
{}

/*
 * USB Test Packet:
 * JKJKJKJK * 9
 * JJKKJJKK * 8
 * JJJJKKKK * 8
 * JJJJJJJKKKKKKK * 8
 * JJJJJJJK * 8
 * {JKKKKKKK * 10}, JK
 */
static const u8 net2272_test_packet[] =;

static void
net2272_set_test_mode(struct net2272 *dev, int mode)
{}

static void
net2272_handle_stat0_irqs(struct net2272 *dev, u8 stat)
{}

static void
net2272_handle_stat1_irqs(struct net2272 *dev, u8 stat)
{}

static irqreturn_t net2272_irq(int irq, void *_dev)
{}

static int net2272_present(struct net2272 *dev)
{}

static void
net2272_gadget_release(struct device *_dev)
{}

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

static void
net2272_remove(struct net2272 *dev)
{}

static struct net2272 *net2272_probe_init(struct device *dev, unsigned int irq)
{}

static int
net2272_probe_fin(struct net2272 *dev, unsigned int irqflags)
{}

#ifdef CONFIG_USB_PCI

/*
 * wrap this driver around the specified device, but
 * don't respond over USB until a gadget driver binds to us
 */

static int
net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev)
{}

static int
net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev)
{}

static int
net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void
net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev)
{}

static void
net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev)
{}

static void
net2272_pci_remove(struct pci_dev *pdev)
{}

/* Table of matching PCI IDs */
static struct pci_device_id pci_ids[] =;
MODULE_DEVICE_TABLE(pci, pci_ids);

static struct pci_driver net2272_pci_driver =;

static int net2272_pci_register(void)
{}

static void net2272_pci_unregister(void)
{}

#else
static inline int net2272_pci_register(void) { return 0; }
static inline void net2272_pci_unregister(void) { }
#endif

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

static int
net2272_plat_probe(struct platform_device *pdev)
{}

static void
net2272_plat_remove(struct platform_device *pdev)
{}

static struct platform_driver net2272_plat_driver =;
MODULE_ALIAS();

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

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

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