Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * Driver for the NXP ISP1761 device controller
  4 *
  5 * Copyright 2021 Linaro, Rui Miguel Silva
  6 * Copyright 2014 Ideas on Board Oy
  7 *
  8 * Contacts:
  9 *	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
 10 *	Rui Miguel Silva <rui.silva@linaro.org>
 
 
 
 11 */
 12
 13#ifndef _ISP1760_UDC_H_
 14#define _ISP1760_UDC_H_
 15
 16#include <linux/ioport.h>
 17#include <linux/list.h>
 18#include <linux/spinlock.h>
 19#include <linux/timer.h>
 20#include <linux/usb/gadget.h>
 21
 22#include "isp1760-regs.h"
 23
 24struct isp1760_device;
 25struct isp1760_udc;
 26
 27enum isp1760_ctrl_state {
 28	ISP1760_CTRL_SETUP,		/* Waiting for a SETUP transaction */
 29	ISP1760_CTRL_DATA_IN,		/* Setup received, data IN stage */
 30	ISP1760_CTRL_DATA_OUT,		/* Setup received, data OUT stage */
 31	ISP1760_CTRL_STATUS,		/* 0-length request in status stage */
 32};
 33
 34struct isp1760_ep {
 35	struct isp1760_udc *udc;
 36	struct usb_ep ep;
 37
 38	struct list_head queue;
 39
 40	unsigned int addr;
 41	unsigned int maxpacket;
 42	char name[7];
 43
 44	const struct usb_endpoint_descriptor *desc;
 45
 46	bool rx_pending;
 47	bool halted;
 48	bool wedged;
 49};
 50
 51/**
 52 * struct isp1760_udc - UDC state information
 53 * irq: IRQ number
 54 * irqname: IRQ name (as passed to request_irq)
 55 * regs: regmap for UDC registers
 56 * driver: Gadget driver
 57 * gadget: Gadget device
 58 * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
 59 * ep: Array of endpoints
 60 * ep0_state: Control request state for endpoint 0
 61 * ep0_dir: Direction of the current control request
 62 * ep0_length: Length of the current control request
 63 * connected: Tracks gadget driver bus connection state
 64 */
 65struct isp1760_udc {
 
 66	struct isp1760_device *isp;
 67
 68	int irq;
 69	char *irqname;
 70
 71	struct regmap *regs;
 72	struct regmap_field *fields[DC_FIELD_MAX];
 73
 74	struct usb_gadget_driver *driver;
 75	struct usb_gadget gadget;
 76
 77	spinlock_t lock;
 78	struct timer_list vbus_timer;
 79
 80	struct isp1760_ep ep[15];
 81
 82	enum isp1760_ctrl_state ep0_state;
 83	u8 ep0_dir;
 84	u16 ep0_length;
 85
 86	bool connected;
 87	bool is_isp1763;
 88
 89	unsigned int devstatus;
 
 90};
 91
 92#ifdef CONFIG_USB_ISP1761_UDC
 93int isp1760_udc_register(struct isp1760_device *isp, int irq,
 94			 unsigned long irqflags);
 95void isp1760_udc_unregister(struct isp1760_device *isp);
 96#else
 97static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
 98				       unsigned long irqflags)
 99{
100	return 0;
101}
102
103static inline void isp1760_udc_unregister(struct isp1760_device *isp)
104{
105}
106#endif
107
108#endif
v4.10.11
 
  1/*
  2 * Driver for the NXP ISP1761 device controller
  3 *
 
  4 * Copyright 2014 Ideas on Board Oy
  5 *
  6 * Contacts:
  7 *	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  8 *
  9 * This program is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU General Public License
 11 * version 2 as published by the Free Software Foundation.
 12 */
 13
 14#ifndef _ISP1760_UDC_H_
 15#define _ISP1760_UDC_H_
 16
 17#include <linux/ioport.h>
 18#include <linux/list.h>
 19#include <linux/spinlock.h>
 20#include <linux/timer.h>
 21#include <linux/usb/gadget.h>
 22
 
 
 23struct isp1760_device;
 24struct isp1760_udc;
 25
 26enum isp1760_ctrl_state {
 27	ISP1760_CTRL_SETUP,		/* Waiting for a SETUP transaction */
 28	ISP1760_CTRL_DATA_IN,		/* Setup received, data IN stage */
 29	ISP1760_CTRL_DATA_OUT,		/* Setup received, data OUT stage */
 30	ISP1760_CTRL_STATUS,		/* 0-length request in status stage */
 31};
 32
 33struct isp1760_ep {
 34	struct isp1760_udc *udc;
 35	struct usb_ep ep;
 36
 37	struct list_head queue;
 38
 39	unsigned int addr;
 40	unsigned int maxpacket;
 41	char name[7];
 42
 43	const struct usb_endpoint_descriptor *desc;
 44
 45	bool rx_pending;
 46	bool halted;
 47	bool wedged;
 48};
 49
 50/**
 51 * struct isp1760_udc - UDC state information
 52 * irq: IRQ number
 53 * irqname: IRQ name (as passed to request_irq)
 54 * regs: Base address of the UDC registers
 55 * driver: Gadget driver
 56 * gadget: Gadget device
 57 * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
 58 * ep: Array of endpoints
 59 * ep0_state: Control request state for endpoint 0
 60 * ep0_dir: Direction of the current control request
 61 * ep0_length: Length of the current control request
 62 * connected: Tracks gadget driver bus connection state
 63 */
 64struct isp1760_udc {
 65#ifdef CONFIG_USB_ISP1761_UDC
 66	struct isp1760_device *isp;
 67
 68	int irq;
 69	char *irqname;
 70	void __iomem *regs;
 
 
 71
 72	struct usb_gadget_driver *driver;
 73	struct usb_gadget gadget;
 74
 75	spinlock_t lock;
 76	struct timer_list vbus_timer;
 77
 78	struct isp1760_ep ep[15];
 79
 80	enum isp1760_ctrl_state ep0_state;
 81	u8 ep0_dir;
 82	u16 ep0_length;
 83
 84	bool connected;
 
 85
 86	unsigned int devstatus;
 87#endif
 88};
 89
 90#ifdef CONFIG_USB_ISP1761_UDC
 91int isp1760_udc_register(struct isp1760_device *isp, int irq,
 92			 unsigned long irqflags);
 93void isp1760_udc_unregister(struct isp1760_device *isp);
 94#else
 95static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
 96				       unsigned long irqflags)
 97{
 98	return 0;
 99}
100
101static inline void isp1760_udc_unregister(struct isp1760_device *isp)
102{
103}
104#endif
105
106#endif