]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/usb/phy/tegra_usb_phy.h
usb: phy: tegra: QC2 speed up charger recogniion
[sojka/nv-tegra/linux-3.10.git] / drivers / usb / phy / tegra_usb_phy.h
1 /*
2  * arch/arm/mach-tegra/include/mach/tegra_usb_phy.h
3  *
4  * Copyright (c) 2012-2014, NVIDIA CORPORATION.  All rights reserved.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #ifndef __MACH_TEGRA_USB_PHY_H
18 #define __MACH_TEGRA_USB_PHY_H
19
20 #include <linux/usb/otg.h>
21
22 /**
23  * defines USB port speeds supported in USB2.0
24  */
25 enum usb_phy_port_speed {
26         USB_PHY_PORT_SPEED_FULL = 0,
27         USB_PHY_PORT_SPEED_LOW,
28         USB_PHY_PORT_SPEED_HIGH,
29         USB_PHY_PORT_SPEED_UNKNOWN,
30 };
31
32 /**
33  * defines structure for oscillator dependent parameters
34  */
35 struct tegra_xtal_freq {
36         int freq;
37         u8 enable_delay;
38         u8 stable_count;
39         u8 active_delay;
40         u16 xtal_freq_count;
41         u16 debounce;
42         u8 pdtrk_count;
43 };
44
45 /**
46  * pre decleration of the usb phy data structure
47  */
48 struct tegra_usb_phy;
49
50 /**
51  * defines function pointers used for differnt phy interfaces
52  */
53 struct tegra_usb_phy_ops {
54         int (*open)(struct tegra_usb_phy *phy);
55         void (*close)(struct tegra_usb_phy *phy);
56         int (*irq)(struct tegra_usb_phy *phy);
57         int (*init)(struct tegra_usb_phy *phy);
58         int (*reset)(struct tegra_usb_phy *phy);
59         int (*pre_suspend)(struct tegra_usb_phy *phy);
60         int (*suspend)(struct tegra_usb_phy *phy);
61         int (*post_suspend)(struct tegra_usb_phy *phy);
62         int (*pre_resume)(struct tegra_usb_phy *phy, bool remote_wakeup);
63         int (*resume)(struct tegra_usb_phy *phy);
64         int (*post_resume)(struct tegra_usb_phy *phy);
65         int (*port_power)(struct tegra_usb_phy *phy);
66         int (*bus_reset)(struct tegra_usb_phy *phy);
67         int (*power_off)(struct tegra_usb_phy *phy);
68         int (*power_on)(struct tegra_usb_phy *phy);
69         bool (*charger_detect)(struct tegra_usb_phy *phy);
70         bool (*cdp_charger_detect)(struct tegra_usb_phy *phy);
71         bool (*qc2_charger_detect)(struct tegra_usb_phy *phy, int max_voltage);
72         bool (*maxim_charger_14675)(struct tegra_usb_phy *phy);
73         bool (*nv_charger_detect)(struct tegra_usb_phy *phy);
74         bool (*apple_charger_1000ma_detect)(struct tegra_usb_phy *phy);
75         bool (*apple_charger_2000ma_detect)(struct tegra_usb_phy *phy);
76         bool (*apple_charger_500ma_detect)(struct tegra_usb_phy *phy);
77         void (*pmc_disable) (struct tegra_usb_phy *phy);
78 };
79
80 /**
81  * defines usb phy data structure
82  */
83 struct tegra_usb_phy {
84         /* Don't move below variable 'phy', from first place*/
85         struct usb_phy phy;
86         struct platform_device *pdev;
87         struct tegra_usb_platform_data *pdata;
88         struct clk *pllu_clk;
89         struct clk *ctrlr_clk;
90         struct clk *ulpi_clk;
91         struct clk *utmi_pad_clk;
92         struct clk *emc_clk;
93         struct clk *sys_clk;
94         struct regulator *vdd_reg;
95         struct regulator *hsic_reg;
96         struct regulator *vbus_reg;
97         struct regulator *pllu_reg;
98         struct tegra_usb_phy_ops *ops;
99         struct tegra_xtal_freq *freq;
100         struct usb_phy *ulpi_vp;
101         enum usb_phy_port_speed port_speed;
102         signed char utmi_xcvr_setup;
103         void __iomem *regs;
104         int inst;
105         bool phy_clk_on;
106         bool ctrl_clk_on;
107         bool vdd_reg_on;
108         bool phy_power_on;
109         bool pmc_remote_wakeup;
110         bool pmc_hotplug_wakeup;
111         bool hw_accessible;
112         bool ulpi_clk_padout_ena;
113         bool pmc_sleepwalk;
114         bool bus_reseting;
115         bool linkphy_init;
116         bool hot_plug;
117         bool ctrlr_suspended;
118         bool qc2_no_reset;
119 };
120
121 int usb_phy_reg_status_wait(void __iomem *reg, u32 mask,
122                 u32 result, u32 timeout);
123
124 int tegra3_usb_phy_init_ops(struct tegra_usb_phy *phy);
125 int tegra2_usb_phy_init_ops(struct tegra_usb_phy *phy);
126 int tegra11x_usb_phy_init_ops(struct tegra_usb_phy *phy);
127
128
129 #endif /* __MACH_TEGRA_USB_PHY_H */