提交 e4347dfb 编写于 作者: M Michael Ellerman 提交者: Paul Mackerras

[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: NMichael Ellerman <michael@ellerman.id.au>
Acked-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 a09ad3c4
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/msi.h> #include <linux/msi.h>
#include <linux/reboot.h> #include <linux/of_platform.h>
#include <asm/dcr.h> #include <asm/dcr.h>
#include <asm/machdep.h> #include <asm/machdep.h>
...@@ -67,12 +67,9 @@ struct axon_msic { ...@@ -67,12 +67,9 @@ struct axon_msic {
struct irq_host *irq_host; struct irq_host *irq_host;
__le32 *fifo; __le32 *fifo;
dcr_host_t dcr_host; dcr_host_t dcr_host;
struct list_head list;
u32 read_offset; u32 read_offset;
}; };
static LIST_HEAD(axon_msic_list);
static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val)
{ {
pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); 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,30 +289,25 @@ static struct irq_host_ops msic_host_ops = {
.map = msic_host_map, .map = msic_host_map,
}; };
static int axon_msi_notify_reboot(struct notifier_block *nb, static int axon_msi_shutdown(struct of_device *device)
unsigned long code, void *data)
{ {
struct axon_msic *msic; struct axon_msic *msic = device->dev.platform_data;
u32 tmp; u32 tmp;
list_for_each_entry(msic, &axon_msic_list, list) { pr_debug("axon_msi: disabling %s\n",
pr_debug("axon_msi: disabling %s\n", msic->irq_host->of_node->full_name);
msic->irq_host->of_node->full_name); tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG);
tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG); tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE;
tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE; msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
msic_dcr_write(msic, MSIC_CTRL_REG, tmp);
}
return 0; return 0;
} }
static struct notifier_block axon_msi_reboot_notifier = { static int axon_msi_probe(struct of_device *device,
.notifier_call = axon_msi_notify_reboot const struct of_device_id *device_id)
};
static int axon_msi_setup_one(struct device_node *dn)
{ {
struct page *page; struct page *page;
struct device_node *dn = device->node;
struct axon_msic *msic; struct axon_msic *msic;
unsigned int virq; unsigned int virq;
int dcr_base, dcr_len; int dcr_base, dcr_len;
...@@ -385,7 +377,11 @@ static int axon_msi_setup_one(struct device_node *dn) ...@@ -385,7 +377,11 @@ static int axon_msi_setup_one(struct device_node *dn)
MSIC_CTRL_IRQ_ENABLE | MSIC_CTRL_ENABLE | MSIC_CTRL_IRQ_ENABLE | MSIC_CTRL_ENABLE |
MSIC_CTRL_FIFO_SIZE); MSIC_CTRL_FIFO_SIZE);
list_add(&msic->list, &axon_msic_list); device->dev.platform_data = msic;
ppc_md.setup_msi_irqs = axon_msi_setup_msi_irqs;
ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs;
ppc_md.msi_check_device = axon_msi_check_device;
printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name); printk(KERN_DEBUG "axon_msi: setup MSIC on %s\n", dn->full_name);
...@@ -402,28 +398,24 @@ static int axon_msi_setup_one(struct device_node *dn) ...@@ -402,28 +398,24 @@ static int axon_msi_setup_one(struct device_node *dn)
return -1; return -1;
} }
static int axon_msi_init(void) static const struct of_device_id axon_msi_device_id[] = {
{ {
struct device_node *dn; .compatible = "ibm,axon-msic"
int found = 0; },
{}
pr_debug("axon_msi: initialising ...\n"); };
for_each_compatible_node(dn, NULL, "ibm,axon-msic") {
if (axon_msi_setup_one(dn) == 0)
found++;
}
if (found) {
ppc_md.setup_msi_irqs = axon_msi_setup_msi_irqs;
ppc_md.teardown_msi_irqs = axon_msi_teardown_msi_irqs;
ppc_md.msi_check_device = axon_msi_check_device;
register_reboot_notifier(&axon_msi_reboot_notifier);
pr_debug("axon_msi: registered callbacks!\n"); static struct of_platform_driver axon_msi_driver = {
} .match_table = axon_msi_device_id,
.probe = axon_msi_probe,
.shutdown = axon_msi_shutdown,
.driver = {
.name = "axon-msi"
},
};
return 0; static int __init axon_msi_init(void)
{
return of_register_platform_driver(&axon_msi_driver);
} }
arch_initcall(axon_msi_init); subsys_initcall(axon_msi_init);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册