[PATCH 6/7] i2c-bcm2708: get the i2c bus clock frequency from device tree
Chris Boot
bootc at bootc.net
Mon May 28 03:04:41 EDT 2012
On 28/05/12 07:24, Stephen Warren wrote:
> On 05/26/2012 03:19 PM, Chris Boot wrote:
>
>> diff --git a/drivers/i2c/busses/i2c-bcm2708.c b/drivers/i2c/busses/i2c-bcm2708.c
>> + bcm2708_wr(bi, BSC_DIV, clk_hz / bus_hz);
> The "clock-frequency" property is presumably the maximum frequency
> allowed for this bus. Hopefully, clk_hz can be divided down to get the
> desired value exactly, but if it can't, because the user put some
> unusual value into the device tree, shouldn't the above be:
>
> bcm2708_wr(bi, BSC_DIV, (clk_hz + bus_hz - 1) / bus_hz);
>
> (or use an existing ROUND_*() macro for this).
Yes. I already use DIV_ROUND_UP() in SPI so I should have twigged
really! I also need to bounds-check the value written into the BSC_DIV
register.
> Also, there really should be a
> Documentation/devicetree/bindings/i2c/broadcom,bcm2708-i2c.txt that
> documents the expected device tree structure, and which this patch edits
> to describe the new property.
Another good point. I'll sort that out.
Cheers,
Chris
--
Chris Boot
bootc at bootc.net
More information about the linux-rpi-kernel
mailing list