blob: e3fd613f2be190c5d6331882e7156a5f1d3ec702 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Stephen Warren1680d7b2015-10-23 10:50:49 -06002/*
3 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
Stephen Warren1680d7b2015-10-23 10:50:49 -06004 */
5
6#ifndef _TEGRA_XUSB_PADCTL_COMMON_H_
7#define _TEGRA_XUSB_PADCTL_COMMON_H_
8
9#include <common.h>
10#include <fdtdec.h>
Simon Glassbe789092017-07-25 08:29:59 -060011#include <dm/ofnode.h>
Stephen Warren1680d7b2015-10-23 10:50:49 -060012
13#include <asm/io.h>
14#include <asm/arch-tegra/xusb-padctl.h>
Simon Glassbe789092017-07-25 08:29:59 -060015#include <linux/ioport.h>
Stephen Warren1680d7b2015-10-23 10:50:49 -060016
17struct tegra_xusb_padctl_lane {
18 const char *name;
19
20 unsigned int offset;
21 unsigned int shift;
22 unsigned int mask;
23 unsigned int iddq;
24
25 const unsigned int *funcs;
26 unsigned int num_funcs;
27};
28
29struct tegra_xusb_phy_ops {
30 int (*prepare)(struct tegra_xusb_phy *phy);
31 int (*enable)(struct tegra_xusb_phy *phy);
32 int (*disable)(struct tegra_xusb_phy *phy);
33 int (*unprepare)(struct tegra_xusb_phy *phy);
34};
35
36struct tegra_xusb_phy {
Stephen Warren095e6582015-10-23 10:50:50 -060037 unsigned int type;
Stephen Warren1680d7b2015-10-23 10:50:49 -060038 const struct tegra_xusb_phy_ops *ops;
Stephen Warren1680d7b2015-10-23 10:50:49 -060039 struct tegra_xusb_padctl *padctl;
40};
41
42struct tegra_xusb_padctl_pin {
43 const struct tegra_xusb_padctl_lane *lane;
44
45 unsigned int func;
46 int iddq;
47};
48
Stephen Warren4e4b5572015-10-23 10:50:52 -060049#define MAX_GROUPS 5
50#define MAX_PINS 7
Stephen Warren1680d7b2015-10-23 10:50:49 -060051
52struct tegra_xusb_padctl_group {
53 const char *name;
54
55 const char *pins[MAX_PINS];
56 unsigned int num_pins;
57
58 const char *func;
59 int iddq;
60};
61
Stephen Warren095e6582015-10-23 10:50:50 -060062struct tegra_xusb_padctl_soc {
63 const struct tegra_xusb_padctl_lane *lanes;
64 unsigned int num_lanes;
65 const char *const *functions;
66 unsigned int num_functions;
67 struct tegra_xusb_phy *phys;
68 unsigned int num_phys;
69};
70
Stephen Warren1680d7b2015-10-23 10:50:49 -060071struct tegra_xusb_padctl_config {
72 const char *name;
73
74 struct tegra_xusb_padctl_group groups[MAX_GROUPS];
75 unsigned int num_groups;
76};
77
78struct tegra_xusb_padctl {
Stephen Warren095e6582015-10-23 10:50:50 -060079 const struct tegra_xusb_padctl_soc *socdata;
80 struct tegra_xusb_padctl_config config;
Simon Glassbe789092017-07-25 08:29:59 -060081 struct resource regs;
Stephen Warren1680d7b2015-10-23 10:50:49 -060082 unsigned int enable;
83
Stephen Warren1680d7b2015-10-23 10:50:49 -060084};
Stephen Warren095e6582015-10-23 10:50:50 -060085extern struct tegra_xusb_padctl padctl;
Stephen Warren1680d7b2015-10-23 10:50:49 -060086
87static inline u32 padctl_readl(struct tegra_xusb_padctl *padctl,
88 unsigned long offset)
89{
90 return readl(padctl->regs.start + offset);
91}
92
93static inline void padctl_writel(struct tegra_xusb_padctl *padctl,
94 u32 value, unsigned long offset)
95{
96 writel(value, padctl->regs.start + offset);
97}
98
Simon Glassbe789092017-07-25 08:29:59 -060099int tegra_xusb_process_nodes(ofnode nodes[], unsigned int count,
100 const struct tegra_xusb_padctl_soc *socdata);
Stephen Warren1680d7b2015-10-23 10:50:49 -0600101
102#endif