WS cleanup: remove SPACE(s) followed by TAB
[platform/kernel/u-boot.git] / drivers / usb / musb / musb_core.h
index f9da3f0..47b839c 100644 (file)
@@ -1,46 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /******************************************************************
  * Copyright 2008 Mentor Graphics Corporation
  * Copyright (C) 2008 by Texas Instruments
  *
  * This file is part of the Inventra Controller Driver for Linux.
- *
- * The Inventra Controller Driver for Linux is free software; you
- * can redistribute it and/or modify it under the terms of the GNU
- * General Public License version 2 as published by the Free Software
- * Foundation.
- *
- * The Inventra Controller Driver for Linux is distributed in
- * the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with The Inventra Controller Driver for Linux ; if not,
- * write to the Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA  02111-1307  USA
- *
- * ANY DOWNLOAD, USE, REPRODUCTION, MODIFICATION OR DISTRIBUTION
- * OF THIS DRIVER INDICATES YOUR COMPLETE AND UNCONDITIONAL ACCEPTANCE
- * OF THOSE TERMS.THIS DRIVER IS PROVIDED "AS IS" AND MENTOR GRAPHICS
- * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, RELATED TO THIS DRIVER.
- * MENTOR GRAPHICS SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY; FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT.  MENTOR GRAPHICS DOES NOT PROVIDE SUPPORT
- * SERVICES OR UPDATES FOR THIS DRIVER, EVEN IF YOU ARE A MENTOR
- * GRAPHICS SUPPORT CUSTOMER.
  ******************************************************************/
 
 #ifndef __MUSB_HDRC_DEFS_H__
 #define __MUSB_HDRC_DEFS_H__
 
-#include <usb.h>
 #include <usb_defs.h>
 #include <asm/io.h>
 
 #define MUSB_EP0_FIFOSIZE      64      /* This is non-configurable */
 
+/* EP0 */
+struct musb_ep0_regs {
+       u16     reserved4;
+       u16     csr0;
+       u16     reserved5;
+       u16     reserved6;
+       u16     count0;
+       u8      host_type0;
+       u8      host_naklimit0;
+       u8      reserved7;
+       u8      reserved8;
+       u8      reserved9;
+       u8      configdata;
+};
+
+/* EP 1-15 */
+struct musb_epN_regs {
+       u16     txmaxp;
+       u16     txcsr;
+       u16     rxmaxp;
+       u16     rxcsr;
+       u16     rxcount;
+       u8      txtype;
+       u8      txinterval;
+       u8      rxtype;
+       u8      rxinterval;
+       u8      reserved0;
+       u8      fifosize;
+};
+
 /* Mentor USB core register overlay structure */
+#ifndef musb_regs
 struct musb_regs {
        /* common registers */
        u8      faddr;
@@ -77,7 +82,10 @@ struct musb_regs {
        u16     rxfifoadd;
        u32     vcontrol;
        u16     hwvers;
-       u16     reserved2[5];
+       u16     reserved2a[1];
+       u8      ulpi_busctl;
+       u8      reserved2b[1];
+       u16     reserved2[3];
        u8      epinfo;
        u8      raminfo;
        u8      linkinfo;
@@ -97,7 +105,18 @@ struct musb_regs {
                u8      rxhubaddr;
                u8      rxhubport;
        } tar[16];
-} __attribute__((aligned(32)));
+       /*
+        * endpoint registers
+        * ep0 elements are valid when array index is 0
+        * otherwise epN is valid
+        */
+       union musb_ep_regs {
+               struct musb_ep0_regs ep0;
+               struct musb_epN_regs epN;
+       } ep[16];
+
+} __attribute__((packed));
+#endif
 
 /*
  * MUSB Register bits
@@ -135,6 +154,10 @@ struct musb_regs {
 #define MUSB_DEVCTL_HR         0x02
 #define MUSB_DEVCTL_SESSION    0x01
 
+/* ULPI VBUSCONTROL */
+#define ULPI_USE_EXTVBUS       0x01
+#define ULPI_USE_EXTVBUSIND    0x02
+
 /* TESTMODE */
 #define MUSB_TEST_FORCE_HOST   0x80
 #define MUSB_TEST_FIFO_ACCESS  0x40
@@ -184,14 +207,14 @@ struct musb_regs {
 /* TxType/RxType */
 #define MUSB_TYPE_SPEED                0xc0
 #define MUSB_TYPE_SPEED_SHIFT  6
-#define MUSB_TYPE_SPEED_HIGH   1
-#define MUSB_TYPE_SPEED_FULL   2
+#define MUSB_TYPE_SPEED_HIGH   1
+#define MUSB_TYPE_SPEED_FULL   2
 #define MUSB_TYPE_SPEED_LOW    3
 #define MUSB_TYPE_PROTO                0x30    /* Implicitly zero for ep0 */
 #define MUSB_TYPE_PROTO_SHIFT  4
 #define MUSB_TYPE_REMOTE_END   0xf     /* Implicitly zero for ep0 */
-#define MUSB_TYPE_PROTO_BULK   2
-#define MUSB_TYPE_PROTO_INTR   3
+#define MUSB_TYPE_PROTO_BULK   2
+#define MUSB_TYPE_PROTO_INTR   3
 
 /* CONFIGDATA */
 #define MUSB_CONFIGDATA_MPRXE          0x80    /* Auto bulk pkt combining */
@@ -281,7 +304,7 @@ struct musb_regs {
  * values are not supported
  */
 struct musb_epinfo {
-       u8      epnum;  /* endpoint number      */
+       u8      epnum;  /* endpoint number      */
        u8      epdir;  /* endpoint direction   */
        u16     epsize; /* endpoint FIFO size   */
 };
@@ -295,6 +318,7 @@ struct musb_config {
        struct  musb_regs       *regs;
        u32                     timeout;
        u8                      musb_speed;
+       u8                      extvbus;
 };
 
 /* externally defined data */
@@ -303,8 +327,17 @@ extern struct musb_regs            *musbr;
 
 /* exported functions */
 extern void musb_start(void);
-extern void musb_configure_ep(struct musb_epinfo *epinfo, u8 cnt);
+extern void musb_configure_ep(const struct musb_epinfo *epinfo, u8 cnt);
 extern void write_fifo(u8 ep, u32 length, void *fifo_data);
 extern void read_fifo(u8 ep, u32 length, void *fifo_data);
 
+static inline u8 musb_read_ulpi_buscontrol(struct musb_regs *musbr)
+{
+       return readb(&musbr->ulpi_busctl);
+}
+static inline void musb_write_ulpi_buscontrol(struct musb_regs *musbr, u8 val)
+{
+       writeb(val, &musbr->ulpi_busctl);
+}
+
 #endif /* __MUSB_HDRC_DEFS_H__ */