1 --- a/drivers/bcma/Kconfig
2 +++ b/drivers/bcma/Kconfig
3 @@ -39,6 +39,11 @@ config BCMA_HOST_SOC
4 depends on BCMA_DRIVER_MIPS
5 select USB_HCD_BCMA if USB_EHCI_HCD || USB_OHCI_HCD
7 +config BCMA_DRIVER_GPIO
9 + depends on BCMA_DRIVER_MIPS
14 depends on BCMA_DRIVER_MIPS
15 --- a/drivers/bcma/Makefile
16 +++ b/drivers/bcma/Makefile
17 @@ -6,6 +6,7 @@ bcma-y += driver_pci.o
18 bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
19 bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
20 bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
21 +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
22 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
23 bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
24 obj-$(CONFIG_BCMA) += bcma.o
26 +++ b/drivers/bcma/driver_gpio.c
29 + * Broadcom specific AMBA
30 + * GPIO driver for SoCs
32 + * Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
34 + * Licensed under the GNU/GPL. See COPYING for details.
37 +#include <linux/export.h>
38 +#include <linux/bcma/bcma.h>
39 +#include <linux/bcma/bcma_driver_gpio.h>
41 +u32 bcma_gpio_in(struct bcma_bus *bus, u32 mask)
43 + unsigned long flags;
46 + spin_lock_irqsave(&bus->gpio_lock, flags);
47 + res = bcma_chipco_gpio_in(&bus->drv_cc, mask);
48 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
52 +EXPORT_SYMBOL(bcma_gpio_in);
54 +u32 bcma_gpio_out(struct bcma_bus *bus, u32 mask, u32 value)
56 + unsigned long flags;
59 + spin_lock_irqsave(&bus->gpio_lock, flags);
60 + res = bcma_chipco_gpio_out(&bus->drv_cc, mask, value);
61 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
65 +EXPORT_SYMBOL(bcma_gpio_out);
67 +u32 bcma_gpio_outen(struct bcma_bus *bus, u32 mask, u32 value)
69 + unsigned long flags;
72 + spin_lock_irqsave(&bus->gpio_lock, flags);
73 + res = bcma_chipco_gpio_outen(&bus->drv_cc, mask, value);
74 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
78 +EXPORT_SYMBOL(bcma_gpio_outen);
80 +u32 bcma_gpio_control(struct bcma_bus *bus, u32 mask, u32 value)
82 + unsigned long flags;
85 + spin_lock_irqsave(&bus->gpio_lock, flags);
86 + res = bcma_chipco_gpio_control(&bus->drv_cc, mask, value);
87 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
91 +EXPORT_SYMBOL(bcma_gpio_control);
93 +u32 bcma_gpio_intmask(struct bcma_bus *bus, u32 mask, u32 value)
95 + unsigned long flags;
98 + spin_lock_irqsave(&bus->gpio_lock, flags);
99 + res = bcma_chipco_gpio_intmask(&bus->drv_cc, mask, value);
100 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
104 +EXPORT_SYMBOL(bcma_gpio_intmask);
106 +u32 bcma_gpio_polarity(struct bcma_bus *bus, u32 mask, u32 value)
108 + unsigned long flags;
111 + spin_lock_irqsave(&bus->gpio_lock, flags);
112 + res = bcma_chipco_gpio_polarity(&bus->drv_cc, mask, value);
113 + spin_unlock_irqrestore(&bus->gpio_lock, flags);
117 +EXPORT_SYMBOL(bcma_gpio_polarity);
118 --- a/drivers/bcma/scan.c
119 +++ b/drivers/bcma/scan.c
120 @@ -422,6 +422,10 @@ void bcma_init_bus(struct bcma_bus *bus)
124 +#ifdef CONFIG_BCMA_DRIVER_GPIO
125 + spin_lock_init(&bus->gpio_lock);
128 INIT_LIST_HEAD(&bus->cores);
131 --- a/include/linux/bcma/bcma.h
132 +++ b/include/linux/bcma/bcma.h
133 @@ -255,6 +255,11 @@ struct bcma_bus {
134 struct bcma_drv_mips drv_mips;
135 struct bcma_drv_gmac_cmn drv_gmac_cmn;
137 +#ifdef CONFIG_BCMA_DRIVER_GPIO
138 + /* Lock for GPIO register access. */
139 + spinlock_t gpio_lock;
140 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
142 /* We decided to share SPROM struct with SSB as long as we do not need
143 * any hacks for BCMA. This simplifies drivers code. */
144 struct ssb_sprom sprom;
146 +++ b/include/linux/bcma/bcma_driver_gpio.h
148 +#ifndef LINUX_BCMA_DRIVER_GPIO_H_
149 +#define LINUX_BCMA_DRIVER_GPIO_H_
151 +#include <linux/types.h>
152 +#include <linux/bcma/bcma.h>
154 +#define BCMA_GPIO_CC_LINES 16
156 +u32 bcma_gpio_in(struct bcma_bus *bus, u32 mask);
157 +u32 bcma_gpio_out(struct bcma_bus *bus, u32 mask, u32 value);
158 +u32 bcma_gpio_outen(struct bcma_bus *bus, u32 mask, u32 value);
159 +u32 bcma_gpio_control(struct bcma_bus *bus, u32 mask, u32 value);
160 +u32 bcma_gpio_intmask(struct bcma_bus *bus, u32 mask, u32 value);
161 +u32 bcma_gpio_polarity(struct bcma_bus *bus, u32 mask, u32 value);
163 +static inline int bcma_gpio_count(struct bcma_bus *bus)
165 + return BCMA_GPIO_CC_LINES;
168 +#endif /* LINUX_BCMA_DRIVER_GPIO_H_ */