Lines Matching refs:i2c_priv
269 static int stm32_i2c_check_device_busy(struct stm32_i2c_priv *i2c_priv) in stm32_i2c_check_device_busy() argument
271 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_check_device_busy()
280 static void stm32_i2c_message_start(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_message_start() argument
283 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_message_start()
324 static void stm32_i2c_handle_reload(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_handle_reload() argument
327 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_handle_reload()
342 static int stm32_i2c_wait_flags(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_wait_flags() argument
345 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_wait_flags()
361 static int stm32_i2c_check_end_of_message(struct stm32_i2c_priv *i2c_priv) in stm32_i2c_check_end_of_message() argument
363 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_check_end_of_message()
369 ret = stm32_i2c_wait_flags(i2c_priv, mask, &status); in stm32_i2c_check_end_of_message()
399 ret = stm32_i2c_wait_flags(i2c_priv, mask, &status); in stm32_i2c_check_end_of_message()
417 static int stm32_i2c_message_xfer(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_message_xfer() argument
420 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_message_xfer()
431 stm32_i2c_message_start(i2c_priv, msg, stop); in stm32_i2c_message_xfer()
438 ret = stm32_i2c_wait_flags(i2c_priv, mask, &status); in stm32_i2c_message_xfer()
460 ret = stm32_i2c_wait_flags(i2c_priv, mask, &status); in stm32_i2c_message_xfer()
469 stm32_i2c_handle_reload(i2c_priv, msg, stop); in stm32_i2c_message_xfer()
473 ret = stm32_i2c_wait_flags(i2c_priv, mask, &status); in stm32_i2c_message_xfer()
487 return stm32_i2c_check_end_of_message(i2c_priv); in stm32_i2c_message_xfer()
493 struct stm32_i2c_priv *i2c_priv = dev_get_priv(bus); in stm32_i2c_xfer() local
496 ret = stm32_i2c_check_device_busy(i2c_priv); in stm32_i2c_xfer()
501 ret = stm32_i2c_message_xfer(i2c_priv, msg, nmsgs == 1); in stm32_i2c_xfer()
680 static int stm32_i2c_compute_timing(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_compute_timing() argument
745 static int stm32_i2c_setup_timing(struct stm32_i2c_priv *i2c_priv, in stm32_i2c_setup_timing() argument
748 struct stm32_i2c_setup *setup = i2c_priv->setup; in stm32_i2c_setup_timing()
751 setup->speed_freq = i2c_priv->speed; in stm32_i2c_setup_timing()
752 setup->clock_src = clk_get_rate(&i2c_priv->clk); in stm32_i2c_setup_timing()
760 ret = stm32_i2c_compute_timing(i2c_priv, setup, timing); in stm32_i2c_setup_timing()
786 i2c_priv->speed = setup->speed_freq; in stm32_i2c_setup_timing()
791 static int stm32_i2c_write_fm_plus_bits(struct stm32_i2c_priv *i2c_priv) in stm32_i2c_write_fm_plus_bits() argument
794 bool enable = i2c_priv->speed > I2C_SPEED_FAST_RATE; in stm32_i2c_write_fm_plus_bits()
797 if (IS_ERR_OR_NULL(i2c_priv->regmap)) in stm32_i2c_write_fm_plus_bits()
800 if (i2c_priv->regmap_sreg == i2c_priv->regmap_creg) in stm32_i2c_write_fm_plus_bits()
801 ret = regmap_update_bits(i2c_priv->regmap, in stm32_i2c_write_fm_plus_bits()
802 i2c_priv->regmap_sreg, in stm32_i2c_write_fm_plus_bits()
803 i2c_priv->regmap_mask, in stm32_i2c_write_fm_plus_bits()
804 enable ? i2c_priv->regmap_mask : 0); in stm32_i2c_write_fm_plus_bits()
806 ret = regmap_write(i2c_priv->regmap, in stm32_i2c_write_fm_plus_bits()
807 enable ? i2c_priv->regmap_sreg : in stm32_i2c_write_fm_plus_bits()
808 i2c_priv->regmap_creg, in stm32_i2c_write_fm_plus_bits()
809 i2c_priv->regmap_mask); in stm32_i2c_write_fm_plus_bits()
814 static int stm32_i2c_hw_config(struct stm32_i2c_priv *i2c_priv) in stm32_i2c_hw_config() argument
816 struct stm32_i2c_regs *regs = i2c_priv->regs; in stm32_i2c_hw_config()
821 ret = stm32_i2c_setup_timing(i2c_priv, &t); in stm32_i2c_hw_config()
829 ret = stm32_i2c_write_fm_plus_bits(i2c_priv); in stm32_i2c_hw_config()
842 if (i2c_priv->setup->analog_filter) in stm32_i2c_hw_config()
853 struct stm32_i2c_priv *i2c_priv = dev_get_priv(dev); in stm32_i2c_set_bus_speed() local
860 i2c_priv->speed = speed; in stm32_i2c_set_bus_speed()
862 return stm32_i2c_hw_config(i2c_priv); in stm32_i2c_set_bus_speed()
867 struct stm32_i2c_priv *i2c_priv = dev_get_priv(dev); in stm32_i2c_probe() local
876 i2c_priv->regs = (struct stm32_i2c_regs *)addr; in stm32_i2c_probe()
878 ret = clk_get_by_index(dev, 0, &i2c_priv->clk); in stm32_i2c_probe()
882 ret = clk_enable(&i2c_priv->clk); in stm32_i2c_probe()
897 clk_disable(&i2c_priv->clk); in stm32_i2c_probe()
899 clk_free(&i2c_priv->clk); in stm32_i2c_probe()
906 struct stm32_i2c_priv *i2c_priv = dev_get_priv(dev); in stm32_of_to_plat() local
910 i2c_priv->setup = (struct stm32_i2c_setup *)dev_get_driver_data(dev); in stm32_of_to_plat()
911 if (!i2c_priv->setup) in stm32_of_to_plat()
916 i2c_priv->setup->rise_time = rise_time; in stm32_of_to_plat()
920 i2c_priv->setup->fall_time = fall_time; in stm32_of_to_plat()
923 i2c_priv->regmap = syscon_regmap_lookup_by_phandle(dev, in stm32_of_to_plat()
925 if (!IS_ERR(i2c_priv->regmap)) { in stm32_of_to_plat()
932 i2c_priv->regmap_sreg = fmp[1]; in stm32_of_to_plat()
933 i2c_priv->regmap_creg = fmp[1] + in stm32_of_to_plat()
934 i2c_priv->setup->fmp_clr_offset; in stm32_of_to_plat()
935 i2c_priv->regmap_mask = fmp[2]; in stm32_of_to_plat()