xref: /kernel/linux/linux-5.10/drivers/phy/tegra/xusb.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2014-2015, NVIDIA CORPORATION.  All rights reserved.
48c2ecf20Sopenharmony_ci * Copyright (c) 2015, Google Inc.
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef __PHY_TEGRA_XUSB_H
88c2ecf20Sopenharmony_ci#define __PHY_TEGRA_XUSB_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/io.h>
118c2ecf20Sopenharmony_ci#include <linux/mutex.h>
128c2ecf20Sopenharmony_ci#include <linux/workqueue.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <linux/usb/otg.h>
158c2ecf20Sopenharmony_ci#include <linux/usb/role.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* legacy entry points for backwards-compatibility */
188c2ecf20Sopenharmony_ciint tegra_xusb_padctl_legacy_probe(struct platform_device *pdev);
198c2ecf20Sopenharmony_ciint tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cistruct phy;
228c2ecf20Sopenharmony_cistruct phy_provider;
238c2ecf20Sopenharmony_cistruct platform_device;
248c2ecf20Sopenharmony_cistruct regulator;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/*
278c2ecf20Sopenharmony_ci * lanes
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_cistruct tegra_xusb_lane_soc {
308c2ecf20Sopenharmony_ci	const char *name;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	unsigned int offset;
338c2ecf20Sopenharmony_ci	unsigned int shift;
348c2ecf20Sopenharmony_ci	unsigned int mask;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci	const char * const *funcs;
378c2ecf20Sopenharmony_ci	unsigned int num_funcs;
388c2ecf20Sopenharmony_ci};
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_cistruct tegra_xusb_lane {
418c2ecf20Sopenharmony_ci	const struct tegra_xusb_lane_soc *soc;
428c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *pad;
438c2ecf20Sopenharmony_ci	struct device_node *np;
448c2ecf20Sopenharmony_ci	struct list_head list;
458c2ecf20Sopenharmony_ci	unsigned int function;
468c2ecf20Sopenharmony_ci	unsigned int index;
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciint tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
508c2ecf20Sopenharmony_ci			     struct device_node *np);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct tegra_xusb_usb3_lane {
538c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb3_lane *
578c2ecf20Sopenharmony_cito_usb3_lane(struct tegra_xusb_lane *lane)
588c2ecf20Sopenharmony_ci{
598c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_usb3_lane, base);
608c2ecf20Sopenharmony_ci}
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_cistruct tegra_xusb_usb2_lane {
638c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci	u32 hs_curr_level_offset;
668c2ecf20Sopenharmony_ci	bool powered_on;
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb2_lane *
708c2ecf20Sopenharmony_cito_usb2_lane(struct tegra_xusb_lane *lane)
718c2ecf20Sopenharmony_ci{
728c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_usb2_lane, base);
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistruct tegra_xusb_ulpi_lane {
768c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_ulpi_lane *
808c2ecf20Sopenharmony_cito_ulpi_lane(struct tegra_xusb_lane *lane)
818c2ecf20Sopenharmony_ci{
828c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_ulpi_lane, base);
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_cistruct tegra_xusb_hsic_lane {
868c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	u32 strobe_trim;
898c2ecf20Sopenharmony_ci	u32 rx_strobe_trim;
908c2ecf20Sopenharmony_ci	u32 rx_data_trim;
918c2ecf20Sopenharmony_ci	u32 tx_rtune_n;
928c2ecf20Sopenharmony_ci	u32 tx_rtune_p;
938c2ecf20Sopenharmony_ci	u32 tx_rslew_n;
948c2ecf20Sopenharmony_ci	u32 tx_rslew_p;
958c2ecf20Sopenharmony_ci	bool auto_term;
968c2ecf20Sopenharmony_ci};
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_hsic_lane *
998c2ecf20Sopenharmony_cito_hsic_lane(struct tegra_xusb_lane *lane)
1008c2ecf20Sopenharmony_ci{
1018c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_hsic_lane, base);
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistruct tegra_xusb_pcie_lane {
1058c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
1068c2ecf20Sopenharmony_ci};
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_pcie_lane *
1098c2ecf20Sopenharmony_cito_pcie_lane(struct tegra_xusb_lane *lane)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_pcie_lane, base);
1128c2ecf20Sopenharmony_ci}
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistruct tegra_xusb_sata_lane {
1158c2ecf20Sopenharmony_ci	struct tegra_xusb_lane base;
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_sata_lane *
1198c2ecf20Sopenharmony_cito_sata_lane(struct tegra_xusb_lane *lane)
1208c2ecf20Sopenharmony_ci{
1218c2ecf20Sopenharmony_ci	return container_of(lane, struct tegra_xusb_sata_lane, base);
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistruct tegra_xusb_lane_ops {
1258c2ecf20Sopenharmony_ci	struct tegra_xusb_lane *(*probe)(struct tegra_xusb_pad *pad,
1268c2ecf20Sopenharmony_ci					 struct device_node *np,
1278c2ecf20Sopenharmony_ci					 unsigned int index);
1288c2ecf20Sopenharmony_ci	void (*remove)(struct tegra_xusb_lane *lane);
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/*
1328c2ecf20Sopenharmony_ci * pads
1338c2ecf20Sopenharmony_ci */
1348c2ecf20Sopenharmony_cistruct tegra_xusb_pad_soc;
1358c2ecf20Sopenharmony_cistruct tegra_xusb_padctl;
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct tegra_xusb_pad_ops {
1388c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *(*probe)(struct tegra_xusb_padctl *padctl,
1398c2ecf20Sopenharmony_ci					const struct tegra_xusb_pad_soc *soc,
1408c2ecf20Sopenharmony_ci					struct device_node *np);
1418c2ecf20Sopenharmony_ci	void (*remove)(struct tegra_xusb_pad *pad);
1428c2ecf20Sopenharmony_ci};
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_cistruct tegra_xusb_pad_soc {
1458c2ecf20Sopenharmony_ci	const char *name;
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	const struct tegra_xusb_lane_soc *lanes;
1488c2ecf20Sopenharmony_ci	unsigned int num_lanes;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	const struct tegra_xusb_pad_ops *ops;
1518c2ecf20Sopenharmony_ci};
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct tegra_xusb_pad {
1548c2ecf20Sopenharmony_ci	const struct tegra_xusb_pad_soc *soc;
1558c2ecf20Sopenharmony_ci	struct tegra_xusb_padctl *padctl;
1568c2ecf20Sopenharmony_ci	struct phy_provider *provider;
1578c2ecf20Sopenharmony_ci	struct phy **lanes;
1588c2ecf20Sopenharmony_ci	struct device dev;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	const struct tegra_xusb_lane_ops *ops;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	struct list_head list;
1638c2ecf20Sopenharmony_ci};
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_pad *to_tegra_xusb_pad(struct device *dev)
1668c2ecf20Sopenharmony_ci{
1678c2ecf20Sopenharmony_ci	return container_of(dev, struct tegra_xusb_pad, dev);
1688c2ecf20Sopenharmony_ci}
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ciint tegra_xusb_pad_init(struct tegra_xusb_pad *pad,
1718c2ecf20Sopenharmony_ci			struct tegra_xusb_padctl *padctl,
1728c2ecf20Sopenharmony_ci			struct device_node *np);
1738c2ecf20Sopenharmony_ciint tegra_xusb_pad_register(struct tegra_xusb_pad *pad,
1748c2ecf20Sopenharmony_ci			    const struct phy_ops *ops);
1758c2ecf20Sopenharmony_civoid tegra_xusb_pad_unregister(struct tegra_xusb_pad *pad);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistruct tegra_xusb_usb3_pad {
1788c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ci	unsigned int enable;
1818c2ecf20Sopenharmony_ci	struct mutex lock;
1828c2ecf20Sopenharmony_ci};
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb3_pad *
1858c2ecf20Sopenharmony_cito_usb3_pad(struct tegra_xusb_pad *pad)
1868c2ecf20Sopenharmony_ci{
1878c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_usb3_pad, base);
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_cistruct tegra_xusb_usb2_pad {
1918c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	struct clk *clk;
1948c2ecf20Sopenharmony_ci	unsigned int enable;
1958c2ecf20Sopenharmony_ci	struct mutex lock;
1968c2ecf20Sopenharmony_ci};
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb2_pad *
1998c2ecf20Sopenharmony_cito_usb2_pad(struct tegra_xusb_pad *pad)
2008c2ecf20Sopenharmony_ci{
2018c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_usb2_pad, base);
2028c2ecf20Sopenharmony_ci}
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_cistruct tegra_xusb_ulpi_pad {
2058c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
2068c2ecf20Sopenharmony_ci};
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_ulpi_pad *
2098c2ecf20Sopenharmony_cito_ulpi_pad(struct tegra_xusb_pad *pad)
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_ulpi_pad, base);
2128c2ecf20Sopenharmony_ci}
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_cistruct tegra_xusb_hsic_pad {
2158c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci	struct regulator *supply;
2188c2ecf20Sopenharmony_ci	struct clk *clk;
2198c2ecf20Sopenharmony_ci};
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_hsic_pad *
2228c2ecf20Sopenharmony_cito_hsic_pad(struct tegra_xusb_pad *pad)
2238c2ecf20Sopenharmony_ci{
2248c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_hsic_pad, base);
2258c2ecf20Sopenharmony_ci}
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct tegra_xusb_pcie_pad {
2288c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci	struct reset_control *rst;
2318c2ecf20Sopenharmony_ci	struct clk *pll;
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	unsigned int enable;
2348c2ecf20Sopenharmony_ci};
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_pcie_pad *
2378c2ecf20Sopenharmony_cito_pcie_pad(struct tegra_xusb_pad *pad)
2388c2ecf20Sopenharmony_ci{
2398c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_pcie_pad, base);
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cistruct tegra_xusb_sata_pad {
2438c2ecf20Sopenharmony_ci	struct tegra_xusb_pad base;
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci	struct reset_control *rst;
2468c2ecf20Sopenharmony_ci	struct clk *pll;
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	unsigned int enable;
2498c2ecf20Sopenharmony_ci};
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_sata_pad *
2528c2ecf20Sopenharmony_cito_sata_pad(struct tegra_xusb_pad *pad)
2538c2ecf20Sopenharmony_ci{
2548c2ecf20Sopenharmony_ci	return container_of(pad, struct tegra_xusb_sata_pad, base);
2558c2ecf20Sopenharmony_ci}
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/*
2588c2ecf20Sopenharmony_ci * ports
2598c2ecf20Sopenharmony_ci */
2608c2ecf20Sopenharmony_cistruct tegra_xusb_port_ops;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_cistruct tegra_xusb_port {
2638c2ecf20Sopenharmony_ci	struct tegra_xusb_padctl *padctl;
2648c2ecf20Sopenharmony_ci	struct tegra_xusb_lane *lane;
2658c2ecf20Sopenharmony_ci	unsigned int index;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	struct list_head list;
2688c2ecf20Sopenharmony_ci	struct device dev;
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	struct usb_role_switch *usb_role_sw;
2718c2ecf20Sopenharmony_ci	struct work_struct usb_phy_work;
2728c2ecf20Sopenharmony_ci	struct usb_phy usb_phy;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	const struct tegra_xusb_port_ops *ops;
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_port *to_tegra_xusb_port(struct device *dev)
2788c2ecf20Sopenharmony_ci{
2798c2ecf20Sopenharmony_ci	return container_of(dev, struct tegra_xusb_port, dev);
2808c2ecf20Sopenharmony_ci}
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistruct tegra_xusb_lane_map {
2838c2ecf20Sopenharmony_ci	unsigned int port;
2848c2ecf20Sopenharmony_ci	const char *type;
2858c2ecf20Sopenharmony_ci	unsigned int index;
2868c2ecf20Sopenharmony_ci	const char *func;
2878c2ecf20Sopenharmony_ci};
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cistruct tegra_xusb_lane *
2908c2ecf20Sopenharmony_citegra_xusb_port_find_lane(struct tegra_xusb_port *port,
2918c2ecf20Sopenharmony_ci			  const struct tegra_xusb_lane_map *map,
2928c2ecf20Sopenharmony_ci			  const char *function);
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistruct tegra_xusb_port *
2958c2ecf20Sopenharmony_citegra_xusb_find_port(struct tegra_xusb_padctl *padctl, const char *type,
2968c2ecf20Sopenharmony_ci		     unsigned int index);
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_cistruct tegra_xusb_usb2_port {
2998c2ecf20Sopenharmony_ci	struct tegra_xusb_port base;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	struct regulator *supply;
3028c2ecf20Sopenharmony_ci	enum usb_dr_mode mode;
3038c2ecf20Sopenharmony_ci	bool internal;
3048c2ecf20Sopenharmony_ci	int usb3_port_fake;
3058c2ecf20Sopenharmony_ci};
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb2_port *
3088c2ecf20Sopenharmony_cito_usb2_port(struct tegra_xusb_port *port)
3098c2ecf20Sopenharmony_ci{
3108c2ecf20Sopenharmony_ci	return container_of(port, struct tegra_xusb_usb2_port, base);
3118c2ecf20Sopenharmony_ci}
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_cistruct tegra_xusb_usb2_port *
3148c2ecf20Sopenharmony_citegra_xusb_find_usb2_port(struct tegra_xusb_padctl *padctl,
3158c2ecf20Sopenharmony_ci			  unsigned int index);
3168c2ecf20Sopenharmony_civoid tegra_xusb_usb2_port_release(struct tegra_xusb_port *port);
3178c2ecf20Sopenharmony_civoid tegra_xusb_usb2_port_remove(struct tegra_xusb_port *port);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_cistruct tegra_xusb_ulpi_port {
3208c2ecf20Sopenharmony_ci	struct tegra_xusb_port base;
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	struct regulator *supply;
3238c2ecf20Sopenharmony_ci	bool internal;
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_ulpi_port *
3278c2ecf20Sopenharmony_cito_ulpi_port(struct tegra_xusb_port *port)
3288c2ecf20Sopenharmony_ci{
3298c2ecf20Sopenharmony_ci	return container_of(port, struct tegra_xusb_ulpi_port, base);
3308c2ecf20Sopenharmony_ci}
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_civoid tegra_xusb_ulpi_port_release(struct tegra_xusb_port *port);
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_cistruct tegra_xusb_hsic_port {
3358c2ecf20Sopenharmony_ci	struct tegra_xusb_port base;
3368c2ecf20Sopenharmony_ci};
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_hsic_port *
3398c2ecf20Sopenharmony_cito_hsic_port(struct tegra_xusb_port *port)
3408c2ecf20Sopenharmony_ci{
3418c2ecf20Sopenharmony_ci	return container_of(port, struct tegra_xusb_hsic_port, base);
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_civoid tegra_xusb_hsic_port_release(struct tegra_xusb_port *port);
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_cistruct tegra_xusb_usb3_port {
3478c2ecf20Sopenharmony_ci	struct tegra_xusb_port base;
3488c2ecf20Sopenharmony_ci	struct regulator *supply;
3498c2ecf20Sopenharmony_ci	bool context_saved;
3508c2ecf20Sopenharmony_ci	unsigned int port;
3518c2ecf20Sopenharmony_ci	bool internal;
3528c2ecf20Sopenharmony_ci	bool disable_gen2;
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	u32 tap1;
3558c2ecf20Sopenharmony_ci	u32 amp;
3568c2ecf20Sopenharmony_ci	u32 ctle_z;
3578c2ecf20Sopenharmony_ci	u32 ctle_g;
3588c2ecf20Sopenharmony_ci};
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_cistatic inline struct tegra_xusb_usb3_port *
3618c2ecf20Sopenharmony_cito_usb3_port(struct tegra_xusb_port *port)
3628c2ecf20Sopenharmony_ci{
3638c2ecf20Sopenharmony_ci	return container_of(port, struct tegra_xusb_usb3_port, base);
3648c2ecf20Sopenharmony_ci}
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cistruct tegra_xusb_usb3_port *
3678c2ecf20Sopenharmony_citegra_xusb_find_usb3_port(struct tegra_xusb_padctl *padctl,
3688c2ecf20Sopenharmony_ci			  unsigned int index);
3698c2ecf20Sopenharmony_civoid tegra_xusb_usb3_port_release(struct tegra_xusb_port *port);
3708c2ecf20Sopenharmony_civoid tegra_xusb_usb3_port_remove(struct tegra_xusb_port *port);
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_cistruct tegra_xusb_port_ops {
3738c2ecf20Sopenharmony_ci	void (*release)(struct tegra_xusb_port *port);
3748c2ecf20Sopenharmony_ci	void (*remove)(struct tegra_xusb_port *port);
3758c2ecf20Sopenharmony_ci	int (*enable)(struct tegra_xusb_port *port);
3768c2ecf20Sopenharmony_ci	void (*disable)(struct tegra_xusb_port *port);
3778c2ecf20Sopenharmony_ci	struct tegra_xusb_lane *(*map)(struct tegra_xusb_port *port);
3788c2ecf20Sopenharmony_ci};
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci/*
3818c2ecf20Sopenharmony_ci * pad controller
3828c2ecf20Sopenharmony_ci */
3838c2ecf20Sopenharmony_cistruct tegra_xusb_padctl_soc;
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_cistruct tegra_xusb_padctl_ops {
3868c2ecf20Sopenharmony_ci	struct tegra_xusb_padctl *
3878c2ecf20Sopenharmony_ci		(*probe)(struct device *dev,
3888c2ecf20Sopenharmony_ci			 const struct tegra_xusb_padctl_soc *soc);
3898c2ecf20Sopenharmony_ci	void (*remove)(struct tegra_xusb_padctl *padctl);
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci	int (*usb3_save_context)(struct tegra_xusb_padctl *padctl,
3928c2ecf20Sopenharmony_ci				 unsigned int index);
3938c2ecf20Sopenharmony_ci	int (*hsic_set_idle)(struct tegra_xusb_padctl *padctl,
3948c2ecf20Sopenharmony_ci			     unsigned int index, bool idle);
3958c2ecf20Sopenharmony_ci	int (*usb3_set_lfps_detect)(struct tegra_xusb_padctl *padctl,
3968c2ecf20Sopenharmony_ci				    unsigned int index, bool enable);
3978c2ecf20Sopenharmony_ci	int (*vbus_override)(struct tegra_xusb_padctl *padctl, bool set);
3988c2ecf20Sopenharmony_ci	int (*utmi_port_reset)(struct phy *phy);
3998c2ecf20Sopenharmony_ci};
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_cistruct tegra_xusb_padctl_soc {
4028c2ecf20Sopenharmony_ci	const struct tegra_xusb_pad_soc * const *pads;
4038c2ecf20Sopenharmony_ci	unsigned int num_pads;
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci	struct {
4068c2ecf20Sopenharmony_ci		struct {
4078c2ecf20Sopenharmony_ci			const struct tegra_xusb_port_ops *ops;
4088c2ecf20Sopenharmony_ci			unsigned int count;
4098c2ecf20Sopenharmony_ci		} usb2, ulpi, hsic, usb3;
4108c2ecf20Sopenharmony_ci	} ports;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	const struct tegra_xusb_padctl_ops *ops;
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci	const char * const *supply_names;
4158c2ecf20Sopenharmony_ci	unsigned int num_supplies;
4168c2ecf20Sopenharmony_ci	bool supports_gen2;
4178c2ecf20Sopenharmony_ci	bool need_fake_usb3_port;
4188c2ecf20Sopenharmony_ci};
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_cistruct tegra_xusb_padctl {
4218c2ecf20Sopenharmony_ci	struct device *dev;
4228c2ecf20Sopenharmony_ci	void __iomem *regs;
4238c2ecf20Sopenharmony_ci	struct mutex lock;
4248c2ecf20Sopenharmony_ci	struct reset_control *rst;
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	const struct tegra_xusb_padctl_soc *soc;
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *pcie;
4298c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *sata;
4308c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *ulpi;
4318c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *usb2;
4328c2ecf20Sopenharmony_ci	struct tegra_xusb_pad *hsic;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	struct list_head ports;
4358c2ecf20Sopenharmony_ci	struct list_head lanes;
4368c2ecf20Sopenharmony_ci	struct list_head pads;
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci	unsigned int enable;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	struct clk *clk;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	struct regulator_bulk_data *supplies;
4438c2ecf20Sopenharmony_ci};
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_cistatic inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value,
4468c2ecf20Sopenharmony_ci				 unsigned long offset)
4478c2ecf20Sopenharmony_ci{
4488c2ecf20Sopenharmony_ci	dev_dbg(padctl->dev, "%08lx < %08x\n", offset, value);
4498c2ecf20Sopenharmony_ci	writel(value, padctl->regs + offset);
4508c2ecf20Sopenharmony_ci}
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_cistatic inline u32 padctl_readl(struct tegra_xusb_padctl *padctl,
4538c2ecf20Sopenharmony_ci			       unsigned long offset)
4548c2ecf20Sopenharmony_ci{
4558c2ecf20Sopenharmony_ci	u32 value = readl(padctl->regs + offset);
4568c2ecf20Sopenharmony_ci	dev_dbg(padctl->dev, "%08lx > %08x\n", offset, value);
4578c2ecf20Sopenharmony_ci	return value;
4588c2ecf20Sopenharmony_ci}
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_cistruct tegra_xusb_lane *tegra_xusb_find_lane(struct tegra_xusb_padctl *padctl,
4618c2ecf20Sopenharmony_ci					     const char *name,
4628c2ecf20Sopenharmony_ci					     unsigned int index);
4638c2ecf20Sopenharmony_ci
4648c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_TEGRA_124_SOC) || defined(CONFIG_ARCH_TEGRA_132_SOC)
4658c2ecf20Sopenharmony_ciextern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc;
4668c2ecf20Sopenharmony_ci#endif
4678c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_TEGRA_210_SOC)
4688c2ecf20Sopenharmony_ciextern const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc;
4698c2ecf20Sopenharmony_ci#endif
4708c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_TEGRA_186_SOC)
4718c2ecf20Sopenharmony_ciextern const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc;
4728c2ecf20Sopenharmony_ci#endif
4738c2ecf20Sopenharmony_ci#if defined(CONFIG_ARCH_TEGRA_194_SOC)
4748c2ecf20Sopenharmony_ciextern const struct tegra_xusb_padctl_soc tegra194_xusb_padctl_soc;
4758c2ecf20Sopenharmony_ci#endif
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci#endif /* __PHY_TEGRA_XUSB_H */
478