blob: c82ac6716f5e6941ee0dc86a2edeaff4b9354642 [file] [log] [blame]
Alan Douglas44d30d62018-11-12 16:42:16 +00001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Cadence Sierra PHY Driver
4 *
5 * Copyright (c) 2018 Cadence Design Systems
6 * Author: Alan Douglas <adouglas@cadence.com>
7 *
8 */
9#include <linux/clk.h>
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +053010#include <linux/clk-provider.h>
Alan Douglas44d30d62018-11-12 16:42:16 +000011#include <linux/delay.h>
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/module.h>
15#include <linux/phy/phy.h>
16#include <linux/platform_device.h>
17#include <linux/pm_runtime.h>
18#include <linux/regmap.h>
19#include <linux/reset.h>
20#include <linux/slab.h>
21#include <linux/of.h>
22#include <linux/of_platform.h>
23#include <dt-bindings/phy/phy.h>
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +053024#include <dt-bindings/phy/phy-cadence.h>
Alan Douglas44d30d62018-11-12 16:42:16 +000025
Swapnil Jakhade078e9e92021-12-23 07:01:24 +010026#define NUM_SSC_MODE 3
27#define NUM_PHY_TYPE 3
28
Alan Douglas44d30d62018-11-12 16:42:16 +000029/* PHY register offsets */
Anil Varughese871002d2019-12-16 15:27:05 +053030#define SIERRA_COMMON_CDB_OFFSET 0x0
31#define SIERRA_MACRO_ID_REG 0x0
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +053032#define SIERRA_CMN_PLLLC_GEN_PREG 0x42
Anil Varughese871002d2019-12-16 15:27:05 +053033#define SIERRA_CMN_PLLLC_MODE_PREG 0x48
34#define SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG 0x49
35#define SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG 0x4A
36#define SIERRA_CMN_PLLLC_LOCK_CNTSTART_PREG 0x4B
37#define SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG 0x4F
38#define SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG 0x50
39#define SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG 0x62
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +053040#define SIERRA_CMN_REFRCV_PREG 0x98
41#define SIERRA_CMN_REFRCV1_PREG 0xB8
42#define SIERRA_CMN_PLLLC1_GEN_PREG 0xC2
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +053043
44#define SIERRA_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
45 ((0x4000 << (block_offset)) + \
46 (((ln) << 9) << (reg_offset)))
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +053047
Anil Varughese871002d2019-12-16 15:27:05 +053048#define SIERRA_DET_STANDEC_A_PREG 0x000
49#define SIERRA_DET_STANDEC_B_PREG 0x001
50#define SIERRA_DET_STANDEC_C_PREG 0x002
51#define SIERRA_DET_STANDEC_D_PREG 0x003
52#define SIERRA_DET_STANDEC_E_PREG 0x004
53#define SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG 0x008
54#define SIERRA_PSM_A0IN_TMR_PREG 0x009
55#define SIERRA_PSM_DIAG_PREG 0x015
56#define SIERRA_PSC_TX_A0_PREG 0x028
57#define SIERRA_PSC_TX_A1_PREG 0x029
58#define SIERRA_PSC_TX_A2_PREG 0x02A
59#define SIERRA_PSC_TX_A3_PREG 0x02B
60#define SIERRA_PSC_RX_A0_PREG 0x030
61#define SIERRA_PSC_RX_A1_PREG 0x031
62#define SIERRA_PSC_RX_A2_PREG 0x032
63#define SIERRA_PSC_RX_A3_PREG 0x033
64#define SIERRA_PLLCTRL_SUBRATE_PREG 0x03A
65#define SIERRA_PLLCTRL_GEN_D_PREG 0x03E
66#define SIERRA_PLLCTRL_CPGAIN_MODE_PREG 0x03F
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +053067#define SIERRA_PLLCTRL_STATUS_PREG 0x044
Anil Varughese871002d2019-12-16 15:27:05 +053068#define SIERRA_CLKPATH_BIASTRIM_PREG 0x04B
69#define SIERRA_DFE_BIASTRIM_PREG 0x04C
70#define SIERRA_DRVCTRL_ATTEN_PREG 0x06A
71#define SIERRA_CLKPATHCTRL_TMR_PREG 0x081
72#define SIERRA_RX_CREQ_FLTR_A_MODE3_PREG 0x085
73#define SIERRA_RX_CREQ_FLTR_A_MODE2_PREG 0x086
74#define SIERRA_RX_CREQ_FLTR_A_MODE1_PREG 0x087
75#define SIERRA_RX_CREQ_FLTR_A_MODE0_PREG 0x088
76#define SIERRA_CREQ_CCLKDET_MODE01_PREG 0x08E
77#define SIERRA_RX_CTLE_MAINTENANCE_PREG 0x091
78#define SIERRA_CREQ_FSMCLK_SEL_PREG 0x092
79#define SIERRA_CREQ_EQ_CTRL_PREG 0x093
80#define SIERRA_CREQ_SPARE_PREG 0x096
81#define SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG 0x097
82#define SIERRA_CTLELUT_CTRL_PREG 0x098
83#define SIERRA_DFE_ECMP_RATESEL_PREG 0x0C0
84#define SIERRA_DFE_SMP_RATESEL_PREG 0x0C1
85#define SIERRA_DEQ_PHALIGN_CTRL 0x0C4
86#define SIERRA_DEQ_CONCUR_CTRL1_PREG 0x0C8
87#define SIERRA_DEQ_CONCUR_CTRL2_PREG 0x0C9
88#define SIERRA_DEQ_EPIPWR_CTRL2_PREG 0x0CD
89#define SIERRA_DEQ_FAST_MAINT_CYCLES_PREG 0x0CE
90#define SIERRA_DEQ_ERRCMP_CTRL_PREG 0x0D0
91#define SIERRA_DEQ_OFFSET_CTRL_PREG 0x0D8
92#define SIERRA_DEQ_GAIN_CTRL_PREG 0x0E0
93#define SIERRA_DEQ_VGATUNE_CTRL_PREG 0x0E1
94#define SIERRA_DEQ_GLUT0 0x0E8
95#define SIERRA_DEQ_GLUT1 0x0E9
96#define SIERRA_DEQ_GLUT2 0x0EA
97#define SIERRA_DEQ_GLUT3 0x0EB
98#define SIERRA_DEQ_GLUT4 0x0EC
99#define SIERRA_DEQ_GLUT5 0x0ED
100#define SIERRA_DEQ_GLUT6 0x0EE
101#define SIERRA_DEQ_GLUT7 0x0EF
102#define SIERRA_DEQ_GLUT8 0x0F0
103#define SIERRA_DEQ_GLUT9 0x0F1
104#define SIERRA_DEQ_GLUT10 0x0F2
105#define SIERRA_DEQ_GLUT11 0x0F3
106#define SIERRA_DEQ_GLUT12 0x0F4
107#define SIERRA_DEQ_GLUT13 0x0F5
108#define SIERRA_DEQ_GLUT14 0x0F6
109#define SIERRA_DEQ_GLUT15 0x0F7
110#define SIERRA_DEQ_GLUT16 0x0F8
111#define SIERRA_DEQ_ALUT0 0x108
112#define SIERRA_DEQ_ALUT1 0x109
113#define SIERRA_DEQ_ALUT2 0x10A
114#define SIERRA_DEQ_ALUT3 0x10B
115#define SIERRA_DEQ_ALUT4 0x10C
116#define SIERRA_DEQ_ALUT5 0x10D
117#define SIERRA_DEQ_ALUT6 0x10E
118#define SIERRA_DEQ_ALUT7 0x10F
119#define SIERRA_DEQ_ALUT8 0x110
120#define SIERRA_DEQ_ALUT9 0x111
121#define SIERRA_DEQ_ALUT10 0x112
122#define SIERRA_DEQ_ALUT11 0x113
123#define SIERRA_DEQ_ALUT12 0x114
124#define SIERRA_DEQ_ALUT13 0x115
125#define SIERRA_DEQ_DFETAP_CTRL_PREG 0x128
126#define SIERRA_DFE_EN_1010_IGNORE_PREG 0x134
127#define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
128#define SIERRA_DEQ_TAU_CTRL2_PREG 0x151
129#define SIERRA_DEQ_PICTRL_PREG 0x161
130#define SIERRA_CPICAL_TMRVAL_MODE1_PREG 0x170
131#define SIERRA_CPICAL_TMRVAL_MODE0_PREG 0x171
132#define SIERRA_CPICAL_PICNT_MODE1_PREG 0x174
133#define SIERRA_CPI_OUTBUF_RATESEL_PREG 0x17C
134#define SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG 0x183
135#define SIERRA_LFPSDET_SUPPORT_PREG 0x188
136#define SIERRA_LFPSFILT_NS_PREG 0x18A
137#define SIERRA_LFPSFILT_RD_PREG 0x18B
138#define SIERRA_LFPSFILT_MP_PREG 0x18C
139#define SIERRA_SIGDET_SUPPORT_PREG 0x190
140#define SIERRA_SDFILT_H2L_A_PREG 0x191
141#define SIERRA_SDFILT_L2H_PREG 0x193
142#define SIERRA_RXBUFFER_CTLECTRL_PREG 0x19E
143#define SIERRA_RXBUFFER_RCDFECTRL_PREG 0x19F
144#define SIERRA_RXBUFFER_DFECTRL_PREG 0x1A0
145#define SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG 0x14F
146#define SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG 0x150
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530147
148#define SIERRA_PHY_CONFIG_CTRL_OFFSET(block_offset) \
149 (0xc000 << (block_offset))
Anil Varughese871002d2019-12-16 15:27:05 +0530150#define SIERRA_PHY_PLL_CFG 0xe
Alan Douglas44d30d62018-11-12 16:42:16 +0000151
Anil Varughese871002d2019-12-16 15:27:05 +0530152#define SIERRA_MACRO_ID 0x00007364
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530153#define SIERRA_MAX_LANES 16
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530154#define PLL_LOCK_TIME 100000
Alan Douglas44d30d62018-11-12 16:42:16 +0000155
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530156#define CDNS_SIERRA_OUTPUT_CLOCKS 2
157#define CDNS_SIERRA_INPUT_CLOCKS 5
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530158enum cdns_sierra_clock_input {
159 PHY_CLK,
160 CMN_REFCLK_DIG_DIV,
161 CMN_REFCLK1_DIG_DIV,
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530162 PLL0_REFCLK,
163 PLL1_REFCLK,
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530164};
165
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530166#define SIERRA_NUM_CMN_PLLC 2
167#define SIERRA_NUM_CMN_PLLC_PARENTS 2
168
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530169static const struct reg_field macro_id_type =
170 REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15);
171static const struct reg_field phy_pll_cfg_1 =
172 REG_FIELD(SIERRA_PHY_PLL_CFG, 1, 1);
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530173static const struct reg_field pllctrl_lock =
174 REG_FIELD(SIERRA_PLLCTRL_STATUS_PREG, 0, 0);
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530175
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530176static const char * const clk_names[] = {
177 [CDNS_SIERRA_PLL_CMNLC] = "pll_cmnlc",
178 [CDNS_SIERRA_PLL_CMNLC1] = "pll_cmnlc1",
179};
180
181enum cdns_sierra_cmn_plllc {
182 CMN_PLLLC,
183 CMN_PLLLC1,
184};
185
186struct cdns_sierra_pll_mux_reg_fields {
187 struct reg_field pfdclk_sel_preg;
188 struct reg_field plllc1en_field;
189 struct reg_field termen_field;
190};
191
192static const struct cdns_sierra_pll_mux_reg_fields cmn_plllc_pfdclk1_sel_preg[] = {
193 [CMN_PLLLC] = {
194 .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC_GEN_PREG, 1, 1),
195 .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 8, 8),
196 .termen_field = REG_FIELD(SIERRA_CMN_REFRCV1_PREG, 0, 0),
197 },
198 [CMN_PLLLC1] = {
199 .pfdclk_sel_preg = REG_FIELD(SIERRA_CMN_PLLLC1_GEN_PREG, 1, 1),
200 .plllc1en_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 8, 8),
201 .termen_field = REG_FIELD(SIERRA_CMN_REFRCV_PREG, 0, 0),
202 },
203};
204
205struct cdns_sierra_pll_mux {
206 struct clk_hw hw;
207 struct regmap_field *pfdclk_sel_preg;
208 struct regmap_field *plllc1en_field;
209 struct regmap_field *termen_field;
210 struct clk_init_data clk_data;
211};
212
213#define to_cdns_sierra_pll_mux(_hw) \
214 container_of(_hw, struct cdns_sierra_pll_mux, hw)
215
216static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
217 [CMN_PLLLC] = { PLL0_REFCLK, PLL1_REFCLK },
218 [CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK },
219};
220
221static u32 cdns_sierra_pll_mux_table[] = { 0, 1 };
222
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100223enum cdns_sierra_phy_type {
224 TYPE_NONE,
225 TYPE_PCIE,
226 TYPE_USB
227};
228
229enum cdns_sierra_ssc_mode {
230 NO_SSC,
231 EXTERNAL_SSC,
232 INTERNAL_SSC
233};
234
Alan Douglas44d30d62018-11-12 16:42:16 +0000235struct cdns_sierra_inst {
236 struct phy *phy;
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100237 enum cdns_sierra_phy_type phy_type;
Alan Douglas44d30d62018-11-12 16:42:16 +0000238 u32 num_lanes;
239 u32 mlane;
240 struct reset_control *lnk_rst;
241};
242
243struct cdns_reg_pairs {
244 u16 val;
245 u32 off;
246};
247
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100248struct cdns_sierra_vals {
249 const struct cdns_reg_pairs *reg_pairs;
250 u32 num_regs;
251};
252
Alan Douglas44d30d62018-11-12 16:42:16 +0000253struct cdns_sierra_data {
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100254 u32 id_value;
255 u8 block_offset_shift;
256 u8 reg_offset_shift;
257 struct cdns_sierra_vals *pma_cmn_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
258 [NUM_SSC_MODE];
259 struct cdns_sierra_vals *pma_ln_vals[NUM_PHY_TYPE][NUM_PHY_TYPE]
260 [NUM_SSC_MODE];
Alan Douglas44d30d62018-11-12 16:42:16 +0000261};
262
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530263struct cdns_regmap_cdb_context {
Alan Douglas44d30d62018-11-12 16:42:16 +0000264 struct device *dev;
265 void __iomem *base;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530266 u8 reg_offset_shift;
267};
268
269struct cdns_sierra_phy {
270 struct device *dev;
271 struct regmap *regmap;
Swapnil Jakhadec3c11d52021-12-23 07:01:23 +0100272 const struct cdns_sierra_data *init_data;
Alan Douglas44d30d62018-11-12 16:42:16 +0000273 struct cdns_sierra_inst phys[SIERRA_MAX_LANES];
274 struct reset_control *phy_rst;
275 struct reset_control *apb_rst;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530276 struct regmap *regmap_lane_cdb[SIERRA_MAX_LANES];
277 struct regmap *regmap_phy_config_ctrl;
278 struct regmap *regmap_common_cdb;
279 struct regmap_field *macro_id_type;
280 struct regmap_field *phy_pll_cfg_1;
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530281 struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES];
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530282 struct regmap_field *cmn_refrcv_refclk_plllc1en_preg[SIERRA_NUM_CMN_PLLC];
283 struct regmap_field *cmn_refrcv_refclk_termen_preg[SIERRA_NUM_CMN_PLLC];
284 struct regmap_field *cmn_plllc_pfdclk1_sel_preg[SIERRA_NUM_CMN_PLLC];
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530285 struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS];
Alan Douglas44d30d62018-11-12 16:42:16 +0000286 int nsubnodes;
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530287 u32 num_lanes;
Alan Douglas44d30d62018-11-12 16:42:16 +0000288 bool autoconf;
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530289 struct clk_onecell_data clk_data;
290 struct clk *output_clks[CDNS_SIERRA_OUTPUT_CLOCKS];
Alan Douglas44d30d62018-11-12 16:42:16 +0000291};
292
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530293static int cdns_regmap_write(void *context, unsigned int reg, unsigned int val)
294{
295 struct cdns_regmap_cdb_context *ctx = context;
296 u32 offset = reg << ctx->reg_offset_shift;
297
298 writew(val, ctx->base + offset);
299
300 return 0;
301}
302
303static int cdns_regmap_read(void *context, unsigned int reg, unsigned int *val)
304{
305 struct cdns_regmap_cdb_context *ctx = context;
306 u32 offset = reg << ctx->reg_offset_shift;
307
308 *val = readw(ctx->base + offset);
309 return 0;
310}
311
312#define SIERRA_LANE_CDB_REGMAP_CONF(n) \
313{ \
314 .name = "sierra_lane" n "_cdb", \
315 .reg_stride = 1, \
316 .fast_io = true, \
317 .reg_write = cdns_regmap_write, \
318 .reg_read = cdns_regmap_read, \
319}
320
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +0200321static const struct regmap_config cdns_sierra_lane_cdb_config[] = {
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530322 SIERRA_LANE_CDB_REGMAP_CONF("0"),
323 SIERRA_LANE_CDB_REGMAP_CONF("1"),
324 SIERRA_LANE_CDB_REGMAP_CONF("2"),
325 SIERRA_LANE_CDB_REGMAP_CONF("3"),
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530326 SIERRA_LANE_CDB_REGMAP_CONF("4"),
327 SIERRA_LANE_CDB_REGMAP_CONF("5"),
328 SIERRA_LANE_CDB_REGMAP_CONF("6"),
329 SIERRA_LANE_CDB_REGMAP_CONF("7"),
330 SIERRA_LANE_CDB_REGMAP_CONF("8"),
331 SIERRA_LANE_CDB_REGMAP_CONF("9"),
332 SIERRA_LANE_CDB_REGMAP_CONF("10"),
333 SIERRA_LANE_CDB_REGMAP_CONF("11"),
334 SIERRA_LANE_CDB_REGMAP_CONF("12"),
335 SIERRA_LANE_CDB_REGMAP_CONF("13"),
336 SIERRA_LANE_CDB_REGMAP_CONF("14"),
337 SIERRA_LANE_CDB_REGMAP_CONF("15"),
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530338};
339
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +0200340static const struct regmap_config cdns_sierra_common_cdb_config = {
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530341 .name = "sierra_common_cdb",
342 .reg_stride = 1,
343 .fast_io = true,
344 .reg_write = cdns_regmap_write,
345 .reg_read = cdns_regmap_read,
346};
347
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +0200348static const struct regmap_config cdns_sierra_phy_config_ctrl_config = {
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530349 .name = "sierra_phy_config_ctrl",
350 .reg_stride = 1,
351 .fast_io = true,
352 .reg_write = cdns_regmap_write,
353 .reg_read = cdns_regmap_read,
354};
355
Kishon Vijay Abraham Icedcc2e2019-12-16 15:27:03 +0530356static int cdns_sierra_phy_init(struct phy *gphy)
Alan Douglas44d30d62018-11-12 16:42:16 +0000357{
358 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
359 struct cdns_sierra_phy *phy = dev_get_drvdata(gphy->dev.parent);
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100360 const struct cdns_sierra_data *init_data = phy->init_data;
361 struct cdns_sierra_vals *pma_cmn_vals, *pma_ln_vals;
362 enum cdns_sierra_phy_type phy_type = ins->phy_type;
363 enum cdns_sierra_ssc_mode ssc = EXTERNAL_SSC;
364 const struct cdns_reg_pairs *reg_pairs;
Colin Ian King80f96fb2020-01-08 11:59:36 +0530365 struct regmap *regmap;
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100366 u32 num_regs;
Alan Douglas44d30d62018-11-12 16:42:16 +0000367 int i, j;
Alan Douglas44d30d62018-11-12 16:42:16 +0000368
Kishon Vijay Abraham Icedcc2e2019-12-16 15:27:03 +0530369 /* Initialise the PHY registers, unless auto configured */
370 if (phy->autoconf)
371 return 0;
372
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530373 clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000);
374 clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000);
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100375
376 /* PMA common registers configurations */
377 pma_cmn_vals = init_data->pma_cmn_vals[phy_type][TYPE_NONE][ssc];
378 if (pma_cmn_vals) {
379 reg_pairs = pma_cmn_vals->reg_pairs;
380 num_regs = pma_cmn_vals->num_regs;
381 regmap = phy->regmap_common_cdb;
382 for (i = 0; i < num_regs; i++)
383 regmap_write(regmap, reg_pairs[i].off, reg_pairs[i].val);
Alan Douglas44d30d62018-11-12 16:42:16 +0000384 }
Anil Varughese871002d2019-12-16 15:27:05 +0530385
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100386 /* PMA lane registers configurations */
387 pma_ln_vals = init_data->pma_ln_vals[phy_type][TYPE_NONE][ssc];
388 if (pma_ln_vals) {
389 reg_pairs = pma_ln_vals->reg_pairs;
390 num_regs = pma_ln_vals->num_regs;
391 for (i = 0; i < ins->num_lanes; i++) {
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530392 regmap = phy->regmap_lane_cdb[i + ins->mlane];
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100393 for (j = 0; j < num_regs; j++)
394 regmap_write(regmap, reg_pairs[j].off, reg_pairs[j].val);
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530395 }
396 }
Kishon Vijay Abraham Icedcc2e2019-12-16 15:27:03 +0530397
398 return 0;
Alan Douglas44d30d62018-11-12 16:42:16 +0000399}
400
401static int cdns_sierra_phy_on(struct phy *gphy)
402{
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530403 struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
Alan Douglas44d30d62018-11-12 16:42:16 +0000404 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530405 struct device *dev = sp->dev;
406 u32 val;
407 int ret;
Alan Douglas44d30d62018-11-12 16:42:16 +0000408
Kishon Vijay Abraham I5b4f5752021-03-19 18:11:16 +0530409 ret = reset_control_deassert(sp->phy_rst);
410 if (ret) {
411 dev_err(dev, "Failed to take the PHY out of reset\n");
412 return ret;
413 }
414
Alan Douglas44d30d62018-11-12 16:42:16 +0000415 /* Take the PHY lane group out of reset */
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530416 ret = reset_control_deassert(ins->lnk_rst);
417 if (ret) {
418 dev_err(dev, "Failed to take the PHY lane out of reset\n");
419 return ret;
420 }
421
422 ret = regmap_field_read_poll_timeout(sp->pllctrl_lock[ins->mlane],
423 val, val, 1000, PLL_LOCK_TIME);
424 if (ret < 0)
425 dev_err(dev, "PLL lock of lane failed\n");
426
427 return ret;
Alan Douglas44d30d62018-11-12 16:42:16 +0000428}
429
430static int cdns_sierra_phy_off(struct phy *gphy)
431{
432 struct cdns_sierra_inst *ins = phy_get_drvdata(gphy);
433
434 return reset_control_assert(ins->lnk_rst);
435}
436
Roger Quadros7904e152020-01-06 15:06:20 +0200437static int cdns_sierra_phy_reset(struct phy *gphy)
438{
439 struct cdns_sierra_phy *sp = dev_get_drvdata(gphy->dev.parent);
440
441 reset_control_assert(sp->phy_rst);
442 reset_control_deassert(sp->phy_rst);
443 return 0;
444};
445
Alan Douglas44d30d62018-11-12 16:42:16 +0000446static const struct phy_ops ops = {
Kishon Vijay Abraham Icedcc2e2019-12-16 15:27:03 +0530447 .init = cdns_sierra_phy_init,
Alan Douglas44d30d62018-11-12 16:42:16 +0000448 .power_on = cdns_sierra_phy_on,
449 .power_off = cdns_sierra_phy_off,
Roger Quadros7904e152020-01-06 15:06:20 +0200450 .reset = cdns_sierra_phy_reset,
Alan Douglas44d30d62018-11-12 16:42:16 +0000451 .owner = THIS_MODULE,
452};
453
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530454static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
455{
456 struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
457 struct regmap_field *field = mux->pfdclk_sel_preg;
458 unsigned int val;
459
460 regmap_field_read(field, &val);
461 return clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table, 0, val);
462}
463
464static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
465{
466 struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
467 struct regmap_field *plllc1en_field = mux->plllc1en_field;
468 struct regmap_field *termen_field = mux->termen_field;
469 struct regmap_field *field = mux->pfdclk_sel_preg;
470 int val, ret;
471
472 ret = regmap_field_write(plllc1en_field, 0);
473 ret |= regmap_field_write(termen_field, 0);
474 if (index == 1) {
475 ret |= regmap_field_write(plllc1en_field, 1);
476 ret |= regmap_field_write(termen_field, 1);
477 }
478
479 val = cdns_sierra_pll_mux_table[index];
480 ret |= regmap_field_write(field, val);
481
482 return ret;
483}
484
485static const struct clk_ops cdns_sierra_pll_mux_ops = {
486 .set_parent = cdns_sierra_pll_mux_set_parent,
487 .get_parent = cdns_sierra_pll_mux_get_parent,
488};
489
490static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
491 struct regmap_field *pfdclk1_sel_field,
492 struct regmap_field *plllc1en_field,
493 struct regmap_field *termen_field,
494 int clk_index)
495{
496 struct cdns_sierra_pll_mux *mux;
497 struct device *dev = sp->dev;
498 struct clk_init_data *init;
499 const char **parent_names;
500 unsigned int num_parents;
501 char clk_name[100];
502 struct clk *clk;
503 int i;
504
505 mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
506 if (!mux)
507 return -ENOMEM;
508
509 num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
510 parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
511 if (!parent_names)
512 return -ENOMEM;
513
514 for (i = 0; i < num_parents; i++) {
515 clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
516 if (IS_ERR_OR_NULL(clk)) {
517 dev_err(dev, "No parent clock for derived_refclk\n");
518 return PTR_ERR(clk);
519 }
520 parent_names[i] = __clk_get_name(clk);
521 }
522
523 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]);
524
525 init = &mux->clk_data;
526
527 init->ops = &cdns_sierra_pll_mux_ops;
528 init->flags = CLK_SET_RATE_NO_REPARENT;
529 init->parent_names = parent_names;
530 init->num_parents = num_parents;
531 init->name = clk_name;
532
533 mux->pfdclk_sel_preg = pfdclk1_sel_field;
534 mux->plllc1en_field = plllc1en_field;
535 mux->termen_field = termen_field;
536 mux->hw.init = init;
537
538 clk = devm_clk_register(dev, &mux->hw);
539 if (IS_ERR(clk))
540 return PTR_ERR(clk);
541
542 sp->output_clks[clk_index] = clk;
543
544 return 0;
545}
546
547static int cdns_sierra_phy_register_pll_mux(struct cdns_sierra_phy *sp)
548{
549 struct regmap_field *pfdclk1_sel_field;
550 struct regmap_field *plllc1en_field;
551 struct regmap_field *termen_field;
552 struct device *dev = sp->dev;
553 int ret = 0, i, clk_index;
554
555 clk_index = CDNS_SIERRA_PLL_CMNLC;
556 for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++, clk_index++) {
557 pfdclk1_sel_field = sp->cmn_plllc_pfdclk1_sel_preg[i];
558 plllc1en_field = sp->cmn_refrcv_refclk_plllc1en_preg[i];
559 termen_field = sp->cmn_refrcv_refclk_termen_preg[i];
560
561 ret = cdns_sierra_pll_mux_register(sp, pfdclk1_sel_field, plllc1en_field,
562 termen_field, clk_index);
563 if (ret) {
564 dev_err(dev, "Fail to register cmn plllc mux\n");
565 return ret;
566 }
567 }
568
569 return 0;
570}
571
572static void cdns_sierra_clk_unregister(struct cdns_sierra_phy *sp)
573{
574 struct device *dev = sp->dev;
575 struct device_node *node = dev->of_node;
576
577 of_clk_del_provider(node);
578}
579
580static int cdns_sierra_clk_register(struct cdns_sierra_phy *sp)
581{
582 struct device *dev = sp->dev;
583 struct device_node *node = dev->of_node;
584 int ret;
585
586 ret = cdns_sierra_phy_register_pll_mux(sp);
587 if (ret) {
588 dev_err(dev, "Failed to pll mux clocks\n");
589 return ret;
590 }
591
592 sp->clk_data.clks = sp->output_clks;
593 sp->clk_data.clk_num = CDNS_SIERRA_OUTPUT_CLOCKS;
594 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &sp->clk_data);
595 if (ret)
596 dev_err(dev, "Failed to add clock provider: %s\n", node->name);
597
598 return ret;
599}
600
Alan Douglas44d30d62018-11-12 16:42:16 +0000601static int cdns_sierra_get_optional(struct cdns_sierra_inst *inst,
602 struct device_node *child)
603{
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100604 u32 phy_type;
605
Alan Douglas44d30d62018-11-12 16:42:16 +0000606 if (of_property_read_u32(child, "reg", &inst->mlane))
607 return -EINVAL;
608
609 if (of_property_read_u32(child, "cdns,num-lanes", &inst->num_lanes))
610 return -EINVAL;
611
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100612 if (of_property_read_u32(child, "cdns,phy-type", &phy_type))
Alan Douglas44d30d62018-11-12 16:42:16 +0000613 return -EINVAL;
614
Swapnil Jakhade078e9e92021-12-23 07:01:24 +0100615 switch (phy_type) {
616 case PHY_TYPE_PCIE:
617 inst->phy_type = TYPE_PCIE;
618 break;
619 case PHY_TYPE_USB3:
620 inst->phy_type = TYPE_USB;
621 break;
622 default:
623 return -EINVAL;
624 }
625
Alan Douglas44d30d62018-11-12 16:42:16 +0000626 return 0;
627}
628
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530629static struct regmap *cdns_regmap_init(struct device *dev, void __iomem *base,
630 u32 block_offset, u8 reg_offset_shift,
631 const struct regmap_config *config)
632{
633 struct cdns_regmap_cdb_context *ctx;
634
635 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
636 if (!ctx)
637 return ERR_PTR(-ENOMEM);
638
639 ctx->dev = dev;
640 ctx->base = base + block_offset;
641 ctx->reg_offset_shift = reg_offset_shift;
642
643 return devm_regmap_init(dev, NULL, ctx, config);
644}
645
646static int cdns_regfield_init(struct cdns_sierra_phy *sp)
647{
648 struct device *dev = sp->dev;
649 struct regmap_field *field;
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530650 struct reg_field reg_field;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530651 struct regmap *regmap;
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530652 int i;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530653
654 regmap = sp->regmap_common_cdb;
655 field = devm_regmap_field_alloc(dev, regmap, macro_id_type);
656 if (IS_ERR(field)) {
657 dev_err(dev, "MACRO_ID_TYPE reg field init failed\n");
658 return PTR_ERR(field);
659 }
660 sp->macro_id_type = field;
661
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530662 for (i = 0; i < SIERRA_NUM_CMN_PLLC; i++) {
663 reg_field = cmn_plllc_pfdclk1_sel_preg[i].pfdclk_sel_preg;
664 field = devm_regmap_field_alloc(dev, regmap, reg_field);
665 if (IS_ERR(field)) {
666 dev_err(dev, "PLLLC%d_PFDCLK1_SEL failed\n", i);
667 return PTR_ERR(field);
668 }
669 sp->cmn_plllc_pfdclk1_sel_preg[i] = field;
670
671 reg_field = cmn_plllc_pfdclk1_sel_preg[i].plllc1en_field;
672 field = devm_regmap_field_alloc(dev, regmap, reg_field);
673 if (IS_ERR(field)) {
674 dev_err(dev, "REFRCV%d_REFCLK_PLLLC1EN failed\n", i);
675 return PTR_ERR(field);
676 }
677 sp->cmn_refrcv_refclk_plllc1en_preg[i] = field;
678
679 reg_field = cmn_plllc_pfdclk1_sel_preg[i].termen_field;
680 field = devm_regmap_field_alloc(dev, regmap, reg_field);
681 if (IS_ERR(field)) {
682 dev_err(dev, "REFRCV%d_REFCLK_TERMEN failed\n", i);
683 return PTR_ERR(field);
684 }
685 sp->cmn_refrcv_refclk_termen_preg[i] = field;
686 }
687
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530688 regmap = sp->regmap_phy_config_ctrl;
689 field = devm_regmap_field_alloc(dev, regmap, phy_pll_cfg_1);
690 if (IS_ERR(field)) {
691 dev_err(dev, "PHY_PLL_CFG_1 reg field init failed\n");
692 return PTR_ERR(field);
693 }
694 sp->phy_pll_cfg_1 = field;
695
Kishon Vijay Abraham Iadc4bd62019-12-16 15:27:07 +0530696 for (i = 0; i < SIERRA_MAX_LANES; i++) {
697 regmap = sp->regmap_lane_cdb[i];
698 field = devm_regmap_field_alloc(dev, regmap, pllctrl_lock);
699 if (IS_ERR(field)) {
700 dev_err(dev, "P%d_ENABLE reg field init failed\n", i);
701 return PTR_ERR(field);
702 }
703 sp->pllctrl_lock[i] = field;
704 }
705
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530706 return 0;
707}
708
709static int cdns_regmap_init_blocks(struct cdns_sierra_phy *sp,
710 void __iomem *base, u8 block_offset_shift,
711 u8 reg_offset_shift)
712{
713 struct device *dev = sp->dev;
714 struct regmap *regmap;
715 u32 block_offset;
716 int i;
717
718 for (i = 0; i < SIERRA_MAX_LANES; i++) {
719 block_offset = SIERRA_LANE_CDB_OFFSET(i, block_offset_shift,
720 reg_offset_shift);
721 regmap = cdns_regmap_init(dev, base, block_offset,
722 reg_offset_shift,
723 &cdns_sierra_lane_cdb_config[i]);
724 if (IS_ERR(regmap)) {
725 dev_err(dev, "Failed to init lane CDB regmap\n");
726 return PTR_ERR(regmap);
727 }
728 sp->regmap_lane_cdb[i] = regmap;
729 }
730
731 regmap = cdns_regmap_init(dev, base, SIERRA_COMMON_CDB_OFFSET,
732 reg_offset_shift,
733 &cdns_sierra_common_cdb_config);
734 if (IS_ERR(regmap)) {
735 dev_err(dev, "Failed to init common CDB regmap\n");
736 return PTR_ERR(regmap);
737 }
738 sp->regmap_common_cdb = regmap;
739
740 block_offset = SIERRA_PHY_CONFIG_CTRL_OFFSET(block_offset_shift);
741 regmap = cdns_regmap_init(dev, base, block_offset, reg_offset_shift,
742 &cdns_sierra_phy_config_ctrl_config);
743 if (IS_ERR(regmap)) {
744 dev_err(dev, "Failed to init PHY config and control regmap\n");
745 return PTR_ERR(regmap);
746 }
747 sp->regmap_phy_config_ctrl = regmap;
748
749 return 0;
750}
751
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530752static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp,
753 struct device *dev)
754{
755 struct clk *clk;
756 int ret;
757
758 clk = devm_clk_get_optional(dev, "phy_clk");
759 if (IS_ERR(clk)) {
760 dev_err(dev, "failed to get clock phy_clk\n");
761 return PTR_ERR(clk);
762 }
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530763 sp->input_clks[PHY_CLK] = clk;
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530764
765 clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div");
766 if (IS_ERR(clk)) {
767 dev_err(dev, "cmn_refclk_dig_div clock not found\n");
768 ret = PTR_ERR(clk);
769 return ret;
770 }
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530771 sp->input_clks[CMN_REFCLK_DIG_DIV] = clk;
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530772
773 clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div");
774 if (IS_ERR(clk)) {
775 dev_err(dev, "cmn_refclk1_dig_div clock not found\n");
776 ret = PTR_ERR(clk);
777 return ret;
778 }
Kishon Vijay Abraham Ia0c30cd2021-03-19 18:11:24 +0530779 sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk;
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530780
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530781 clk = devm_clk_get_optional(dev, "pll0_refclk");
782 if (IS_ERR(clk)) {
783 dev_err(dev, "pll0_refclk clock not found\n");
784 ret = PTR_ERR(clk);
785 return ret;
786 }
787 sp->input_clks[PLL0_REFCLK] = clk;
788
789 clk = devm_clk_get_optional(dev, "pll1_refclk");
790 if (IS_ERR(clk)) {
791 dev_err(dev, "pll1_refclk clock not found\n");
792 ret = PTR_ERR(clk);
793 return ret;
794 }
795 sp->input_clks[PLL1_REFCLK] = clk;
796
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530797 return 0;
798}
799
Kishon Vijay Abraham I1436ec32021-03-19 18:11:28 +0530800static int cdns_sierra_phy_enable_clocks(struct cdns_sierra_phy *sp)
801{
802 int ret;
803
804 ret = clk_prepare_enable(sp->input_clks[PHY_CLK]);
805 if (ret)
806 return ret;
807
808 ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
809 if (ret)
810 goto err_pll_cmnlc;
811
812 ret = clk_prepare_enable(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
813 if (ret)
814 goto err_pll_cmnlc1;
815
816 return 0;
817
818err_pll_cmnlc1:
819 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
820
821err_pll_cmnlc:
822 clk_disable_unprepare(sp->input_clks[PHY_CLK]);
823
824 return ret;
825}
826
827static void cdns_sierra_phy_disable_clocks(struct cdns_sierra_phy *sp)
828{
829 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC1]);
830 clk_disable_unprepare(sp->output_clks[CDNS_SIERRA_PLL_CMNLC]);
831 clk_disable_unprepare(sp->input_clks[PHY_CLK]);
832}
833
Kishon Vijay Abraham I1d5f40e2021-03-19 18:11:21 +0530834static int cdns_sierra_phy_get_resets(struct cdns_sierra_phy *sp,
835 struct device *dev)
836{
837 struct reset_control *rst;
838
Kishon Vijay Abraham I15b0b822021-03-19 18:11:22 +0530839 rst = devm_reset_control_get_exclusive(dev, "sierra_reset");
Kishon Vijay Abraham I1d5f40e2021-03-19 18:11:21 +0530840 if (IS_ERR(rst)) {
841 dev_err(dev, "failed to get reset\n");
842 return PTR_ERR(rst);
843 }
844 sp->phy_rst = rst;
845
Kishon Vijay Abraham I15b0b822021-03-19 18:11:22 +0530846 rst = devm_reset_control_get_optional_exclusive(dev, "sierra_apb");
Kishon Vijay Abraham I1d5f40e2021-03-19 18:11:21 +0530847 if (IS_ERR(rst)) {
848 dev_err(dev, "failed to get apb reset\n");
849 return PTR_ERR(rst);
850 }
851 sp->apb_rst = rst;
852
853 return 0;
854}
855
Alan Douglas44d30d62018-11-12 16:42:16 +0000856static int cdns_sierra_phy_probe(struct platform_device *pdev)
857{
858 struct cdns_sierra_phy *sp;
859 struct phy_provider *phy_provider;
860 struct device *dev = &pdev->dev;
Swapnil Jakhadec3c11d52021-12-23 07:01:23 +0100861 const struct cdns_sierra_data *data;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530862 unsigned int id_value;
Alan Douglas44d30d62018-11-12 16:42:16 +0000863 int i, ret, node = 0;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530864 void __iomem *base;
Alan Douglas44d30d62018-11-12 16:42:16 +0000865 struct device_node *dn = dev->of_node, *child;
866
867 if (of_get_child_count(dn) == 0)
868 return -ENODEV;
869
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530870 /* Get init data for this PHY */
Swapnil Jakhadec3c11d52021-12-23 07:01:23 +0100871 data = of_device_get_match_data(dev);
872 if (!data)
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530873 return -EINVAL;
874
Alan Douglas44d30d62018-11-12 16:42:16 +0000875 sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL);
876 if (!sp)
877 return -ENOMEM;
878 dev_set_drvdata(dev, sp);
879 sp->dev = dev;
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530880 sp->init_data = data;
Alan Douglas44d30d62018-11-12 16:42:16 +0000881
Chunfeng Yunfa629092020-11-06 14:08:37 +0800882 base = devm_platform_ioremap_resource(pdev, 0);
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530883 if (IS_ERR(base)) {
Alan Douglas44d30d62018-11-12 16:42:16 +0000884 dev_err(dev, "missing \"reg\"\n");
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530885 return PTR_ERR(base);
Alan Douglas44d30d62018-11-12 16:42:16 +0000886 }
887
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530888 ret = cdns_regmap_init_blocks(sp, base, data->block_offset_shift,
889 data->reg_offset_shift);
890 if (ret)
891 return ret;
892
893 ret = cdns_regfield_init(sp);
894 if (ret)
895 return ret;
Alan Douglas44d30d62018-11-12 16:42:16 +0000896
897 platform_set_drvdata(pdev, sp);
898
Kishon Vijay Abraham I7e016cb2021-03-19 18:11:20 +0530899 ret = cdns_sierra_phy_get_clocks(sp, dev);
900 if (ret)
901 return ret;
Alan Douglas44d30d62018-11-12 16:42:16 +0000902
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530903 ret = cdns_sierra_clk_register(sp);
Kishon Vijay Abraham I1d5f40e2021-03-19 18:11:21 +0530904 if (ret)
905 return ret;
Alan Douglas44d30d62018-11-12 16:42:16 +0000906
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530907 ret = cdns_sierra_phy_get_resets(sp, dev);
908 if (ret)
909 goto unregister_clk;
910
Kishon Vijay Abraham I1436ec32021-03-19 18:11:28 +0530911 ret = cdns_sierra_phy_enable_clocks(sp);
Alan Douglas44d30d62018-11-12 16:42:16 +0000912 if (ret)
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530913 goto unregister_clk;
Alan Douglas44d30d62018-11-12 16:42:16 +0000914
915 /* Enable APB */
916 reset_control_deassert(sp->apb_rst);
917
918 /* Check that PHY is present */
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530919 regmap_field_read(sp->macro_id_type, &id_value);
920 if (sp->init_data->id_value != id_value) {
Alan Douglas44d30d62018-11-12 16:42:16 +0000921 ret = -EINVAL;
922 goto clk_disable;
923 }
924
925 sp->autoconf = of_property_read_bool(dn, "cdns,autoconf");
926
927 for_each_available_child_of_node(dn, child) {
928 struct phy *gphy;
929
Kishon Vijay Abraham I03ada5a32021-03-19 18:11:18 +0530930 if (!(of_node_name_eq(child, "phy") ||
931 of_node_name_eq(child, "link")))
932 continue;
933
Alan Douglas44d30d62018-11-12 16:42:16 +0000934 sp->phys[node].lnk_rst =
Kishon Vijay Abraham Ib8729362019-12-16 15:27:06 +0530935 of_reset_control_array_get_exclusive(child);
Alan Douglas44d30d62018-11-12 16:42:16 +0000936
937 if (IS_ERR(sp->phys[node].lnk_rst)) {
938 dev_err(dev, "failed to get reset %s\n",
939 child->full_name);
940 ret = PTR_ERR(sp->phys[node].lnk_rst);
941 goto put_child2;
942 }
943
944 if (!sp->autoconf) {
945 ret = cdns_sierra_get_optional(&sp->phys[node], child);
946 if (ret) {
947 dev_err(dev, "missing property in node %s\n",
948 child->name);
949 goto put_child;
950 }
951 }
952
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530953 sp->num_lanes += sp->phys[node].num_lanes;
954
Alan Douglas44d30d62018-11-12 16:42:16 +0000955 gphy = devm_phy_create(dev, child, &ops);
956
957 if (IS_ERR(gphy)) {
958 ret = PTR_ERR(gphy);
959 goto put_child;
960 }
961 sp->phys[node].phy = gphy;
962 phy_set_drvdata(gphy, &sp->phys[node]);
963
Alan Douglas44d30d62018-11-12 16:42:16 +0000964 node++;
965 }
966 sp->nsubnodes = node;
967
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530968 if (sp->num_lanes > SIERRA_MAX_LANES) {
Wang Wensheng6411e382021-05-17 01:57:49 +0000969 ret = -EINVAL;
Kishon Vijay Abraham Ia43f72a2019-12-16 15:27:08 +0530970 dev_err(dev, "Invalid lane configuration\n");
971 goto put_child2;
972 }
973
Alan Douglas44d30d62018-11-12 16:42:16 +0000974 /* If more than one subnode, configure the PHY as multilink */
975 if (!sp->autoconf && sp->nsubnodes > 1)
Kishon Vijay Abraham I380f5702019-12-16 15:27:01 +0530976 regmap_field_write(sp->phy_pll_cfg_1, 0x1);
Alan Douglas44d30d62018-11-12 16:42:16 +0000977
978 pm_runtime_enable(dev);
979 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
Alan Douglas44d30d62018-11-12 16:42:16 +0000980 return PTR_ERR_OR_ZERO(phy_provider);
981
982put_child:
983 node++;
984put_child2:
985 for (i = 0; i < node; i++)
986 reset_control_put(sp->phys[i].lnk_rst);
987 of_node_put(child);
988clk_disable:
Kishon Vijay Abraham I1436ec32021-03-19 18:11:28 +0530989 cdns_sierra_phy_disable_clocks(sp);
Alan Douglas44d30d62018-11-12 16:42:16 +0000990 reset_control_assert(sp->apb_rst);
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +0530991unregister_clk:
992 cdns_sierra_clk_unregister(sp);
Alan Douglas44d30d62018-11-12 16:42:16 +0000993 return ret;
994}
995
996static int cdns_sierra_phy_remove(struct platform_device *pdev)
997{
Kishon Vijay Abraham I748e3452019-12-16 15:27:10 +0530998 struct cdns_sierra_phy *phy = platform_get_drvdata(pdev);
Alan Douglas44d30d62018-11-12 16:42:16 +0000999 int i;
1000
1001 reset_control_assert(phy->phy_rst);
1002 reset_control_assert(phy->apb_rst);
1003 pm_runtime_disable(&pdev->dev);
1004
Kishon Vijay Abraham I1436ec32021-03-19 18:11:28 +05301005 cdns_sierra_phy_disable_clocks(phy);
Alan Douglas44d30d62018-11-12 16:42:16 +00001006 /*
1007 * The device level resets will be put automatically.
1008 * Need to put the subnode resets here though.
1009 */
1010 for (i = 0; i < phy->nsubnodes; i++) {
1011 reset_control_assert(phy->phys[i].lnk_rst);
1012 reset_control_put(phy->phys[i].lnk_rst);
1013 }
Kishon Vijay Abraham I29c2d022021-03-19 18:11:25 +05301014
Kishon Vijay Abraham I28081b72021-03-19 18:11:27 +05301015 cdns_sierra_clk_unregister(phy);
Kishon Vijay Abraham I29c2d022021-03-19 18:11:25 +05301016
Alan Douglas44d30d62018-11-12 16:42:16 +00001017 return 0;
1018}
1019
Anil Varughese871002d2019-12-16 15:27:05 +05301020/* refclk100MHz_32b_PCIe_cmn_pll_ext_ssc */
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +02001021static const struct cdns_reg_pairs cdns_pcie_cmn_regs_ext_ssc[] = {
Anil Varughese871002d2019-12-16 15:27:05 +05301022 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1023 {0x2106, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1024 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE1_PREG},
1025 {0x8A06, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1026 {0x1B1B, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1027};
1028
1029/* refclk100MHz_32b_PCIe_ln_ext_ssc */
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +02001030static const struct cdns_reg_pairs cdns_pcie_ln_regs_ext_ssc[] = {
Anil Varughese871002d2019-12-16 15:27:05 +05301031 {0x813E, SIERRA_CLKPATHCTRL_TMR_PREG},
1032 {0x8047, SIERRA_RX_CREQ_FLTR_A_MODE3_PREG},
1033 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE2_PREG},
1034 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1035 {0x808F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
1036 {0x033C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
1037 {0x44CC, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG}
1038};
1039
Swapnil Jakhade078e9e92021-12-23 07:01:24 +01001040static struct cdns_sierra_vals pcie_100_ext_ssc_cmn_vals = {
1041 .reg_pairs = cdns_pcie_cmn_regs_ext_ssc,
1042 .num_regs = ARRAY_SIZE(cdns_pcie_cmn_regs_ext_ssc),
1043};
1044
1045static struct cdns_sierra_vals pcie_100_ext_ssc_ln_vals = {
1046 .reg_pairs = cdns_pcie_ln_regs_ext_ssc,
1047 .num_regs = ARRAY_SIZE(cdns_pcie_ln_regs_ext_ssc),
1048};
1049
Anil Varughese871002d2019-12-16 15:27:05 +05301050/* refclk100MHz_20b_USB_cmn_pll_ext_ssc */
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +02001051static const struct cdns_reg_pairs cdns_usb_cmn_regs_ext_ssc[] = {
Anil Varughese871002d2019-12-16 15:27:05 +05301052 {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE1_PREG},
1053 {0x2085, SIERRA_CMN_PLLLC_LF_COEFF_MODE0_PREG},
1054 {0x0000, SIERRA_CMN_PLLLC_BWCAL_MODE0_PREG},
1055 {0x0000, SIERRA_CMN_PLLLC_SS_TIME_STEPSIZE_MODE_PREG}
1056};
1057
1058/* refclk100MHz_20b_USB_ln_ext_ssc */
Rikard Falkeborn3cfb0e82020-09-12 22:46:37 +02001059static const struct cdns_reg_pairs cdns_usb_ln_regs_ext_ssc[] = {
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301060 {0xFE0A, SIERRA_DET_STANDEC_A_PREG},
1061 {0x000F, SIERRA_DET_STANDEC_B_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001062 {0x55A5, SIERRA_DET_STANDEC_C_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301063 {0x69ad, SIERRA_DET_STANDEC_D_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301064 {0x0241, SIERRA_DET_STANDEC_E_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001065 {0x0110, SIERRA_PSM_LANECAL_DLY_A1_RESETS_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301066 {0x0014, SIERRA_PSM_A0IN_TMR_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301067 {0xCF00, SIERRA_PSM_DIAG_PREG},
1068 {0x001F, SIERRA_PSC_TX_A0_PREG},
1069 {0x0007, SIERRA_PSC_TX_A1_PREG},
1070 {0x0003, SIERRA_PSC_TX_A2_PREG},
1071 {0x0003, SIERRA_PSC_TX_A3_PREG},
1072 {0x0FFF, SIERRA_PSC_RX_A0_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001073 {0x0003, SIERRA_PSC_RX_A1_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301074 {0x0003, SIERRA_PSC_RX_A2_PREG},
1075 {0x0001, SIERRA_PSC_RX_A3_PREG},
1076 {0x0001, SIERRA_PLLCTRL_SUBRATE_PREG},
1077 {0x0406, SIERRA_PLLCTRL_GEN_D_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301078 {0x5233, SIERRA_PLLCTRL_CPGAIN_MODE_PREG},
1079 {0x00CA, SIERRA_CLKPATH_BIASTRIM_PREG},
1080 {0x2512, SIERRA_DFE_BIASTRIM_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301081 {0x0000, SIERRA_DRVCTRL_ATTEN_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001082 {0x823E, SIERRA_CLKPATHCTRL_TMR_PREG},
1083 {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE1_PREG},
1084 {0x078F, SIERRA_RX_CREQ_FLTR_A_MODE0_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301085 {0x7B3C, SIERRA_CREQ_CCLKDET_MODE01_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001086 {0x023C, SIERRA_RX_CTLE_MAINTENANCE_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301087 {0x3232, SIERRA_CREQ_FSMCLK_SEL_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301088 {0x0000, SIERRA_CREQ_EQ_CTRL_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001089 {0x0000, SIERRA_CREQ_SPARE_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301090 {0xCC44, SIERRA_CREQ_EQ_OPEN_EYE_THRESH_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001091 {0x8452, SIERRA_CTLELUT_CTRL_PREG},
1092 {0x4121, SIERRA_DFE_ECMP_RATESEL_PREG},
1093 {0x4121, SIERRA_DFE_SMP_RATESEL_PREG},
1094 {0x0003, SIERRA_DEQ_PHALIGN_CTRL},
Anil Varughese871002d2019-12-16 15:27:05 +05301095 {0x3200, SIERRA_DEQ_CONCUR_CTRL1_PREG},
1096 {0x5064, SIERRA_DEQ_CONCUR_CTRL2_PREG},
1097 {0x0030, SIERRA_DEQ_EPIPWR_CTRL2_PREG},
1098 {0x0048, SIERRA_DEQ_FAST_MAINT_CYCLES_PREG},
1099 {0x5A5A, SIERRA_DEQ_ERRCMP_CTRL_PREG},
1100 {0x02F5, SIERRA_DEQ_OFFSET_CTRL_PREG},
1101 {0x02F5, SIERRA_DEQ_GAIN_CTRL_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001102 {0x9999, SIERRA_DEQ_VGATUNE_CTRL_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301103 {0x0014, SIERRA_DEQ_GLUT0},
1104 {0x0014, SIERRA_DEQ_GLUT1},
1105 {0x0014, SIERRA_DEQ_GLUT2},
1106 {0x0014, SIERRA_DEQ_GLUT3},
1107 {0x0014, SIERRA_DEQ_GLUT4},
1108 {0x0014, SIERRA_DEQ_GLUT5},
1109 {0x0014, SIERRA_DEQ_GLUT6},
1110 {0x0014, SIERRA_DEQ_GLUT7},
1111 {0x0014, SIERRA_DEQ_GLUT8},
1112 {0x0014, SIERRA_DEQ_GLUT9},
1113 {0x0014, SIERRA_DEQ_GLUT10},
1114 {0x0014, SIERRA_DEQ_GLUT11},
1115 {0x0014, SIERRA_DEQ_GLUT12},
1116 {0x0014, SIERRA_DEQ_GLUT13},
1117 {0x0014, SIERRA_DEQ_GLUT14},
1118 {0x0014, SIERRA_DEQ_GLUT15},
1119 {0x0014, SIERRA_DEQ_GLUT16},
1120 {0x0BAE, SIERRA_DEQ_ALUT0},
1121 {0x0AEB, SIERRA_DEQ_ALUT1},
1122 {0x0A28, SIERRA_DEQ_ALUT2},
1123 {0x0965, SIERRA_DEQ_ALUT3},
1124 {0x08A2, SIERRA_DEQ_ALUT4},
1125 {0x07DF, SIERRA_DEQ_ALUT5},
1126 {0x071C, SIERRA_DEQ_ALUT6},
1127 {0x0659, SIERRA_DEQ_ALUT7},
1128 {0x0596, SIERRA_DEQ_ALUT8},
1129 {0x0514, SIERRA_DEQ_ALUT9},
1130 {0x0492, SIERRA_DEQ_ALUT10},
1131 {0x0410, SIERRA_DEQ_ALUT11},
1132 {0x038E, SIERRA_DEQ_ALUT12},
1133 {0x030C, SIERRA_DEQ_ALUT13},
1134 {0x03F4, SIERRA_DEQ_DFETAP_CTRL_PREG},
1135 {0x0001, SIERRA_DFE_EN_1010_IGNORE_PREG},
1136 {0x3C01, SIERRA_DEQ_TAU_CTRL1_FAST_MAINT_PREG},
1137 {0x3C40, SIERRA_DEQ_TAU_CTRL1_SLOW_MAINT_PREG},
1138 {0x1C08, SIERRA_DEQ_TAU_CTRL2_PREG},
1139 {0x0033, SIERRA_DEQ_PICTRL_PREG},
1140 {0x0400, SIERRA_CPICAL_TMRVAL_MODE1_PREG},
1141 {0x0330, SIERRA_CPICAL_TMRVAL_MODE0_PREG},
1142 {0x01FF, SIERRA_CPICAL_PICNT_MODE1_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301143 {0x0009, SIERRA_CPI_OUTBUF_RATESEL_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301144 {0x3232, SIERRA_CPICAL_RES_STARTCODE_MODE23_PREG},
1145 {0x0005, SIERRA_LFPSDET_SUPPORT_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301146 {0x000F, SIERRA_LFPSFILT_NS_PREG},
1147 {0x0009, SIERRA_LFPSFILT_RD_PREG},
1148 {0x0001, SIERRA_LFPSFILT_MP_PREG},
Sanket Parmar2bcf14c2020-05-18 14:14:13 +02001149 {0x6013, SIERRA_SIGDET_SUPPORT_PREG},
Kishon Vijay Abraham Iaead5fd2019-12-16 15:27:04 +05301150 {0x8013, SIERRA_SDFILT_H2L_A_PREG},
Anil Varughese871002d2019-12-16 15:27:05 +05301151 {0x8009, SIERRA_SDFILT_L2H_PREG},
1152 {0x0024, SIERRA_RXBUFFER_CTLECTRL_PREG},
1153 {0x0020, SIERRA_RXBUFFER_RCDFECTRL_PREG},
1154 {0x4243, SIERRA_RXBUFFER_DFECTRL_PREG}
Alan Douglas44d30d62018-11-12 16:42:16 +00001155};
1156
Swapnil Jakhade078e9e92021-12-23 07:01:24 +01001157static struct cdns_sierra_vals usb_100_ext_ssc_cmn_vals = {
1158 .reg_pairs = cdns_usb_cmn_regs_ext_ssc,
1159 .num_regs = ARRAY_SIZE(cdns_usb_cmn_regs_ext_ssc),
1160};
1161
1162static struct cdns_sierra_vals usb_100_ext_ssc_ln_vals = {
1163 .reg_pairs = cdns_usb_ln_regs_ext_ssc,
1164 .num_regs = ARRAY_SIZE(cdns_usb_ln_regs_ext_ssc),
1165};
1166
Alan Douglas44d30d62018-11-12 16:42:16 +00001167static const struct cdns_sierra_data cdns_map_sierra = {
Swapnil Jakhade078e9e92021-12-23 07:01:24 +01001168 .id_value = SIERRA_MACRO_ID,
1169 .block_offset_shift = 0x2,
1170 .reg_offset_shift = 0x2,
1171 .pma_cmn_vals = {
1172 [TYPE_PCIE] = {
1173 [TYPE_NONE] = {
1174 [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
1175 },
1176 },
1177 [TYPE_USB] = {
1178 [TYPE_NONE] = {
1179 [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1180 },
1181 },
1182 },
1183 .pma_ln_vals = {
1184 [TYPE_PCIE] = {
1185 [TYPE_NONE] = {
1186 [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
1187 },
1188 },
1189 [TYPE_USB] = {
1190 [TYPE_NONE] = {
1191 [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1192 },
1193 },
1194 },
Alan Douglas44d30d62018-11-12 16:42:16 +00001195};
1196
Kishon Vijay Abraham I367da972019-12-16 15:27:02 +05301197static const struct cdns_sierra_data cdns_ti_map_sierra = {
Swapnil Jakhade078e9e92021-12-23 07:01:24 +01001198 .id_value = SIERRA_MACRO_ID,
1199 .block_offset_shift = 0x0,
1200 .reg_offset_shift = 0x1,
1201 .pma_cmn_vals = {
1202 [TYPE_PCIE] = {
1203 [TYPE_NONE] = {
1204 [EXTERNAL_SSC] = &pcie_100_ext_ssc_cmn_vals,
1205 },
1206 },
1207 [TYPE_USB] = {
1208 [TYPE_NONE] = {
1209 [EXTERNAL_SSC] = &usb_100_ext_ssc_cmn_vals,
1210 },
1211 },
1212 },
1213 .pma_ln_vals = {
1214 [TYPE_PCIE] = {
1215 [TYPE_NONE] = {
1216 [EXTERNAL_SSC] = &pcie_100_ext_ssc_ln_vals,
1217 },
1218 },
1219 [TYPE_USB] = {
1220 [TYPE_NONE] = {
1221 [EXTERNAL_SSC] = &usb_100_ext_ssc_ln_vals,
1222 },
1223 },
1224 },
Kishon Vijay Abraham I367da972019-12-16 15:27:02 +05301225};
1226
Alan Douglas44d30d62018-11-12 16:42:16 +00001227static const struct of_device_id cdns_sierra_id_table[] = {
1228 {
1229 .compatible = "cdns,sierra-phy-t0",
1230 .data = &cdns_map_sierra,
1231 },
Kishon Vijay Abraham I367da972019-12-16 15:27:02 +05301232 {
1233 .compatible = "ti,sierra-phy-t0",
1234 .data = &cdns_ti_map_sierra,
1235 },
Alan Douglas44d30d62018-11-12 16:42:16 +00001236 {}
1237};
1238MODULE_DEVICE_TABLE(of, cdns_sierra_id_table);
1239
1240static struct platform_driver cdns_sierra_driver = {
1241 .probe = cdns_sierra_phy_probe,
1242 .remove = cdns_sierra_phy_remove,
1243 .driver = {
1244 .name = "cdns-sierra-phy",
1245 .of_match_table = cdns_sierra_id_table,
1246 },
1247};
1248module_platform_driver(cdns_sierra_driver);
1249
1250MODULE_ALIAS("platform:cdns_sierra");
1251MODULE_AUTHOR("Cadence Design Systems");
1252MODULE_DESCRIPTION("CDNS sierra phy driver");
1253MODULE_LICENSE("GPL v2");