19
19
#include <linux/mtd/cfi.h>
20
20
#include <linux/platform_device.h>
21
21
#include <linux/mtd/physmap.h>
23
24
#include <lantiq_soc.h>
24
#include <lantiq_platform.h>
27
27
* The NOR flash is connected to the same external bus unit (EBU) as PCI.
44
44
struct map_info *map;
47
static char ltq_map_name[] = "ltq_nor";
48
static const char *ltq_probe_types[] __devinitconst = { "cmdlinepart", NULL };
47
static const char ltq_map_name[] = "ltq_nor";
48
static const char *ltq_probe_types[] __devinitconst = {
49
"cmdlinepart", "ofpart", NULL };
51
52
ltq_read16(struct map_info *map, unsigned long adr)
108
109
spin_unlock_irqrestore(&ebu_lock, flags);
112
113
ltq_mtd_probe(struct platform_device *pdev)
114
struct physmap_flash_data *ltq_mtd_data = dev_get_platdata(&pdev->dev);
115
struct mtd_part_parser_data ppdata;
115
116
struct ltq_mtd *ltq_mtd;
116
struct resource *res;
117
117
struct cfi_private *cfi;
120
if (of_machine_is_compatible("lantiq,falcon") &&
121
(ltq_boot_select() != BS_FLASH)) {
122
dev_err(&pdev->dev, "invalid bootstrap options\n");
120
126
ltq_mtd = kzalloc(sizeof(struct ltq_mtd), GFP_KERNEL);
121
127
platform_set_drvdata(pdev, ltq_mtd);
123
129
ltq_mtd->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
124
130
if (!ltq_mtd->res) {
125
dev_err(&pdev->dev, "failed to get memory resource");
131
dev_err(&pdev->dev, "failed to get memory resource\n");
130
res = devm_request_mem_region(&pdev->dev, ltq_mtd->res->start,
131
resource_size(ltq_mtd->res), dev_name(&pdev->dev));
133
dev_err(&pdev->dev, "failed to request mem resource");
138
136
ltq_mtd->map = kzalloc(sizeof(struct map_info), GFP_KERNEL);
139
ltq_mtd->map->phys = res->start;
140
ltq_mtd->map->size = resource_size(res);
141
ltq_mtd->map->virt = devm_ioremap_nocache(&pdev->dev,
142
ltq_mtd->map->phys, ltq_mtd->map->size);
137
ltq_mtd->map->phys = ltq_mtd->res->start;
138
ltq_mtd->map->size = resource_size(ltq_mtd->res);
139
ltq_mtd->map->virt = devm_request_and_ioremap(&pdev->dev, ltq_mtd->res);
143
140
if (!ltq_mtd->map->virt) {
144
dev_err(&pdev->dev, "failed to ioremap!\n");
141
dev_err(&pdev->dev, "failed to remap mem resource\n");
149
146
ltq_mtd->map->name = ltq_map_name;
169
166
cfi->addr_unlock1 ^= 1;
170
167
cfi->addr_unlock2 ^= 1;
172
err = mtd_device_parse_register(ltq_mtd->mtd, ltq_probe_types, NULL,
174
ltq_mtd_data->nr_parts);
169
ppdata.of_node = pdev->dev.of_node;
170
err = mtd_device_parse_register(ltq_mtd->mtd, ltq_probe_types,
176
173
dev_err(&pdev->dev, "failed to add partitions\n");
177
174
goto err_destroy;
204
static const struct of_device_id ltq_mtd_match[] = {
205
{ .compatible = "lantiq,nor" },
208
MODULE_DEVICE_TABLE(of, ltq_mtd_match);
207
210
static struct platform_driver ltq_mtd_driver = {
211
.probe = ltq_mtd_probe,
208
212
.remove = __devexit_p(ltq_mtd_remove),
211
215
.owner = THIS_MODULE,
216
.of_match_table = ltq_mtd_match,
218
int ret = platform_driver_probe(<q_mtd_driver, ltq_mtd_probe);
221
pr_err("ltq_nor: error registering platform driver");
228
platform_driver_unregister(<q_mtd_driver);
231
module_init(init_ltq_mtd);
232
module_exit(exit_ltq_mtd);
220
module_platform_driver(ltq_mtd_driver);
234
222
MODULE_LICENSE("GPL");
235
223
MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");