aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2012-01-26 08:25:47 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2012-02-09 10:34:50 -0500
commitae99ddbc976572194e8a68cb9ca1e27805ce30c7 (patch)
tree1c9beadf736c4038625a77cefd6f030cfba130ce /arch
parent6bd72f0562142ddae26a052cfc4e578ad6953d06 (diff)
ARM: sa1111: add platform enable/disable functions
Add platform hooks to be called when individual sa1111 devices are enabled and disabled. This will allow us to move some platform specifics out of the individual drivers. Acked-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/common/sa1111.c22
-rw-r--r--arch/arm/include/asm/hardware/sa1111.h8
2 files changed, 23 insertions, 7 deletions
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index b0f93628dcd7..1366e82e6707 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -106,6 +106,7 @@ struct sa1111 {
106 int irq_base; /* base for cascaded on-chip IRQs */ 106 int irq_base; /* base for cascaded on-chip IRQs */
107 spinlock_t lock; 107 spinlock_t lock;
108 void __iomem *base; 108 void __iomem *base;
109 struct sa1111_platform_data *pdata;
109#ifdef CONFIG_PM 110#ifdef CONFIG_PM
110 void *saved_state; 111 void *saved_state;
111#endif 112#endif
@@ -756,6 +757,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
756 sachip->dev = me; 757 sachip->dev = me;
757 dev_set_drvdata(sachip->dev, sachip); 758 dev_set_drvdata(sachip->dev, sachip);
758 759
760 sachip->pdata = pd;
759 sachip->phys = mem->start; 761 sachip->phys = mem->start;
760 sachip->irq = irq; 762 sachip->irq = irq;
761 763
@@ -1282,16 +1284,23 @@ EXPORT_SYMBOL(sa1111_set_sleep_io);
1282 * sa1111_enable_device - enable an on-chip SA1111 function block 1284 * sa1111_enable_device - enable an on-chip SA1111 function block
1283 * @sadev: SA1111 function block device to enable 1285 * @sadev: SA1111 function block device to enable
1284 */ 1286 */
1285void sa1111_enable_device(struct sa1111_dev *sadev) 1287int sa1111_enable_device(struct sa1111_dev *sadev)
1286{ 1288{
1287 struct sa1111 *sachip = sa1111_chip_driver(sadev); 1289 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1288 unsigned long flags; 1290 unsigned long flags;
1289 unsigned int val; 1291 unsigned int val;
1292 int ret = 0;
1290 1293
1291 spin_lock_irqsave(&sachip->lock, flags); 1294 if (sachip->pdata && sachip->pdata->enable)
1292 val = sa1111_readl(sachip->base + SA1111_SKPCR); 1295 ret = sachip->pdata->enable(sachip->pdata->data, sadev->devid);
1293 sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); 1296
1294 spin_unlock_irqrestore(&sachip->lock, flags); 1297 if (ret == 0) {
1298 spin_lock_irqsave(&sachip->lock, flags);
1299 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1300 sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1301 spin_unlock_irqrestore(&sachip->lock, flags);
1302 }
1303 return ret;
1295} 1304}
1296EXPORT_SYMBOL(sa1111_enable_device); 1305EXPORT_SYMBOL(sa1111_enable_device);
1297 1306
@@ -1309,6 +1318,9 @@ void sa1111_disable_device(struct sa1111_dev *sadev)
1309 val = sa1111_readl(sachip->base + SA1111_SKPCR); 1318 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1310 sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR); 1319 sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1311 spin_unlock_irqrestore(&sachip->lock, flags); 1320 spin_unlock_irqrestore(&sachip->lock, flags);
1321
1322 if (sachip->pdata && sachip->pdata->disable)
1323 sachip->pdata->disable(sachip->pdata->data, sadev->devid);
1312} 1324}
1313EXPORT_SYMBOL(sa1111_disable_device); 1325EXPORT_SYMBOL(sa1111_disable_device);
1314 1326
diff --git a/arch/arm/include/asm/hardware/sa1111.h b/arch/arm/include/asm/hardware/sa1111.h
index 29e320f6f85f..d54d781021c8 100644
--- a/arch/arm/include/asm/hardware/sa1111.h
+++ b/arch/arm/include/asm/hardware/sa1111.h
@@ -556,9 +556,10 @@ struct sa1111_driver {
556#define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name) 556#define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name)
557 557
558/* 558/*
559 * These frob the SKPCR register. 559 * These frob the SKPCR register, and call platform specific
560 * enable/disable functions.
560 */ 561 */
561void sa1111_enable_device(struct sa1111_dev *); 562int sa1111_enable_device(struct sa1111_dev *);
562void sa1111_disable_device(struct sa1111_dev *); 563void sa1111_disable_device(struct sa1111_dev *);
563 564
564unsigned int sa1111_pll_clock(struct sa1111_dev *); 565unsigned int sa1111_pll_clock(struct sa1111_dev *);
@@ -581,6 +582,9 @@ void sa1111_set_sleep_io(struct sa1111_dev *sadev, unsigned int bits, unsigned i
581 582
582struct sa1111_platform_data { 583struct sa1111_platform_data {
583 int irq_base; /* base for cascaded on-chip IRQs */ 584 int irq_base; /* base for cascaded on-chip IRQs */
585 void *data;
586 int (*enable)(void *, unsigned);
587 void (*disable)(void *, unsigned);
584}; 588};
585 589
586#endif /* _ASM_ARCH_SA1111 */ 590#endif /* _ASM_ARCH_SA1111 */