2012-09-19 10:17:51 +00:00
|
|
|
--- a/drivers/bcma/driver_chipcommon.c
|
|
|
|
+++ b/drivers/bcma/driver_chipcommon.c
|
2012-09-30 11:44:44 +00:00
|
|
|
@@ -70,6 +70,8 @@ void bcma_core_chipcommon_init(struct bc
|
2012-09-19 10:17:51 +00:00
|
|
|
(leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
|
|
|
|
}
|
2012-08-04 19:46:25 +00:00
|
|
|
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_init(&cc->gpio_lock);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
cc->setup_done = true;
|
|
|
|
}
|
|
|
|
|
2012-09-30 11:44:44 +00:00
|
|
|
@@ -92,34 +94,81 @@ u32 bcma_chipco_irq_status(struct bcma_d
|
2012-09-19 10:17:51 +00:00
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask)
|
|
|
|
{
|
|
|
|
- return bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask;
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask;
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_in);
|
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
|
|
|
|
{
|
|
|
|
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
|
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
|
|
|
|
{
|
|
|
|
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
|
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
|
|
|
|
{
|
|
|
|
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
|
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
|
|
|
|
{
|
|
|
|
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_intmask);
|
|
|
|
|
|
|
|
u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
|
|
|
|
{
|
|
|
|
- return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
|
2012-08-04 19:46:25 +00:00
|
|
|
+ unsigned long flags;
|
2012-09-19 10:17:51 +00:00
|
|
|
+ u32 res;
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
2012-09-19 10:17:51 +00:00
|
|
|
+ spin_lock_irqsave(&cc->gpio_lock, flags);
|
|
|
|
+ res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
|
|
|
|
+ spin_unlock_irqrestore(&cc->gpio_lock, flags);
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ return res;
|
2012-09-19 10:17:51 +00:00
|
|
|
}
|
|
|
|
+EXPORT_SYMBOL_GPL(bcma_chipco_gpio_polarity);
|
2012-08-04 19:46:25 +00:00
|
|
|
|
2012-09-19 10:17:51 +00:00
|
|
|
#ifdef CONFIG_BCMA_DRIVER_MIPS
|
|
|
|
void bcma_chipco_serial_init(struct bcma_drv_cc *cc)
|
|
|
|
--- a/include/linux/bcma/bcma_driver_chipcommon.h
|
|
|
|
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
|
2012-10-25 14:33:47 +00:00
|
|
|
@@ -551,6 +551,9 @@ struct bcma_drv_cc {
|
2012-09-19 10:17:51 +00:00
|
|
|
int nr_serial_ports;
|
|
|
|
struct bcma_serial_port serial_ports[4];
|
|
|
|
#endif /* CONFIG_BCMA_DRIVER_MIPS */
|
2012-08-04 19:46:25 +00:00
|
|
|
+
|
|
|
|
+ /* Lock for GPIO register access. */
|
|
|
|
+ spinlock_t gpio_lock;
|
2012-09-19 10:17:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Register access */
|
2012-10-25 14:33:47 +00:00
|
|
|
@@ -581,13 +584,22 @@ void bcma_chipco_irq_mask(struct bcma_dr
|
2012-09-19 10:17:51 +00:00
|
|
|
|
|
|
|
u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
|
|
|
|
|
|
|
|
+#define BCMA_CC_GPIO_LINES 16
|
|
|
|
+
|
|
|
|
/* Chipcommon GPIO pin access. */
|
|
|
|
-u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
|
|
|
|
-u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
-u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
-u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
-u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
-u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
+extern u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask);
|
|
|
|
+extern u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
+extern u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value);
|
|
|
|
+extern u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask,
|
|
|
|
+ u32 value);
|
|
|
|
+extern u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask,
|
|
|
|
+ u32 value);
|
|
|
|
+extern u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask,
|
|
|
|
+ u32 value);
|
|
|
|
+static inline int bcma_chipco_gpio_count(void)
|
2012-08-05 12:40:05 +00:00
|
|
|
+{
|
2012-09-19 10:17:51 +00:00
|
|
|
+ return BCMA_CC_GPIO_LINES;
|
2012-08-05 12:40:05 +00:00
|
|
|
+}
|
2012-09-19 10:17:51 +00:00
|
|
|
|
|
|
|
/* PMU support */
|
|
|
|
extern void bcma_pmu_init(struct bcma_drv_cc *cc);
|