IB/rdmavt, IB/qib, IB/hfi1: Use new QP put get routines
[linux/fpc-iii.git] / drivers / phy / tegra / xusb.h
blobb49dbc36efa32e006e9acd9a189e627181756639
1 /*
2 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3 * Copyright (c) 2015, Google Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
15 #ifndef __PHY_TEGRA_XUSB_H
16 #define __PHY_TEGRA_XUSB_H
18 #include <linux/io.h>
19 #include <linux/mutex.h>
20 #include <linux/workqueue.h>
22 /* legacy entry points for backwards-compatibility */
23 int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev);
24 int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
26 struct phy;
27 struct phy_provider;
28 struct platform_device;
29 struct regulator;
32 * lanes
34 struct tegra_xusb_lane_soc {
35 const char *name;
37 unsigned int offset;
38 unsigned int shift;
39 unsigned int mask;
41 const char * const *funcs;
42 unsigned int num_funcs;
45 struct tegra_xusb_lane {
46 const struct tegra_xusb_lane_soc *soc;
47 struct tegra_xusb_pad *pad;
48 struct device_node *np;
49 struct list_head list;
50 unsigned int function;
51 unsigned int index;
54 int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
55 struct device_node *np);
57 struct tegra_xusb_usb2_lane {
58 struct tegra_xusb_lane base;
60 u32 hs_curr_level_offset;
63 static inline struct tegra_xusb_usb2_lane *
64 to_usb2_lane(struct tegra_xusb_lane *lane)
66 return container_of(lane, struct tegra_xusb_usb2_lane, base);
69 struct tegra_xusb_ulpi_lane {
70 struct tegra_xusb_lane base;
73 static inline struct tegra_xusb_ulpi_lane *
74 to_ulpi_lane(struct tegra_xusb_lane *lane)
76 return container_of(lane, struct tegra_xusb_ulpi_lane, base);
79 struct tegra_xusb_hsic_lane {
80 struct tegra_xusb_lane base;
82 u32 strobe_trim;
83 u32 rx_strobe_trim;
84 u32 rx_data_trim;
85 u32 tx_rtune_n;
86 u32 tx_rtune_p;
87 u32 tx_rslew_n;
88 u32 tx_rslew_p;
89 bool auto_term;
92 static inline struct tegra_xusb_hsic_lane *
93 to_hsic_lane(struct tegra_xusb_lane *lane)
95 return container_of(lane, struct tegra_xusb_hsic_lane, base);
98 struct tegra_xusb_pcie_lane {
99 struct tegra_xusb_lane base;
102 static inline struct tegra_xusb_pcie_lane *
103 to_pcie_lane(struct tegra_xusb_lane *lane)
105 return container_of(lane, struct tegra_xusb_pcie_lane, base);
108 struct tegra_xusb_sata_lane {
109 struct tegra_xusb_lane base;
112 static inline struct tegra_xusb_sata_lane *
113 to_sata_lane(struct tegra_xusb_lane *lane)
115 return container_of(lane, struct tegra_xusb_sata_lane, base);
118 struct tegra_xusb_lane_ops {
119 struct tegra_xusb_lane *(*probe)(struct tegra_xusb_pad *pad,
120 struct device_node *np,
121 unsigned int index);
122 void (*remove)(struct tegra_xusb_lane *lane);
126 * pads
128 struct tegra_xusb_pad_soc;
129 struct tegra_xusb_padctl;
131 struct tegra_xusb_pad_ops {
132 struct tegra_xusb_pad *(*probe)(struct tegra_xusb_padctl *padctl,
133 const struct tegra_xusb_pad_soc *soc,
134 struct device_node *np);
135 void (*remove)(struct tegra_xusb_pad *pad);
138 struct tegra_xusb_pad_soc {
139 const char *name;
141 const struct tegra_xusb_lane_soc *lanes;
142 unsigned int num_lanes;
144 const struct tegra_xusb_pad_ops *ops;
147 struct tegra_xusb_pad {
148 const struct tegra_xusb_pad_soc *soc;
149 struct tegra_xusb_padctl *padctl;
150 struct phy_provider *provider;
151 struct phy **lanes;
152 struct device dev;
154 const struct tegra_xusb_lane_ops *ops;
156 struct list_head list;
159 static inline struct tegra_xusb_pad *to_tegra_xusb_pad(struct device *dev)
161 return container_of(dev, struct tegra_xusb_pad, dev);
164 int tegra_xusb_pad_init(struct tegra_xusb_pad *pad,
165 struct tegra_xusb_padctl *padctl,
166 struct device_node *np);
167 int tegra_xusb_pad_register(struct tegra_xusb_pad *pad,
168 const struct phy_ops *ops);
169 void tegra_xusb_pad_unregister(struct tegra_xusb_pad *pad);
171 struct tegra_xusb_usb2_pad {
172 struct tegra_xusb_pad base;
174 struct clk *clk;
175 unsigned int enable;
176 struct mutex lock;
179 static inline struct tegra_xusb_usb2_pad *
180 to_usb2_pad(struct tegra_xusb_pad *pad)
182 return container_of(pad, struct tegra_xusb_usb2_pad, base);
185 struct tegra_xusb_ulpi_pad {
186 struct tegra_xusb_pad base;
189 static inline struct tegra_xusb_ulpi_pad *
190 to_ulpi_pad(struct tegra_xusb_pad *pad)
192 return container_of(pad, struct tegra_xusb_ulpi_pad, base);
195 struct tegra_xusb_hsic_pad {
196 struct tegra_xusb_pad base;
198 struct regulator *supply;
199 struct clk *clk;
202 static inline struct tegra_xusb_hsic_pad *
203 to_hsic_pad(struct tegra_xusb_pad *pad)
205 return container_of(pad, struct tegra_xusb_hsic_pad, base);
208 struct tegra_xusb_pcie_pad {
209 struct tegra_xusb_pad base;
211 struct reset_control *rst;
212 struct clk *pll;
214 unsigned int enable;
217 static inline struct tegra_xusb_pcie_pad *
218 to_pcie_pad(struct tegra_xusb_pad *pad)
220 return container_of(pad, struct tegra_xusb_pcie_pad, base);
223 struct tegra_xusb_sata_pad {
224 struct tegra_xusb_pad base;
226 struct reset_control *rst;
227 struct clk *pll;
229 unsigned int enable;
232 static inline struct tegra_xusb_sata_pad *
233 to_sata_pad(struct tegra_xusb_pad *pad)
235 return container_of(pad, struct tegra_xusb_sata_pad, base);
239 * ports
241 struct tegra_xusb_port_ops;
243 struct tegra_xusb_port {
244 struct tegra_xusb_padctl *padctl;
245 struct tegra_xusb_lane *lane;
246 unsigned int index;
248 struct list_head list;
249 struct device dev;
251 const struct tegra_xusb_port_ops *ops;
254 struct tegra_xusb_lane_map {
255 unsigned int port;
256 const char *type;
257 unsigned int index;
258 const char *func;
261 struct tegra_xusb_lane *
262 tegra_xusb_port_find_lane(struct tegra_xusb_port *port,
263 const struct tegra_xusb_lane_map *map,
264 const char *function);
266 struct tegra_xusb_port *
267 tegra_xusb_find_port(struct tegra_xusb_padctl *padctl, const char *type,
268 unsigned int index);
270 struct tegra_xusb_usb2_port {
271 struct tegra_xusb_port base;
273 struct regulator *supply;
274 bool internal;
277 static inline struct tegra_xusb_usb2_port *
278 to_usb2_port(struct tegra_xusb_port *port)
280 return container_of(port, struct tegra_xusb_usb2_port, base);
283 struct tegra_xusb_usb2_port *
284 tegra_xusb_find_usb2_port(struct tegra_xusb_padctl *padctl,
285 unsigned int index);
287 struct tegra_xusb_ulpi_port {
288 struct tegra_xusb_port base;
290 struct regulator *supply;
291 bool internal;
294 static inline struct tegra_xusb_ulpi_port *
295 to_ulpi_port(struct tegra_xusb_port *port)
297 return container_of(port, struct tegra_xusb_ulpi_port, base);
300 struct tegra_xusb_hsic_port {
301 struct tegra_xusb_port base;
304 static inline struct tegra_xusb_hsic_port *
305 to_hsic_port(struct tegra_xusb_port *port)
307 return container_of(port, struct tegra_xusb_hsic_port, base);
310 struct tegra_xusb_usb3_port {
311 struct tegra_xusb_port base;
312 struct regulator *supply;
313 bool context_saved;
314 unsigned int port;
315 bool internal;
317 u32 tap1;
318 u32 amp;
319 u32 ctle_z;
320 u32 ctle_g;
323 static inline struct tegra_xusb_usb3_port *
324 to_usb3_port(struct tegra_xusb_port *port)
326 return container_of(port, struct tegra_xusb_usb3_port, base);
329 struct tegra_xusb_usb3_port *
330 tegra_xusb_find_usb3_port(struct tegra_xusb_padctl *padctl,
331 unsigned int index);
333 struct tegra_xusb_port_ops {
334 int (*enable)(struct tegra_xusb_port *port);
335 void (*disable)(struct tegra_xusb_port *port);
336 struct tegra_xusb_lane *(*map)(struct tegra_xusb_port *port);
340 * pad controller
342 struct tegra_xusb_padctl_soc;
344 struct tegra_xusb_padctl_ops {
345 struct tegra_xusb_padctl *
346 (*probe)(struct device *dev,
347 const struct tegra_xusb_padctl_soc *soc);
348 void (*remove)(struct tegra_xusb_padctl *padctl);
350 int (*usb3_save_context)(struct tegra_xusb_padctl *padctl,
351 unsigned int index);
352 int (*hsic_set_idle)(struct tegra_xusb_padctl *padctl,
353 unsigned int index, bool idle);
354 int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl,
355 unsigned int index, bool enable);
358 struct tegra_xusb_padctl_soc {
359 const struct tegra_xusb_pad_soc * const *pads;
360 unsigned int num_pads;
362 struct {
363 struct {
364 const struct tegra_xusb_port_ops *ops;
365 unsigned int count;
366 } usb2, ulpi, hsic, usb3;
367 } ports;
369 const struct tegra_xusb_padctl_ops *ops;
372 struct tegra_xusb_padctl {
373 struct device *dev;
374 void __iomem *regs;
375 struct mutex lock;
376 struct reset_control *rst;
378 const struct tegra_xusb_padctl_soc *soc;
380 struct tegra_xusb_pad *pcie;
381 struct tegra_xusb_pad *sata;
382 struct tegra_xusb_pad *ulpi;
383 struct tegra_xusb_pad *usb2;
384 struct tegra_xusb_pad *hsic;
386 struct list_head ports;
387 struct list_head lanes;
388 struct list_head pads;
390 unsigned int enable;
392 struct clk *clk;
395 static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value,
396 unsigned long offset)
398 dev_dbg(padctl->dev, "%08lx < %08x\n", offset, value);
399 writel(value, padctl->regs + offset);
402 static inline u32 padctl_readl(struct tegra_xusb_padctl *padctl,
403 unsigned long offset)
405 u32 value = readl(padctl->regs + offset);
406 dev_dbg(padctl->dev, "%08lx > %08x\n", offset, value);
407 return value;
410 struct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
411 const char *name,
412 unsigned int index);
414 #if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
415 extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
416 #endif
417 #if defined(CONFIG_ARCH_TEGRA_210_SOC)
418 extern const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc;
419 #endif
421 #endif /* __PHY_TEGRA_XUSB_H */