1d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/*
2d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * c67x00.h: Cypress C67X00 USB register and field definitions
3d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *
4d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * Copyright (C) 2006-2008 Barco N.V.
5d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *    Derived from the Cypress cy7c67200/300 ezusb linux driver and
6d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *    based on multiple host controller drivers inside the linux kernel.
7d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *
8d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * This program is free software; you can redistribute it and/or modify
9d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * it under the terms of the GNU General Public License as published by
10d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * the Free Software Foundation; either version 2 of the License, or
11d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * (at your option) any later version.
12d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *
13d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * This program is distributed in the hope that it will be useful,
14d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * but WITHOUT ANY WARRANTY; without even the implied warranty of
15d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * GNU General Public License for more details.
17d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard *
18d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * You should have received a copy of the GNU General Public License
19d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * along with this program; if not, write to the Free Software
20d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * MA  02110-1301  USA.
22d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
23d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
24d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#ifndef _USB_C67X00_H
25d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define _USB_C67X00_H
26d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
27d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#include <linux/spinlock.h>
28d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#include <linux/platform_device.h>
29d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#include <linux/completion.h>
30d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#include <linux/mutex.h>
31d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
32d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ---------------------------------------------------------------------
33d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * Cypress C67x00 register definitions
34d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
35d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
36d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Hardware Revision Register */
37d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HW_REV_REG		0xC004
38d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
39d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* General USB registers */
40d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ===================== */
41d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
42d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* USB Control Register */
43d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define USB_CTL_REG(x)		((x) ? 0xC0AA : 0xC08A)
44d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
45d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define LOW_SPEED_PORT(x)	((x) ? 0x0800 : 0x0400)
46d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_MODE		0x0200
47d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define PORT_RES_EN(x)		((x) ? 0x0100 : 0x0080)
48d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOF_EOP_EN(x)		((x) ? 0x0002 : 0x0001)
49d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
50d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* USB status register - Notice it has different content in hcd/udc mode */
51d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define USB_STAT_REG(x)		((x) ? 0xC0B0 : 0xC090)
52d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
53d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP0_IRQ_FLG		0x0001
54d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP1_IRQ_FLG		0x0002
55d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP2_IRQ_FLG		0x0004
56d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP3_IRQ_FLG		0x0008
57d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP4_IRQ_FLG		0x0010
58d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP5_IRQ_FLG		0x0020
59d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP6_IRQ_FLG		0x0040
60d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define EP7_IRQ_FLG		0x0080
61d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define RESET_IRQ_FLG		0x0100
62d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOF_EOP_IRQ_FLG		0x0200
63d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ID_IRQ_FLG		0x4000
64d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define VBUS_IRQ_FLG		0x8000
65d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
66d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* USB Host only registers */
67d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ======================= */
68d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
69d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Host n Control Register */
70d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_CTL_REG(x)		((x) ? 0xC0A0 : 0xC080)
71d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
72d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define PREAMBLE_EN		0x0080	/* Preamble enable */
73d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SEQ_SEL			0x0040	/* Data Toggle Sequence Bit Select */
74d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ISO_EN			0x0010	/* Isochronous enable  */
75d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ARM_EN			0x0001	/* Arm operation */
76d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
77d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Host n Interrupt Enable Register */
78d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_IRQ_EN_REG(x)	((x) ? 0xC0AC : 0xC08C)
79d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
80d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOF_EOP_IRQ_EN		0x0200	/* SOF/EOP Interrupt Enable  */
81d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOF_EOP_TMOUT_IRQ_EN	0x0800	/* SOF/EOP Timeout Interrupt Enable  */
82d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ID_IRQ_EN		0x4000	/* ID interrupt enable */
83d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define VBUS_IRQ_EN		0x8000	/* VBUS interrupt enable */
84d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DONE_IRQ_EN		0x0001	/* Done Interrupt Enable  */
85d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
86d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* USB status register */
87d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_STAT_MASK		0x02FD
88d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define PORT_CONNECT_CHANGE(x)	((x) ? 0x0020 : 0x0010)
89d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define PORT_SE0_STATUS(x)	((x) ? 0x0008 : 0x0004)
90d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
91d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Host Frame Register */
92d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_FRAME_REG(x)	((x) ? 0xC0B6 : 0xC096)
93d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
94d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HOST_FRAME_MASK		0x07FF
95d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
96d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* USB Peripheral only registers */
97d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ============================= */
98d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
99d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Device n Port Sel reg */
100d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DEVICE_N_PORT_SEL(x)	((x) ? 0xC0A4 : 0xC084)
101d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
102d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Device n Interrupt Enable Register */
103d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DEVICE_N_IRQ_EN_REG(x)	((x) ? 0xC0AC : 0xC08C)
104d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
105d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DEVICE_N_ENDPOINT_N_CTL_REG(dev, ep)	((dev)  		\
106d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard						 ? (0x0280 + (ep << 4)) \
107d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard						 : (0x0200 + (ep << 4)))
108d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DEVICE_N_ENDPOINT_N_STAT_REG(dev, ep)	((dev)			\
109d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard						 ? (0x0286 + (ep << 4)) \
110d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard						 : (0x0206 + (ep << 4)))
111d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
112d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DEVICE_N_ADDRESS(dev)	((dev) ? (0xC0AE) : (0xC08E))
113d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
114d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* HPI registers */
115d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ============= */
116d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
117d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* HPI Status register */
118d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOFEOP_FLG(x)		(1 << ((x) ? 12 : 10))
119d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIEMSG_FLG(x)		(1 << (4 + (x)))
120d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define RESET_FLG(x)		((x) ? 0x0200 : 0x0002)
121d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DONE_FLG(x)		(1 << (2 + (x)))
122d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define RESUME_FLG(x)		(1 << (6 + (x)))
123d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define MBX_OUT_FLG		0x0001	/* Message out available */
124d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define MBX_IN_FLG		0x0100
125d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ID_FLG			0x4000
126d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define VBUS_FLG		0x8000
127d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
128d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Interrupt routing register */
129d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HPI_IRQ_ROUTING_REG	0x0142
130d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
131d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HPI_SWAP_ENABLE(x)	((x) ? 0x0100 : 0x0001)
132d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define RESET_TO_HPI_ENABLE(x)	((x) ? 0x0200 : 0x0002)
133d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define DONE_TO_HPI_ENABLE(x)	((x) ? 0x0008 : 0x0004)
134d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define RESUME_TO_HPI_ENABLE(x)	((x) ? 0x0080 : 0x0040)
135d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOFEOP_TO_HPI_EN(x)	((x) ? 0x2000 : 0x0800)
136d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SOFEOP_TO_CPU_EN(x)	((x) ? 0x1000 : 0x0400)
137d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define ID_TO_HPI_ENABLE	0x4000
138d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define VBUS_TO_HPI_ENABLE	0x8000
139d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
140d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* SIE msg registers */
141d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIEMSG_REG(x)		((x) ? 0x0148 : 0x0144)
142d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
143d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define HUSB_TDListDone		0x1000
144d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
145d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP0_MSG		0x0001
146d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP1_MSG		0x0002
147d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP2_MSG		0x0004
148d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP3_MSG		0x0008
149d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP4_MSG		0x0010
150d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP5_MSG		0x0020
151d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP6_MSG		0x0040
152d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_EP7_MSG		0x0080
153d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_RST_MSG		0x0100
154d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_SOF_MSG		0x0200
155d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_CFG_MSG		0x0400
156d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_SUS_MSG		0x0800
157d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_ID_MSG	       	0x4000
158d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSB_VBUS_MSG		0x8000
159d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
160d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* BIOS interrupt routines */
161d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
162d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSBx_RECEIVE_INT(x)	((x) ? 97 : 81)
163d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSBx_SEND_INT(x)	((x) ? 96 : 80)
164d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
165d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSBx_DEV_DESC_VEC(x)	((x) ? 0x00D4 : 0x00B4)
166d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSBx_CONF_DESC_VEC(x)	((x) ? 0x00D6 : 0x00B6)
167d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SUSBx_STRING_DESC_VEC(x) ((x) ? 0x00D8 : 0x00B8)
168d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
169d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_HCD_BUF_ADDR		0x500	/* Base address for host */
170d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIE_TD_SIZE		0x200	/* size of the td list */
171d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIE_TD_BUF_SIZE		0x400	/* size of the data buffer */
172d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
173d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIE_TD_OFFSET(host)	((host) ? (SIE_TD_SIZE+SIE_TD_BUF_SIZE) : 0)
174d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define SIE_BUF_OFFSET(host)	(SIE_TD_OFFSET(host) + SIE_TD_SIZE)
175d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
176d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Base address of HCD + 2 x TD_SIZE + 2 x TD_BUF_SIZE */
177d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_HEADER_BASE	0x1100
178d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* 8- byte request headers for IN/OUT transfers */
179d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_HEADER_SIZE	8
180d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
181d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_HEADER_ADDR(ep_num)	(CY_UDC_REQ_HEADER_BASE + \
182d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard					 ((ep_num) * CY_UDC_REQ_HEADER_SIZE))
183d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_DESC_BASE_ADDRESS	(CY_UDC_REQ_HEADER_ADDR(8))
184d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
185d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_BIOS_REPLACE_BASE	0x1800
186d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_BUFFER_BASE		0x2000
187d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_BUFFER_SIZE		0x0400
188d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define CY_UDC_REQ_BUFFER_ADDR(ep_num)	(CY_UDC_REQ_BUFFER_BASE + \
189d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard					 ((ep_num) * CY_UDC_REQ_BUFFER_SIZE))
190d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
191d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ---------------------------------------------------------------------
192d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * Driver data structures
193d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
194d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
195d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardstruct c67x00_device;
196d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
197d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/**
198d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * struct c67x00_sie - Common data associated with a SIE
199d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @lock: lock to protect this struct and the associated chip registers
200d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @private_data: subdriver dependent data
201d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @irq: subdriver dependent irq handler, set NULL when not used
202d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @dev: link to common driver structure
203d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @sie_num: SIE number on chip, starting from 0
204d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @mode: SIE mode (host/peripheral/otg/not used)
205d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
206d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardstruct c67x00_sie {
207d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	/* Entries to be used by the subdrivers */
208d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	spinlock_t lock;	/* protect this structure */
209d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	void *private_data;
210d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	void (*irq) (struct c67x00_sie *sie, u16 int_status, u16 msg);
211d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
212d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	/* Read only: */
213d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct c67x00_device *dev;
214d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	int sie_num;
215d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	int mode;
216d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard};
217d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
218d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define sie_dev(s)	(&(s)->dev->pdev->dev)
219d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
220d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/**
221d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * struct c67x00_lcp
222d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
223d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardstruct c67x00_lcp {
224d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	/* Internal use only */
225d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct mutex mutex;
226d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct completion msg_received;
227d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	u16 last_msg;
228d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard};
229d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
230d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/*
231d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * struct c67x00_hpi
232d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
233d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardstruct c67x00_hpi {
234d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	void __iomem *base;
235d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	int regstep;
236d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	spinlock_t lock;
237d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct c67x00_lcp lcp;
238d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard};
239d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
240d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define C67X00_SIES	2
241d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#define C67X00_PORTS	2
242d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
243d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/**
244d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * struct c67x00_device - Common data associated with a c67x00 instance
245d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @hpi: hpi addresses
246d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @sie: array of sie's on this chip
247d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @pdev: platform device of instance
248d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * @pdata: configuration provided by the platform
249d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
250d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardstruct c67x00_device {
251d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct c67x00_hpi hpi;
252d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct c67x00_sie sie[C67X00_SIES];
253d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct platform_device *pdev;
254d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard	struct c67x00_platform_data *pdata;
255d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard};
256d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
257d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* ---------------------------------------------------------------------
258d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard * Low level interface functions
259d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard */
260d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
261d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Host Port Interface (HPI) functions */
262d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardu16 c67x00_ll_hpi_status(struct c67x00_device *dev);
263d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_hpi_reg_init(struct c67x00_device *dev);
264d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_hpi_enable_sofeop(struct c67x00_sie *sie);
265d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_hpi_disable_sofeop(struct c67x00_sie *sie);
266d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
267d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* General functions */
268d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardu16 c67x00_ll_fetch_siemsg(struct c67x00_device *dev, int sie_num);
269d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardu16 c67x00_ll_get_usb_ctl(struct c67x00_sie *sie);
270d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_usb_clear_status(struct c67x00_sie *sie, u16 bits);
271d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardu16 c67x00_ll_usb_get_status(struct c67x00_sie *sie);
272d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_write_mem_le16(struct c67x00_device *dev, u16 addr,
273d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard			      void *data, int len);
274d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_read_mem_le16(struct c67x00_device *dev, u16 addr,
275d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard			     void *data, int len);
276d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
277e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaard/* Host specific functions */
278e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardvoid c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value);
279e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardvoid c67x00_ll_husb_reset(struct c67x00_sie *sie, int port);
280e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardvoid c67x00_ll_husb_set_current_td(struct c67x00_sie *sie, u16 addr);
281e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardu16 c67x00_ll_husb_get_current_td(struct c67x00_sie *sie);
282e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardu16 c67x00_ll_husb_get_frame(struct c67x00_sie *sie);
283e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardvoid c67x00_ll_husb_init_host_port(struct c67x00_sie *sie);
284e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaardvoid c67x00_ll_husb_reset_port(struct c67x00_sie *sie, int port);
285e9b29ffc519b9e63d4e1c0b1278bb951bb418a9dPeter Korsgaard
286d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Called by c67x00_irq to handle lcp interrupts */
287d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_irq(struct c67x00_device *dev, u16 int_status);
288d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
289d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard/* Setup and teardown */
290d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_init(struct c67x00_device *dev);
291d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardvoid c67x00_ll_release(struct c67x00_device *dev);
292d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaardint c67x00_ll_reset(struct c67x00_device *dev);
293d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard
294d6f945044ee3b91a170183e8e34c3db29696d9b8Peter Korsgaard#endif				/* _USB_C67X00_H */
295