Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 1 | /* |
Alexander Kuleshov | 775c503 | 2014-12-28 12:44:45 +0600 | [diff] [blame] | 2 | * Freescale MPC85xx Memory Controller kernel module |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 3 | * |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 4 | * Parts Copyrighted (c) 2013 by Freescale Semiconductor, Inc. |
| 5 | * |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 6 | * Author: Dave Jiang <djiang@mvista.com> |
| 7 | * |
| 8 | * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under |
| 9 | * the terms of the GNU General Public License version 2. This program |
| 10 | * is licensed "as is" without any warranty of any kind, whether express |
| 11 | * or implied. |
| 12 | * |
| 13 | */ |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/ctype.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/mod_devicetable.h> |
| 20 | #include <linux/edac.h> |
Andrew Kilkenny | 60be755 | 2008-10-15 22:04:28 -0700 | [diff] [blame] | 21 | #include <linux/smp.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/gfp.h> |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 23 | #include <linux/fsl/edac.h> |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 24 | |
| 25 | #include <linux/of_platform.h> |
| 26 | #include <linux/of_device.h> |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 27 | #include "edac_module.h" |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 28 | #include "mpc85xx_edac.h" |
York Sun | ea2eb9a | 2016-08-11 13:15:18 -0700 | [diff] [blame] | 29 | #include "fsl_ddr_edac.h" |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 30 | |
| 31 | static int edac_dev_idx; |
Ira W. Snyder | 0616fb0 | 2009-10-26 16:50:10 -0700 | [diff] [blame] | 32 | #ifdef CONFIG_PCI |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 33 | static int edac_pci_idx; |
Ira W. Snyder | 0616fb0 | 2009-10-26 16:50:10 -0700 | [diff] [blame] | 34 | #endif |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * PCI Err defines |
| 38 | */ |
| 39 | #ifdef CONFIG_PCI |
| 40 | static u32 orig_pci_err_cap_dr; |
| 41 | static u32 orig_pci_err_en; |
| 42 | #endif |
| 43 | |
| 44 | static u32 orig_l2_err_disable; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 45 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 46 | /**************************** PCI Err device ***************************/ |
| 47 | #ifdef CONFIG_PCI |
| 48 | |
| 49 | static void mpc85xx_pci_check(struct edac_pci_ctl_info *pci) |
| 50 | { |
| 51 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; |
| 52 | u32 err_detect; |
| 53 | |
| 54 | err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR); |
| 55 | |
| 56 | /* master aborts can happen during PCI config cycles */ |
| 57 | if (!(err_detect & ~(PCI_EDE_MULTI_ERR | PCI_EDE_MST_ABRT))) { |
| 58 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect); |
| 59 | return; |
| 60 | } |
| 61 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 62 | pr_err("PCI error(s) detected\n"); |
| 63 | pr_err("PCI/X ERR_DR register: %#08x\n", err_detect); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 64 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 65 | pr_err("PCI/X ERR_ATTRIB register: %#08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 66 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ATTRIB)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 67 | pr_err("PCI/X ERR_ADDR register: %#08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 68 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 69 | pr_err("PCI/X ERR_EXT_ADDR register: %#08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 70 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EXT_ADDR)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 71 | pr_err("PCI/X ERR_DL register: %#08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 72 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DL)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 73 | pr_err("PCI/X ERR_DH register: %#08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 74 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DH)); |
| 75 | |
| 76 | /* clear error bits */ |
| 77 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect); |
| 78 | |
| 79 | if (err_detect & PCI_EDE_PERR_MASK) |
| 80 | edac_pci_handle_pe(pci, pci->ctl_name); |
| 81 | |
| 82 | if ((err_detect & ~PCI_EDE_MULTI_ERR) & ~PCI_EDE_PERR_MASK) |
| 83 | edac_pci_handle_npe(pci, pci->ctl_name); |
| 84 | } |
| 85 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 86 | static void mpc85xx_pcie_check(struct edac_pci_ctl_info *pci) |
| 87 | { |
| 88 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; |
Tillmann Heidsieck | 6fa06b0d | 2016-08-15 21:08:49 +0200 | [diff] [blame] | 89 | u32 err_detect, err_cap_stat; |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 90 | |
| 91 | err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR); |
Tillmann Heidsieck | 6fa06b0d | 2016-08-15 21:08:49 +0200 | [diff] [blame] | 92 | err_cap_stat = in_be32(pdata->pci_vbase + MPC85XX_PCI_GAS_TIMR); |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 93 | |
| 94 | pr_err("PCIe error(s) detected\n"); |
| 95 | pr_err("PCIe ERR_DR register: 0x%08x\n", err_detect); |
Tillmann Heidsieck | 6fa06b0d | 2016-08-15 21:08:49 +0200 | [diff] [blame] | 96 | pr_err("PCIe ERR_CAP_STAT register: 0x%08x\n", err_cap_stat); |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 97 | pr_err("PCIe ERR_CAP_R0 register: 0x%08x\n", |
| 98 | in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R0)); |
| 99 | pr_err("PCIe ERR_CAP_R1 register: 0x%08x\n", |
| 100 | in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R1)); |
| 101 | pr_err("PCIe ERR_CAP_R2 register: 0x%08x\n", |
| 102 | in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R2)); |
| 103 | pr_err("PCIe ERR_CAP_R3 register: 0x%08x\n", |
| 104 | in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R3)); |
| 105 | |
| 106 | /* clear error bits */ |
| 107 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect); |
Tillmann Heidsieck | 6fa06b0d | 2016-08-15 21:08:49 +0200 | [diff] [blame] | 108 | |
| 109 | /* reset error capture */ |
| 110 | out_be32(pdata->pci_vbase + MPC85XX_PCI_GAS_TIMR, err_cap_stat | 0x1); |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static int mpc85xx_pcie_find_capability(struct device_node *np) |
| 114 | { |
| 115 | struct pci_controller *hose; |
| 116 | |
| 117 | if (!np) |
| 118 | return -EINVAL; |
| 119 | |
| 120 | hose = pci_find_hose_for_OF_device(np); |
| 121 | |
| 122 | return early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP); |
| 123 | } |
| 124 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 125 | static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) |
| 126 | { |
| 127 | struct edac_pci_ctl_info *pci = dev_id; |
| 128 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; |
| 129 | u32 err_detect; |
| 130 | |
| 131 | err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR); |
| 132 | |
| 133 | if (!err_detect) |
| 134 | return IRQ_NONE; |
| 135 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 136 | if (pdata->is_pcie) |
| 137 | mpc85xx_pcie_check(pci); |
| 138 | else |
| 139 | mpc85xx_pci_check(pci); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 140 | |
| 141 | return IRQ_HANDLED; |
| 142 | } |
| 143 | |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 144 | static int mpc85xx_pci_err_probe(struct platform_device *op) |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 145 | { |
| 146 | struct edac_pci_ctl_info *pci; |
| 147 | struct mpc85xx_pci_pdata *pdata; |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 148 | struct mpc85xx_edac_pci_plat_data *plat_data; |
| 149 | struct device_node *of_node; |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 150 | struct resource r; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 151 | int res = 0; |
| 152 | |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 153 | if (!devres_open_group(&op->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 154 | return -ENOMEM; |
| 155 | |
| 156 | pci = edac_pci_alloc_ctl_info(sizeof(*pdata), "mpc85xx_pci_err"); |
| 157 | if (!pci) |
| 158 | return -ENOMEM; |
| 159 | |
Jia Hongtao | 905e75c | 2012-08-28 15:44:08 +0800 | [diff] [blame] | 160 | /* make sure error reporting method is sane */ |
| 161 | switch (edac_op_state) { |
| 162 | case EDAC_OPSTATE_POLL: |
| 163 | case EDAC_OPSTATE_INT: |
| 164 | break; |
| 165 | default: |
| 166 | edac_op_state = EDAC_OPSTATE_INT; |
| 167 | break; |
| 168 | } |
| 169 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 170 | pdata = pci->pvt_info; |
| 171 | pdata->name = "mpc85xx_pci_err"; |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 172 | |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 173 | plat_data = op->dev.platform_data; |
| 174 | if (!plat_data) { |
| 175 | dev_err(&op->dev, "no platform data"); |
| 176 | res = -ENXIO; |
| 177 | goto err; |
| 178 | } |
| 179 | of_node = plat_data->of_node; |
| 180 | |
| 181 | if (mpc85xx_pcie_find_capability(of_node) > 0) |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 182 | pdata->is_pcie = true; |
| 183 | |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 184 | dev_set_drvdata(&op->dev, pci); |
| 185 | pci->dev = &op->dev; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 186 | pci->mod_name = EDAC_MOD_STR; |
| 187 | pci->ctl_name = pdata->name; |
Kay Sievers | 031d551 | 2009-03-24 16:38:21 -0700 | [diff] [blame] | 188 | pci->dev_name = dev_name(&op->dev); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 189 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 190 | if (edac_op_state == EDAC_OPSTATE_POLL) { |
| 191 | if (pdata->is_pcie) |
| 192 | pci->edac_check = mpc85xx_pcie_check; |
| 193 | else |
| 194 | pci->edac_check = mpc85xx_pci_check; |
| 195 | } |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 196 | |
| 197 | pdata->edac_idx = edac_pci_idx++; |
| 198 | |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 199 | res = of_address_to_resource(of_node, 0, &r); |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 200 | if (res) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 201 | pr_err("%s: Unable to get resource for PCI err regs\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 202 | goto err; |
| 203 | } |
| 204 | |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 205 | /* we only need the error registers */ |
| 206 | r.start += 0xe00; |
| 207 | |
H Hartley Sweeten | 66ed3f7 | 2010-03-10 15:23:13 -0800 | [diff] [blame] | 208 | if (!devm_request_mem_region(&op->dev, r.start, resource_size(&r), |
| 209 | pdata->name)) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 210 | pr_err("%s: Error while requesting mem region\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 211 | res = -EBUSY; |
| 212 | goto err; |
| 213 | } |
| 214 | |
H Hartley Sweeten | 66ed3f7 | 2010-03-10 15:23:13 -0800 | [diff] [blame] | 215 | pdata->pci_vbase = devm_ioremap(&op->dev, r.start, resource_size(&r)); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 216 | if (!pdata->pci_vbase) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 217 | pr_err("%s: Unable to setup PCI err regs\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 218 | res = -ENOMEM; |
| 219 | goto err; |
| 220 | } |
| 221 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 222 | if (pdata->is_pcie) { |
| 223 | orig_pci_err_cap_dr = |
| 224 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR); |
| 225 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, ~0); |
| 226 | orig_pci_err_en = |
| 227 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN); |
| 228 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, 0); |
| 229 | } else { |
| 230 | orig_pci_err_cap_dr = |
| 231 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 232 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 233 | /* PCI master abort is expected during config cycles */ |
| 234 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR, 0x40); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 235 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 236 | orig_pci_err_en = |
| 237 | in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 238 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 239 | /* disable master abort reporting */ |
| 240 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, ~0x40); |
| 241 | } |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 242 | |
| 243 | /* clear error bits */ |
| 244 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, ~0); |
| 245 | |
Tillmann Heidsieck | 6fa06b0d | 2016-08-15 21:08:49 +0200 | [diff] [blame] | 246 | /* reset error capture */ |
| 247 | out_be32(pdata->pci_vbase + MPC85XX_PCI_GAS_TIMR, 0x1); |
| 248 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 249 | if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 250 | edac_dbg(3, "failed edac_pci_add_device()\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 251 | goto err; |
| 252 | } |
| 253 | |
| 254 | if (edac_op_state == EDAC_OPSTATE_INT) { |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 255 | pdata->irq = irq_of_parse_and_map(of_node, 0); |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 256 | res = devm_request_irq(&op->dev, pdata->irq, |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 257 | mpc85xx_pci_isr, |
Johannes Thumshirn | e245e3b | 2014-01-21 09:42:27 +0100 | [diff] [blame] | 258 | IRQF_SHARED, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 259 | "[EDAC] PCI err", pci); |
| 260 | if (res < 0) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 261 | pr_err("%s: Unable to request irq %d for MPC85xx PCI err\n", |
| 262 | __func__, pdata->irq); |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 263 | irq_dispose_mapping(pdata->irq); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 264 | res = -ENODEV; |
| 265 | goto err2; |
| 266 | } |
| 267 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 268 | pr_info(EDAC_MOD_STR " acquired irq %d for PCI Err\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 269 | pdata->irq); |
| 270 | } |
| 271 | |
Chunhe Lan | c92132f | 2013-11-25 11:28:41 +0100 | [diff] [blame] | 272 | if (pdata->is_pcie) { |
| 273 | /* |
| 274 | * Enable all PCIe error interrupt & error detect except invalid |
| 275 | * PEX_CONFIG_ADDR/PEX_CONFIG_DATA access interrupt generation |
| 276 | * enable bit and invalid PEX_CONFIG_ADDR/PEX_CONFIG_DATA access |
| 277 | * detection enable bit. Because PCIe bus code to initialize and |
| 278 | * configure these PCIe devices on booting will use some invalid |
| 279 | * PEX_CONFIG_ADDR/PEX_CONFIG_DATA, edac driver prints the much |
| 280 | * notice information. So disable this detect to fix ugly print. |
| 281 | */ |
| 282 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, ~0 |
| 283 | & ~PEX_ERR_ICCAIE_EN_BIT); |
| 284 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, 0 |
| 285 | | PEX_ERR_ICCAD_DISR_BIT); |
| 286 | } |
| 287 | |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 288 | devres_remove_group(&op->dev, mpc85xx_pci_err_probe); |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 289 | edac_dbg(3, "success\n"); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 290 | pr_info(EDAC_MOD_STR " PCI err registered\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 291 | |
| 292 | return 0; |
| 293 | |
| 294 | err2: |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 295 | edac_pci_del_device(&op->dev); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 296 | err: |
| 297 | edac_pci_free_ctl_info(pci); |
Dave Jiang | f87bd33 | 2008-07-25 01:49:14 -0700 | [diff] [blame] | 298 | devres_release_group(&op->dev, mpc85xx_pci_err_probe); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 299 | return res; |
| 300 | } |
| 301 | |
Yanjiang Jin | 27bda20 | 2016-11-17 10:56:20 +0800 | [diff] [blame] | 302 | static int mpc85xx_pci_err_remove(struct platform_device *op) |
| 303 | { |
| 304 | struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev); |
| 305 | struct mpc85xx_pci_pdata *pdata = pci->pvt_info; |
| 306 | |
| 307 | edac_dbg(0, "\n"); |
| 308 | |
| 309 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, orig_pci_err_cap_dr); |
| 310 | out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en); |
| 311 | |
| 312 | edac_pci_del_device(&op->dev); |
| 313 | edac_pci_free_ctl_info(pci); |
| 314 | |
| 315 | return 0; |
| 316 | } |
| 317 | |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 318 | static const struct platform_device_id mpc85xx_pci_err_match[] = { |
| 319 | { |
| 320 | .name = "mpc85xx-pci-edac" |
| 321 | }, |
| 322 | {} |
| 323 | }; |
| 324 | |
| 325 | static struct platform_driver mpc85xx_pci_err_driver = { |
| 326 | .probe = mpc85xx_pci_err_probe, |
Yanjiang Jin | 27bda20 | 2016-11-17 10:56:20 +0800 | [diff] [blame] | 327 | .remove = mpc85xx_pci_err_remove, |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 328 | .id_table = mpc85xx_pci_err_match, |
| 329 | .driver = { |
| 330 | .name = "mpc85xx_pci_err", |
| 331 | .suppress_bind_attrs = true, |
| 332 | }, |
| 333 | }; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 334 | #endif /* CONFIG_PCI */ |
| 335 | |
| 336 | /**************************** L2 Err device ***************************/ |
| 337 | |
| 338 | /************************ L2 SYSFS parts ***********************************/ |
| 339 | |
| 340 | static ssize_t mpc85xx_l2_inject_data_hi_show(struct edac_device_ctl_info |
| 341 | *edac_dev, char *data) |
| 342 | { |
| 343 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 344 | return sprintf(data, "0x%08x", |
| 345 | in_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJHI)); |
| 346 | } |
| 347 | |
| 348 | static ssize_t mpc85xx_l2_inject_data_lo_show(struct edac_device_ctl_info |
| 349 | *edac_dev, char *data) |
| 350 | { |
| 351 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 352 | return sprintf(data, "0x%08x", |
| 353 | in_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJLO)); |
| 354 | } |
| 355 | |
| 356 | static ssize_t mpc85xx_l2_inject_ctrl_show(struct edac_device_ctl_info |
| 357 | *edac_dev, char *data) |
| 358 | { |
| 359 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 360 | return sprintf(data, "0x%08x", |
| 361 | in_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJCTL)); |
| 362 | } |
| 363 | |
| 364 | static ssize_t mpc85xx_l2_inject_data_hi_store(struct edac_device_ctl_info |
| 365 | *edac_dev, const char *data, |
| 366 | size_t count) |
| 367 | { |
| 368 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 369 | if (isdigit(*data)) { |
| 370 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJHI, |
| 371 | simple_strtoul(data, NULL, 0)); |
| 372 | return count; |
| 373 | } |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | static ssize_t mpc85xx_l2_inject_data_lo_store(struct edac_device_ctl_info |
| 378 | *edac_dev, const char *data, |
| 379 | size_t count) |
| 380 | { |
| 381 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 382 | if (isdigit(*data)) { |
| 383 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJLO, |
| 384 | simple_strtoul(data, NULL, 0)); |
| 385 | return count; |
| 386 | } |
| 387 | return 0; |
| 388 | } |
| 389 | |
| 390 | static ssize_t mpc85xx_l2_inject_ctrl_store(struct edac_device_ctl_info |
| 391 | *edac_dev, const char *data, |
| 392 | size_t count) |
| 393 | { |
| 394 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 395 | if (isdigit(*data)) { |
| 396 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINJCTL, |
| 397 | simple_strtoul(data, NULL, 0)); |
| 398 | return count; |
| 399 | } |
| 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | static struct edac_dev_sysfs_attribute mpc85xx_l2_sysfs_attributes[] = { |
| 404 | { |
| 405 | .attr = { |
| 406 | .name = "inject_data_hi", |
| 407 | .mode = (S_IRUGO | S_IWUSR) |
| 408 | }, |
| 409 | .show = mpc85xx_l2_inject_data_hi_show, |
| 410 | .store = mpc85xx_l2_inject_data_hi_store}, |
| 411 | { |
| 412 | .attr = { |
| 413 | .name = "inject_data_lo", |
| 414 | .mode = (S_IRUGO | S_IWUSR) |
| 415 | }, |
| 416 | .show = mpc85xx_l2_inject_data_lo_show, |
| 417 | .store = mpc85xx_l2_inject_data_lo_store}, |
| 418 | { |
| 419 | .attr = { |
| 420 | .name = "inject_ctrl", |
| 421 | .mode = (S_IRUGO | S_IWUSR) |
| 422 | }, |
| 423 | .show = mpc85xx_l2_inject_ctrl_show, |
| 424 | .store = mpc85xx_l2_inject_ctrl_store}, |
| 425 | |
| 426 | /* End of list */ |
| 427 | { |
| 428 | .attr = {.name = NULL} |
| 429 | } |
| 430 | }; |
| 431 | |
| 432 | static void mpc85xx_set_l2_sysfs_attributes(struct edac_device_ctl_info |
| 433 | *edac_dev) |
| 434 | { |
| 435 | edac_dev->sysfs_attributes = mpc85xx_l2_sysfs_attributes; |
| 436 | } |
| 437 | |
| 438 | /***************************** L2 ops ***********************************/ |
| 439 | |
| 440 | static void mpc85xx_l2_check(struct edac_device_ctl_info *edac_dev) |
| 441 | { |
| 442 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 443 | u32 err_detect; |
| 444 | |
| 445 | err_detect = in_be32(pdata->l2_vbase + MPC85XX_L2_ERRDET); |
| 446 | |
| 447 | if (!(err_detect & L2_EDE_MASK)) |
| 448 | return; |
| 449 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 450 | pr_err("ECC Error in CPU L2 cache\n"); |
| 451 | pr_err("L2 Error Detect Register: 0x%08x\n", err_detect); |
| 452 | pr_err("L2 Error Capture Data High Register: 0x%08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 453 | in_be32(pdata->l2_vbase + MPC85XX_L2_CAPTDATAHI)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 454 | pr_err("L2 Error Capture Data Lo Register: 0x%08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 455 | in_be32(pdata->l2_vbase + MPC85XX_L2_CAPTDATALO)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 456 | pr_err("L2 Error Syndrome Register: 0x%08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 457 | in_be32(pdata->l2_vbase + MPC85XX_L2_CAPTECC)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 458 | pr_err("L2 Error Attributes Capture Register: 0x%08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 459 | in_be32(pdata->l2_vbase + MPC85XX_L2_ERRATTR)); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 460 | pr_err("L2 Error Address Capture Register: 0x%08x\n", |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 461 | in_be32(pdata->l2_vbase + MPC85XX_L2_ERRADDR)); |
| 462 | |
| 463 | /* clear error detect register */ |
| 464 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDET, err_detect); |
| 465 | |
| 466 | if (err_detect & L2_EDE_CE_MASK) |
| 467 | edac_device_handle_ce(edac_dev, 0, 0, edac_dev->ctl_name); |
| 468 | |
| 469 | if (err_detect & L2_EDE_UE_MASK) |
| 470 | edac_device_handle_ue(edac_dev, 0, 0, edac_dev->ctl_name); |
| 471 | } |
| 472 | |
| 473 | static irqreturn_t mpc85xx_l2_isr(int irq, void *dev_id) |
| 474 | { |
| 475 | struct edac_device_ctl_info *edac_dev = dev_id; |
| 476 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 477 | u32 err_detect; |
| 478 | |
| 479 | err_detect = in_be32(pdata->l2_vbase + MPC85XX_L2_ERRDET); |
| 480 | |
| 481 | if (!(err_detect & L2_EDE_MASK)) |
| 482 | return IRQ_NONE; |
| 483 | |
| 484 | mpc85xx_l2_check(edac_dev); |
| 485 | |
| 486 | return IRQ_HANDLED; |
| 487 | } |
| 488 | |
Greg Kroah-Hartman | 9b3c6e8 | 2012-12-21 13:23:51 -0800 | [diff] [blame] | 489 | static int mpc85xx_l2_err_probe(struct platform_device *op) |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 490 | { |
| 491 | struct edac_device_ctl_info *edac_dev; |
| 492 | struct mpc85xx_l2_pdata *pdata; |
| 493 | struct resource r; |
| 494 | int res; |
| 495 | |
| 496 | if (!devres_open_group(&op->dev, mpc85xx_l2_err_probe, GFP_KERNEL)) |
| 497 | return -ENOMEM; |
| 498 | |
| 499 | edac_dev = edac_device_alloc_ctl_info(sizeof(*pdata), |
| 500 | "cpu", 1, "L", 1, 2, NULL, 0, |
| 501 | edac_dev_idx); |
| 502 | if (!edac_dev) { |
| 503 | devres_release_group(&op->dev, mpc85xx_l2_err_probe); |
| 504 | return -ENOMEM; |
| 505 | } |
| 506 | |
| 507 | pdata = edac_dev->pvt_info; |
| 508 | pdata->name = "mpc85xx_l2_err"; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 509 | edac_dev->dev = &op->dev; |
| 510 | dev_set_drvdata(edac_dev->dev, edac_dev); |
| 511 | edac_dev->ctl_name = pdata->name; |
| 512 | edac_dev->dev_name = pdata->name; |
| 513 | |
Anatolij Gustschin | a26f95f | 2010-06-03 03:17:42 +0200 | [diff] [blame] | 514 | res = of_address_to_resource(op->dev.of_node, 0, &r); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 515 | if (res) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 516 | pr_err("%s: Unable to get resource for L2 err regs\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 517 | goto err; |
| 518 | } |
| 519 | |
| 520 | /* we only need the error registers */ |
| 521 | r.start += 0xe00; |
| 522 | |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 523 | if (!devm_request_mem_region(&op->dev, r.start, resource_size(&r), |
| 524 | pdata->name)) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 525 | pr_err("%s: Error while requesting mem region\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 526 | res = -EBUSY; |
| 527 | goto err; |
| 528 | } |
| 529 | |
Joe Perches | 28f65c11 | 2011-06-09 09:13:32 -0700 | [diff] [blame] | 530 | pdata->l2_vbase = devm_ioremap(&op->dev, r.start, resource_size(&r)); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 531 | if (!pdata->l2_vbase) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 532 | pr_err("%s: Unable to setup L2 err regs\n", __func__); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 533 | res = -ENOMEM; |
| 534 | goto err; |
| 535 | } |
| 536 | |
| 537 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDET, ~0); |
| 538 | |
| 539 | orig_l2_err_disable = in_be32(pdata->l2_vbase + MPC85XX_L2_ERRDIS); |
| 540 | |
| 541 | /* clear the err_dis */ |
| 542 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDIS, 0); |
| 543 | |
| 544 | edac_dev->mod_name = EDAC_MOD_STR; |
| 545 | |
| 546 | if (edac_op_state == EDAC_OPSTATE_POLL) |
| 547 | edac_dev->edac_check = mpc85xx_l2_check; |
| 548 | |
| 549 | mpc85xx_set_l2_sysfs_attributes(edac_dev); |
| 550 | |
| 551 | pdata->edac_idx = edac_dev_idx++; |
| 552 | |
| 553 | if (edac_device_add_device(edac_dev) > 0) { |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 554 | edac_dbg(3, "failed edac_device_add_device()\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 555 | goto err; |
| 556 | } |
| 557 | |
| 558 | if (edac_op_state == EDAC_OPSTATE_INT) { |
Anatolij Gustschin | a26f95f | 2010-06-03 03:17:42 +0200 | [diff] [blame] | 559 | pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 560 | res = devm_request_irq(&op->dev, pdata->irq, |
Borislav Petkov | a18c3f1 | 2014-09-30 12:55:41 +0200 | [diff] [blame] | 561 | mpc85xx_l2_isr, IRQF_SHARED, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 562 | "[EDAC] L2 err", edac_dev); |
| 563 | if (res < 0) { |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 564 | pr_err("%s: Unable to request irq %d for MPC85xx L2 err\n", |
| 565 | __func__, pdata->irq); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 566 | irq_dispose_mapping(pdata->irq); |
| 567 | res = -ENODEV; |
| 568 | goto err2; |
| 569 | } |
| 570 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 571 | pr_info(EDAC_MOD_STR " acquired irq %d for L2 Err\n", pdata->irq); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 572 | |
| 573 | edac_dev->op_state = OP_RUNNING_INTERRUPT; |
| 574 | |
| 575 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, L2_EIE_MASK); |
| 576 | } |
| 577 | |
| 578 | devres_remove_group(&op->dev, mpc85xx_l2_err_probe); |
| 579 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 580 | edac_dbg(3, "success\n"); |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 581 | pr_info(EDAC_MOD_STR " L2 err registered\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 582 | |
| 583 | return 0; |
| 584 | |
| 585 | err2: |
| 586 | edac_device_del_device(&op->dev); |
| 587 | err: |
| 588 | devres_release_group(&op->dev, mpc85xx_l2_err_probe); |
| 589 | edac_device_free_ctl_info(edac_dev); |
| 590 | return res; |
| 591 | } |
| 592 | |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 593 | static int mpc85xx_l2_err_remove(struct platform_device *op) |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 594 | { |
| 595 | struct edac_device_ctl_info *edac_dev = dev_get_drvdata(&op->dev); |
| 596 | struct mpc85xx_l2_pdata *pdata = edac_dev->pvt_info; |
| 597 | |
Joe Perches | 956b9ba | 2012-04-29 17:08:39 -0300 | [diff] [blame] | 598 | edac_dbg(0, "\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 599 | |
| 600 | if (edac_op_state == EDAC_OPSTATE_INT) { |
| 601 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRINTEN, 0); |
| 602 | irq_dispose_mapping(pdata->irq); |
| 603 | } |
| 604 | |
| 605 | out_be32(pdata->l2_vbase + MPC85XX_L2_ERRDIS, orig_l2_err_disable); |
| 606 | edac_device_del_device(&op->dev); |
| 607 | edac_device_free_ctl_info(edac_dev); |
| 608 | return 0; |
| 609 | } |
| 610 | |
Fabian Frederick | 1afaa05 | 2015-03-16 20:54:41 +0100 | [diff] [blame] | 611 | static const struct of_device_id mpc85xx_l2_err_of_match[] = { |
Kumar Gala | 29d6cf2 | 2009-01-06 14:42:59 -0800 | [diff] [blame] | 612 | /* deprecate the fsl,85.. forms in the future, 2.6.30? */ |
| 613 | { .compatible = "fsl,8540-l2-cache-controller", }, |
| 614 | { .compatible = "fsl,8541-l2-cache-controller", }, |
| 615 | { .compatible = "fsl,8544-l2-cache-controller", }, |
| 616 | { .compatible = "fsl,8548-l2-cache-controller", }, |
| 617 | { .compatible = "fsl,8555-l2-cache-controller", }, |
| 618 | { .compatible = "fsl,8568-l2-cache-controller", }, |
| 619 | { .compatible = "fsl,mpc8536-l2-cache-controller", }, |
| 620 | { .compatible = "fsl,mpc8540-l2-cache-controller", }, |
| 621 | { .compatible = "fsl,mpc8541-l2-cache-controller", }, |
| 622 | { .compatible = "fsl,mpc8544-l2-cache-controller", }, |
| 623 | { .compatible = "fsl,mpc8548-l2-cache-controller", }, |
| 624 | { .compatible = "fsl,mpc8555-l2-cache-controller", }, |
| 625 | { .compatible = "fsl,mpc8560-l2-cache-controller", }, |
| 626 | { .compatible = "fsl,mpc8568-l2-cache-controller", }, |
Anton Vorontsov | cd1542c | 2010-08-10 18:03:21 -0700 | [diff] [blame] | 627 | { .compatible = "fsl,mpc8569-l2-cache-controller", }, |
Kumar Gala | 29d6cf2 | 2009-01-06 14:42:59 -0800 | [diff] [blame] | 628 | { .compatible = "fsl,mpc8572-l2-cache-controller", }, |
Anton Vorontsov | cd1542c | 2010-08-10 18:03:21 -0700 | [diff] [blame] | 629 | { .compatible = "fsl,p1020-l2-cache-controller", }, |
| 630 | { .compatible = "fsl,p1021-l2-cache-controller", }, |
Yang Shi | a014554 | 2009-09-23 15:57:24 -0700 | [diff] [blame] | 631 | { .compatible = "fsl,p2020-l2-cache-controller", }, |
Chris Packham | 321d17c | 2017-02-02 12:16:24 +1300 | [diff] [blame] | 632 | { .compatible = "fsl,t2080-l2-cache-controller", }, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 633 | {}, |
| 634 | }; |
Anton Vorontsov | 952e1c6 | 2010-07-27 13:18:05 -0700 | [diff] [blame] | 635 | MODULE_DEVICE_TABLE(of, mpc85xx_l2_err_of_match); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 636 | |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 637 | static struct platform_driver mpc85xx_l2_err_driver = { |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 638 | .probe = mpc85xx_l2_err_probe, |
| 639 | .remove = mpc85xx_l2_err_remove, |
| 640 | .driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 641 | .name = "mpc85xx_l2_err", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 642 | .of_match_table = mpc85xx_l2_err_of_match, |
| 643 | }, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 644 | }; |
| 645 | |
Fabian Frederick | 1afaa05 | 2015-03-16 20:54:41 +0100 | [diff] [blame] | 646 | static const struct of_device_id mpc85xx_mc_err_of_match[] = { |
Kumar Gala | 29d6cf2 | 2009-01-06 14:42:59 -0800 | [diff] [blame] | 647 | /* deprecate the fsl,85.. forms in the future, 2.6.30? */ |
| 648 | { .compatible = "fsl,8540-memory-controller", }, |
| 649 | { .compatible = "fsl,8541-memory-controller", }, |
| 650 | { .compatible = "fsl,8544-memory-controller", }, |
| 651 | { .compatible = "fsl,8548-memory-controller", }, |
| 652 | { .compatible = "fsl,8555-memory-controller", }, |
| 653 | { .compatible = "fsl,8568-memory-controller", }, |
| 654 | { .compatible = "fsl,mpc8536-memory-controller", }, |
| 655 | { .compatible = "fsl,mpc8540-memory-controller", }, |
| 656 | { .compatible = "fsl,mpc8541-memory-controller", }, |
| 657 | { .compatible = "fsl,mpc8544-memory-controller", }, |
| 658 | { .compatible = "fsl,mpc8548-memory-controller", }, |
| 659 | { .compatible = "fsl,mpc8555-memory-controller", }, |
| 660 | { .compatible = "fsl,mpc8560-memory-controller", }, |
| 661 | { .compatible = "fsl,mpc8568-memory-controller", }, |
Anton Vorontsov | 5528e22 | 2010-07-20 13:24:28 -0700 | [diff] [blame] | 662 | { .compatible = "fsl,mpc8569-memory-controller", }, |
Kumar Gala | 29d6cf2 | 2009-01-06 14:42:59 -0800 | [diff] [blame] | 663 | { .compatible = "fsl,mpc8572-memory-controller", }, |
Ira W. Snyder | b484625 | 2009-09-23 15:57:25 -0700 | [diff] [blame] | 664 | { .compatible = "fsl,mpc8349-memory-controller", }, |
Anton Vorontsov | cd1542c | 2010-08-10 18:03:21 -0700 | [diff] [blame] | 665 | { .compatible = "fsl,p1020-memory-controller", }, |
| 666 | { .compatible = "fsl,p1021-memory-controller", }, |
Yang Shi | a014554 | 2009-09-23 15:57:24 -0700 | [diff] [blame] | 667 | { .compatible = "fsl,p2020-memory-controller", }, |
Shaohui Xie | 86f9a43 | 2011-11-15 14:52:22 -0800 | [diff] [blame] | 668 | { .compatible = "fsl,qoriq-memory-controller", }, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 669 | {}, |
| 670 | }; |
Anton Vorontsov | 952e1c6 | 2010-07-27 13:18:05 -0700 | [diff] [blame] | 671 | MODULE_DEVICE_TABLE(of, mpc85xx_mc_err_of_match); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 672 | |
Grant Likely | 0000612 | 2011-02-22 19:59:54 -0700 | [diff] [blame] | 673 | static struct platform_driver mpc85xx_mc_err_driver = { |
York Sun | d43a9fb | 2016-08-09 14:55:41 -0700 | [diff] [blame] | 674 | .probe = fsl_mc_err_probe, |
| 675 | .remove = fsl_mc_err_remove, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 676 | .driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 677 | .name = "mpc85xx_mc_err", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 678 | .of_match_table = mpc85xx_mc_err_of_match, |
| 679 | }, |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 680 | }; |
| 681 | |
Thierry Reding | d54051f | 2015-12-03 10:57:12 +0100 | [diff] [blame] | 682 | static struct platform_driver * const drivers[] = { |
| 683 | &mpc85xx_mc_err_driver, |
| 684 | &mpc85xx_l2_err_driver, |
Scott Wood | 666db56 | 2015-12-10 13:07:12 -0600 | [diff] [blame] | 685 | #ifdef CONFIG_PCI |
| 686 | &mpc85xx_pci_err_driver, |
| 687 | #endif |
Thierry Reding | d54051f | 2015-12-03 10:57:12 +0100 | [diff] [blame] | 688 | }; |
| 689 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 690 | static int __init mpc85xx_mc_init(void) |
| 691 | { |
| 692 | int res = 0; |
Sudip Mukherjee | f2b59ac | 2016-02-02 21:09:33 +0530 | [diff] [blame] | 693 | u32 __maybe_unused pvr = 0; |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 694 | |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 695 | pr_info("Freescale(R) MPC85xx EDAC driver, (C) 2006 Montavista Software\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 696 | |
| 697 | /* make sure error reporting method is sane */ |
| 698 | switch (edac_op_state) { |
| 699 | case EDAC_OPSTATE_POLL: |
| 700 | case EDAC_OPSTATE_INT: |
| 701 | break; |
| 702 | default: |
| 703 | edac_op_state = EDAC_OPSTATE_INT; |
| 704 | break; |
| 705 | } |
| 706 | |
Thierry Reding | d54051f | 2015-12-03 10:57:12 +0100 | [diff] [blame] | 707 | res = platform_register_drivers(drivers, ARRAY_SIZE(drivers)); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 708 | if (res) |
York Sun | 88857eb | 2016-08-09 14:55:39 -0700 | [diff] [blame] | 709 | pr_warn(EDAC_MOD_STR "drivers fail to register\n"); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 710 | |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | module_init(mpc85xx_mc_init); |
| 715 | |
| 716 | static void __exit mpc85xx_mc_exit(void) |
| 717 | { |
Thierry Reding | d54051f | 2015-12-03 10:57:12 +0100 | [diff] [blame] | 718 | platform_unregister_drivers(drivers, ARRAY_SIZE(drivers)); |
Dave Jiang | a9a753d | 2008-02-07 00:14:55 -0800 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | module_exit(mpc85xx_mc_exit); |
| 722 | |
| 723 | MODULE_LICENSE("GPL"); |
| 724 | MODULE_AUTHOR("Montavista Software, Inc."); |
| 725 | module_param(edac_op_state, int, 0444); |
| 726 | MODULE_PARM_DESC(edac_op_state, |
| 727 | "EDAC Error Reporting state: 0=Poll, 2=Interrupt"); |