ixp4xx: remove linux 3.10 support
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0036-set-i2c-speed-via-module-parameter-or-menuconfig.-Th.patch
1 From ec78c7da4fe9f7289cdc3e948b70a43c900f2be4 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Wed, 3 Oct 2012 20:08:19 +0100
4 Subject: [PATCH 036/196] set i2c speed via module-parameter or menuconfig.
5  Thanks FrankBoesing
6
7 ---
8  drivers/i2c/busses/Kconfig       | 11 +++++++++++
9  drivers/i2c/busses/i2c-bcm2708.c | 12 ++++++++----
10  2 files changed, 19 insertions(+), 4 deletions(-)
11
12 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
13 index 290aee4..abaff1a 100644
14 --- a/drivers/i2c/busses/Kconfig
15 +++ b/drivers/i2c/busses/Kconfig
16 @@ -355,6 +355,17 @@ config I2C_BCM2708
17           support for the BCM2708. BSC is a Broadcom proprietary bus compatible
18           with I2C/TWI/SMBus.
19  
20 +config I2C_BCM2708_BAUDRATE
21 +    prompt "BCM2708 I2C baudrate"
22 +       depends on I2C_BCM2708
23 +    int
24 +    default 100000
25 +    help
26 +      Set the I2C baudrate. This will alter the default value. A
27 +      different baudrate can be set by using a module parameter as well. If
28 +      no parameter is provided when loading, this is the value that will be
29 +      used.
30 +
31  config I2C_BLACKFIN_TWI
32         tristate "Blackfin TWI I2C support"
33         depends on BLACKFIN
34 diff --git a/drivers/i2c/busses/i2c-bcm2708.c b/drivers/i2c/busses/i2c-bcm2708.c
35 index 7cae615..3391889 100644
36 --- a/drivers/i2c/busses/i2c-bcm2708.c
37 +++ b/drivers/i2c/busses/i2c-bcm2708.c
38 @@ -66,11 +66,15 @@
39  #define BSC_S_DONE             0x00000002
40  #define BSC_S_TA               0x00000001
41  
42 -#define I2C_CLOCK_HZ   100000 /* FIXME: get from DT */
43  #define I2C_TIMEOUT_MS 150
44  
45  #define DRV_NAME       "bcm2708_i2c"
46  
47 +static unsigned int baudrate = CONFIG_I2C_BCM2708_BAUDRATE;
48 +module_param(baudrate, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
49 +MODULE_PARM_DESC(baudrate, "The I2C baudrate");
50 +
51 +
52  struct bcm2708_i2c {
53         struct i2c_adapter adapter;
54  
55 @@ -148,7 +152,7 @@ static inline void bcm2708_bsc_setup(struct bcm2708_i2c *bi)
56         u32 c = BSC_C_I2CEN | BSC_C_INTD | BSC_C_ST | BSC_C_CLEAR_1;
57  
58         bus_hz = clk_get_rate(bi->clk);
59 -       cdiv = bus_hz / I2C_CLOCK_HZ;
60 +       cdiv = bus_hz / baudrate;
61  
62         if (bi->msg->flags & I2C_M_RD)
63                 c |= BSC_C_INTR | BSC_C_READ;
64 @@ -331,8 +335,8 @@ static int bcm2708_i2c_probe(struct platform_device *pdev)
65                 goto out_free_irq;
66         }
67  
68 -       dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d)\n",
69 -               pdev->id, (unsigned long)regs->start, irq);
70 +       dev_info(&pdev->dev, "BSC%d Controller at 0x%08lx (irq %d) (baudrate %dk)\n",
71 +               pdev->id, (unsigned long)regs->start, irq, baudrate/1000);
72  
73         return 0;
74  
75 -- 
76 1.9.1
77