1/*
2 * arch/ubicom32/mach-common/usb_tio.h
3 *   Definitions for usb_tio.c
4 *
5 * (C) Copyright 2009, Ubicom, Inc.
6 *
7 * This file is part of the Ubicom32 Linux Kernel Port.
8 *
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port.  If not,
21 * see <http://www.gnu.org/licenses/>.
22 *
23 * Ubicom32 implementation derived from (with many thanks):
24 *   arch/m68knommu
25 *   arch/blackfin
26 *   arch/parisc
27 */
28
29#include <linux/version.h>
30#include <linux/kernel.h>
31#include <linux/types.h>
32#include <linux/errno.h>
33#include <linux/err.h>
34#include <asm/devtree.h>
35#include <asm/ip5000.h>
36
37#ifndef _USB_TIO_H
38#define _USB_TIO_H
39
40#undef  USB_TIO_DEBUG
41
42#define USB_TIO_REQUEST_MAGIC1	0x2307
43#define USB_TIO_REQUEST_MAGIC2	0x0789
44#if defined(USB_TIO_DEBUG)
45#define USB_TIO_REQUEST_VERIFY_MAGIC(req)	usb_tio_request_verify_magic(req)
46#define USB_TIO_REQUEST_SET_MAGIC(req)          usb_tio_request_set_magic(req)
47#define USB_TIO_REQUEST_CLEAR_MAGIC(req)	usb_tio_request_clear_magic(req)
48#else
49#define USB_TIO_REQUEST_VERIFY_MAGIC(req)
50#define USB_TIO_REQUEST_SET_MAGIC(req)          usb_tio_request_set_magic(req)
51#define USB_TIO_REQUEST_CLEAR_MAGIC(req)
52#endif
53
54enum USB_TIO_status {
55	USB_TIO_OK,
56	USB_TIO_ERROR,
57	USB_TIO_ERROR_COMMIT,
58};
59
60enum USB_TIO_cmds {
61	USB_TIO_READ16_SYNC,
62	USB_TIO_READ8_SYNC,
63	USB_TIO_READ_FIFO_SYNC,
64
65	USB_TIO_WRITE16_ASYNC,
66	USB_TIO_WRITE8_ASYNC,
67	USB_TIO_WRITE_FIFO_ASYNC,
68
69	USB_TIO_WRITE16_SYNC,
70	USB_TIO_WRITE8_SYNC,
71	USB_TIO_WRITE_FIFO_SYNC,
72
73};
74
75enum USB_TIO_state {
76	USB_TIO_NORMAL,
77	USB_TIO_DMA_SETUP,
78};
79
80struct usb_tio_request {
81	volatile u32_t address;
82	union {
83		volatile u32_t data;
84		volatile u32_t buffer;
85	};
86	volatile u16_t cmd;
87	const volatile u16_t status;
88	volatile u32_t transfer_length;
89	volatile u32_t thread_mask;
90	volatile u16_t magic;
91};
92
93struct usbtio_node {
94	struct devtree_node dn;
95	volatile struct usb_tio_request * volatile pdesc;
96	struct usb_tio_request	request;
97	volatile u32_t usb_vp_config;
98	volatile u32_t usb_vp_control;
99	const volatile u32_t usb_vp_status;
100	volatile u16_t usb_vp_hw_int_tx;
101	volatile u16_t usb_vp_hw_int_rx;
102	volatile u8_t  usb_vp_hw_int_usb;
103	volatile u8_t usb_vp_hw_int_mask_usb;
104        volatile u16_t usb_vp_hw_int_mask_tx;
105        volatile u16_t usb_vp_hw_int_mask_rx;
106
107};
108
109extern struct usbtio_node *usb_node;
110extern void ubi32_usb_init(void);
111#endif
112