Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 1 | /* |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 2 | * Copyright (C) 2007-2010 Freescale Semiconductor, Inc. |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 3 | * |
| 4 | * Author: Tony Li <tony.li@freescale.com> |
| 5 | * Jason Jin <Jason.jin@freescale.com> |
| 6 | * |
| 7 | * The hwirq alloc and free code reuse from sysdev/mpic_msi.c |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation; version 2 of the |
| 12 | * License. |
| 13 | * |
| 14 | */ |
| 15 | #include <linux/irq.h> |
| 16 | #include <linux/bootmem.h> |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 17 | #include <linux/msi.h> |
| 18 | #include <linux/pci.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 20 | #include <linux/of_platform.h> |
| 21 | #include <sysdev/fsl_soc.h> |
| 22 | #include <asm/prom.h> |
| 23 | #include <asm/hw_irq.h> |
| 24 | #include <asm/ppc-pci.h> |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 25 | #include <asm/mpic.h> |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 26 | #include "fsl_msi.h" |
| 27 | |
| 28 | struct fsl_msi_feature { |
| 29 | u32 fsl_pic_ip; |
| 30 | u32 msiir_offset; |
| 31 | }; |
| 32 | |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 33 | struct fsl_msi_cascade_data { |
| 34 | struct fsl_msi *msi_data; |
| 35 | int index; |
| 36 | }; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 37 | |
| 38 | static inline u32 fsl_msi_read(u32 __iomem *base, unsigned int reg) |
| 39 | { |
| 40 | return in_be32(base + (reg >> 2)); |
| 41 | } |
| 42 | |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 43 | /* |
| 44 | * We do not need this actually. The MSIR register has been read once |
| 45 | * in the cascade interrupt. So, this MSI interrupt has been acked |
| 46 | */ |
| 47 | static void fsl_msi_end_irq(unsigned int virq) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | static struct irq_chip fsl_msi_chip = { |
| 52 | .mask = mask_msi_irq, |
| 53 | .unmask = unmask_msi_irq, |
| 54 | .ack = fsl_msi_end_irq, |
Anton Blanchard | fc380c0 | 2010-01-31 20:33:41 +0000 | [diff] [blame] | 55 | .name = "FSL-MSI", |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static int fsl_msi_host_map(struct irq_host *h, unsigned int virq, |
| 59 | irq_hw_number_t hw) |
| 60 | { |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 61 | struct fsl_msi *msi_data = h->host_data; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 62 | struct irq_chip *chip = &fsl_msi_chip; |
| 63 | |
Michael Ellerman | 6cff46f | 2009-10-13 19:44:51 +0000 | [diff] [blame] | 64 | irq_to_desc(virq)->status |= IRQ_TYPE_EDGE_FALLING; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 65 | |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 66 | set_irq_chip_data(virq, msi_data); |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 67 | set_irq_chip_and_handler(virq, chip, handle_edge_irq); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static struct irq_host_ops fsl_msi_host_ops = { |
| 73 | .map = fsl_msi_host_map, |
| 74 | }; |
| 75 | |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 76 | static int fsl_msi_init_allocator(struct fsl_msi *msi_data) |
| 77 | { |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 78 | int rc; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 79 | |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 80 | rc = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS, |
| 81 | msi_data->irqhost->of_node); |
| 82 | if (rc) |
| 83 | return rc; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 84 | |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 85 | rc = msi_bitmap_reserve_dt_hwirqs(&msi_data->bitmap); |
| 86 | if (rc < 0) { |
| 87 | msi_bitmap_free(&msi_data->bitmap); |
| 88 | return rc; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 89 | } |
| 90 | |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 91 | return 0; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static int fsl_msi_check_device(struct pci_dev *pdev, int nvec, int type) |
| 95 | { |
| 96 | if (type == PCI_CAP_ID_MSIX) |
| 97 | pr_debug("fslmsi: MSI-X untested, trying anyway.\n"); |
| 98 | |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | static void fsl_teardown_msi_irqs(struct pci_dev *pdev) |
| 103 | { |
| 104 | struct msi_desc *entry; |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 105 | struct fsl_msi *msi_data; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 106 | |
| 107 | list_for_each_entry(entry, &pdev->msi_list, list) { |
| 108 | if (entry->irq == NO_IRQ) |
| 109 | continue; |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 110 | msi_data = get_irq_data(entry->irq); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 111 | set_irq_msi(entry->irq, NULL); |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 112 | msi_bitmap_free_hwirqs(&msi_data->bitmap, |
| 113 | virq_to_hw(entry->irq), 1); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 114 | irq_dispose_mapping(entry->irq); |
| 115 | } |
| 116 | |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq, |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 121 | struct msi_msg *msg, |
| 122 | struct fsl_msi *fsl_msi_data) |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 123 | { |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 124 | struct fsl_msi *msi_data = fsl_msi_data; |
Kumar Gala | 3da34aa | 2009-05-12 15:51:56 -0500 | [diff] [blame] | 125 | struct pci_controller *hose = pci_bus_to_host(pdev->bus); |
| 126 | u32 base = 0; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 127 | |
Kumar Gala | 3da34aa | 2009-05-12 15:51:56 -0500 | [diff] [blame] | 128 | pci_bus_read_config_dword(hose->bus, |
| 129 | PCI_DEVFN(0, 0), PCI_BASE_ADDRESS_0, &base); |
| 130 | |
| 131 | msg->address_lo = msi_data->msi_addr_lo + base; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 132 | msg->address_hi = msi_data->msi_addr_hi; |
| 133 | msg->data = hwirq; |
| 134 | |
| 135 | pr_debug("%s: allocated srs: %d, ibs: %d\n", |
| 136 | __func__, hwirq / IRQS_PER_MSI_REG, hwirq % IRQS_PER_MSI_REG); |
| 137 | } |
| 138 | |
| 139 | static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) |
| 140 | { |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 141 | int rc, hwirq = NO_IRQ; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 142 | unsigned int virq; |
| 143 | struct msi_desc *entry; |
| 144 | struct msi_msg msg; |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 145 | struct fsl_msi *msi_data; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 146 | |
| 147 | list_for_each_entry(entry, &pdev->msi_list, list) { |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 148 | msi_data = get_irq_chip_data(entry->irq); |
| 149 | |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 150 | hwirq = msi_bitmap_alloc_hwirqs(&msi_data->bitmap, 1); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 151 | if (hwirq < 0) { |
| 152 | rc = hwirq; |
| 153 | pr_debug("%s: fail allocating msi interrupt\n", |
| 154 | __func__); |
| 155 | goto out_free; |
| 156 | } |
| 157 | |
| 158 | virq = irq_create_mapping(msi_data->irqhost, hwirq); |
| 159 | |
| 160 | if (virq == NO_IRQ) { |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 161 | pr_debug("%s: fail mapping hwirq 0x%x\n", |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 162 | __func__, hwirq); |
Michael Ellerman | 7e7ab36 | 2008-08-06 09:10:02 +1000 | [diff] [blame] | 163 | msi_bitmap_free_hwirqs(&msi_data->bitmap, hwirq, 1); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 164 | rc = -ENOSPC; |
| 165 | goto out_free; |
| 166 | } |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 167 | set_irq_data(virq, msi_data); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 168 | set_irq_msi(virq, entry); |
| 169 | |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 170 | fsl_compose_msi_msg(pdev, hwirq, &msg, msi_data); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 171 | write_msi_msg(virq, &msg); |
| 172 | } |
| 173 | return 0; |
| 174 | |
| 175 | out_free: |
| 176 | return rc; |
| 177 | } |
| 178 | |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 179 | static void fsl_msi_cascade(unsigned int irq, struct irq_desc *desc) |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 180 | { |
| 181 | unsigned int cascade_irq; |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 182 | struct fsl_msi *msi_data; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 183 | int msir_index = -1; |
| 184 | u32 msir_value = 0; |
| 185 | u32 intr_index; |
| 186 | u32 have_shift = 0; |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 187 | struct fsl_msi_cascade_data *cascade_data; |
| 188 | |
| 189 | cascade_data = (struct fsl_msi_cascade_data *)get_irq_data(irq); |
| 190 | msi_data = cascade_data->msi_data; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 191 | |
Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 192 | raw_spin_lock(&desc->lock); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 193 | if ((msi_data->feature & FSL_PIC_IP_MASK) == FSL_PIC_IP_IPIC) { |
| 194 | if (desc->chip->mask_ack) |
| 195 | desc->chip->mask_ack(irq); |
| 196 | else { |
| 197 | desc->chip->mask(irq); |
| 198 | desc->chip->ack(irq); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | if (unlikely(desc->status & IRQ_INPROGRESS)) |
| 203 | goto unlock; |
| 204 | |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 205 | msir_index = cascade_data->index; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 206 | |
| 207 | if (msir_index >= NR_MSI_REG) |
| 208 | cascade_irq = NO_IRQ; |
| 209 | |
| 210 | desc->status |= IRQ_INPROGRESS; |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 211 | switch (msi_data->feature & FSL_PIC_IP_MASK) { |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 212 | case FSL_PIC_IP_MPIC: |
| 213 | msir_value = fsl_msi_read(msi_data->msi_regs, |
| 214 | msir_index * 0x10); |
| 215 | break; |
| 216 | case FSL_PIC_IP_IPIC: |
| 217 | msir_value = fsl_msi_read(msi_data->msi_regs, msir_index * 0x4); |
| 218 | break; |
| 219 | } |
| 220 | |
| 221 | while (msir_value) { |
| 222 | intr_index = ffs(msir_value) - 1; |
| 223 | |
| 224 | cascade_irq = irq_linear_revmap(msi_data->irqhost, |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 225 | msir_index * IRQS_PER_MSI_REG + |
| 226 | intr_index + have_shift); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 227 | if (cascade_irq != NO_IRQ) |
| 228 | generic_handle_irq(cascade_irq); |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 229 | have_shift += intr_index + 1; |
| 230 | msir_value = msir_value >> (intr_index + 1); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 231 | } |
| 232 | desc->status &= ~IRQ_INPROGRESS; |
| 233 | |
| 234 | switch (msi_data->feature & FSL_PIC_IP_MASK) { |
| 235 | case FSL_PIC_IP_MPIC: |
| 236 | desc->chip->eoi(irq); |
| 237 | break; |
| 238 | case FSL_PIC_IP_IPIC: |
| 239 | if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask) |
| 240 | desc->chip->unmask(irq); |
| 241 | break; |
| 242 | } |
| 243 | unlock: |
Thomas Gleixner | 239007b | 2009-11-17 16:46:45 +0100 | [diff] [blame] | 244 | raw_spin_unlock(&desc->lock); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static int __devinit fsl_of_msi_probe(struct of_device *dev, |
| 248 | const struct of_device_id *match) |
| 249 | { |
| 250 | struct fsl_msi *msi; |
| 251 | struct resource res; |
| 252 | int err, i, count; |
| 253 | int rc; |
| 254 | int virt_msir; |
| 255 | const u32 *p; |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 256 | struct fsl_msi_feature *features = match->data; |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 257 | struct fsl_msi_cascade_data *cascade_data = NULL; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 258 | |
| 259 | printk(KERN_DEBUG "Setting up Freescale MSI support\n"); |
| 260 | |
| 261 | msi = kzalloc(sizeof(struct fsl_msi), GFP_KERNEL); |
| 262 | if (!msi) { |
| 263 | dev_err(&dev->dev, "No memory for MSI structure\n"); |
| 264 | err = -ENOMEM; |
| 265 | goto error_out; |
| 266 | } |
| 267 | |
Michael Ellerman | 611cd90 | 2008-08-06 09:10:00 +1000 | [diff] [blame] | 268 | msi->irqhost = irq_alloc_host(dev->node, IRQ_HOST_MAP_LINEAR, |
| 269 | NR_MSI_IRQS, &fsl_msi_host_ops, 0); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 270 | |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 271 | if (msi->irqhost == NULL) { |
| 272 | dev_err(&dev->dev, "No memory for MSI irqhost\n"); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 273 | err = -ENOMEM; |
| 274 | goto error_out; |
| 275 | } |
| 276 | |
| 277 | /* Get the MSI reg base */ |
| 278 | err = of_address_to_resource(dev->node, 0, &res); |
| 279 | if (err) { |
| 280 | dev_err(&dev->dev, "%s resource error!\n", |
| 281 | dev->node->full_name); |
| 282 | goto error_out; |
| 283 | } |
| 284 | |
| 285 | msi->msi_regs = ioremap(res.start, res.end - res.start + 1); |
| 286 | if (!msi->msi_regs) { |
| 287 | dev_err(&dev->dev, "ioremap problem failed\n"); |
| 288 | goto error_out; |
| 289 | } |
| 290 | |
Anton Vorontsov | 692d103 | 2008-05-23 17:41:02 +0400 | [diff] [blame] | 291 | msi->feature = features->fsl_pic_ip; |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 292 | |
| 293 | msi->irqhost->host_data = msi; |
| 294 | |
| 295 | msi->msi_addr_hi = 0x0; |
Kumar Gala | 3da34aa | 2009-05-12 15:51:56 -0500 | [diff] [blame] | 296 | msi->msi_addr_lo = features->msiir_offset + (res.start & 0xfffff); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 297 | |
| 298 | rc = fsl_msi_init_allocator(msi); |
| 299 | if (rc) { |
| 300 | dev_err(&dev->dev, "Error allocating MSI bitmap\n"); |
| 301 | goto error_out; |
| 302 | } |
| 303 | |
| 304 | p = of_get_property(dev->node, "interrupts", &count); |
| 305 | if (!p) { |
| 306 | dev_err(&dev->dev, "no interrupts property found on %s\n", |
| 307 | dev->node->full_name); |
| 308 | err = -ENODEV; |
| 309 | goto error_out; |
| 310 | } |
| 311 | if (count % 8 != 0) { |
| 312 | dev_err(&dev->dev, "Malformed interrupts property on %s\n", |
| 313 | dev->node->full_name); |
| 314 | err = -EINVAL; |
| 315 | goto error_out; |
| 316 | } |
| 317 | |
| 318 | count /= sizeof(u32); |
| 319 | for (i = 0; i < count / 2; i++) { |
| 320 | if (i > NR_MSI_REG) |
| 321 | break; |
| 322 | virt_msir = irq_of_parse_and_map(dev->node, i); |
| 323 | if (virt_msir != NO_IRQ) { |
Li Yang | 02adac6 | 2010-04-22 16:31:35 +0800 | [diff] [blame^] | 324 | cascade_data = kzalloc( |
| 325 | sizeof(struct fsl_msi_cascade_data), |
| 326 | GFP_KERNEL); |
| 327 | if (!cascade_data) { |
| 328 | dev_err(&dev->dev, |
| 329 | "No memory for MSI cascade data\n"); |
| 330 | err = -ENOMEM; |
| 331 | goto error_out; |
| 332 | } |
| 333 | cascade_data->index = i; |
| 334 | cascade_data->msi_data = msi; |
| 335 | set_irq_data(virt_msir, (void *)cascade_data); |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 336 | set_irq_chained_handler(virt_msir, fsl_msi_cascade); |
| 337 | } |
| 338 | } |
| 339 | |
Lan Chunhe-B25806 | 8081881 | 2010-03-15 06:38:33 +0000 | [diff] [blame] | 340 | /* The multiple setting ppc_md.setup_msi_irqs will not harm things */ |
| 341 | if (!ppc_md.setup_msi_irqs) { |
| 342 | ppc_md.setup_msi_irqs = fsl_setup_msi_irqs; |
| 343 | ppc_md.teardown_msi_irqs = fsl_teardown_msi_irqs; |
| 344 | ppc_md.msi_check_device = fsl_msi_check_device; |
| 345 | } else if (ppc_md.setup_msi_irqs != fsl_setup_msi_irqs) { |
| 346 | dev_err(&dev->dev, "Different MSI driver already installed!\n"); |
| 347 | err = -ENODEV; |
| 348 | goto error_out; |
| 349 | } |
Jason Jin | 34e36c1 | 2008-05-23 16:32:46 +0800 | [diff] [blame] | 350 | return 0; |
| 351 | error_out: |
| 352 | kfree(msi); |
| 353 | return err; |
| 354 | } |
| 355 | |
| 356 | static const struct fsl_msi_feature mpic_msi_feature = { |
| 357 | .fsl_pic_ip = FSL_PIC_IP_MPIC, |
| 358 | .msiir_offset = 0x140, |
| 359 | }; |
| 360 | |
| 361 | static const struct fsl_msi_feature ipic_msi_feature = { |
| 362 | .fsl_pic_ip = FSL_PIC_IP_IPIC, |
| 363 | .msiir_offset = 0x38, |
| 364 | }; |
| 365 | |
| 366 | static const struct of_device_id fsl_of_msi_ids[] = { |
| 367 | { |
| 368 | .compatible = "fsl,mpic-msi", |
| 369 | .data = (void *)&mpic_msi_feature, |
| 370 | }, |
| 371 | { |
| 372 | .compatible = "fsl,ipic-msi", |
| 373 | .data = (void *)&ipic_msi_feature, |
| 374 | }, |
| 375 | {} |
| 376 | }; |
| 377 | |
| 378 | static struct of_platform_driver fsl_of_msi_driver = { |
| 379 | .name = "fsl-msi", |
| 380 | .match_table = fsl_of_msi_ids, |
| 381 | .probe = fsl_of_msi_probe, |
| 382 | }; |
| 383 | |
| 384 | static __init int fsl_of_msi_init(void) |
| 385 | { |
| 386 | return of_register_platform_driver(&fsl_of_msi_driver); |
| 387 | } |
| 388 | |
| 389 | subsys_initcall(fsl_of_msi_init); |