1 From 4efc768113042d0b48fdb4e170d5469f93f6e20b Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Tue, 19 Jan 2016 16:28:05 +0000
4 Subject: [PATCH] FIXUP i2c_bcm2708: Don't change module baudrate parameter
6 Overwriting the baudrate module parameter creates an apparent
7 forced baudrate for i2c busses after the first. Not only does this
8 override the baudrate from DT it also prevents the bus ID from
11 Also fix whitespace errors.
13 drivers/i2c/busses/i2c-bcm2708.c | 48 +++++++++++++++++++++-------------------
14 1 file changed, 25 insertions(+), 23 deletions(-)
16 --- a/drivers/i2c/busses/i2c-bcm2708.c
17 +++ b/drivers/i2c/busses/i2c-bcm2708.c
20 #define DRV_NAME "bcm2708_i2c"
22 -static unsigned int baudrate_default = CONFIG_I2C_BCM2708_BAUDRATE;
23 static unsigned int baudrate;
24 module_param(baudrate, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
25 MODULE_PARM_DESC(baudrate, "The I2C baudrate");
26 @@ -317,25 +316,28 @@ static int bcm2708_i2c_probe(struct plat
27 struct i2c_adapter *adap;
32 - baudrate = baudrate_default;
33 - if (pdev->dev.of_node) {
35 - pdev->id = of_alias_get_id(pdev->dev.of_node, "i2c");
37 - dev_err(&pdev->dev, "alias is missing\n");
40 - if (!of_property_read_u32(pdev->dev.of_node,
41 - "clock-frequency", &bus_clk_rate))
42 - baudrate = bus_clk_rate;
44 - dev_warn(&pdev->dev,
45 - "Could not read clock-frequency property\n");
48 + baud = CONFIG_I2C_BCM2708_BAUDRATE;
50 + if (pdev->dev.of_node) {
52 + pdev->id = of_alias_get_id(pdev->dev.of_node, "i2c");
54 + dev_err(&pdev->dev, "alias is missing\n");
57 + if (!of_property_read_u32(pdev->dev.of_node,
58 + "clock-frequency", &bus_clk_rate))
59 + baud = bus_clk_rate;
61 + dev_warn(&pdev->dev,
62 + "Could not read clock-frequency property\n");
68 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
70 dev_err(&pdev->dev, "could not get IO memory\n");
71 @@ -419,21 +421,21 @@ static int bcm2708_i2c_probe(struct plat
74 bus_hz = clk_get_rate(bi->clk);
75 - cdiv = bus_hz / baudrate;
76 + cdiv = bus_hz / baud;
79 - baudrate = bus_hz / cdiv;
80 + baud = bus_hz / cdiv;
83 - clk_tout = 35/1000*baudrate; //35ms timeout as per SMBus specs.
84 - if (clk_tout > 0xffff)
86 + clk_tout = 35/1000*baud; //35ms timeout as per SMBus specs.
87 + if (clk_tout > 0xffff)
91 bi->clk_tout = clk_tout;
93 dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d) (baudrate %d)\n",
94 - pdev->id, (unsigned long)regs->start, irq, baudrate);
95 + pdev->id, (unsigned long)regs->start, irq, baud);