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
15 #include <linux/errno.h>
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/pci.h>
23 #define DENALI_NAND_NAME "denali-nand-pci"
25 #define INTEL_CE4100 1
28 /* List of platforms this NAND controller has be integrated into */
29 static const struct pci_device_id denali_pci_ids
[] = {
30 { PCI_VDEVICE(INTEL
, 0x0701), INTEL_CE4100
},
31 { PCI_VDEVICE(INTEL
, 0x0809), INTEL_MRST
},
32 { /* end: all zeroes */ }
34 MODULE_DEVICE_TABLE(pci
, denali_pci_ids
);
36 NAND_ECC_CAPS_SINGLE(denali_pci_ecc_caps
, denali_calc_ecc_bytes
, 512, 8, 15);
38 static int denali_pci_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
41 resource_size_t csr_base
, mem_base
;
42 unsigned long csr_len
, mem_len
;
43 struct denali_nand_info
*denali
;
45 denali
= devm_kzalloc(&dev
->dev
, sizeof(*denali
), GFP_KERNEL
);
49 ret
= pcim_enable_device(dev
);
51 dev_err(&dev
->dev
, "Spectra: pci_enable_device failed.\n");
55 if (id
->driver_data
== INTEL_CE4100
) {
56 mem_base
= pci_resource_start(dev
, 0);
57 mem_len
= pci_resource_len(dev
, 1);
58 csr_base
= pci_resource_start(dev
, 1);
59 csr_len
= pci_resource_len(dev
, 1);
61 csr_base
= pci_resource_start(dev
, 0);
62 csr_len
= pci_resource_len(dev
, 0);
63 mem_base
= pci_resource_start(dev
, 1);
64 mem_len
= pci_resource_len(dev
, 1);
66 mem_base
= csr_base
+ csr_len
;
72 denali
->dev
= &dev
->dev
;
73 denali
->irq
= dev
->irq
;
74 denali
->ecc_caps
= &denali_pci_ecc_caps
;
75 denali
->nand
.ecc
.options
|= NAND_ECC_MAXIMIZE
;
76 denali
->clk_rate
= 50000000; /* 50 MHz */
77 denali
->clk_x_rate
= 200000000; /* 200 MHz */
79 ret
= pci_request_regions(dev
, DENALI_NAND_NAME
);
81 dev_err(&dev
->dev
, "Spectra: Unable to request memory regions\n");
85 denali
->reg
= ioremap_nocache(csr_base
, csr_len
);
87 dev_err(&dev
->dev
, "Spectra: Unable to remap memory region\n");
91 denali
->host
= ioremap_nocache(mem_base
, mem_len
);
93 dev_err(&dev
->dev
, "Spectra: ioremap_nocache failed!");
95 goto failed_remap_reg
;
98 ret
= denali_init(denali
);
100 goto failed_remap_mem
;
102 pci_set_drvdata(dev
, denali
);
107 iounmap(denali
->host
);
109 iounmap(denali
->reg
);
113 static void denali_pci_remove(struct pci_dev
*dev
)
115 struct denali_nand_info
*denali
= pci_get_drvdata(dev
);
117 denali_remove(denali
);
118 iounmap(denali
->reg
);
119 iounmap(denali
->host
);
122 static struct pci_driver denali_pci_driver
= {
123 .name
= DENALI_NAND_NAME
,
124 .id_table
= denali_pci_ids
,
125 .probe
= denali_pci_probe
,
126 .remove
= denali_pci_remove
,
128 module_pci_driver(denali_pci_driver
);
130 MODULE_DESCRIPTION("PCI driver for Denali NAND controller");
131 MODULE_AUTHOR("Intel Corporation and its suppliers");
132 MODULE_LICENSE("GPL v2");