| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. |
|---|
| 3 | 4 | * Copyright (c) 2015, Google Inc. |
|---|
| 4 | | - * |
|---|
| 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. |
|---|
| 8 | | - * |
|---|
| 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. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #ifndef __PHY_TEGRA_XUSB_H |
|---|
| .. | .. |
|---|
| 18 | 10 | #include <linux/io.h> |
|---|
| 19 | 11 | #include <linux/mutex.h> |
|---|
| 20 | 12 | #include <linux/workqueue.h> |
|---|
| 13 | + |
|---|
| 14 | +#include <linux/usb/otg.h> |
|---|
| 15 | +#include <linux/usb/role.h> |
|---|
| 21 | 16 | |
|---|
| 22 | 17 | /* legacy entry points for backwards-compatibility */ |
|---|
| 23 | 18 | int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev); |
|---|
| .. | .. |
|---|
| 54 | 49 | int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane, |
|---|
| 55 | 50 | struct device_node *np); |
|---|
| 56 | 51 | |
|---|
| 52 | +struct tegra_xusb_usb3_lane { |
|---|
| 53 | + struct tegra_xusb_lane base; |
|---|
| 54 | +}; |
|---|
| 55 | + |
|---|
| 56 | +static inline struct tegra_xusb_usb3_lane * |
|---|
| 57 | +to_usb3_lane(struct tegra_xusb_lane *lane) |
|---|
| 58 | +{ |
|---|
| 59 | + return container_of(lane, struct tegra_xusb_usb3_lane, base); |
|---|
| 60 | +} |
|---|
| 61 | + |
|---|
| 57 | 62 | struct tegra_xusb_usb2_lane { |
|---|
| 58 | 63 | struct tegra_xusb_lane base; |
|---|
| 59 | 64 | |
|---|
| 60 | 65 | u32 hs_curr_level_offset; |
|---|
| 66 | + bool powered_on; |
|---|
| 61 | 67 | }; |
|---|
| 62 | 68 | |
|---|
| 63 | 69 | static inline struct tegra_xusb_usb2_lane * |
|---|
| .. | .. |
|---|
| 168 | 174 | const struct phy_ops *ops); |
|---|
| 169 | 175 | void tegra_xusb_pad_unregister(struct tegra_xusb_pad *pad); |
|---|
| 170 | 176 | |
|---|
| 177 | +struct tegra_xusb_usb3_pad { |
|---|
| 178 | + struct tegra_xusb_pad base; |
|---|
| 179 | + |
|---|
| 180 | + unsigned int enable; |
|---|
| 181 | + struct mutex lock; |
|---|
| 182 | +}; |
|---|
| 183 | + |
|---|
| 184 | +static inline struct tegra_xusb_usb3_pad * |
|---|
| 185 | +to_usb3_pad(struct tegra_xusb_pad *pad) |
|---|
| 186 | +{ |
|---|
| 187 | + return container_of(pad, struct tegra_xusb_usb3_pad, base); |
|---|
| 188 | +} |
|---|
| 189 | + |
|---|
| 171 | 190 | struct tegra_xusb_usb2_pad { |
|---|
| 172 | 191 | struct tegra_xusb_pad base; |
|---|
| 173 | 192 | |
|---|
| .. | .. |
|---|
| 248 | 267 | struct list_head list; |
|---|
| 249 | 268 | struct device dev; |
|---|
| 250 | 269 | |
|---|
| 270 | + struct usb_role_switch *usb_role_sw; |
|---|
| 271 | + struct work_struct usb_phy_work; |
|---|
| 272 | + struct usb_phy usb_phy; |
|---|
| 273 | + |
|---|
| 251 | 274 | const struct tegra_xusb_port_ops *ops; |
|---|
| 252 | 275 | }; |
|---|
| 276 | + |
|---|
| 277 | +static inline struct tegra_xusb_port *to_tegra_xusb_port(struct device *dev) |
|---|
| 278 | +{ |
|---|
| 279 | + return container_of(dev, struct tegra_xusb_port, dev); |
|---|
| 280 | +} |
|---|
| 253 | 281 | |
|---|
| 254 | 282 | struct tegra_xusb_lane_map { |
|---|
| 255 | 283 | unsigned int port; |
|---|
| .. | .. |
|---|
| 271 | 299 | struct tegra_xusb_port base; |
|---|
| 272 | 300 | |
|---|
| 273 | 301 | struct regulator *supply; |
|---|
| 302 | + enum usb_dr_mode mode; |
|---|
| 274 | 303 | bool internal; |
|---|
| 304 | + int usb3_port_fake; |
|---|
| 275 | 305 | }; |
|---|
| 276 | 306 | |
|---|
| 277 | 307 | static inline struct tegra_xusb_usb2_port * |
|---|
| .. | .. |
|---|
| 283 | 313 | struct tegra_xusb_usb2_port * |
|---|
| 284 | 314 | tegra_xusb_find_usb2_port(struct tegra_xusb_padctl *padctl, |
|---|
| 285 | 315 | unsigned int index); |
|---|
| 316 | +void tegra_xusb_usb2_port_release(struct tegra_xusb_port *port); |
|---|
| 317 | +void tegra_xusb_usb2_port_remove(struct tegra_xusb_port *port); |
|---|
| 286 | 318 | |
|---|
| 287 | 319 | struct tegra_xusb_ulpi_port { |
|---|
| 288 | 320 | struct tegra_xusb_port base; |
|---|
| .. | .. |
|---|
| 297 | 329 | return container_of(port, struct tegra_xusb_ulpi_port, base); |
|---|
| 298 | 330 | } |
|---|
| 299 | 331 | |
|---|
| 332 | +void tegra_xusb_ulpi_port_release(struct tegra_xusb_port *port); |
|---|
| 333 | + |
|---|
| 300 | 334 | struct tegra_xusb_hsic_port { |
|---|
| 301 | 335 | struct tegra_xusb_port base; |
|---|
| 302 | 336 | }; |
|---|
| .. | .. |
|---|
| 307 | 341 | return container_of(port, struct tegra_xusb_hsic_port, base); |
|---|
| 308 | 342 | } |
|---|
| 309 | 343 | |
|---|
| 344 | +void tegra_xusb_hsic_port_release(struct tegra_xusb_port *port); |
|---|
| 345 | + |
|---|
| 310 | 346 | struct tegra_xusb_usb3_port { |
|---|
| 311 | 347 | struct tegra_xusb_port base; |
|---|
| 312 | 348 | struct regulator *supply; |
|---|
| 313 | 349 | bool context_saved; |
|---|
| 314 | 350 | unsigned int port; |
|---|
| 315 | 351 | bool internal; |
|---|
| 352 | + bool disable_gen2; |
|---|
| 316 | 353 | |
|---|
| 317 | 354 | u32 tap1; |
|---|
| 318 | 355 | u32 amp; |
|---|
| .. | .. |
|---|
| 329 | 366 | struct tegra_xusb_usb3_port * |
|---|
| 330 | 367 | tegra_xusb_find_usb3_port(struct tegra_xusb_padctl *padctl, |
|---|
| 331 | 368 | unsigned int index); |
|---|
| 369 | +void tegra_xusb_usb3_port_release(struct tegra_xusb_port *port); |
|---|
| 370 | +void tegra_xusb_usb3_port_remove(struct tegra_xusb_port *port); |
|---|
| 332 | 371 | |
|---|
| 333 | 372 | struct tegra_xusb_port_ops { |
|---|
| 373 | + void (*release)(struct tegra_xusb_port *port); |
|---|
| 374 | + void (*remove)(struct tegra_xusb_port *port); |
|---|
| 334 | 375 | int (*enable)(struct tegra_xusb_port *port); |
|---|
| 335 | 376 | void (*disable)(struct tegra_xusb_port *port); |
|---|
| 336 | 377 | struct tegra_xusb_lane *(*map)(struct tegra_xusb_port *port); |
|---|
| .. | .. |
|---|
| 353 | 394 | unsigned int index, bool idle); |
|---|
| 354 | 395 | int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl, |
|---|
| 355 | 396 | unsigned int index, bool enable); |
|---|
| 397 | + int (*vbus_override)(struct tegra_xusb_padctl *padctl, bool set); |
|---|
| 398 | + int (*utmi_port_reset)(struct phy *phy); |
|---|
| 356 | 399 | }; |
|---|
| 357 | 400 | |
|---|
| 358 | 401 | struct tegra_xusb_padctl_soc { |
|---|
| .. | .. |
|---|
| 367 | 410 | } ports; |
|---|
| 368 | 411 | |
|---|
| 369 | 412 | const struct tegra_xusb_padctl_ops *ops; |
|---|
| 413 | + |
|---|
| 414 | + const char * const *supply_names; |
|---|
| 415 | + unsigned int num_supplies; |
|---|
| 416 | + bool supports_gen2; |
|---|
| 417 | + bool need_fake_usb3_port; |
|---|
| 370 | 418 | }; |
|---|
| 371 | 419 | |
|---|
| 372 | 420 | struct tegra_xusb_padctl { |
|---|
| .. | .. |
|---|
| 390 | 438 | unsigned int enable; |
|---|
| 391 | 439 | |
|---|
| 392 | 440 | struct clk *clk; |
|---|
| 441 | + |
|---|
| 442 | + struct regulator_bulk_data *supplies; |
|---|
| 393 | 443 | }; |
|---|
| 394 | 444 | |
|---|
| 395 | 445 | static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value, |
|---|
| .. | .. |
|---|
| 417 | 467 | #if defined(CONFIG_ARCH_TEGRA_210_SOC) |
|---|
| 418 | 468 | extern const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc; |
|---|
| 419 | 469 | #endif |
|---|
| 470 | +#if defined(CONFIG_ARCH_TEGRA_186_SOC) |
|---|
| 471 | +extern const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc; |
|---|
| 472 | +#endif |
|---|
| 473 | +#if defined(CONFIG_ARCH_TEGRA_194_SOC) |
|---|
| 474 | +extern const struct tegra_xusb_padctl_soc tegra194_xusb_padctl_soc; |
|---|
| 475 | +#endif |
|---|
| 420 | 476 | |
|---|
| 421 | 477 | #endif /* __PHY_TEGRA_XUSB_H */ |
|---|