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);
119 +int bcma_gpio_count(struct bcma_bus *bus)
121 + return BCMA_GPIO_CC_LINES;
123 +EXPORT_SYMBOL(bcma_gpio_count);
124 --- a/drivers/bcma/scan.c
125 +++ b/drivers/bcma/scan.c
126 @@ -422,6 +422,10 @@ void bcma_init_bus(struct bcma_bus *bus)
130 +#ifdef CONFIG_BCMA_DRIVER_GPIO
131 + spin_lock_init(&bus->gpio_lock);
134 INIT_LIST_HEAD(&bus->cores);
137 --- a/include/linux/bcma/bcma.h
138 +++ b/include/linux/bcma/bcma.h
139 @@ -255,6 +255,11 @@ struct bcma_bus {
140 struct bcma_drv_mips drv_mips;
141 struct bcma_drv_gmac_cmn drv_gmac_cmn;
143 +#ifdef CONFIG_BCMA_DRIVER_GPIO
144 + /* Lock for GPIO register access. */
145 + spinlock_t gpio_lock;
146 +#endif /* CONFIG_BCMA_DRIVER_GPIO */
148 /* We decided to share SPROM struct with SSB as long as we do not need
149 * any hacks for BCMA. This simplifies drivers code. */
150 struct ssb_sprom sprom;
152 +++ b/include/linux/bcma/bcma_driver_gpio.h
154 +#ifndef LINUX_BCMA_DRIVER_GPIO_H_
155 +#define LINUX_BCMA_DRIVER_GPIO_H_
157 +#include <linux/types.h>
158 +#include <linux/bcma/bcma.h>
160 +#define BCMA_GPIO_CC_LINES 16
162 +u32 bcma_gpio_in(struct bcma_bus *bus, u32 mask);
163 +u32 bcma_gpio_out(struct bcma_bus *bus, u32 mask, u32 value);
164 +u32 bcma_gpio_outen(struct bcma_bus *bus, u32 mask, u32 value);
165 +u32 bcma_gpio_control(struct bcma_bus *bus, u32 mask, u32 value);
166 +u32 bcma_gpio_intmask(struct bcma_bus *bus, u32 mask, u32 value);
167 +u32 bcma_gpio_polarity(struct bcma_bus *bus, u32 mask, u32 value);
168 +int bcma_gpio_count(struct bcma_bus *bus);
170 +#endif /* LINUX_BCMA_DRIVER_GPIO_H_ */