@@ -153,6 +153,37 @@ struct mtk_gen3_pcie {
153153 DECLARE_BITMAP (msi_irq_in_use , PCIE_MSI_IRQS_NUM );
154154};
155155
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+
156187/**
157188 * mtk_pcie_config_tlp_header() - Configure a configuration TLP header
158189 * @bus: PCI bus to query
@@ -327,8 +358,16 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie)
327358 !!(val & PCIE_PORT_LINKUP ), 20 ,
328359 PCI_PM_D3COLD_WAIT * USEC_PER_MSEC );
329360 if (err ) {
361+ const char * ltssm_state ;
362+ int ltssm_index ;
363+
330364 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 );
332371 return err ;
333372 }
334373
@@ -600,7 +639,8 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
600639 & intx_domain_ops , pcie );
601640 if (!pcie -> intx_domain ) {
602641 dev_err (dev , "failed to create INTx IRQ domain\n" );
603- return - ENODEV ;
642+ ret = - ENODEV ;
643+ goto out_put_node ;
604644 }
605645
606646 /* Setup MSI */
@@ -623,13 +663,15 @@ static int mtk_pcie_init_irq_domains(struct mtk_gen3_pcie *pcie)
623663 goto err_msi_domain ;
624664 }
625665
666+ of_node_put (intc_node );
626667 return 0 ;
627668
628669err_msi_domain :
629670 irq_domain_remove (pcie -> msi_bottom_domain );
630671err_msi_bottom_domain :
631672 irq_domain_remove (pcie -> intx_domain );
632-
673+ out_put_node :
674+ of_node_put (intc_node );
633675 return ret ;
634676}
635677
0 commit comments