Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 4 | */ |
| 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 Glass | be78909 | 2017-07-25 08:29:59 -0600 | [diff] [blame] | 11 | #include <dm/ofnode.h> |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 12 | |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/arch-tegra/xusb-padctl.h> |
Simon Glass | be78909 | 2017-07-25 08:29:59 -0600 | [diff] [blame] | 15 | #include <linux/ioport.h> |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 16 | |
| 17 | struct 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 | |
| 29 | struct 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 | |
| 36 | struct tegra_xusb_phy { |
Stephen Warren | 095e658 | 2015-10-23 10:50:50 -0600 | [diff] [blame] | 37 | unsigned int type; |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 38 | const struct tegra_xusb_phy_ops *ops; |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 39 | struct tegra_xusb_padctl *padctl; |
| 40 | }; |
| 41 | |
| 42 | struct tegra_xusb_padctl_pin { |
| 43 | const struct tegra_xusb_padctl_lane *lane; |
| 44 | |
| 45 | unsigned int func; |
| 46 | int iddq; |
| 47 | }; |
| 48 | |
Stephen Warren | 4e4b557 | 2015-10-23 10:50:52 -0600 | [diff] [blame] | 49 | #define MAX_GROUPS 5 |
| 50 | #define MAX_PINS 7 |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 51 | |
| 52 | struct 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 Warren | 095e658 | 2015-10-23 10:50:50 -0600 | [diff] [blame] | 62 | struct 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 Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 71 | struct 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 | |
| 78 | struct tegra_xusb_padctl { |
Stephen Warren | 095e658 | 2015-10-23 10:50:50 -0600 | [diff] [blame] | 79 | const struct tegra_xusb_padctl_soc *socdata; |
| 80 | struct tegra_xusb_padctl_config config; |
Simon Glass | be78909 | 2017-07-25 08:29:59 -0600 | [diff] [blame] | 81 | struct resource regs; |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 82 | unsigned int enable; |
| 83 | |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 84 | }; |
Stephen Warren | 095e658 | 2015-10-23 10:50:50 -0600 | [diff] [blame] | 85 | extern struct tegra_xusb_padctl padctl; |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 86 | |
| 87 | static inline u32 padctl_readl(struct tegra_xusb_padctl *padctl, |
| 88 | unsigned long offset) |
| 89 | { |
| 90 | return readl(padctl->regs.start + offset); |
| 91 | } |
| 92 | |
| 93 | static 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 Glass | be78909 | 2017-07-25 08:29:59 -0600 | [diff] [blame] | 99 | int tegra_xusb_process_nodes(ofnode nodes[], unsigned int count, |
| 100 | const struct tegra_xusb_padctl_soc *socdata); |
Stephen Warren | 1680d7b | 2015-10-23 10:50:49 -0600 | [diff] [blame] | 101 | |
| 102 | #endif |