blob: a28251691d156858fd407241d633ac0427407160 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*
* Copyright (C) 2015 Samsung Electronics Co., Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __PHY_EXYNOS_USBDRD_H__
#define __PHY_EXYNOS_USBDRD_H__
#include "phy-samsung-usb-cal.h"
#include "phy-samsung-usb3-cal.h"
/* PMU register offset for USB */
#define EXYNOS_USBDEV_PHY_CONTROL (0x704)
#define EXYNOS_USBDRD_ENABLE BIT(0)
#define EXYNOS_USBHOST_ENABLE BIT(1)
/* Exynos USB PHY registers */
#define EXYNOS_FSEL_9MHZ6 0x0
#define EXYNOS_FSEL_10MHZ 0x1
#define EXYNOS_FSEL_12MHZ 0x2
#define EXYNOS_FSEL_19MHZ2 0x3
#define EXYNOS_FSEL_20MHZ 0x4
#define EXYNOS_FSEL_24MHZ 0x5
#define EXYNOS_FSEL_26MHZ 0x82
#define EXYNOS_FSEL_50MHZ 0x7
/* EXYNOS: USB DRD PHY registers */
#define EXYNOS_DRD_LINKSYSTEM 0x04
#define LINKSYSTEM_FLADJ_MASK (0x3f << 1)
#define LINKSYSTEM_FLADJ(_x) ((_x) << 1)
#define EXYNOS_DRD_PHYUTMI 0x08
#define EXYNOS_DRD_PHYPIPE 0x0c
#define PHY_CLOCK_SEL (0x1 << 4)
#define EXYNOS_DRD_PHYCLKRST 0x10
#define PHYCLKRST_SSC_REFCLKSEL_MASK (0xff << 23)
#define PHYCLKRST_SSC_REFCLKSEL(_x) ((_x) << 23)
#define PHYCLKRST_SSC_RANGE_MASK (0x03 << 21)
#define PHYCLKRST_SSC_RANGE(_x) ((_x) << 21)
#define PHYCLKRST_MPLL_MULTIPLIER_MASK (0x7f << 11)
#define PHYCLKRST_MPLL_MULTIPLIER_100MHZ_REF (0x19 << 11)
#define PHYCLKRST_MPLL_MULTIPLIER_50M_REF (0x32 << 11)
#define PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF (0x68 << 11)
#define PHYCLKRST_MPLL_MULTIPLIER_20MHZ_REF (0x7d << 11)
#define PHYCLKRST_MPLL_MULTIPLIER_19200KHZ_REF (0x02 << 11)
#define PHYCLKRST_FSEL_UTMI_MASK (0x7 << 5)
#define PHYCLKRST_FSEL_PIPE_MASK (0x7 << 8)
#define PHYCLKRST_FSEL(_x) ((_x) << 5)
#define PHYCLKRST_FSEL_PAD_100MHZ (0x27 << 5)
#define PHYCLKRST_FSEL_PAD_24MHZ (0x2a << 5)
#define PHYCLKRST_FSEL_PAD_20MHZ (0x31 << 5)
#define PHYCLKRST_FSEL_PAD_19_2MHZ (0x38 << 5)
#define PHYCLKRST_REFCLKSEL_MASK (0x03 << 2)
#define PHYCLKRST_REFCLKSEL_PAD_REFCLK (0x2 << 2)
#define PHYCLKRST_REFCLKSEL_EXT_REFCLK (0x3 << 2)
#define EXYNOS_DRD_PHYREG0 0x14
#define EXYNOS_DRD_PHYREG1 0x18
#define EXYNOS_DRD_PHYPARAM0 0x1c
#define PHYPARAM0_REF_LOSLEVEL_MASK (0x1f << 26)
#define PHYPARAM0_REF_LOSLEVEL (0x9 << 26)
#define EXYNOS_DRD_PHYPARAM1 0x20
#define PHYPARAM1_PCS_TXDEEMPH_MASK (0x1f << 0)
#define PHYPARAM1_PCS_TXDEEMPH (0x1c)
#define EXYNOS_DRD_PHYTERM 0x24
#define EXYNOS_DRD_PHYTEST 0x28
#define EXYNOS_DRD_PHYADP 0x2c
#define EXYNOS_DRD_PHYUTMICLKSEL 0x30
#define PHYUTMICLKSEL_UTMI_CLKSEL BIT(2)
#define EXYNOS_DRD_PHYRESUME 0x34
#define EXYNOS_DRD_LINKPORT 0x44
#define KHZ 1000
#define MHZ (KHZ * KHZ)
enum exynos_usbdrd_phy_id {
EXYNOS_DRDPHY_UTMI,
EXYNOS_DRDPHY_PIPE3,
EXYNOS_DRDPHYS_NUM,
};
struct phy_usb_instance;
struct exynos_usbdrd_phy;
struct exynos_usbdrd_phy_config {
u32 id;
void (*phy_isol)(struct phy_usb_instance *inst, u32 on, unsigned int);
void (*phy_init)(struct exynos_usbdrd_phy *phy_drd);
void (*phy_exit)(struct exynos_usbdrd_phy *phy_drd);
void (*phy_tune)(struct exynos_usbdrd_phy *phy_drd, int);
void (*phy_set)(struct exynos_usbdrd_phy *phy_drd, int, void *);
unsigned int (*set_refclk)(struct phy_usb_instance *inst);
};
struct exynos_usbdrd_phy_drvdata {
const struct exynos_usbdrd_phy_config *phy_cfg;
u32 pmu_offset_usbdrd0_phy;
u32 pmu_offset_usbdrd1_phy;
u32 cpu_type;
u32 ip_type;
};
/**
* struct exynos_usbdrd_phy - driver data for USB DRD PHY
* @dev: pointer to device instance of this platform device
* @reg_phy: usb phy controller register memory base
* @clk: phy clock for register access
* @drv_data: pointer to SoC level driver data structure
* @phys[]: array for 'EXYNOS_DRDPHYS_NUM' number of PHY
* instances each with its 'phy' and 'phy_cfg'.
* @extrefclk: frequency select settings when using 'separate
* reference clocks' for SS and HS operations
* @ref_clk: reference clock to PHY block from which PHY's
* operational clocks are derived
* @ref_rate: rate of above reference clock
*/
struct exynos_usbdrd_phy {
struct device *dev;
void __iomem *reg_phy;
struct clk **clocks;
const struct exynos_usbdrd_phy_drvdata *drv_data;
struct phy_usb_instance {
struct phy *phy;
u32 index;
struct regmap *reg_pmu;
u32 pmu_offset;
const struct exynos_usbdrd_phy_config *phy_cfg;
} phys[EXYNOS_DRDPHYS_NUM];
u32 extrefclk;
u32 use_additional_tuning;
struct clk *ref_clk;
struct regulator *vbus;
struct exynos_usbphy_info usbphy_info;
#if IS_ENABLED(CONFIG_EXYNOS_OTP)
#define OTP_SUPPORT_USBPHY_NUMBER 2
#define OTP_USB3PHY_INDEX 0
#define OTP_USB2PHY_INDEX 1
u8 otp_type[OTP_SUPPORT_USBPHY_NUMBER];
u8 otp_index[OTP_SUPPORT_USBPHY_NUMBER];
struct tune_bits *otp_data[OTP_SUPPORT_USBPHY_NUMBER];
#endif
};
#endif /* __PHY_EXYNOS_USBDRD_H__ */
|