@@ -153,6 +153,37 @@ struct mtk_gen3_pcie {
153
153
DECLARE_BITMAP (msi_irq_in_use , PCIE_MSI_IRQS_NUM );
154
154
};
155
155
156
+ /* LTSSM state in PCIE_LTSSM_STATUS_REG bit[28:24] */
157
+ static const char * const ltssm_str [] = {
158
+ "detect.quiet" , /* 0x00 */
159
+ "detect.active" , /* 0x01 */
160
+ "polling.active" , /* 0x02 */
161
+ "polling.compliance" , /* 0x03 */
162
+ "polling.configuration" , /* 0x04 */
163
+ "config.linkwidthstart" , /* 0x05 */
164
+ "config.linkwidthaccept" , /* 0x06 */
165
+ "config.lanenumwait" , /* 0x07 */
166
+ "config.lanenumaccept" , /* 0x08 */
167
+ "config.complete" , /* 0x09 */
168
+ "config.idle" , /* 0x0A */
169
+ "recovery.receiverlock" , /* 0x0B */
170
+ "recovery.equalization" , /* 0x0C */
171
+ "recovery.speed" , /* 0x0D */
172
+ "recovery.receiverconfig" , /* 0x0E */
173
+ "recovery.idle" , /* 0x0F */
174
+ "L0" , /* 0x10 */
175
+ "L0s" , /* 0x11 */
176
+ "L1.entry" , /* 0x12 */
177
+ "L1.idle" , /* 0x13 */
178
+ "L2.idle" , /* 0x14 */
179
+ "L2.transmitwake" , /* 0x15 */
180
+ "disable" , /* 0x16 */
181
+ "loopback.entry" , /* 0x17 */
182
+ "loopback.active" , /* 0x18 */
183
+ "loopback.exit" , /* 0x19 */
184
+ "hotreset" , /* 0x1A */
185
+ };
186
+
156
187
/**
157
188
* mtk_pcie_config_tlp_header() - Configure a configuration TLP header
158
189
* @bus: PCI bus to query
@@ -327,8 +358,16 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
327
358
!!(val & PCIE_PORT_LINKUP ), 20 ,
328
359
PCI_PM_D3COLD_WAIT * USEC_PER_MSEC );
329
360
if (err ) {
361
+ const char * ltssm_state ;
362
+ int ltssm_index ;
363
+
330
364
val = readl_relaxed (pcie -> base + PCIE_LTSSM_STATUS_REG );
331
- dev_err (pcie -> dev , "PCIe link down, ltssm reg val: %#x\n" , val );
365
+ ltssm_index = PCIE_LTSSM_STATE (val );
366
+ ltssm_state = ltssm_index >= ARRAY_SIZE (ltssm_str ) ?
367
+ "Unknown state" : ltssm_str [ltssm_index ];
368
+ dev_err (pcie -> dev ,
369
+ "PCIe link down, current LTSSM state: %s (%#x)\n" ,
370
+ ltssm_state , val );
332
371
return err ;
333
372
}
334
373
@@ -600,7 +639,8 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
600
639
& intx_domain_ops , pcie );
601
640
if (!pcie -> intx_domain ) {
602
641
dev_err (dev , "failed to create INTx IRQ domain\n" );
603
- return - ENODEV ;
642
+ ret = - ENODEV ;
643
+ goto out_put_node ;
604
644
}
605
645
606
646
/* Setup MSI */
@@ -623,13 +663,15 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
623
663
goto err_msi_domain ;
624
664
}
625
665
666
+ of_node_put (intc_node );
626
667
return 0 ;
627
668
628
669
err_msi_domain :
629
670
irq_domain_remove (pcie -> msi_bottom_domain );
630
671
err_msi_bottom_domain :
631
672
irq_domain_remove (pcie -> intx_domain );
632
-
673
+ out_put_node :
674
+ of_node_put (intc_node );
633
675
return ret ;
634
676
}
635
677
0 commit comments