2 * Copyright (C) 2009 Gabor Juhos <juhosg@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
9 #include <linux/init.h>
10 #include <linux/spi/spi.h>
11 #include <linux/spi/flash.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/concat.h>
17 #include "dev-m25p80.h"
19 static struct spi_board_info ar71xx_spi_info
[] = {
23 .max_speed_hz
= 25000000,
29 .max_speed_hz
= 25000000,
34 void __init
ar71xx_add_device_m25p80(struct flash_platform_data
*pdata
)
36 ar71xx_spi_info
[0].platform_data
= pdata
;
37 ar71xx_add_device_spi(NULL
, ar71xx_spi_info
, 1);
40 static struct flash_platform_data
*multi_pdata
;
42 static struct mtd_info
*concat_devs
[2] = { NULL
, NULL
};
43 static struct work_struct mtd_concat_work
;
45 static void mtd_concat_add_work(struct work_struct
*work
)
49 mtd
= mtd_concat_create(concat_devs
, ARRAY_SIZE(concat_devs
), "flash");
51 #ifdef CONFIG_MTD_PARTITIONS
52 add_mtd_partitions(mtd
, multi_pdata
->parts
, multi_pdata
->nr_parts
);
58 static void mtd_concat_add(struct mtd_info
*mtd
)
60 static bool registered
= false;
65 if (!strcmp(mtd
->name
, "spi0.0"))
67 else if (!strcmp(mtd
->name
, "spi0.1"))
72 if (!concat_devs
[0] || !concat_devs
[1])
76 INIT_WORK(&mtd_concat_work
, mtd_concat_add_work
);
77 schedule_work(&mtd_concat_work
);
80 static void mtd_concat_remove(struct mtd_info
*mtd
)
84 static void add_mtd_concat_notifier(void)
86 static struct mtd_notifier
not = {
87 .add
= mtd_concat_add
,
88 .remove
= mtd_concat_remove
,
91 register_mtd_user(¬);
95 void __init
ar71xx_add_device_m25p80_multi(struct flash_platform_data
*pdata
)
98 add_mtd_concat_notifier();
99 ar71xx_add_device_spi(NULL
, ar71xx_spi_info
, ARRAY_SIZE(ar71xx_spi_info
));