i2c: i2c-bcm2708: fixes cdiv uneven number
PATCH 1/1 i2c: i2c-bcm2708: fixes cdiv uneven number
Prevents that cdiv can be an uneven number as per datasheet cdiv is always rounded down to an even number.
Datasheet at page 34 on
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
--- drivers/i2c/busses/i2c-bcm2708.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-bcm2708.c +8 -2
@@ -441,9 +441,15 @@ static int bcm2708_i2c_probe(struct platform_device *pdev) bus_hz =clk_get_rate (bi->clk); cdiv = bus_hz / baudrate; -if (cdiv >0xffff ) { - cdiv =0xffff ; +/* as per datasheet cdiv is always rounded down to an even number */ +if (cdiv >0xfffe ) { + cdiv =0xfffe ; baudrate = bus_hz / cdiv; + }else { +if ((cdiv &0xfffe ) != cdiv) { + cdiv &=0xfffe ; + baudrate = bus_hz / cdiv; + } } bi->cdiv = cdiv;
Signature · 1 line
2.1.4
A message that is not in the archive (sent off-list or not yet received): 1430417266-14900-1-git-send-email-linux_wi-ADq4ffItWIY@public.gmane.org
Quoted 16 lines · Silvan Wicki
Prevents that cdiv can be an uneven number as per datasheet cdiv is always rounded down to an even number.
Datasheet at page 34 on
http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdfSigned-off-by Silvan Wicki <[email protected]>--- drivers/i2c/busses/i2c-bcm2708.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-bcm2708.c +0
-0
drivers/i2c/busses/i2c-bcm2708.c static int bcm2708_i2c_probe(struct platform_device *pdev) · line 446
Quoted 8 lines
drivers/i2c/busses/i2c-bcm2708.c +3
-2@@ -441,9 +441,15 @@ static int bcm2708_i2c_probe(struct platform_device *pdev) bus_hz =clk_get_rate (bi->clk); cdiv = bus_hz / baudrate; -if (cdiv >0xffff ) { - cdiv =0xffff ; +/* as per datasheet cdiv is always rounded down to an even number */ +if (cdiv >0xfffe ) { + cdiv =0xfffe ;
Use #define
~Rajeev
Quoted 16 lines
drivers/i2c/busses/i2c-bcm2708.c +5
-1baudrate = bus_hz / cdiv; + }else { +if ((cdiv &0xfffe ) != cdiv) { + cdiv &=0xfffe ; + baudrate = bus_hz / cdiv; + } } bi->cdiv = cdiv; --2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html