@@ -246,7 +246,7 @@ struct tegra_i2c_hw_feature {
246
246
* @msg_buf: pointer to current message data
247
247
* @msg_buf_remaining: size of unsent data in the message buffer
248
248
* @msg_read: indicates that the transfer is a read access
249
- * @bus_clk_rate: current I2C bus clock rate
249
+ * @timings: i2c timings information like bus frequency
250
250
* @multimaster_mode: indicates that I2C controller is in multi-master mode
251
251
* @tx_dma_chan: DMA transmit channel
252
252
* @rx_dma_chan: DMA receive channel
@@ -273,7 +273,7 @@ struct tegra_i2c_dev {
273
273
unsigned int nclocks ;
274
274
275
275
struct clk * div_clk ;
276
- u32 bus_clk_rate ;
276
+ struct i2c_timings timings ;
277
277
278
278
struct completion msg_complete ;
279
279
size_t msg_buf_remaining ;
@@ -610,6 +610,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
610
610
{
611
611
u32 val , clk_divisor , clk_multiplier , tsu_thd , tlow , thigh , non_hs_mode ;
612
612
acpi_handle handle = ACPI_HANDLE (i2c_dev -> dev );
613
+ struct i2c_timings * t = & i2c_dev -> timings ;
613
614
int err ;
614
615
615
616
/*
@@ -642,14 +643,14 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
642
643
if (i2c_dev -> is_vi )
643
644
tegra_i2c_vi_init (i2c_dev );
644
645
645
- switch (i2c_dev -> bus_clk_rate ) {
646
+ switch (t -> bus_freq_hz ) {
646
647
case I2C_MAX_STANDARD_MODE_FREQ + 1 ... I2C_MAX_FAST_MODE_PLUS_FREQ :
647
648
default :
648
649
tlow = i2c_dev -> hw -> tlow_fast_fastplus_mode ;
649
650
thigh = i2c_dev -> hw -> thigh_fast_fastplus_mode ;
650
651
tsu_thd = i2c_dev -> hw -> setup_hold_time_fast_fast_plus_mode ;
651
652
652
- if (i2c_dev -> bus_clk_rate > I2C_MAX_FAST_MODE_FREQ )
653
+ if (t -> bus_freq_hz > I2C_MAX_FAST_MODE_FREQ )
653
654
non_hs_mode = i2c_dev -> hw -> clk_divisor_fast_plus_mode ;
654
655
else
655
656
non_hs_mode = i2c_dev -> hw -> clk_divisor_fast_mode ;
@@ -685,7 +686,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
685
686
clk_multiplier = (tlow + thigh + 2 ) * (non_hs_mode + 1 );
686
687
687
688
err = clk_set_rate (i2c_dev -> div_clk ,
688
- i2c_dev -> bus_clk_rate * clk_multiplier );
689
+ t -> bus_freq_hz * clk_multiplier );
689
690
if (err ) {
690
691
dev_err (i2c_dev -> dev , "failed to set div-clk rate: %d\n" , err );
691
692
return err ;
@@ -724,7 +725,7 @@ static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev)
724
725
* before disabling the controller so that the STOP condition has
725
726
* been delivered properly.
726
727
*/
727
- udelay (DIV_ROUND_UP (2 * 1000000 , i2c_dev -> bus_clk_rate ));
728
+ udelay (DIV_ROUND_UP (2 * 1000000 , i2c_dev -> timings . bus_freq_hz ));
728
729
729
730
cnfg = i2c_readl (i2c_dev , I2C_CNFG );
730
731
if (cnfg & I2C_CNFG_PACKET_MODE_EN )
@@ -1254,7 +1255,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
1254
1255
* Total bits = 9 bits per byte (including ACK bit) + Start & stop bits
1255
1256
*/
1256
1257
xfer_time += DIV_ROUND_CLOSEST (((xfer_size * 9 ) + 2 ) * MSEC_PER_SEC ,
1257
- i2c_dev -> bus_clk_rate );
1258
+ i2c_dev -> timings . bus_freq_hz );
1258
1259
1259
1260
int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST ;
1260
1261
tegra_i2c_unmask_irq (i2c_dev , int_mask );
@@ -1631,12 +1632,8 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
1631
1632
{
1632
1633
struct device_node * np = i2c_dev -> dev -> of_node ;
1633
1634
bool multi_mode ;
1634
- int err ;
1635
1635
1636
- err = device_property_read_u32 (i2c_dev -> dev , "clock-frequency" ,
1637
- & i2c_dev -> bus_clk_rate );
1638
- if (err )
1639
- i2c_dev -> bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ ;
1636
+ i2c_parse_fw_timings (i2c_dev -> dev , & i2c_dev -> timings , true);
1640
1637
1641
1638
multi_mode = device_property_read_bool (i2c_dev -> dev , "multi-master" );
1642
1639
i2c_dev -> multimaster_mode = multi_mode ;
0 commit comments