6161#define PCL_RDLH_LINK_UP BIT(1)
6262#define PCL_XMLH_LINK_UP BIT(0)
6363
64- struct uniphier_pcie_priv {
65- void __iomem * base ;
64+ struct uniphier_pcie {
6665 struct dw_pcie pci ;
66+ void __iomem * base ;
6767 struct clk * clk ;
6868 struct reset_control * rst ;
6969 struct phy * phy ;
@@ -72,62 +72,62 @@ struct uniphier_pcie_priv {
7272
7373#define to_uniphier_pcie (x ) dev_get_drvdata((x)->dev)
7474
75- static void uniphier_pcie_ltssm_enable (struct uniphier_pcie_priv * priv ,
75+ static void uniphier_pcie_ltssm_enable (struct uniphier_pcie * pcie ,
7676 bool enable )
7777{
7878 u32 val ;
7979
80- val = readl (priv -> base + PCL_APP_READY_CTRL );
80+ val = readl (pcie -> base + PCL_APP_READY_CTRL );
8181 if (enable )
8282 val |= PCL_APP_LTSSM_ENABLE ;
8383 else
8484 val &= ~PCL_APP_LTSSM_ENABLE ;
85- writel (val , priv -> base + PCL_APP_READY_CTRL );
85+ writel (val , pcie -> base + PCL_APP_READY_CTRL );
8686}
8787
88- static void uniphier_pcie_init_rc (struct uniphier_pcie_priv * priv )
88+ static void uniphier_pcie_init_rc (struct uniphier_pcie * pcie )
8989{
9090 u32 val ;
9191
9292 /* set RC MODE */
93- val = readl (priv -> base + PCL_MODE );
93+ val = readl (pcie -> base + PCL_MODE );
9494 val |= PCL_MODE_REGEN ;
9595 val &= ~PCL_MODE_REGVAL ;
96- writel (val , priv -> base + PCL_MODE );
96+ writel (val , pcie -> base + PCL_MODE );
9797
9898 /* use auxiliary power detection */
99- val = readl (priv -> base + PCL_APP_PM0 );
99+ val = readl (pcie -> base + PCL_APP_PM0 );
100100 val |= PCL_SYS_AUX_PWR_DET ;
101- writel (val , priv -> base + PCL_APP_PM0 );
101+ writel (val , pcie -> base + PCL_APP_PM0 );
102102
103103 /* assert PERST# */
104- val = readl (priv -> base + PCL_PINCTRL0 );
104+ val = readl (pcie -> base + PCL_PINCTRL0 );
105105 val &= ~(PCL_PERST_NOE_REGVAL | PCL_PERST_OUT_REGVAL
106106 | PCL_PERST_PLDN_REGVAL );
107107 val |= PCL_PERST_NOE_REGEN | PCL_PERST_OUT_REGEN
108108 | PCL_PERST_PLDN_REGEN ;
109- writel (val , priv -> base + PCL_PINCTRL0 );
109+ writel (val , pcie -> base + PCL_PINCTRL0 );
110110
111- uniphier_pcie_ltssm_enable (priv , false);
111+ uniphier_pcie_ltssm_enable (pcie , false);
112112
113113 usleep_range (100000 , 200000 );
114114
115115 /* deassert PERST# */
116- val = readl (priv -> base + PCL_PINCTRL0 );
116+ val = readl (pcie -> base + PCL_PINCTRL0 );
117117 val |= PCL_PERST_OUT_REGVAL | PCL_PERST_OUT_REGEN ;
118- writel (val , priv -> base + PCL_PINCTRL0 );
118+ writel (val , pcie -> base + PCL_PINCTRL0 );
119119}
120120
121- static int uniphier_pcie_wait_rc (struct uniphier_pcie_priv * priv )
121+ static int uniphier_pcie_wait_rc (struct uniphier_pcie * pcie )
122122{
123123 u32 status ;
124124 int ret ;
125125
126126 /* wait PIPE clock */
127- ret = readl_poll_timeout (priv -> base + PCL_PIPEMON , status ,
127+ ret = readl_poll_timeout (pcie -> base + PCL_PIPEMON , status ,
128128 status & PCL_PCLK_ALIVE , 100000 , 1000000 );
129129 if (ret ) {
130- dev_err (priv -> pci .dev ,
130+ dev_err (pcie -> pci .dev ,
131131 "Failed to initialize controller in RC mode\n" );
132132 return ret ;
133133 }
@@ -137,50 +137,51 @@ static int uniphier_pcie_wait_rc(struct uniphier_pcie_priv *priv)
137137
138138static int uniphier_pcie_link_up (struct dw_pcie * pci )
139139{
140- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
140+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
141141 u32 val , mask ;
142142
143- val = readl (priv -> base + PCL_STATUS_LINK );
143+ val = readl (pcie -> base + PCL_STATUS_LINK );
144144 mask = PCL_RDLH_LINK_UP | PCL_XMLH_LINK_UP ;
145145
146146 return (val & mask ) == mask ;
147147}
148148
149149static int uniphier_pcie_start_link (struct dw_pcie * pci )
150150{
151- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
151+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
152152
153- uniphier_pcie_ltssm_enable (priv , true);
153+ uniphier_pcie_ltssm_enable (pcie , true);
154154
155155 return 0 ;
156156}
157157
158158static void uniphier_pcie_stop_link (struct dw_pcie * pci )
159159{
160- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
160+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
161161
162- uniphier_pcie_ltssm_enable (priv , false);
162+ uniphier_pcie_ltssm_enable (pcie , false);
163163}
164164
165- static void uniphier_pcie_irq_enable (struct uniphier_pcie_priv * priv )
165+ static void uniphier_pcie_irq_enable (struct uniphier_pcie * pcie )
166166{
167- writel (PCL_RCV_INT_ALL_ENABLE , priv -> base + PCL_RCV_INT );
168- writel (PCL_RCV_INTX_ALL_ENABLE , priv -> base + PCL_RCV_INTX );
167+ writel (PCL_RCV_INT_ALL_ENABLE , pcie -> base + PCL_RCV_INT );
168+ writel (PCL_RCV_INTX_ALL_ENABLE , pcie -> base + PCL_RCV_INTX );
169169}
170170
171+
171172static void uniphier_pcie_irq_mask (struct irq_data * d )
172173{
173174 struct pcie_port * pp = irq_data_get_irq_chip_data (d );
174175 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
175- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
176+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
176177 unsigned long flags ;
177178 u32 val ;
178179
179180 raw_spin_lock_irqsave (& pp -> lock , flags );
180181
181- val = readl (priv -> base + PCL_RCV_INTX );
182+ val = readl (pcie -> base + PCL_RCV_INTX );
182183 val |= BIT (irqd_to_hwirq (d ) + PCL_RCV_INTX_MASK_SHIFT );
183- writel (val , priv -> base + PCL_RCV_INTX );
184+ writel (val , pcie -> base + PCL_RCV_INTX );
184185
185186 raw_spin_unlock_irqrestore (& pp -> lock , flags );
186187}
@@ -189,15 +190,15 @@ static void uniphier_pcie_irq_unmask(struct irq_data *d)
189190{
190191 struct pcie_port * pp = irq_data_get_irq_chip_data (d );
191192 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
192- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
193+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
193194 unsigned long flags ;
194195 u32 val ;
195196
196197 raw_spin_lock_irqsave (& pp -> lock , flags );
197198
198- val = readl (priv -> base + PCL_RCV_INTX );
199+ val = readl (pcie -> base + PCL_RCV_INTX );
199200 val &= ~BIT (irqd_to_hwirq (d ) + PCL_RCV_INTX_MASK_SHIFT );
200- writel (val , priv -> base + PCL_RCV_INTX );
201+ writel (val , pcie -> base + PCL_RCV_INTX );
201202
202203 raw_spin_unlock_irqrestore (& pp -> lock , flags );
203204}
@@ -226,13 +227,13 @@ static void uniphier_pcie_irq_handler(struct irq_desc *desc)
226227{
227228 struct pcie_port * pp = irq_desc_get_handler_data (desc );
228229 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
229- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
230+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
230231 struct irq_chip * chip = irq_desc_get_chip (desc );
231232 unsigned long reg ;
232233 u32 val , bit ;
233234
234235 /* INT for debug */
235- val = readl (priv -> base + PCL_RCV_INT );
236+ val = readl (pcie -> base + PCL_RCV_INT );
236237
237238 if (val & PCL_CFG_BW_MGT_STATUS )
238239 dev_dbg (pci -> dev , "Link Bandwidth Management Event\n" );
@@ -243,24 +244,24 @@ static void uniphier_pcie_irq_handler(struct irq_desc *desc)
243244 if (val & PCL_CFG_PME_MSI_STATUS )
244245 dev_dbg (pci -> dev , "PME Interrupt\n" );
245246
246- writel (val , priv -> base + PCL_RCV_INT );
247+ writel (val , pcie -> base + PCL_RCV_INT );
247248
248249 /* INTx */
249250 chained_irq_enter (chip , desc );
250251
251- val = readl (priv -> base + PCL_RCV_INTX );
252+ val = readl (pcie -> base + PCL_RCV_INTX );
252253 reg = FIELD_GET (PCL_RCV_INTX_ALL_STATUS , val );
253254
254255 for_each_set_bit (bit , & reg , PCI_NUM_INTX )
255- generic_handle_domain_irq (priv -> legacy_irq_domain , bit );
256+ generic_handle_domain_irq (pcie -> legacy_irq_domain , bit );
256257
257258 chained_irq_exit (chip , desc );
258259}
259260
260261static int uniphier_pcie_config_legacy_irq (struct pcie_port * pp )
261262{
262263 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
263- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
264+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
264265 struct device_node * np = pci -> dev -> of_node ;
265266 struct device_node * np_intc ;
266267 int ret = 0 ;
@@ -278,9 +279,9 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp)
278279 goto out_put_node ;
279280 }
280281
281- priv -> legacy_irq_domain = irq_domain_add_linear (np_intc , PCI_NUM_INTX ,
282+ pcie -> legacy_irq_domain = irq_domain_add_linear (np_intc , PCI_NUM_INTX ,
282283 & uniphier_intx_domain_ops , pp );
283- if (!priv -> legacy_irq_domain ) {
284+ if (!pcie -> legacy_irq_domain ) {
284285 dev_err (pci -> dev , "Failed to get INTx domain\n" );
285286 ret = - ENODEV ;
286287 goto out_put_node ;
@@ -297,14 +298,14 @@ static int uniphier_pcie_config_legacy_irq(struct pcie_port *pp)
297298static int uniphier_pcie_host_init (struct pcie_port * pp )
298299{
299300 struct dw_pcie * pci = to_dw_pcie_from_pp (pp );
300- struct uniphier_pcie_priv * priv = to_uniphier_pcie (pci );
301+ struct uniphier_pcie * pcie = to_uniphier_pcie (pci );
301302 int ret ;
302303
303304 ret = uniphier_pcie_config_legacy_irq (pp );
304305 if (ret )
305306 return ret ;
306307
307- uniphier_pcie_irq_enable (priv );
308+ uniphier_pcie_irq_enable (pcie );
308309
309310 return 0 ;
310311}
@@ -313,36 +314,36 @@ static const struct dw_pcie_host_ops uniphier_pcie_host_ops = {
313314 .host_init = uniphier_pcie_host_init ,
314315};
315316
316- static int uniphier_pcie_host_enable (struct uniphier_pcie_priv * priv )
317+ static int uniphier_pcie_host_enable (struct uniphier_pcie * pcie )
317318{
318319 int ret ;
319320
320- ret = clk_prepare_enable (priv -> clk );
321+ ret = clk_prepare_enable (pcie -> clk );
321322 if (ret )
322323 return ret ;
323324
324- ret = reset_control_deassert (priv -> rst );
325+ ret = reset_control_deassert (pcie -> rst );
325326 if (ret )
326327 goto out_clk_disable ;
327328
328- uniphier_pcie_init_rc (priv );
329+ uniphier_pcie_init_rc (pcie );
329330
330- ret = phy_init (priv -> phy );
331+ ret = phy_init (pcie -> phy );
331332 if (ret )
332333 goto out_rst_assert ;
333334
334- ret = uniphier_pcie_wait_rc (priv );
335+ ret = uniphier_pcie_wait_rc (pcie );
335336 if (ret )
336337 goto out_phy_exit ;
337338
338339 return 0 ;
339340
340341out_phy_exit :
341- phy_exit (priv -> phy );
342+ phy_exit (pcie -> phy );
342343out_rst_assert :
343- reset_control_assert (priv -> rst );
344+ reset_control_assert (pcie -> rst );
344345out_clk_disable :
345- clk_disable_unprepare (priv -> clk );
346+ clk_disable_unprepare (pcie -> clk );
346347
347348 return ret ;
348349}
@@ -356,41 +357,41 @@ static const struct dw_pcie_ops dw_pcie_ops = {
356357static int uniphier_pcie_probe (struct platform_device * pdev )
357358{
358359 struct device * dev = & pdev -> dev ;
359- struct uniphier_pcie_priv * priv ;
360+ struct uniphier_pcie * pcie ;
360361 int ret ;
361362
362- priv = devm_kzalloc (dev , sizeof (* priv ), GFP_KERNEL );
363- if (!priv )
363+ pcie = devm_kzalloc (dev , sizeof (* pcie ), GFP_KERNEL );
364+ if (!pcie )
364365 return - ENOMEM ;
365366
366- priv -> pci .dev = dev ;
367- priv -> pci .ops = & dw_pcie_ops ;
367+ pcie -> pci .dev = dev ;
368+ pcie -> pci .ops = & dw_pcie_ops ;
368369
369- priv -> base = devm_platform_ioremap_resource_byname (pdev , "link" );
370- if (IS_ERR (priv -> base ))
371- return PTR_ERR (priv -> base );
370+ pcie -> base = devm_platform_ioremap_resource_byname (pdev , "link" );
371+ if (IS_ERR (pcie -> base ))
372+ return PTR_ERR (pcie -> base );
372373
373- priv -> clk = devm_clk_get (dev , NULL );
374- if (IS_ERR (priv -> clk ))
375- return PTR_ERR (priv -> clk );
374+ pcie -> clk = devm_clk_get (dev , NULL );
375+ if (IS_ERR (pcie -> clk ))
376+ return PTR_ERR (pcie -> clk );
376377
377- priv -> rst = devm_reset_control_get_shared (dev , NULL );
378- if (IS_ERR (priv -> rst ))
379- return PTR_ERR (priv -> rst );
378+ pcie -> rst = devm_reset_control_get_shared (dev , NULL );
379+ if (IS_ERR (pcie -> rst ))
380+ return PTR_ERR (pcie -> rst );
380381
381- priv -> phy = devm_phy_optional_get (dev , "pcie-phy" );
382- if (IS_ERR (priv -> phy ))
383- return PTR_ERR (priv -> phy );
382+ pcie -> phy = devm_phy_optional_get (dev , "pcie-phy" );
383+ if (IS_ERR (pcie -> phy ))
384+ return PTR_ERR (pcie -> phy );
384385
385- platform_set_drvdata (pdev , priv );
386+ platform_set_drvdata (pdev , pcie );
386387
387- ret = uniphier_pcie_host_enable (priv );
388+ ret = uniphier_pcie_host_enable (pcie );
388389 if (ret )
389390 return ret ;
390391
391- priv -> pci .pp .ops = & uniphier_pcie_host_ops ;
392+ pcie -> pci .pp .ops = & uniphier_pcie_host_ops ;
392393
393- return dw_pcie_host_init (& priv -> pci .pp );
394+ return dw_pcie_host_init (& pcie -> pci .pp );
394395}
395396
396397static const struct of_device_id uniphier_pcie_match [] = {
0 commit comments