34
34
#define PF_DBG_WE BIT(31)
35
35
#define PF_DBG_PABR BIT(27)
36
36
37
- #define to_ls_pcie_g4 (x ) platform_get_drvdata((x)->pdev)
37
+ #define to_ls_g4_pcie (x ) platform_get_drvdata((x)->pdev)
38
38
39
- struct ls_pcie_g4 {
39
+ struct ls_g4_pcie {
40
40
struct mobiveil_pcie pci ;
41
41
struct delayed_work dwork ;
42
42
int irq ;
43
43
};
44
44
45
- static inline u32 ls_pcie_g4_pf_readl (struct ls_pcie_g4 * pcie , u32 off )
45
+ static inline u32 ls_g4_pcie_pf_readl (struct ls_g4_pcie * pcie , u32 off )
46
46
{
47
47
return ioread32 (pcie -> pci .csr_axi_slave_base + PCIE_PF_OFF + off );
48
48
}
49
49
50
- static inline void ls_pcie_g4_pf_writel (struct ls_pcie_g4 * pcie ,
50
+ static inline void ls_g4_pcie_pf_writel (struct ls_g4_pcie * pcie ,
51
51
u32 off , u32 val )
52
52
{
53
53
iowrite32 (val , pcie -> pci .csr_axi_slave_base + PCIE_PF_OFF + off );
54
54
}
55
55
56
- static int ls_pcie_g4_link_up (struct mobiveil_pcie * pci )
56
+ static int ls_g4_pcie_link_up (struct mobiveil_pcie * pci )
57
57
{
58
- struct ls_pcie_g4 * pcie = to_ls_pcie_g4 (pci );
58
+ struct ls_g4_pcie * pcie = to_ls_g4_pcie (pci );
59
59
u32 state ;
60
60
61
- state = ls_pcie_g4_pf_readl (pcie , PCIE_PF_DBG );
61
+ state = ls_g4_pcie_pf_readl (pcie , PCIE_PF_DBG );
62
62
state = state & PF_DBG_LTSSM_MASK ;
63
63
64
64
if (state == PF_DBG_LTSSM_L0 )
@@ -67,14 +67,14 @@ static int ls_pcie_g4_link_up(struct mobiveil_pcie *pci)
67
67
return 0 ;
68
68
}
69
69
70
- static void ls_pcie_g4_disable_interrupt (struct ls_pcie_g4 * pcie )
70
+ static void ls_g4_pcie_disable_interrupt (struct ls_g4_pcie * pcie )
71
71
{
72
72
struct mobiveil_pcie * mv_pci = & pcie -> pci ;
73
73
74
74
mobiveil_csr_writel (mv_pci , 0 , PAB_INTP_AMBA_MISC_ENB );
75
75
}
76
76
77
- static void ls_pcie_g4_enable_interrupt (struct ls_pcie_g4 * pcie )
77
+ static void ls_g4_pcie_enable_interrupt (struct ls_g4_pcie * pcie )
78
78
{
79
79
struct mobiveil_pcie * mv_pci = & pcie -> pci ;
80
80
u32 val ;
@@ -87,7 +87,7 @@ static void ls_pcie_g4_enable_interrupt(struct ls_pcie_g4 *pcie)
87
87
mobiveil_csr_writel (mv_pci , val , PAB_INTP_AMBA_MISC_ENB );
88
88
}
89
89
90
- static int ls_pcie_g4_reinit_hw (struct ls_pcie_g4 * pcie )
90
+ static int ls_g4_pcie_reinit_hw (struct ls_g4_pcie * pcie )
91
91
{
92
92
struct mobiveil_pcie * mv_pci = & pcie -> pci ;
93
93
struct device * dev = & mv_pci -> pdev -> dev ;
@@ -97,7 +97,7 @@ static int ls_pcie_g4_reinit_hw(struct ls_pcie_g4 *pcie)
97
97
/* Poll for pab_csb_reset to set and PAB activity to clear */
98
98
do {
99
99
usleep_range (10 , 15 );
100
- val = ls_pcie_g4_pf_readl (pcie , PCIE_PF_INT_STAT );
100
+ val = ls_g4_pcie_pf_readl (pcie , PCIE_PF_INT_STAT );
101
101
act_stat = mobiveil_csr_readl (mv_pci , PAB_ACTIVITY_STAT );
102
102
} while (((val & PF_INT_STAT_PABRST ) == 0 || act_stat ) && to -- );
103
103
if (to < 0 ) {
@@ -106,22 +106,22 @@ static int ls_pcie_g4_reinit_hw(struct ls_pcie_g4 *pcie)
106
106
}
107
107
108
108
/* clear PEX_RESET bit in PEX_PF0_DBG register */
109
- val = ls_pcie_g4_pf_readl (pcie , PCIE_PF_DBG );
109
+ val = ls_g4_pcie_pf_readl (pcie , PCIE_PF_DBG );
110
110
val |= PF_DBG_WE ;
111
- ls_pcie_g4_pf_writel (pcie , PCIE_PF_DBG , val );
111
+ ls_g4_pcie_pf_writel (pcie , PCIE_PF_DBG , val );
112
112
113
- val = ls_pcie_g4_pf_readl (pcie , PCIE_PF_DBG );
113
+ val = ls_g4_pcie_pf_readl (pcie , PCIE_PF_DBG );
114
114
val |= PF_DBG_PABR ;
115
- ls_pcie_g4_pf_writel (pcie , PCIE_PF_DBG , val );
115
+ ls_g4_pcie_pf_writel (pcie , PCIE_PF_DBG , val );
116
116
117
- val = ls_pcie_g4_pf_readl (pcie , PCIE_PF_DBG );
117
+ val = ls_g4_pcie_pf_readl (pcie , PCIE_PF_DBG );
118
118
val &= ~PF_DBG_WE ;
119
- ls_pcie_g4_pf_writel (pcie , PCIE_PF_DBG , val );
119
+ ls_g4_pcie_pf_writel (pcie , PCIE_PF_DBG , val );
120
120
121
121
mobiveil_host_init (mv_pci , true);
122
122
123
123
to = 100 ;
124
- while (!ls_pcie_g4_link_up (mv_pci ) && to -- )
124
+ while (!ls_g4_pcie_link_up (mv_pci ) && to -- )
125
125
usleep_range (200 , 250 );
126
126
if (to < 0 ) {
127
127
dev_err (dev , "PCIe link training timeout\n" );
@@ -131,9 +131,9 @@ static int ls_pcie_g4_reinit_hw(struct ls_pcie_g4 *pcie)
131
131
return 0 ;
132
132
}
133
133
134
- static irqreturn_t ls_pcie_g4_isr (int irq , void * dev_id )
134
+ static irqreturn_t ls_g4_pcie_isr (int irq , void * dev_id )
135
135
{
136
- struct ls_pcie_g4 * pcie = (struct ls_pcie_g4 * )dev_id ;
136
+ struct ls_g4_pcie * pcie = (struct ls_g4_pcie * )dev_id ;
137
137
struct mobiveil_pcie * mv_pci = & pcie -> pci ;
138
138
u32 val ;
139
139
@@ -142,7 +142,7 @@ static irqreturn_t ls_pcie_g4_isr(int irq, void *dev_id)
142
142
return IRQ_NONE ;
143
143
144
144
if (val & PAB_INTP_RESET ) {
145
- ls_pcie_g4_disable_interrupt (pcie );
145
+ ls_g4_pcie_disable_interrupt (pcie );
146
146
schedule_delayed_work (& pcie -> dwork , msecs_to_jiffies (1 ));
147
147
}
148
148
@@ -151,9 +151,9 @@ static irqreturn_t ls_pcie_g4_isr(int irq, void *dev_id)
151
151
return IRQ_HANDLED ;
152
152
}
153
153
154
- static int ls_pcie_g4_interrupt_init (struct mobiveil_pcie * mv_pci )
154
+ static int ls_g4_pcie_interrupt_init (struct mobiveil_pcie * mv_pci )
155
155
{
156
- struct ls_pcie_g4 * pcie = to_ls_pcie_g4 (mv_pci );
156
+ struct ls_g4_pcie * pcie = to_ls_g4_pcie (mv_pci );
157
157
struct platform_device * pdev = mv_pci -> pdev ;
158
158
struct device * dev = & pdev -> dev ;
159
159
int ret ;
@@ -162,7 +162,7 @@ static int ls_pcie_g4_interrupt_init(struct mobiveil_pcie *mv_pci)
162
162
if (pcie -> irq < 0 )
163
163
return pcie -> irq ;
164
164
165
- ret = devm_request_irq (dev , pcie -> irq , ls_pcie_g4_isr ,
165
+ ret = devm_request_irq (dev , pcie -> irq , ls_g4_pcie_isr ,
166
166
IRQF_SHARED , pdev -> name , pcie );
167
167
if (ret ) {
168
168
dev_err (dev , "Can't register PCIe IRQ, errno = %d\n" , ret );
@@ -172,38 +172,38 @@ static int ls_pcie_g4_interrupt_init(struct mobiveil_pcie *mv_pci)
172
172
return 0 ;
173
173
}
174
174
175
- static void ls_pcie_g4_reset (struct work_struct * work )
175
+ static void ls_g4_pcie_reset (struct work_struct * work )
176
176
{
177
177
struct delayed_work * dwork = container_of (work , struct delayed_work ,
178
178
work );
179
- struct ls_pcie_g4 * pcie = container_of (dwork , struct ls_pcie_g4 , dwork );
179
+ struct ls_g4_pcie * pcie = container_of (dwork , struct ls_g4_pcie , dwork );
180
180
struct mobiveil_pcie * mv_pci = & pcie -> pci ;
181
181
u16 ctrl ;
182
182
183
183
ctrl = mobiveil_csr_readw (mv_pci , PCI_BRIDGE_CONTROL );
184
184
ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET ;
185
185
mobiveil_csr_writew (mv_pci , ctrl , PCI_BRIDGE_CONTROL );
186
186
187
- if (!ls_pcie_g4_reinit_hw (pcie ))
187
+ if (!ls_g4_pcie_reinit_hw (pcie ))
188
188
return ;
189
189
190
- ls_pcie_g4_enable_interrupt (pcie );
190
+ ls_g4_pcie_enable_interrupt (pcie );
191
191
}
192
192
193
- static struct mobiveil_rp_ops ls_pcie_g4_rp_ops = {
194
- .interrupt_init = ls_pcie_g4_interrupt_init ,
193
+ static struct mobiveil_rp_ops ls_g4_pcie_rp_ops = {
194
+ .interrupt_init = ls_g4_pcie_interrupt_init ,
195
195
};
196
196
197
- static const struct mobiveil_pab_ops ls_pcie_g4_pab_ops = {
198
- .link_up = ls_pcie_g4_link_up ,
197
+ static const struct mobiveil_pab_ops ls_g4_pcie_pab_ops = {
198
+ .link_up = ls_g4_pcie_link_up ,
199
199
};
200
200
201
- static int __init ls_pcie_g4_probe (struct platform_device * pdev )
201
+ static int __init ls_g4_pcie_probe (struct platform_device * pdev )
202
202
{
203
203
struct device * dev = & pdev -> dev ;
204
204
struct pci_host_bridge * bridge ;
205
205
struct mobiveil_pcie * mv_pci ;
206
- struct ls_pcie_g4 * pcie ;
206
+ struct ls_g4_pcie * pcie ;
207
207
struct device_node * np = dev -> of_node ;
208
208
int ret ;
209
209
@@ -220,36 +220,36 @@ static int __init ls_pcie_g4_probe(struct platform_device *pdev)
220
220
mv_pci = & pcie -> pci ;
221
221
222
222
mv_pci -> pdev = pdev ;
223
- mv_pci -> ops = & ls_pcie_g4_pab_ops ;
224
- mv_pci -> rp .ops = & ls_pcie_g4_rp_ops ;
223
+ mv_pci -> ops = & ls_g4_pcie_pab_ops ;
224
+ mv_pci -> rp .ops = & ls_g4_pcie_rp_ops ;
225
225
mv_pci -> rp .bridge = bridge ;
226
226
227
227
platform_set_drvdata (pdev , pcie );
228
228
229
- INIT_DELAYED_WORK (& pcie -> dwork , ls_pcie_g4_reset );
229
+ INIT_DELAYED_WORK (& pcie -> dwork , ls_g4_pcie_reset );
230
230
231
231
ret = mobiveil_pcie_host_probe (mv_pci );
232
232
if (ret ) {
233
233
dev_err (dev , "Fail to probe\n" );
234
234
return ret ;
235
235
}
236
236
237
- ls_pcie_g4_enable_interrupt (pcie );
237
+ ls_g4_pcie_enable_interrupt (pcie );
238
238
239
239
return 0 ;
240
240
}
241
241
242
- static const struct of_device_id ls_pcie_g4_of_match [] = {
242
+ static const struct of_device_id ls_g4_pcie_of_match [] = {
243
243
{ .compatible = "fsl,lx2160a-pcie" , },
244
244
{ },
245
245
};
246
246
247
- static struct platform_driver ls_pcie_g4_driver = {
247
+ static struct platform_driver ls_g4_pcie_driver = {
248
248
.driver = {
249
249
.name = "layerscape-pcie-gen4" ,
250
- .of_match_table = ls_pcie_g4_of_match ,
250
+ .of_match_table = ls_g4_pcie_of_match ,
251
251
.suppress_bind_attrs = true,
252
252
},
253
253
};
254
254
255
- builtin_platform_driver_probe (ls_pcie_g4_driver , ls_pcie_g4_probe );
255
+ builtin_platform_driver_probe (ls_g4_pcie_driver , ls_g4_pcie_probe );
0 commit comments