On 06/06/2015 12:18 PM, Silvan Wicki wrote: > Adds: make sure bits 16-31 of DIV register are always 0 > Adds: assume minimal divider of 2 if divider resulted in 0 > (bcm2835 sets divider to 32768 if cdiv is set to 0) > > See page 33/34 of BCM2835-ARM-Peripherals.pdf for the DIV register. > https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf > diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c > @@ -252,12 +255,28 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) > + if (divider > BCM2835_I2C_CDIV_MAX) { > + dev_warn(&pdev->dev, > + "Clock too slow, falling back to min clock speed\n"); > + divider = BCM2835_I2C_CDIV_MAX; > + } > bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider); Shouldn't this be an error? i.e. dev_err() not dev_warn(), and return an error code. If the divider that's required to reach the requested clock is higher than the HW can implement, that means the actual clock will be faster than the requested clock. Presumably there's a reason the specific slow rate was requested, and if we exceed it, there will be problems. -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html