[PATCH 6/7] i2c-bcm2708: get the i2c bus clock frequency from device tree

Stephen Warren swarren at wwwdotorg.org
Mon May 28 02:24:32 EDT 2012


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).

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.




More information about the linux-rpi-kernel mailing list