File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ struct lpi2c_imx_struct {
100100 __u8 * rx_buf ;
101101 __u8 * tx_buf ;
102102 struct completion complete ;
103+ unsigned long rate_per ;
103104 unsigned int msglen ;
104105 unsigned int delivered ;
105106 unsigned int block_data ;
@@ -208,7 +209,8 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
208209
209210 lpi2c_imx_set_mode (lpi2c_imx );
210211
211- clk_rate = clk_get_rate (lpi2c_imx -> clks [0 ].clk );
212+ clk_rate = lpi2c_imx -> rate_per ;
213+
212214 if (lpi2c_imx -> mode == HS || lpi2c_imx -> mode == ULTRA_FAST )
213215 filt = 0 ;
214216 else
@@ -594,6 +596,20 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
594596 if (ret )
595597 return ret ;
596598
599+ /*
600+ * Lock the parent clock rate to avoid getting parent clock upon
601+ * each transfer
602+ */
603+ ret = devm_clk_rate_exclusive_get (& pdev -> dev , lpi2c_imx -> clks [0 ].clk );
604+ if (ret )
605+ return dev_err_probe (& pdev -> dev , ret ,
606+ "can't lock I2C peripheral clock rate\n" );
607+
608+ lpi2c_imx -> rate_per = clk_get_rate (lpi2c_imx -> clks [0 ].clk );
609+ if (!lpi2c_imx -> rate_per )
610+ return dev_err_probe (& pdev -> dev , - EINVAL ,
611+ "can't get I2C peripheral clock rate\n" );
612+
597613 pm_runtime_set_autosuspend_delay (& pdev -> dev , I2C_PM_TIMEOUT );
598614 pm_runtime_use_autosuspend (& pdev -> dev );
599615 pm_runtime_get_noresume (& pdev -> dev );
You can’t perform that action at this time.
0 commit comments