aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMichael Ellerman <michael@ellerman.id.au>2008-01-25 00:59:14 -0500
committerPaul Mackerras <paulus@samba.org>2008-02-06 00:30:00 -0500
commite4347dfb580e0172185cb38529266ecf3b4d0baa (patch)
tree88c5a868e67c13eb79c6e4cc01d691adf6b47114 /arch/powerpc
parenta09ad3c462e802f0a522969ce377820cfad89ee8 (diff)
[POWERPC] Convert axon_msi to an of_platform driver
Now that we create of_platform devices earlier on cell, we can make the axon_msi driver an of_platform driver. This makes the code cleaner in several ways, and most importantly means we have a struct device. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/axon_msi.c76
1 files changed, 34 insertions, 42 deletions
diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 095988f13bf4..ea3dc8c64a38 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -13,7 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/msi.h> 15#include <linux/msi.h>
16#include <linux/reboot.h> 16#include <linux/of_platform.h>
17 17
18#include <asm/dcr.h> 18#include <asm/dcr.h>
19#include <asm/machdep.h> 19#include <asm/machdep.h>
@@ -67,12 +67,9 @@ struct axon_msic {
67 struct irq_host *irq_host; 67 struct irq_host *irq_host;
68 __le32 *fifo; 68 __le32 *fifo;
69 dcr_host_t dcr_host; 69 dcr_host_t dcr_host;
70 struct list_head list;
71 u32 read_offset; 70 u32 read_offset;
72}; 71};
73 72
74static LIST_HEAD(axon_msic_list);
75
76static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) 73static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val)
77{ 74{
78 pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); 75 pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n);
@@ -292,30 +289,25 @@ static struct irq_host_ops msic_host_ops = {
292 .map = msic_host_map, 289 .map = msic_host_map,
293}; 290};
294 291
295static int axon_msi_notify_reboot(struct notifier_block *nb, 292static int axon_msi_shutdown(struct of_device *device)
296 unsigned long code, void *data)
297{ 293{
298 struct axon_msic *msic; 294 struct axon_msic *msic = device->dev.platform_data;
299 u32 tmp; 295 u32 tmp;
300 296
301 list_for_each_entry(msic, &axon_msic_list, list) { 297 pr_debug("axon_msi: disabling %s\n",
302 pr_debug("axon_msi: disabling %s\n", 298 msic->irq_host->of_node->full_name);
303 msic->irq_host->of_node->full_name); 299 tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG);
304 tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG); 300 tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE;
305 tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE; 301 msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
306 msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
307 }
308 302
309 return 0; 303 return 0;
310} 304}
311 305
312static struct notifier_block axon_msi_reboot_notifier = { 306static int axon_msi_probe(struct of_device *device,
313 .notifier_call = axon_msi_notify_reboot 307 const struct of_device_id *device_id)
314};
315
316static int axon_msi_setup_one(struct device_node *dn)
317{ 308{
318 struct page *page; 309 struct page *page;
310 struct device_node *dn = device->node;
319 struct axon_msic *msic; 311 struct axon_msic *msic;
320 unsigned int virq; 312 unsigned int virq;
321 int dcr_base, dcr_len; 313 int dcr_base, dcr_len;
@@ -385,7 +377,11 @@ static int axon_msi_setup_one(struct device_node *dn)
385 MSIC_CTRL_IRQ_ENABLE | MSIC_CTRL_ENABLE | 377 MSIC_CTRL_IRQ_ENABLE | MSIC_CTRL_ENABLE |
386 MSIC_CTRL_FIFO_SIZE); 378 MSIC_CTRL_FIFO_SIZE);
387 379
388 list_add(&msic->list, &axon_msic_list); 380 device->dev.platform_data = msic;
381
382 ppc_md.setup_msi_irqs = axon_msi_setup_msi_irqs;
383 ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs;
384 ppc_md.msi_check_device = axon_msi_check_device;
389 385
390 printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name); 386 printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name);
391 387
@@ -402,28 +398,24 @@ out:
402 return -1; 398 return -1;
403} 399}
404 400
405static int axon_msi_init(void) 401static const struct of_device_id axon_msi_device_id[] = {
406{ 402 {
407 struct device_node *dn; 403 .compatible = "ibm,axon-msic"
408 int found = 0; 404 },
409 405 {}
410 pr_debug("axon_msi: initialising ...\n"); 406};
411
412 for_each_compatible_node(dn, NULL, "ibm,axon-msic") {
413 if (axon_msi_setup_one(dn) == 0)
414 found++;
415 }
416
417 if (found) {
418 ppc_md.setup_msi_irqs = axon_msi_setup_msi_irqs;
419 ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs;
420 ppc_md.msi_check_device = axon_msi_check_device;
421
422 register_reboot_notifier(&axon_msi_reboot_notifier);
423 407
424 pr_debug("axon_msi: registered callbacks!\n"); 408static struct of_platform_driver axon_msi_driver = {
425 } 409 .match_table = axon_msi_device_id,
410 .probe = axon_msi_probe,
411 .shutdown = axon_msi_shutdown,
412 .driver = {
413 .name = "axon-msi"
414 },
415};
426 416
427 return 0; 417static int __init axon_msi_init(void)
418{
419 return of_register_platform_driver(&axon_msi_driver);
428} 420}
429arch_initcall(axon_msi_init); 421subsys_initcall(axon_msi_init);