keystone_rio_serdes.h
4.08 KB
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
/*
* Texas Instruments Keystone SerDes driver
* Authors: Aurelien Jacquiot <a-jacquiot@ti.com>
*
* This is the Rapidio SerDes driver for Keystone devices. This is
* required to support RapidIO functionality on K2HK devices.
*
* Copyright (C) 2016 Texas Instruments Incorporated - http://www.ti.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef KEYSTONE_RIO_SERDES_H
#define KEYSTONE_RIO_SERDES_H
#define KEYSTONE_SERDES_TYPE_K1 0
#define KEYSTONE_SERDES_TYPE_K2 1
#define KEYSTONE_SERDES_LANE(lane) (BIT(lane))
#define KEYSTONE_SERDES_MAX_LANES 4
#define KEYSTONE_SERDES_LANE_MASK 0xf
#define KEYSTONE_SERDES_TIMEOUT 100
#define KEYSTONE_SERDES_BAUD_1_250 0
#define KEYSTONE_SERDES_BAUD_2_500 1
#define KEYSTONE_SERDES_BAUD_3_125 2
#define KEYSTONE_SERDES_BAUD_5_000 3
#define KEYSTONE_SERDES_BAUD_6_250 4
#define KEYSTONE_SERDES_QUARTER_RATE 0
#define KEYSTONE_SERDES_HALF_RATE 1
#define KEYSTONE_SERDES_FULL_RATE 2
struct keystone_serdes_lane_tx_config {
u32 pre_1lsb;
u32 c1_coeff;
u32 c2_coeff;
u32 cm_coeff;
u32 att;
u32 vreg;
u32 vdreg;
};
struct keystone_serdes_lane_rx_config {
u32 att;
u32 boost;
u32 mean_att;
u32 mean_boost;
u32 start_att;
u32 start_boost;
};
struct keystone_serdes_config {
u16 prescalar_srv_clk;
struct keystone_serdes_lane_tx_config tx[KEYSTONE_SERDES_MAX_LANES];
struct keystone_serdes_lane_rx_config rx[KEYSTONE_SERDES_MAX_LANES];
u32 cal_timeout;
int do_phy_init_cfg;
u32 rate;
};
struct keystone_serdes_data;
struct keystone_serdes_ops {
int (*config_lanes)(u32 lanes, u32 baud,
struct keystone_serdes_data *serdes);
int (*start_tx_lanes)(u32 lanes, struct keystone_serdes_data *serdes);
int (*wait_lanes_ok)(u32 lanes, struct keystone_serdes_data *serdes);
int (*disable_lanes)(u32 lanes, struct keystone_serdes_data *serdes);
int (*shutdown_lanes)(u32 lanes, struct keystone_serdes_data *serdes);
void (*recover_lanes)(u32 lanes, struct keystone_serdes_data *serdes);
int (*calibrate_lanes)(u32 lanes, struct keystone_serdes_data *serdes);
};
struct keystone_serdes_data {
const struct keystone_serdes_ops *ops;
struct device *dev;
void __iomem *regs;
void __iomem *sts_reg;
struct keystone_serdes_config *config;
struct kobject *serdes_kobj;
struct kobject serdes_rx_kobj;
struct kobject serdes_tx_kobj;
};
int keystone_rio_serdes_register(u16 serdes_type,
void __iomem *regs,
void __iomem *sts_reg,
struct device *dev,
struct keystone_serdes_data *serdes,
struct keystone_serdes_config *serdes_config);
void keystone_rio_serdes_unregister(struct device *dev,
struct keystone_serdes_data *serdes);
#endif