2 * NAND Flash Controller Device Driver
3 * Copyright © 2009-2010, Intel Corporation and its suppliers.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/pci.h>
20 #define DENALI_NAND_NAME "denali-nand-pci"
22 #define INTEL_CE4100 1
25 /* List of platforms this NAND controller has be integrated into */
26 static const struct pci_device_id denali_pci_ids
[] = {
27 { PCI_VDEVICE(INTEL
, 0x0701), INTEL_CE4100
},
28 { PCI_VDEVICE(INTEL
, 0x0809), INTEL_MRST
},
29 { /* end: all zeroes */ }
31 MODULE_DEVICE_TABLE(pci
, denali_pci_ids
);
33 NAND_ECC_CAPS_SINGLE(denali_pci_ecc_caps
, denali_calc_ecc_bytes
, 512, 8, 15);
35 static int denali_pci_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
38 resource_size_t csr_base
, mem_base
;
39 unsigned long csr_len
, mem_len
;
40 struct denali_nand_info
*denali
;
42 denali
= devm_kzalloc(&dev
->dev
, sizeof(*denali
), GFP_KERNEL
);
46 ret
= pcim_enable_device(dev
);
48 dev_err(&dev
->dev
, "Spectra: pci_enable_device failed.\n");
52 if (id
->driver_data
== INTEL_CE4100
) {
53 mem_base
= pci_resource_start(dev
, 0);
54 mem_len
= pci_resource_len(dev
, 1);
55 csr_base
= pci_resource_start(dev
, 1);
56 csr_len
= pci_resource_len(dev
, 1);
58 csr_base
= pci_resource_start(dev
, 0);
59 csr_len
= pci_resource_len(dev
, 0);
60 mem_base
= pci_resource_start(dev
, 1);
61 mem_len
= pci_resource_len(dev
, 1);
63 mem_base
= csr_base
+ csr_len
;
69 denali
->dev
= &dev
->dev
;
70 denali
->irq
= dev
->irq
;
71 denali
->ecc_caps
= &denali_pci_ecc_caps
;
72 denali
->nand
.ecc
.options
|= NAND_ECC_MAXIMIZE
;
73 denali
->clk_x_rate
= 200000000; /* 200 MHz */
75 ret
= pci_request_regions(dev
, DENALI_NAND_NAME
);
77 dev_err(&dev
->dev
, "Spectra: Unable to request memory regions\n");
81 denali
->reg
= ioremap_nocache(csr_base
, csr_len
);
83 dev_err(&dev
->dev
, "Spectra: Unable to remap memory region\n");
87 denali
->host
= ioremap_nocache(mem_base
, mem_len
);
89 dev_err(&dev
->dev
, "Spectra: ioremap_nocache failed!");
91 goto failed_remap_reg
;
94 ret
= denali_init(denali
);
96 goto failed_remap_mem
;
98 pci_set_drvdata(dev
, denali
);
103 iounmap(denali
->host
);
105 iounmap(denali
->reg
);
109 /* driver exit point */
110 static void denali_pci_remove(struct pci_dev
*dev
)
112 struct denali_nand_info
*denali
= pci_get_drvdata(dev
);
114 denali_remove(denali
);
115 iounmap(denali
->reg
);
116 iounmap(denali
->host
);
119 static struct pci_driver denali_pci_driver
= {
120 .name
= DENALI_NAND_NAME
,
121 .id_table
= denali_pci_ids
,
122 .probe
= denali_pci_probe
,
123 .remove
= denali_pci_remove
,
126 module_pci_driver(denali_pci_driver
);
128 MODULE_DESCRIPTION("PCI driver for Denali NAND controller");
129 MODULE_AUTHOR("Intel Corporation and its suppliers");
130 MODULE_LICENSE("GPL v2");