@@ -340,6 +340,7 @@ struct dw_mipi_dsi {
340340 struct regmap * regmap ;
341341 struct clk * pclk ;
342342 struct clk * h2p_clk ;
343+ int irq ;
343344
344345 /* dual-channel */
345346 struct dw_mipi_dsi * master ;
@@ -1201,12 +1202,14 @@ static void dw_mipi_dsi_dphy_interface_config(struct dw_mipi_dsi *dsi)
12011202 PHY_STOP_WAIT_TIME (0x20 ) | N_LANES (dsi -> lanes ));
12021203}
12031204
1204- static void dw_mipi_dsi_clear_err (struct dw_mipi_dsi * dsi )
1205+ static void dw_mipi_dsi_interrupt_enable (struct dw_mipi_dsi * dsi )
12051206{
1206- unsigned int val ;
1207+ regmap_write (dsi -> regmap , DSI_INT_MSK0 , 0x1fffff );
1208+ regmap_write (dsi -> regmap , DSI_INT_MSK1 , 0x1f7f );
1209+ }
12071210
1208- regmap_read ( dsi -> regmap , DSI_INT_ST0 , & val );
1209- regmap_read ( dsi -> regmap , DSI_INT_ST1 , & val );
1211+ static void dw_mipi_dsi_interrupt_disable ( struct dw_mipi_dsi * dsi )
1212+ {
12101213 regmap_write (dsi -> regmap , DSI_INT_MSK0 , 0 );
12111214 regmap_write (dsi -> regmap , DSI_INT_MSK1 , 0 );
12121215}
@@ -1233,6 +1236,7 @@ static void dw_mipi_dsi_disable(struct dw_mipi_dsi *dsi)
12331236
12341237static void dw_mipi_dsi_post_disable (struct dw_mipi_dsi * dsi )
12351238{
1239+ dw_mipi_dsi_interrupt_disable (dsi );
12361240 dw_mipi_dsi_host_power_off (dsi );
12371241 mipi_dphy_power_off (dsi );
12381242
@@ -1281,7 +1285,7 @@ static void dw_mipi_dsi_host_init(struct dw_mipi_dsi *dsi)
12811285 dw_mipi_dsi_vertical_timing_config (dsi );
12821286 dw_mipi_dsi_dphy_timing_config (dsi );
12831287 dw_mipi_dsi_dphy_interface_config (dsi );
1284- dw_mipi_dsi_clear_err (dsi );
1288+ dw_mipi_dsi_interrupt_enable (dsi );
12851289}
12861290
12871291static void dw_mipi_dsi_pre_enable (struct dw_mipi_dsi * dsi )
@@ -1611,6 +1615,73 @@ static const struct component_ops dw_mipi_dsi_ops = {
16111615 .unbind = dw_mipi_dsi_unbind ,
16121616};
16131617
1618+ static const char * const dphy_error [] = {
1619+ "ErrEsc escape entry error from Lane 0" ,
1620+ "ErrSyncEsc low-power data transmission synchronization error from Lane 0" ,
1621+ "the ErrControl error from Lane 0" ,
1622+ "LP0 contention error ErrContentionLP0 from Lane 0" ,
1623+ "LP1 contention error ErrContentionLP1 from Lane 0" ,
1624+ };
1625+
1626+ static const char * const ack_with_err [] = {
1627+ "the SoT error from the Acknowledge error report" ,
1628+ "the SoT Sync error from the Acknowledge error report" ,
1629+ "the EoT Sync error from the Acknowledge error report" ,
1630+ "the Escape Mode Entry Command error from the Acknowledge error report" ,
1631+ "the LP Transmit Sync error from the Acknowledge error report" ,
1632+ "the Peripheral Timeout error from the Acknowledge Error report" ,
1633+ "the False Control error from the Acknowledge error report" ,
1634+ "the reserved (specific to device) from the Acknowledge error report" ,
1635+ "the ECC error, single-bit (detected and corrected) from the Acknowledge error report" ,
1636+ "the ECC error, multi-bit (detected, not corrected) from the Acknowledge error report" ,
1637+ "the checksum error (long packet only) from the Acknowledge error report" ,
1638+ "the not recognized DSI data type from the Acknowledge error report" ,
1639+ "the DSI VC ID Invalid from the Acknowledge error report" ,
1640+ "the invalid transmission length from the Acknowledge error report" ,
1641+ "the reserved (specific to device) from the Acknowledge error report" ,
1642+ "the DSI protocol violation from the Acknowledge error report" ,
1643+ };
1644+
1645+ static const char * const error_report [] = {
1646+ "Host reports that the configured timeout counter for the high-speed transmission has expired" ,
1647+ "Host reports that the configured timeout counter for the low-power reception has expired" ,
1648+ "Host reports that a received packet contains a single bit error" ,
1649+ "Host reports that a received packet contains multiple ECC errors" ,
1650+ "Host reports that a received long packet has a CRC error in its payload" ,
1651+ "Host receives a transmission that does not end in the expected by boundaries" ,
1652+ "Host receives a transmission that does not end with an End of Transmission packet" ,
1653+ "An overflow occurs in the DPI pixel payload FIFO" ,
1654+ "An overflow occurs in the Generic command FIFO" ,
1655+ "An overflow occurs in the Generic write payload FIFO" ,
1656+ "An underflow occurs in the Generic write payload FIFO" ,
1657+ "An underflow occurs in the Generic read FIFO" ,
1658+ "An overflow occurs in the Generic read FIFO" ,
1659+ };
1660+
1661+ static irqreturn_t dw_mipi_dsi_irq_handler (int irq , void * dev_id )
1662+ {
1663+ struct dw_mipi_dsi * dsi = dev_id ;
1664+ u32 int_st0 , int_st1 ;
1665+ unsigned int i ;
1666+
1667+ regmap_read (dsi -> regmap , DSI_INT_ST0 , & int_st0 );
1668+ regmap_read (dsi -> regmap , DSI_INT_ST1 , & int_st1 );
1669+
1670+ for (i = 0 ; i < ARRAY_SIZE (ack_with_err ); i ++ )
1671+ if (int_st0 & BIT (i ))
1672+ dev_dbg (dsi -> dev , "%s\n" , ack_with_err [i ]);
1673+
1674+ for (i = 0 ; i < ARRAY_SIZE (dphy_error ); i ++ )
1675+ if (int_st0 & BIT (16 + i ))
1676+ dev_dbg (dsi -> dev , "%s\n" , dphy_error [i ]);
1677+
1678+ for (i = 0 ; i < ARRAY_SIZE (error_report ); i ++ )
1679+ if (int_st1 & BIT (i ))
1680+ dev_dbg (dsi -> dev , "%s\n" , error_report [i ]);
1681+
1682+ return IRQ_HANDLED ;
1683+ }
1684+
16141685static const struct regmap_config testif_regmap_config = {
16151686 .name = "phy" ,
16161687 .reg_bits = 8 ,
@@ -1734,6 +1805,10 @@ static int dw_mipi_dsi_probe(struct platform_device *pdev)
17341805 if (IS_ERR (regs ))
17351806 return PTR_ERR (regs );
17361807
1808+ dsi -> irq = platform_get_irq (pdev , 0 );
1809+ if (dsi -> irq < 0 )
1810+ return dsi -> irq ;
1811+
17371812 dsi -> pclk = devm_clk_get (dev , "pclk" );
17381813 if (IS_ERR (dsi -> pclk )) {
17391814 ret = PTR_ERR (dsi -> pclk );
@@ -1772,6 +1847,13 @@ static int dw_mipi_dsi_probe(struct platform_device *pdev)
17721847 if (ret )
17731848 return ret ;
17741849
1850+ ret = devm_request_irq (dev , dsi -> irq , dw_mipi_dsi_irq_handler ,
1851+ IRQF_SHARED , dev_name (dev ), dsi );
1852+ if (ret ) {
1853+ dev_err (dev , "failed to request irq: %d\n" , ret );
1854+ return ret ;
1855+ }
1856+
17751857 dsi -> dsi_host .ops = & dw_mipi_dsi_host_ops ;
17761858 dsi -> dsi_host .dev = dev ;
17771859
0 commit comments