target/linux/*: kmod-fs-ext{2,3} RIP
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.10 / 085-MIPS-BCM47XX-Get-GPIO-pin-from-nvram-configuration.patch
1 commit e49ec29e2da1fd7cdd6d966f389add031a1027a9
2 Author: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Wed Sep 18 13:31:15 2013 +0200
4
5 MIPS: BCM47XX: Get GPIO pin from nvram configuration
6
7 The nvram contains some gpio configuration for boards. It is stored in
8 a gpio<number>=name format e.g.
9 gpio8=wps_button
10 gpio4=robo_reset
11
12 This patches adds a function to parse these entries, so other driver
13 can use it.
14
15 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
16 Cc: linux-mips@linux-mips.org
17 Patchwork: https://patchwork.linux-mips.org/patch/5841/
18 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
19
20 --- a/arch/mips/bcm47xx/nvram.c
21 +++ b/arch/mips/bcm47xx/nvram.c
22 @@ -190,3 +190,23 @@ int bcm47xx_nvram_getenv(char *name, cha
23 return -ENOENT;
24 }
25 EXPORT_SYMBOL(bcm47xx_nvram_getenv);
26 +
27 +int bcm47xx_nvram_gpio_pin(const char *name)
28 +{
29 + int i, err;
30 + char nvram_var[10];
31 + char buf[30];
32 +
33 + for (i = 0; i < 16; i++) {
34 + err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
35 + if (err <= 0)
36 + continue;
37 + err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
38 + if (err <= 0)
39 + continue;
40 + if (!strcmp(name, buf))
41 + return i;
42 + }
43 + return -ENOENT;
44 +}
45 +EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
46 --- a/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
47 +++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
48 @@ -48,4 +48,6 @@ static inline void bcm47xx_nvram_parse_m
49 printk(KERN_WARNING "Can not parse mac address: %s\n", buf);
50 }
51
52 +int bcm47xx_nvram_gpio_pin(const char *name);
53 +
54 #endif /* __BCM47XX_NVRAM_H */