blob: 5973a6313529cd36eabb1bca226c3973769b575f [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +05302/*
3 * omap_usb.h -- omap usb2 phy header file
4 *
5 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +05306 * Author: Kishon Vijay Abraham I <kishon@ti.com>
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +05307 */
8
9#ifndef __DRIVERS_OMAP_USB2_H
10#define __DRIVERS_OMAP_USB2_H
11
Kishon Vijay Abraham I57f6ce02013-01-25 08:21:48 +053012#include <linux/io.h>
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053013#include <linux/usb/otg.h>
14
Kishon Vijay Abraham I57f6ce02013-01-25 08:21:48 +053015struct usb_dpll_params {
16 u16 m;
17 u8 n;
18 u8 freq:3;
19 u8 sd;
20 u32 mf;
21};
22
Kishon Vijay Abraham I9955a782015-12-21 14:24:13 +053023enum omap_usb_phy_type {
24 TYPE_USB2, /* USB2_PHY, power down in CONTROL_DEV_CONF */
25 TYPE_DRA7USB2, /* USB2 PHY, power and power_aux e.g. DRA7 */
26 TYPE_AM437USB2, /* USB2 PHY, power e.g. AM437x */
27};
28
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053029struct omap_usb {
30 struct usb_phy phy;
31 struct phy_companion *comparator;
Austin Beam7e472402014-03-06 18:11:53 +053032 void __iomem *pll_ctrl_base;
33 void __iomem *phy_base;
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053034 struct device *dev;
Kishon Vijay Abraham Ica784be2013-01-25 15:54:00 +053035 struct device *control_dev;
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053036 struct clk *wkupclk;
Kishon Vijay Abraham I57f6ce02013-01-25 08:21:48 +053037 struct clk *optclk;
Austin Beam7e472402014-03-06 18:11:53 +053038 u8 flags;
Kishon Vijay Abraham I9955a782015-12-21 14:24:13 +053039 enum omap_usb_phy_type type;
40 struct regmap *syscon_phy_power; /* ctrl. reg. acces */
41 unsigned int power_reg; /* power reg. index within syscon */
42 u32 mask;
43 u32 power_on;
44 u32 power_off;
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053045};
46
George Cherian09a01682014-03-06 18:11:52 +053047struct usb_phy_data {
48 const char *label;
49 u8 flags;
Kishon Vijay Abraham I9955a782015-12-21 14:24:13 +053050 u32 mask;
51 u32 power_on;
52 u32 power_off;
George Cherian09a01682014-03-06 18:11:52 +053053};
54
55/* Driver Flags */
56#define OMAP_USB2_HAS_START_SRP (1 << 0)
57#define OMAP_USB2_HAS_SET_VBUS (1 << 1)
Austin Beam7e472402014-03-06 18:11:53 +053058#define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT (1 << 2)
George Cherian09a01682014-03-06 18:11:52 +053059
Kishon Vijay Abraham I9955a782015-12-21 14:24:13 +053060#define OMAP_DEV_PHY_PD BIT(0)
61#define OMAP_USB2_PHY_PD BIT(28)
62
63#define AM437X_USB2_PHY_PD BIT(0)
64#define AM437X_USB2_OTG_PD BIT(1)
65#define AM437X_USB2_OTGVDET_EN BIT(19)
66#define AM437X_USB2_OTGSESSEND_EN BIT(20)
67
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053068#define phy_to_omapusb(x) container_of((x), struct omap_usb, phy)
69
70#if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
71extern int omap_usb2_set_comparator(struct phy_companion *comparator);
72#else
73static inline int omap_usb2_set_comparator(struct phy_companion *comparator)
74{
75 return -ENODEV;
76}
77#endif
78
Kishon Vijay Abraham I57f6ce02013-01-25 08:21:48 +053079static inline u32 omap_usb_readl(void __iomem *addr, unsigned offset)
80{
81 return __raw_readl(addr + offset);
82}
83
84static inline void omap_usb_writel(void __iomem *addr, unsigned offset,
85 u32 data)
86{
87 __raw_writel(data, addr + offset);
88}
89
Kishon Vijay Abraham I657b3062012-09-06 20:27:06 +053090#endif /* __DRIVERS_OMAP_USB_H */