blob: 68365883c7811f9b7780fa1263ce81e335443baa [file] [log] [blame]
Stephen Warren1680d7b2015-10-23 10:50:49 -06001/*
2 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * SPDX-License-Identifier: GPL-2.0
5 */
6
7#ifndef _TEGRA_XUSB_PADCTL_COMMON_H_
8#define _TEGRA_XUSB_PADCTL_COMMON_H_
9
10#include <common.h>
11#include <fdtdec.h>
Simon Glassbe789092017-07-25 08:29:59 -060012#include <dm/ofnode.h>
Stephen Warren1680d7b2015-10-23 10:50:49 -060013
14#include <asm/io.h>
15#include <asm/arch-tegra/xusb-padctl.h>
Simon Glassbe789092017-07-25 08:29:59 -060016#include <linux/ioport.h>
Stephen Warren1680d7b2015-10-23 10:50:49 -060017
18struct tegra_xusb_padctl_lane {
19 const char *name;
20
21 unsigned int offset;
22 unsigned int shift;
23 unsigned int mask;
24 unsigned int iddq;
25
26 const unsigned int *funcs;
27 unsigned int num_funcs;
28};
29
30struct tegra_xusb_phy_ops {
31 int (*prepare)(struct tegra_xusb_phy *phy);
32 int (*enable)(struct tegra_xusb_phy *phy);
33 int (*disable)(struct tegra_xusb_phy *phy);
34 int (*unprepare)(struct tegra_xusb_phy *phy);
35};
36
37struct tegra_xusb_phy {
Stephen Warren095e6582015-10-23 10:50:50 -060038 unsigned int type;
Stephen Warren1680d7b2015-10-23 10:50:49 -060039 const struct tegra_xusb_phy_ops *ops;
Stephen Warren1680d7b2015-10-23 10:50:49 -060040 struct tegra_xusb_padctl *padctl;
41};
42
43struct tegra_xusb_padctl_pin {
44 const struct tegra_xusb_padctl_lane *lane;
45
46 unsigned int func;
47 int iddq;
48};
49
Stephen Warren4e4b5572015-10-23 10:50:52 -060050#define MAX_GROUPS 5
51#define MAX_PINS 7
Stephen Warren1680d7b2015-10-23 10:50:49 -060052
53struct tegra_xusb_padctl_group {
54 const char *name;
55
56 const char *pins[MAX_PINS];
57 unsigned int num_pins;
58
59 const char *func;
60 int iddq;
61};
62
Stephen Warren095e6582015-10-23 10:50:50 -060063struct tegra_xusb_padctl_soc {
64 const struct tegra_xusb_padctl_lane *lanes;
65 unsigned int num_lanes;
66 const char *const *functions;
67 unsigned int num_functions;
68 struct tegra_xusb_phy *phys;
69 unsigned int num_phys;
70};
71
Stephen Warren1680d7b2015-10-23 10:50:49 -060072struct tegra_xusb_padctl_config {
73 const char *name;
74
75 struct tegra_xusb_padctl_group groups[MAX_GROUPS];
76 unsigned int num_groups;
77};
78
79struct tegra_xusb_padctl {
Stephen Warren095e6582015-10-23 10:50:50 -060080 const struct tegra_xusb_padctl_soc *socdata;
81 struct tegra_xusb_padctl_config config;
Simon Glassbe789092017-07-25 08:29:59 -060082 struct resource regs;
Stephen Warren1680d7b2015-10-23 10:50:49 -060083 unsigned int enable;
84
Stephen Warren1680d7b2015-10-23 10:50:49 -060085};
Stephen Warren095e6582015-10-23 10:50:50 -060086extern struct tegra_xusb_padctl padctl;
Stephen Warren1680d7b2015-10-23 10:50:49 -060087
88static inline u32 padctl_readl(struct tegra_xusb_padctl *padctl,
89 unsigned long offset)
90{
91 return readl(padctl->regs.start + offset);
92}
93
94static inline void padctl_writel(struct tegra_xusb_padctl *padctl,
95 u32 value, unsigned long offset)
96{
97 writel(value, padctl->regs.start + offset);
98}
99
Simon Glassbe789092017-07-25 08:29:59 -0600100int tegra_xusb_process_nodes(ofnode nodes[], unsigned int count,
101 const struct tegra_xusb_padctl_soc *socdata);
Stephen Warren1680d7b2015-10-23 10:50:49 -0600102
103#endif