blob: 0c5c3ea8b2d75ef6e8fb70f8489c55fc6a5ecc84 [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Benoit Goby91525d02011-03-09 16:28:55 -08002/*
Benoit Goby91525d02011-03-09 16:28:55 -08003 * Copyright (C) 2010 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
Venu Byravarasu1ba82162012-09-05 18:50:23 +053016#ifndef __TEGRA_USB_PHY_H
17#define __TEGRA_USB_PHY_H
Benoit Goby91525d02011-03-09 16:28:55 -080018
19#include <linux/clk.h>
Dmitry Osipenko14347032018-04-10 01:02:58 +030020#include <linux/reset.h>
Benoit Goby91525d02011-03-09 16:28:55 -080021#include <linux/usb/otg.h>
22
Tuomas Tynkkynen3e635202013-08-12 16:06:51 +030023/*
24 * utmi_pll_config_in_car_module: true if the UTMI PLL configuration registers
25 * should be set up by clk-tegra, false if by the PHY code
26 * has_hostpc: true if the USB controller has the HOSTPC extension, which
27 * changes the location of the PHCD and PTS fields
28 * requires_usbmode_setup: true if the USBMODE register needs to be set to
29 * enter host mode
30 * requires_extra_tuning_parameters: true if xcvr_hsslew, hssquelch_level
31 * and hsdiscon_level should be set for adequate signal quality
32 */
33
34struct tegra_phy_soc_config {
35 bool utmi_pll_config_in_car_module;
36 bool has_hostpc;
37 bool requires_usbmode_setup;
38 bool requires_extra_tuning_parameters;
39};
40
Benoit Goby91525d02011-03-09 16:28:55 -080041struct tegra_utmip_config {
42 u8 hssync_start_delay;
43 u8 elastic_limit;
44 u8 idle_wait_delay;
45 u8 term_range_adj;
Tuomas Tynkkynene497a242013-08-12 16:06:53 +030046 bool xcvr_setup_use_fuses;
Benoit Goby91525d02011-03-09 16:28:55 -080047 u8 xcvr_setup;
48 u8 xcvr_lsfslew;
49 u8 xcvr_lsrslew;
Tuomas Tynkkynene497a242013-08-12 16:06:53 +030050 u8 xcvr_hsslew;
51 u8 hssquelch_level;
52 u8 hsdiscon_level;
Benoit Goby91525d02011-03-09 16:28:55 -080053};
54
Benoit Goby91525d02011-03-09 16:28:55 -080055enum tegra_usb_phy_port_speed {
56 TEGRA_USB_PHY_PORT_SPEED_FULL = 0,
57 TEGRA_USB_PHY_PORT_SPEED_LOW,
58 TEGRA_USB_PHY_PORT_SPEED_HIGH,
59};
60
Benoit Goby91525d02011-03-09 16:28:55 -080061struct tegra_xtal_freq;
62
63struct tegra_usb_phy {
64 int instance;
65 const struct tegra_xtal_freq *freq;
66 void __iomem *regs;
67 void __iomem *pad_regs;
68 struct clk *clk;
69 struct clk *pll_u;
70 struct clk *pad_clk;
Mikko Perttunenf5b8c8b2013-07-17 10:37:49 +030071 struct regulator *vbus;
Tuomas Tynkkynen6558d7e2013-07-25 21:38:09 +030072 enum usb_dr_mode mode;
Benoit Goby91525d02011-03-09 16:28:55 -080073 void *config;
Tuomas Tynkkynen3e635202013-08-12 16:06:51 +030074 const struct tegra_phy_soc_config *soc_config;
Heikki Krogerus86753812012-02-13 13:24:02 +020075 struct usb_phy *ulpi;
Venu Byravarasu1ba82162012-09-05 18:50:23 +053076 struct usb_phy u_phy;
Venu Byravarasu3a55c6a2013-01-16 03:30:20 +000077 bool is_legacy_phy;
Venu Byravarasu3f9db1a2013-01-16 03:30:21 +000078 bool is_ulpi_phy;
Venu Byravarasu12ea18e2013-05-16 19:43:00 +053079 int reset_gpio;
Dmitry Osipenko14347032018-04-10 01:02:58 +030080 struct reset_control *pad_rst;
Benoit Goby91525d02011-03-09 16:28:55 -080081};
82
Venu Byravarasuab137d02013-01-24 15:57:03 +053083void tegra_usb_phy_preresume(struct usb_phy *phy);
Benoit Goby91525d02011-03-09 16:28:55 -080084
Venu Byravarasuab137d02013-01-24 15:57:03 +053085void tegra_usb_phy_postresume(struct usb_phy *phy);
Benoit Goby91525d02011-03-09 16:28:55 -080086
Venu Byravarasuab137d02013-01-24 15:57:03 +053087void tegra_ehci_phy_restore_start(struct usb_phy *phy,
Benoit Goby91525d02011-03-09 16:28:55 -080088 enum tegra_usb_phy_port_speed port_speed);
89
Venu Byravarasuab137d02013-01-24 15:57:03 +053090void tegra_ehci_phy_restore_end(struct usb_phy *phy);
Benoit Goby91525d02011-03-09 16:28:55 -080091
Venu Byravarasu1ba82162012-09-05 18:50:23 +053092#endif /* __TEGRA_USB_PHY_H */