Re: [PATCH v3 1/4] i2c: spacemit: configure ILCR for accurate SCL frequency

Alex Elder
2025-12-29T00:58:03Z

On 12/26/25 1:52 AM, Troy Mitchell wrote:
>>>> +static int spacemit_i2c_clk_set_rate(struct clk_hw *hw, unsigned long rate,
>>>> + unsigned long parent_rate)
>>>> +{
>>>> + struct spacemit_i2c_dev *i2c = container_of(hw, struct spacemit_i2c_dev, scl_clk_hw);
>>>> + u32 lv, lcr, mask, shift, max_lv;
>>>> +
>>>> + lv = DIV_ROUND_UP(parent_rate, rate);
>>>
>>> Would DIV_ROUND_CLOSEST() give a more accurate value?
>> I'll test it.
> Same result. So I'll keep it.

Is that true for all clock rates? Anyway, it's not
a huge deal, but especially when the number of rates
isn't very high this can make a difference.

-Alex

> - Troy