brcm2708: update against latest rpi-3.10.y branch
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0066-Only-init-gpio-pins-of-selected-i2c-bus.patch
1 From 7776b6ebf1063d2f9fac33313c8d049b424fce46 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sat, 8 Jun 2013 22:14:13 +0100
4 Subject: [PATCH 066/174] Only init gpio pins of selected i2c bus
5
6 ---
7  drivers/i2c/busses/i2c-bcm2708.c | 8 +++++---
8  1 file changed, 5 insertions(+), 3 deletions(-)
9
10 --- a/drivers/i2c/busses/i2c-bcm2708.c
11 +++ b/drivers/i2c/busses/i2c-bcm2708.c
12 @@ -97,7 +97,7 @@ struct bcm2708_i2c {
13   *
14   * FIXME: This is a hack. Use pinmux / pinctrl.
15   */
16 -static void bcm2708_i2c_init_pinmode(void)
17 +static void bcm2708_i2c_init_pinmode(int id)
18  {
19  #define INP_GPIO(g) *(gpio+((g)/10)) &= ~(7<<(((g)%10)*3))
20  #define SET_GPIO_ALT(g,a) *(gpio+(((g)/10))) |= (((a)<=3?(a)+4:(a)==4?3:2)<<(((g)%10)*3))
21 @@ -105,8 +105,10 @@ static void bcm2708_i2c_init_pinmode(voi
22         int pin;
23         u32 *gpio = ioremap(0x20200000, SZ_16K);
24  
25 +        BUG_ON(id != 0 && id != 1);
26         /* BSC0 is on GPIO 0 & 1, BSC1 is on GPIO 2 & 3 */
27 -       for (pin = 0; pin <= 3; pin++) {
28 +       for (pin = id*2+0; pin <= id*2+1; pin++) {
29 +printk("bcm2708_i2c_init_pinmode(%d,%d)\n", id, pin);
30                 INP_GPIO(pin);          /* set mode to GPIO input first */
31                 SET_GPIO_ALT(pin, 0);   /* set mode to ALT 0 */
32         }
33 @@ -279,7 +281,7 @@ static int bcm2708_i2c_probe(struct plat
34                 return PTR_ERR(clk);
35         }
36  
37 -       bcm2708_i2c_init_pinmode();
38 +       bcm2708_i2c_init_pinmode(pdev->id);
39  
40         bi = kzalloc(sizeof(*bi), GFP_KERNEL);
41         if (!bi)