1 // SPDX-License-Identifier: GPL-2.0
5 * flash chip on alpha ds10...
8 #include <asm/core_tsunami.h>
9 #include <linux/init.h>
10 #include <linux/mtd/map.h>
11 #include <linux/mtd/mtd.h>
13 #define FLASH_ENABLE_PORT 0x00C00001
14 #define FLASH_ENABLE_BYTE 0x01
15 #define FLASH_DISABLE_BYTE 0x00
17 #define MAX_TIG_FLASH_SIZE (12*1024*1024)
18 static inline map_word
tsunami_flash_read8(struct map_info
*map
, unsigned long offset
)
21 val
.x
[0] = tsunami_tig_readb(offset
);
25 static void tsunami_flash_write8(struct map_info
*map
, map_word value
, unsigned long offset
)
27 tsunami_tig_writeb(value
.x
[0], offset
);
30 static void tsunami_flash_copy_from(
31 struct map_info
*map
, void *addr
, unsigned long offset
, ssize_t len
)
35 while(len
&& (offset
< MAX_TIG_FLASH_SIZE
)) {
36 *dest
= tsunami_tig_readb(offset
);
43 static void tsunami_flash_copy_to(
44 struct map_info
*map
, unsigned long offset
,
45 const void *addr
, ssize_t len
)
47 const unsigned char *src
;
49 while(len
&& (offset
< MAX_TIG_FLASH_SIZE
)) {
50 tsunami_tig_writeb(*src
, offset
);
58 * Deliberately don't provide operations wider than 8 bits. I don't
59 * have then and it scares me to think how you could mess up if
60 * you tried to use them. Buswidth is correctly so I'm safe.
62 static struct map_info tsunami_flash_map
= {
63 .name
= "flash chip on the Tsunami TIG bus",
64 .size
= MAX_TIG_FLASH_SIZE
,
67 .read
= tsunami_flash_read8
,
68 .copy_from
= tsunami_flash_copy_from
,
69 .write
= tsunami_flash_write8
,
70 .copy_to
= tsunami_flash_copy_to
,
73 static struct mtd_info
*tsunami_flash_mtd
;
75 static void __exit
cleanup_tsunami_flash(void)
78 mtd
= tsunami_flash_mtd
;
80 mtd_device_unregister(mtd
);
83 tsunami_flash_mtd
= 0;
86 static const char * const rom_probe_types
[] = {
87 "cfi_probe", "jedec_probe", "map_rom", NULL
};
89 static int __init
init_tsunami_flash(void)
91 const char * const *type
;
93 tsunami_tig_writeb(FLASH_ENABLE_BYTE
, FLASH_ENABLE_PORT
);
95 tsunami_flash_mtd
= 0;
96 type
= rom_probe_types
;
97 for(; !tsunami_flash_mtd
&& *type
; type
++) {
98 tsunami_flash_mtd
= do_map_probe(*type
, &tsunami_flash_map
);
100 if (tsunami_flash_mtd
) {
101 tsunami_flash_mtd
->owner
= THIS_MODULE
;
102 mtd_device_register(tsunami_flash_mtd
, NULL
, 0);
108 module_init(init_tsunami_flash
);
109 module_exit(cleanup_tsunami_flash
);