Commit c68c03f52badc90951dbf8a054c0e500e04bf365
Committed by
Tom Rini
1 parent
95688de311
Exists in
smarc_8mq_lf_v2020.04
and in
20 other branches
Drop CONFIG_HAS_DATAFLASH
Last user of this option went away in commit: fdc7718999 ("board: usb_a9263: Update to support DT and DM") Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Showing 31 changed files with 16 additions and 1626 deletions Side-by-side Diff
- README
- arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
- arch/arm/mach-at91/arm926ejs/at91sam9261_devices.c
- arch/arm/mach-at91/arm926ejs/at91sam9263_devices.c
- arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
- arch/arm/mach-at91/arm926ejs/at91sam9rl_devices.c
- board/atmel/at91sam9260ek/Makefile
- board/atmel/at91sam9260ek/partition.c
- board/atmel/at91sam9261ek/Makefile
- board/atmel/at91sam9261ek/partition.c
- board/atmel/at91sam9263ek/Makefile
- board/atmel/at91sam9263ek/partition.c
- board/atmel/at91sam9rlek/Makefile
- board/atmel/at91sam9rlek/partition.c
- board/esd/meesc/Makefile
- board/esd/meesc/partition.c
- board/mini-box/picosam9g45/picosam9g45.c
- board/ronetix/pm9261/Makefile
- board/ronetix/pm9261/partition.c
- board/ronetix/pm9263/Makefile
- board/ronetix/pm9263/partition.c
- board/siemens/corvus/board.c
- cmd/flash.c
- cmd/mem.c
- common/board_r.c
- common/image.c
- drivers/mtd/Makefile
- drivers/mtd/at45.c
- drivers/mtd/dataflash.c
- include/dataflash.h
- scripts/config_whitelist.txt
README
| ... | ... | @@ -2312,13 +2312,6 @@ |
| 2312 | 2312 | this is instead controlled by the value of |
| 2313 | 2313 | /config/load-environment. |
| 2314 | 2314 | |
| 2315 | -- DataFlash Support: | |
| 2316 | - CONFIG_HAS_DATAFLASH | |
| 2317 | - | |
| 2318 | - Defining this option enables DataFlash features and | |
| 2319 | - allows to read/write in Dataflash via the standard | |
| 2320 | - commands cp, md... | |
| 2321 | - | |
| 2322 | 2315 | - Serial Flash support |
| 2323 | 2316 | Usage requires an initial 'sf probe' to define the serial |
| 2324 | 2317 | flash parameters, followed by read/write/erase/update |
arch/arm/mach-at91/arm926ejs/at91sam9260_devices.c
| ... | ... | @@ -58,7 +58,7 @@ |
| 58 | 58 | at91_periph_clk_enable(ATMEL_ID_SYS); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | -#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) | |
| 61 | +#ifdef CONFIG_ATMEL_SPI | |
| 62 | 62 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 63 | 63 | { |
| 64 | 64 | at91_set_a_periph(AT91_PIO_PORTA, 0, PUP); /* SPI0_MISO */ |
arch/arm/mach-at91/arm926ejs/at91sam9261_devices.c
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | at91_periph_clk_enable(ATMEL_ID_SYS); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) | |
| 58 | +#ifdef CONFIG_ATMEL_SPI | |
| 59 | 59 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 60 | 60 | { |
| 61 | 61 | at91_set_a_periph(AT91_PIO_PORTA, 0, PUP); /* SPI0_MISO */ |
arch/arm/mach-at91/arm926ejs/at91sam9263_devices.c
| ... | ... | @@ -59,7 +59,7 @@ |
| 59 | 59 | at91_periph_clk_enable(ATMEL_ID_SYS); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | -#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) | |
| 62 | +#ifdef CONFIG_ATMEL_SPI | |
| 63 | 63 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 64 | 64 | { |
| 65 | 65 | at91_set_b_periph(AT91_PIO_PORTA, 0, PUP); /* SPI0_MISO */ |
arch/arm/mach-at91/arm926ejs/at91sam9m10g45_devices.c
| ... | ... | @@ -56,7 +56,7 @@ |
| 56 | 56 | at91_periph_clk_enable(ATMEL_ID_SYS); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) | |
| 59 | +#ifdef CONFIG_ATMEL_SPI | |
| 60 | 60 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 61 | 61 | { |
| 62 | 62 | at91_set_a_periph(AT91_PIO_PORTB, 0, PUP); /* SPI0_MISO */ |
arch/arm/mach-at91/arm926ejs/at91sam9rl_devices.c
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | at91_periph_clk_enable(ATMEL_ID_SYS); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) | |
| 58 | +#ifdef CONFIG_ATMEL_SPI | |
| 59 | 59 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 60 | 60 | { |
| 61 | 61 | at91_set_a_periph(AT91_PIO_PORTA, 25, PUP); /* SPI0_MISO */ |
board/atmel/at91sam9260ek/Makefile
board/atmel/at91sam9260ek/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 13 | - | |
| 14 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 15 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 16 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1, 1} | |
| 17 | -}; | |
| 18 | - | |
| 19 | -/*define the area offsets*/ | |
| 20 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 21 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 22 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 23 | - {0x00008400, 0x00083FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 24 | - {0x00084000, 0x00293FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 25 | - {0x00294000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 26 | -}; |
board/atmel/at91sam9261ek/Makefile
board/atmel/at91sam9261ek/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 13 | - | |
| 14 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 15 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 16 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3, 3} | |
| 17 | -}; | |
| 18 | - | |
| 19 | -/*define the area offsets*/ | |
| 20 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 21 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 22 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 23 | - {0x00008400, 0x00083FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 24 | - {0x00084000, 0x00293FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 25 | - {0x00294000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 26 | -}; |
board/atmel/at91sam9263ek/Makefile
board/atmel/at91sam9263ek/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 13 | - | |
| 14 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 15 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 16 | -}; | |
| 17 | - | |
| 18 | -/*define the area offsets*/ | |
| 19 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 20 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 21 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 22 | - {0x00008400, 0x00083FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 23 | - {0x00084000, 0x00293FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 24 | - {0x00294000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 25 | -}; |
board/atmel/at91sam9rlek/Makefile
board/atmel/at91sam9rlek/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 13 | - | |
| 14 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 15 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 16 | -}; | |
| 17 | - | |
| 18 | -/*define the area offsets*/ | |
| 19 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 20 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 21 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 22 | - {0x00008400, 0x00083FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 23 | - {0x00084000, 0x00293FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 24 | - {0x00294000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 25 | -}; |
board/esd/meesc/Makefile
board/esd/meesc/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 13 | - | |
| 14 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 15 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 16 | -}; | |
| 17 | - | |
| 18 | -/* define the area offsets */ | |
| 19 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 20 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 21 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 22 | - {0x00008400, 0x00041FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 23 | -}; |
board/mini-box/picosam9g45/picosam9g45.c
board/ronetix/pm9261/Makefile
board/ronetix/pm9261/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * Ilko Iliev <www.ronetix.at> | |
| 5 | - * | |
| 6 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 7 | - */ | |
| 8 | -#include <common.h> | |
| 9 | -#include <config.h> | |
| 10 | -#include <asm/hardware.h> | |
| 11 | -#include <dataflash.h> | |
| 12 | - | |
| 13 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 14 | - | |
| 15 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 16 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 17 | -}; | |
| 18 | - | |
| 19 | -/*define the area offsets*/ | |
| 20 | -#ifdef CONFIG_SYS_USE_DATAFLASH | |
| 21 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 22 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 23 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 24 | - {0x00008400, 0x00041FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 25 | - {0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 26 | - {0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 27 | -}; | |
| 28 | -#else | |
| 29 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 30 | - {0x00000000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, ""}, | |
| 31 | -}; | |
| 32 | - | |
| 33 | -#endif |
board/ronetix/pm9263/Makefile
board/ronetix/pm9263/partition.c
| 1 | -/* | |
| 2 | - * (C) Copyright 2008 | |
| 3 | - * Ulf Samuelsson <ulf@atmel.com> | |
| 4 | - * Ilko Iliev <www.ronetix.at> | |
| 5 | - * | |
| 6 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 7 | - */ | |
| 8 | -#include <common.h> | |
| 9 | -#include <config.h> | |
| 10 | -#include <asm/hardware.h> | |
| 11 | -#include <dataflash.h> | |
| 12 | - | |
| 13 | -AT91S_DATAFLASH_INFO dataflash_info[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 14 | - | |
| 15 | -struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS] = { | |
| 16 | - {CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS0, 0}, /* Logical adress, CS */ | |
| 17 | -}; | |
| 18 | - | |
| 19 | -/*define the area offsets*/ | |
| 20 | -#ifdef CONFIG_SYS_USE_DATAFLASH | |
| 21 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 22 | - {0x00000000, 0x000041FF, FLAG_PROTECT_SET, 0, "Bootstrap"}, | |
| 23 | - {0x00004200, 0x000083FF, FLAG_PROTECT_CLEAR, 0, "Environment"}, | |
| 24 | - {0x00008400, 0x00041FFF, FLAG_PROTECT_SET, 0, "U-Boot"}, | |
| 25 | - {0x00042000, 0x00251FFF, FLAG_PROTECT_CLEAR, 0, "Kernel"}, | |
| 26 | - {0x00252000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, "FS"}, | |
| 27 | -}; | |
| 28 | -#else | |
| 29 | -dataflash_protect_t area_list[NB_DATAFLASH_AREA] = { | |
| 30 | - {0x00000000, 0xFFFFFFFF, FLAG_PROTECT_CLEAR, 0, ""}, | |
| 31 | -}; | |
| 32 | - | |
| 33 | -#endif |
board/siemens/corvus/board.c
cmd/flash.c
| ... | ... | @@ -11,10 +11,6 @@ |
| 11 | 11 | #include <common.h> |
| 12 | 12 | #include <command.h> |
| 13 | 13 | |
| 14 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 15 | -#include <dataflash.h> | |
| 16 | -#endif | |
| 17 | - | |
| 18 | 14 | #if defined(CONFIG_CMD_MTDPARTS) |
| 19 | 15 | #include <jffs2/jffs2.h> |
| 20 | 16 | |
| ... | ... | @@ -279,10 +275,6 @@ |
| 279 | 275 | ulong bank; |
| 280 | 276 | #endif |
| 281 | 277 | |
| 282 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 283 | - dataflash_print_info(); | |
| 284 | -#endif | |
| 285 | - | |
| 286 | 278 | #ifdef CONFIG_MTD_NOR_FLASH |
| 287 | 279 | if (argc == 1) { /* print info for all FLASH banks */ |
| 288 | 280 | for (bank=0; bank <CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { |
| ... | ... | @@ -451,10 +443,7 @@ |
| 451 | 443 | u8 dev_type, dev_num, pnum; |
| 452 | 444 | #endif |
| 453 | 445 | #endif /* CONFIG_MTD_NOR_FLASH */ |
| 454 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 455 | - int status; | |
| 456 | -#endif | |
| 457 | -#if defined(CONFIG_MTD_NOR_FLASH) || defined(CONFIG_HAS_DATAFLASH) | |
| 446 | +#if defined(CONFIG_MTD_NOR_FLASH) | |
| 458 | 447 | int p; |
| 459 | 448 | ulong addr_first, addr_last; |
| 460 | 449 | #endif |
| 461 | 450 | |
| ... | ... | @@ -462,31 +451,13 @@ |
| 462 | 451 | if (argc < 3) |
| 463 | 452 | return CMD_RET_USAGE; |
| 464 | 453 | |
| 465 | -#if defined(CONFIG_MTD_NOR_FLASH) || defined(CONFIG_HAS_DATAFLASH) | |
| 454 | +#if defined(CONFIG_MTD_NOR_FLASH) | |
| 466 | 455 | if (strcmp(argv[1], "off") == 0) |
| 467 | 456 | p = 0; |
| 468 | 457 | else if (strcmp(argv[1], "on") == 0) |
| 469 | 458 | p = 1; |
| 470 | 459 | else |
| 471 | 460 | return CMD_RET_USAGE; |
| 472 | -#endif | |
| 473 | - | |
| 474 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 475 | - if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) { | |
| 476 | - addr_first = simple_strtoul(argv[2], NULL, 16); | |
| 477 | - addr_last = simple_strtoul(argv[3], NULL, 16); | |
| 478 | - | |
| 479 | - if (addr_dataflash(addr_first) && addr_dataflash(addr_last)) { | |
| 480 | - status = dataflash_real_protect(p,addr_first,addr_last); | |
| 481 | - if (status < 0){ | |
| 482 | - puts ("Bad DataFlash sector specification\n"); | |
| 483 | - return 1; | |
| 484 | - } | |
| 485 | - printf("%sProtect %d DataFlash Sectors\n", | |
| 486 | - p ? "" : "Un-", status); | |
| 487 | - return 0; | |
| 488 | - } | |
| 489 | - } | |
| 490 | 461 | #endif |
| 491 | 462 | |
| 492 | 463 | #ifdef CONFIG_MTD_NOR_FLASH |
cmd/mem.c
| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #include <cli.h> |
| 18 | 18 | #include <command.h> |
| 19 | 19 | #include <console.h> |
| 20 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 21 | -#include <dataflash.h> | |
| 22 | -#endif | |
| 23 | 20 | #include <hash.h> |
| 24 | 21 | #include <inttypes.h> |
| 25 | 22 | #include <mapmem.h> |
| ... | ... | @@ -52,10 +49,8 @@ |
| 52 | 49 | #define DISP_LINE_LEN 16 |
| 53 | 50 | static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 54 | 51 | { |
| 55 | - ulong addr, length; | |
| 56 | -#if defined(CONFIG_HAS_DATAFLASH) | |
| 57 | - ulong nbytes, linebytes; | |
| 58 | -#endif | |
| 52 | + ulong addr, length, bytes; | |
| 53 | + const void *buf; | |
| 59 | 54 | int size; |
| 60 | 55 | int rc = 0; |
| 61 | 56 | |
| 62 | 57 | |
| 63 | 58 | |
| ... | ... | @@ -88,41 +83,14 @@ |
| 88 | 83 | length = simple_strtoul(argv[2], NULL, 16); |
| 89 | 84 | } |
| 90 | 85 | |
| 91 | -#if defined(CONFIG_HAS_DATAFLASH) | |
| 92 | - /* Print the lines. | |
| 93 | - * | |
| 94 | - * We buffer all read data, so we can make sure data is read only | |
| 95 | - * once, and all accesses are with the specified bus width. | |
| 96 | - */ | |
| 97 | - nbytes = length * size; | |
| 98 | - do { | |
| 99 | - char linebuf[DISP_LINE_LEN]; | |
| 100 | - void* p; | |
| 101 | - linebytes = (nbytes>DISP_LINE_LEN)?DISP_LINE_LEN:nbytes; | |
| 86 | + bytes = size * length; | |
| 87 | + buf = map_sysmem(addr, bytes); | |
| 102 | 88 | |
| 103 | - rc = read_dataflash(addr, (linebytes/size)*size, linebuf); | |
| 104 | - p = (rc == DATAFLASH_OK) ? linebuf : (void*)addr; | |
| 105 | - print_buffer(addr, p, size, linebytes/size, DISP_LINE_LEN/size); | |
| 89 | + /* Print the lines. */ | |
| 90 | + print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); | |
| 91 | + addr += bytes; | |
| 92 | + unmap_sysmem(buf); | |
| 106 | 93 | |
| 107 | - nbytes -= linebytes; | |
| 108 | - addr += linebytes; | |
| 109 | - if (ctrlc()) { | |
| 110 | - rc = 1; | |
| 111 | - break; | |
| 112 | - } | |
| 113 | - } while (nbytes > 0); | |
| 114 | -#else | |
| 115 | - { | |
| 116 | - ulong bytes = size * length; | |
| 117 | - const void *buf = map_sysmem(addr, bytes); | |
| 118 | - | |
| 119 | - /* Print the lines. */ | |
| 120 | - print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); | |
| 121 | - addr += bytes; | |
| 122 | - unmap_sysmem(buf); | |
| 123 | - } | |
| 124 | -#endif | |
| 125 | - | |
| 126 | 94 | dp_last_addr = addr; |
| 127 | 95 | dp_last_length = length; |
| 128 | 96 | dp_last_size = size; |
| ... | ... | @@ -286,13 +254,6 @@ |
| 286 | 254 | |
| 287 | 255 | count = simple_strtoul(argv[3], NULL, 16); |
| 288 | 256 | |
| 289 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 290 | - if (addr_dataflash(addr1) | addr_dataflash(addr2)){ | |
| 291 | - puts ("Comparison with DataFlash space not supported.\n\r"); | |
| 292 | - return 0; | |
| 293 | - } | |
| 294 | -#endif | |
| 295 | - | |
| 296 | 257 | bytes = size * count; |
| 297 | 258 | base = buf1 = map_sysmem(addr1, bytes); |
| 298 | 259 | buf2 = map_sysmem(addr2, bytes); |
| ... | ... | @@ -370,11 +331,7 @@ |
| 370 | 331 | |
| 371 | 332 | #ifdef CONFIG_MTD_NOR_FLASH |
| 372 | 333 | /* check if we are copying to Flash */ |
| 373 | - if ( (addr2info(dest) != NULL) | |
| 374 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 375 | - && (!addr_dataflash(dest)) | |
| 376 | -#endif | |
| 377 | - ) { | |
| 334 | + if (addr2info(dest) != NULL) { | |
| 378 | 335 | int rc; |
| 379 | 336 | |
| 380 | 337 | puts ("Copy to Flash... "); |
| ... | ... | @@ -389,44 +346,6 @@ |
| 389 | 346 | } |
| 390 | 347 | #endif |
| 391 | 348 | |
| 392 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 393 | - /* Check if we are copying from RAM or Flash to DataFlash */ | |
| 394 | - if (addr_dataflash(dest) && !addr_dataflash(addr)){ | |
| 395 | - int rc; | |
| 396 | - | |
| 397 | - puts ("Copy to DataFlash... "); | |
| 398 | - | |
| 399 | - rc = write_dataflash (dest, addr, count*size); | |
| 400 | - | |
| 401 | - if (rc != 1) { | |
| 402 | - dataflash_perror (rc); | |
| 403 | - return (1); | |
| 404 | - } | |
| 405 | - puts ("done\n"); | |
| 406 | - return 0; | |
| 407 | - } | |
| 408 | - | |
| 409 | - /* Check if we are copying from DataFlash to RAM */ | |
| 410 | - if (addr_dataflash(addr) && !addr_dataflash(dest) | |
| 411 | -#ifdef CONFIG_MTD_NOR_FLASH | |
| 412 | - && (addr2info(dest) == NULL) | |
| 413 | -#endif | |
| 414 | - ){ | |
| 415 | - int rc; | |
| 416 | - rc = read_dataflash(addr, count * size, (char *) dest); | |
| 417 | - if (rc != 1) { | |
| 418 | - dataflash_perror (rc); | |
| 419 | - return (1); | |
| 420 | - } | |
| 421 | - return 0; | |
| 422 | - } | |
| 423 | - | |
| 424 | - if (addr_dataflash(addr) && addr_dataflash(dest)){ | |
| 425 | - puts ("Unsupported combination of source/destination.\n\r"); | |
| 426 | - return 1; | |
| 427 | - } | |
| 428 | -#endif | |
| 429 | - | |
| 430 | 349 | memcpy((void *)dest, (void *)addr, count * size); |
| 431 | 350 | |
| 432 | 351 | return 0; |
| ... | ... | @@ -1071,13 +990,6 @@ |
| 1071 | 990 | addr = simple_strtoul(argv[1], NULL, 16); |
| 1072 | 991 | addr += base_address; |
| 1073 | 992 | } |
| 1074 | - | |
| 1075 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 1076 | - if (addr_dataflash(addr)){ | |
| 1077 | - puts ("Can't modify DataFlash in place. Use cp instead.\n\r"); | |
| 1078 | - return 0; | |
| 1079 | - } | |
| 1080 | -#endif | |
| 1081 | 993 | |
| 1082 | 994 | /* Print the address, followed by value. Then accept input for |
| 1083 | 995 | * the next value. A non-converted value exits. |
common/board_r.c
| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #endif |
| 19 | 19 | #include <command.h> |
| 20 | 20 | #include <console.h> |
| 21 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 22 | -#include <dataflash.h> | |
| 23 | -#endif | |
| 24 | 21 | #include <dm.h> |
| 25 | 22 | #include <environment.h> |
| 26 | 23 | #include <fdtdec.h> |
| ... | ... | @@ -447,15 +444,6 @@ |
| 447 | 444 | } |
| 448 | 445 | #endif |
| 449 | 446 | |
| 450 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 451 | -static int initr_dataflash(void) | |
| 452 | -{ | |
| 453 | - AT91F_DataflashInit(); | |
| 454 | - dataflash_print_info(); | |
| 455 | - return 0; | |
| 456 | -} | |
| 457 | -#endif | |
| 458 | - | |
| 459 | 447 | /* |
| 460 | 448 | * Tell if it's OK to load the environment early in boot. |
| 461 | 449 | * |
| ... | ... | @@ -802,9 +790,6 @@ |
| 802 | 790 | #endif |
| 803 | 791 | #ifdef CONFIG_MMC |
| 804 | 792 | initr_mmc, |
| 805 | -#endif | |
| 806 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 807 | - initr_dataflash, | |
| 808 | 793 | #endif |
| 809 | 794 | initr_env, |
| 810 | 795 | #ifdef CONFIG_SYS_BOOTPARAMS_LEN |
common/image.c
| ... | ... | @@ -15,10 +15,6 @@ |
| 15 | 15 | #include <status_led.h> |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 19 | -#include <dataflash.h> | |
| 20 | -#endif | |
| 21 | - | |
| 22 | 18 | #ifdef CONFIG_LOGBUFFER |
| 23 | 19 | #include <logbuff.h> |
| 24 | 20 | #endif |
| ... | ... | @@ -902,64 +898,6 @@ |
| 902 | 898 | ulong genimg_get_image(ulong img_addr) |
| 903 | 899 | { |
| 904 | 900 | ulong ram_addr = img_addr; |
| 905 | - | |
| 906 | -#ifdef CONFIG_HAS_DATAFLASH | |
| 907 | - ulong h_size, d_size; | |
| 908 | - | |
| 909 | - if (addr_dataflash(img_addr)) { | |
| 910 | - void *buf; | |
| 911 | - | |
| 912 | - /* ger RAM address */ | |
| 913 | - ram_addr = CONFIG_SYS_LOAD_ADDR; | |
| 914 | - | |
| 915 | - /* get header size */ | |
| 916 | - h_size = image_get_header_size(); | |
| 917 | -#if IMAGE_ENABLE_FIT | |
| 918 | - if (sizeof(struct fdt_header) > h_size) | |
| 919 | - h_size = sizeof(struct fdt_header); | |
| 920 | -#endif | |
| 921 | - | |
| 922 | - /* read in header */ | |
| 923 | - debug(" Reading image header from dataflash address " | |
| 924 | - "%08lx to RAM address %08lx\n", img_addr, ram_addr); | |
| 925 | - | |
| 926 | - buf = map_sysmem(ram_addr, 0); | |
| 927 | - read_dataflash(img_addr, h_size, buf); | |
| 928 | - | |
| 929 | - /* get data size */ | |
| 930 | - switch (genimg_get_format(buf)) { | |
| 931 | -#if defined(CONFIG_IMAGE_FORMAT_LEGACY) | |
| 932 | - case IMAGE_FORMAT_LEGACY: | |
| 933 | - d_size = image_get_data_size(buf); | |
| 934 | - debug(" Legacy format image found at 0x%08lx, " | |
| 935 | - "size 0x%08lx\n", | |
| 936 | - ram_addr, d_size); | |
| 937 | - break; | |
| 938 | -#endif | |
| 939 | -#if IMAGE_ENABLE_FIT | |
| 940 | - case IMAGE_FORMAT_FIT: | |
| 941 | - d_size = fit_get_size(buf) - h_size; | |
| 942 | - debug(" FIT/FDT format image found at 0x%08lx, " | |
| 943 | - "size 0x%08lx\n", | |
| 944 | - ram_addr, d_size); | |
| 945 | - break; | |
| 946 | -#endif | |
| 947 | - default: | |
| 948 | - printf(" No valid image found at 0x%08lx\n", | |
| 949 | - img_addr); | |
| 950 | - return ram_addr; | |
| 951 | - } | |
| 952 | - | |
| 953 | - /* read in image data */ | |
| 954 | - debug(" Reading image remaining data from dataflash address " | |
| 955 | - "%08lx to RAM address %08lx\n", img_addr + h_size, | |
| 956 | - ram_addr + h_size); | |
| 957 | - | |
| 958 | - read_dataflash(img_addr + h_size, d_size, | |
| 959 | - (char *)(buf + h_size)); | |
| 960 | - | |
| 961 | - } | |
| 962 | -#endif /* CONFIG_HAS_DATAFLASH */ | |
| 963 | 901 | |
| 964 | 902 | return ram_addr; |
| 965 | 903 | } |
drivers/mtd/Makefile
| ... | ... | @@ -12,10 +12,8 @@ |
| 12 | 12 | obj-$(CONFIG_MTD_PARTITIONS) += mtdpart.o |
| 13 | 13 | obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o |
| 14 | 14 | obj-$(CONFIG_ALTERA_QSPI) += altera_qspi.o |
| 15 | -obj-$(CONFIG_HAS_DATAFLASH) += at45.o | |
| 16 | 15 | obj-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o |
| 17 | 16 | obj-$(CONFIG_FLASH_CFI_MTD) += cfi_mtd.o |
| 18 | -obj-$(CONFIG_HAS_DATAFLASH) += dataflash.o | |
| 19 | 17 | obj-$(CONFIG_FTSMC020) += ftsmc020.o |
| 20 | 18 | obj-$(CONFIG_FLASH_CFI_LEGACY) += jedec_flash.o |
| 21 | 19 | obj-$(CONFIG_MW_EEPROM) += mw_eeprom.o |
drivers/mtd/at45.c
| 1 | -/* Driver for ATMEL DataFlash support | |
| 2 | - * Author : Hamid Ikdoumi (Atmel) | |
| 3 | - * | |
| 4 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 5 | - */ | |
| 6 | - | |
| 7 | -#include <config.h> | |
| 8 | -#include <common.h> | |
| 9 | -#include <dataflash.h> | |
| 10 | - | |
| 11 | -/* | |
| 12 | - * spi.c API | |
| 13 | - */ | |
| 14 | -extern unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc); | |
| 15 | -extern void AT91F_SpiEnable(int cs); | |
| 16 | - | |
| 17 | -#define AT91C_TIMEOUT_WRDY 200000 | |
| 18 | - | |
| 19 | -/*----------------------------------------------------------------------*/ | |
| 20 | -/* \fn AT91F_DataFlashSendCommand */ | |
| 21 | -/* \brief Generic function to send a command to the dataflash */ | |
| 22 | -/*----------------------------------------------------------------------*/ | |
| 23 | -AT91S_DataFlashStatus AT91F_DataFlashSendCommand(AT91PS_DataFlash pDataFlash, | |
| 24 | - unsigned char OpCode, | |
| 25 | - unsigned int CmdSize, | |
| 26 | - unsigned int DataflashAddress) | |
| 27 | -{ | |
| 28 | - unsigned int adr; | |
| 29 | - | |
| 30 | - if ((pDataFlash->pDataFlashDesc->state) != IDLE) | |
| 31 | - return DATAFLASH_BUSY; | |
| 32 | - | |
| 33 | - /* process the address to obtain page address and byte address */ | |
| 34 | - adr = ((DataflashAddress / (pDataFlash->pDevice->pages_size)) << | |
| 35 | - pDataFlash->pDevice->page_offset) + | |
| 36 | - (DataflashAddress % (pDataFlash->pDevice->pages_size)); | |
| 37 | - | |
| 38 | - /* fill the command buffer */ | |
| 39 | - pDataFlash->pDataFlashDesc->command[0] = OpCode; | |
| 40 | - if (pDataFlash->pDevice->pages_number >= 16384) { | |
| 41 | - pDataFlash->pDataFlashDesc->command[1] = | |
| 42 | - (unsigned char)((adr & 0x0F000000) >> 24); | |
| 43 | - pDataFlash->pDataFlashDesc->command[2] = | |
| 44 | - (unsigned char)((adr & 0x00FF0000) >> 16); | |
| 45 | - pDataFlash->pDataFlashDesc->command[3] = | |
| 46 | - (unsigned char)((adr & 0x0000FF00) >> 8); | |
| 47 | - pDataFlash->pDataFlashDesc->command[4] = | |
| 48 | - (unsigned char)(adr & 0x000000FF); | |
| 49 | - } else { | |
| 50 | - pDataFlash->pDataFlashDesc->command[1] = | |
| 51 | - (unsigned char)((adr & 0x00FF0000) >> 16); | |
| 52 | - pDataFlash->pDataFlashDesc->command[2] = | |
| 53 | - (unsigned char)((adr & 0x0000FF00) >> 8); | |
| 54 | - pDataFlash->pDataFlashDesc->command[3] = | |
| 55 | - (unsigned char)(adr & 0x000000FF); | |
| 56 | - pDataFlash->pDataFlashDesc->command[4] = 0; | |
| 57 | - } | |
| 58 | - pDataFlash->pDataFlashDesc->command[5] = 0; | |
| 59 | - pDataFlash->pDataFlashDesc->command[6] = 0; | |
| 60 | - pDataFlash->pDataFlashDesc->command[7] = 0; | |
| 61 | - | |
| 62 | - /* Initialize the SpiData structure for the spi write fuction */ | |
| 63 | - pDataFlash->pDataFlashDesc->tx_cmd_pt = | |
| 64 | - pDataFlash->pDataFlashDesc->command; | |
| 65 | - pDataFlash->pDataFlashDesc->tx_cmd_size = CmdSize; | |
| 66 | - pDataFlash->pDataFlashDesc->rx_cmd_pt = | |
| 67 | - pDataFlash->pDataFlashDesc->command; | |
| 68 | - pDataFlash->pDataFlashDesc->rx_cmd_size = CmdSize; | |
| 69 | - | |
| 70 | - /* send the command and read the data */ | |
| 71 | - return AT91F_SpiWrite(pDataFlash->pDataFlashDesc); | |
| 72 | -} | |
| 73 | - | |
| 74 | -/*----------------------------------------------------------------------*/ | |
| 75 | -/* \fn AT91F_DataFlashGetStatus */ | |
| 76 | -/* \brief Read the status register of the dataflash */ | |
| 77 | -/*----------------------------------------------------------------------*/ | |
| 78 | -AT91S_DataFlashStatus AT91F_DataFlashGetStatus(AT91PS_DataflashDesc pDesc) | |
| 79 | -{ | |
| 80 | - AT91S_DataFlashStatus status; | |
| 81 | - | |
| 82 | - /* if a transfert is in progress ==> return 0 */ | |
| 83 | - if ((pDesc->state) != IDLE) | |
| 84 | - return DATAFLASH_BUSY; | |
| 85 | - | |
| 86 | - /* first send the read status command (D7H) */ | |
| 87 | - pDesc->command[0] = DB_STATUS; | |
| 88 | - pDesc->command[1] = 0; | |
| 89 | - | |
| 90 | - pDesc->DataFlash_state = GET_STATUS; | |
| 91 | - pDesc->tx_data_size = 0; /* Transmit the command */ | |
| 92 | - /* and receive response */ | |
| 93 | - pDesc->tx_cmd_pt = pDesc->command; | |
| 94 | - pDesc->rx_cmd_pt = pDesc->command; | |
| 95 | - pDesc->rx_cmd_size = 2; | |
| 96 | - pDesc->tx_cmd_size = 2; | |
| 97 | - status = AT91F_SpiWrite(pDesc); | |
| 98 | - | |
| 99 | - pDesc->DataFlash_state = *((unsigned char *)(pDesc->rx_cmd_pt) + 1); | |
| 100 | - | |
| 101 | - return status; | |
| 102 | -} | |
| 103 | - | |
| 104 | -/*----------------------------------------------------------------------*/ | |
| 105 | -/* \fn AT91F_DataFlashWaitReady */ | |
| 106 | -/* \brief wait for dataflash ready (bit7 of the status register == 1) */ | |
| 107 | -/*----------------------------------------------------------------------*/ | |
| 108 | -AT91S_DataFlashStatus AT91F_DataFlashWaitReady(AT91PS_DataflashDesc | |
| 109 | - pDataFlashDesc, | |
| 110 | - unsigned int timeout) | |
| 111 | -{ | |
| 112 | - pDataFlashDesc->DataFlash_state = IDLE; | |
| 113 | - | |
| 114 | - do { | |
| 115 | - AT91F_DataFlashGetStatus(pDataFlashDesc); | |
| 116 | - timeout--; | |
| 117 | - } while (((pDataFlashDesc->DataFlash_state & 0x80) != 0x80) && | |
| 118 | - (timeout > 0)); | |
| 119 | - | |
| 120 | - if ((pDataFlashDesc->DataFlash_state & 0x80) != 0x80) | |
| 121 | - return DATAFLASH_ERROR; | |
| 122 | - | |
| 123 | - return DATAFLASH_OK; | |
| 124 | -} | |
| 125 | - | |
| 126 | -/*--------------------------------------------------------------------------*/ | |
| 127 | -/* Function Name : AT91F_DataFlashContinuousRead */ | |
| 128 | -/* Object : Continuous stream Read */ | |
| 129 | -/* Input Parameters : DataFlash Service */ | |
| 130 | -/* : <src> = dataflash address */ | |
| 131 | -/* : <*dataBuffer> = data buffer pointer */ | |
| 132 | -/* : <sizeToRead> = data buffer size */ | |
| 133 | -/* Return value : State of the dataflash */ | |
| 134 | -/*--------------------------------------------------------------------------*/ | |
| 135 | -AT91S_DataFlashStatus AT91F_DataFlashContinuousRead( | |
| 136 | - AT91PS_DataFlash pDataFlash, | |
| 137 | - int src, | |
| 138 | - unsigned char *dataBuffer, | |
| 139 | - int sizeToRead) | |
| 140 | -{ | |
| 141 | - AT91S_DataFlashStatus status; | |
| 142 | - /* Test the size to read in the device */ | |
| 143 | - if ((src + sizeToRead) > | |
| 144 | - (pDataFlash->pDevice->pages_size * | |
| 145 | - (pDataFlash->pDevice->pages_number))) | |
| 146 | - return DATAFLASH_MEMORY_OVERFLOW; | |
| 147 | - | |
| 148 | - pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer; | |
| 149 | - pDataFlash->pDataFlashDesc->rx_data_size = sizeToRead; | |
| 150 | - pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer; | |
| 151 | - pDataFlash->pDataFlashDesc->tx_data_size = sizeToRead; | |
| 152 | - | |
| 153 | - status = AT91F_DataFlashSendCommand( | |
| 154 | - pDataFlash, DB_CONTINUOUS_ARRAY_READ, 8, src); | |
| 155 | - /* Send the command to the dataflash */ | |
| 156 | - return (status); | |
| 157 | -} | |
| 158 | - | |
| 159 | -/*---------------------------------------------------------------------------*/ | |
| 160 | -/* Function Name : AT91F_DataFlashPagePgmBuf */ | |
| 161 | -/* Object : Main memory page program thru buffer 1 or buffer 2 */ | |
| 162 | -/* Input Parameters : DataFlash Service */ | |
| 163 | -/* : <*src> = Source buffer */ | |
| 164 | -/* : <dest> = dataflash destination address */ | |
| 165 | -/* : <SizeToWrite> = data buffer size */ | |
| 166 | -/* Return value : State of the dataflash */ | |
| 167 | -/*---------------------------------------------------------------------------*/ | |
| 168 | -AT91S_DataFlashStatus AT91F_DataFlashPagePgmBuf(AT91PS_DataFlash pDataFlash, | |
| 169 | - unsigned char *src, | |
| 170 | - unsigned int dest, | |
| 171 | - unsigned int SizeToWrite) | |
| 172 | -{ | |
| 173 | - int cmdsize; | |
| 174 | - pDataFlash->pDataFlashDesc->tx_data_pt = src; | |
| 175 | - pDataFlash->pDataFlashDesc->tx_data_size = SizeToWrite; | |
| 176 | - pDataFlash->pDataFlashDesc->rx_data_pt = src; | |
| 177 | - pDataFlash->pDataFlashDesc->rx_data_size = SizeToWrite; | |
| 178 | - | |
| 179 | - cmdsize = 4; | |
| 180 | - /* Send the command to the dataflash */ | |
| 181 | - if (pDataFlash->pDevice->pages_number >= 16384) | |
| 182 | - cmdsize = 5; | |
| 183 | - return (AT91F_DataFlashSendCommand( | |
| 184 | - pDataFlash, DB_PAGE_PGM_BUF1, cmdsize, dest)); | |
| 185 | -} | |
| 186 | - | |
| 187 | -/*---------------------------------------------------------------------------*/ | |
| 188 | -/* Function Name : AT91F_MainMemoryToBufferTransfert */ | |
| 189 | -/* Object : Read a page in the SRAM Buffer 1 or 2 */ | |
| 190 | -/* Input Parameters : DataFlash Service */ | |
| 191 | -/* : Page concerned */ | |
| 192 | -/* : */ | |
| 193 | -/* Return value : State of the dataflash */ | |
| 194 | -/*---------------------------------------------------------------------------*/ | |
| 195 | -AT91S_DataFlashStatus AT91F_MainMemoryToBufferTransfert( | |
| 196 | - AT91PS_DataFlash | |
| 197 | - pDataFlash, | |
| 198 | - unsigned char | |
| 199 | - BufferCommand, | |
| 200 | - unsigned int page) | |
| 201 | -{ | |
| 202 | - int cmdsize; | |
| 203 | - /* Test if the buffer command is legal */ | |
| 204 | - if ((BufferCommand != DB_PAGE_2_BUF1_TRF) && | |
| 205 | - (BufferCommand != DB_PAGE_2_BUF2_TRF)) { | |
| 206 | - return DATAFLASH_BAD_COMMAND; | |
| 207 | - } | |
| 208 | - | |
| 209 | - /* no data to transmit or receive */ | |
| 210 | - pDataFlash->pDataFlashDesc->tx_data_size = 0; | |
| 211 | - cmdsize = 4; | |
| 212 | - if (pDataFlash->pDevice->pages_number >= 16384) | |
| 213 | - cmdsize = 5; | |
| 214 | - return (AT91F_DataFlashSendCommand( | |
| 215 | - pDataFlash, BufferCommand, cmdsize, | |
| 216 | - page * pDataFlash->pDevice->pages_size)); | |
| 217 | -} | |
| 218 | - | |
| 219 | -/*-------------------------------------------------------------------------- */ | |
| 220 | -/* Function Name : AT91F_DataFlashWriteBuffer */ | |
| 221 | -/* Object : Write data to the internal sram buffer 1 or 2 */ | |
| 222 | -/* Input Parameters : DataFlash Service */ | |
| 223 | -/* : <BufferCommand> = command to write buffer1 or 2 */ | |
| 224 | -/* : <*dataBuffer> = data buffer to write */ | |
| 225 | -/* : <bufferAddress> = address in the internal buffer */ | |
| 226 | -/* : <SizeToWrite> = data buffer size */ | |
| 227 | -/* Return value : State of the dataflash */ | |
| 228 | -/*---------------------------------------------------------------------------*/ | |
| 229 | -AT91S_DataFlashStatus AT91F_DataFlashWriteBuffer( | |
| 230 | - AT91PS_DataFlash pDataFlash, | |
| 231 | - unsigned char BufferCommand, | |
| 232 | - unsigned char *dataBuffer, | |
| 233 | - unsigned int bufferAddress, | |
| 234 | - int SizeToWrite) | |
| 235 | -{ | |
| 236 | - int cmdsize; | |
| 237 | - /* Test if the buffer command is legal */ | |
| 238 | - if ((BufferCommand != DB_BUF1_WRITE) && | |
| 239 | - (BufferCommand != DB_BUF2_WRITE)) { | |
| 240 | - return DATAFLASH_BAD_COMMAND; | |
| 241 | - } | |
| 242 | - | |
| 243 | - /* buffer address must be lower than page size */ | |
| 244 | - if (bufferAddress > pDataFlash->pDevice->pages_size) | |
| 245 | - return DATAFLASH_BAD_ADDRESS; | |
| 246 | - | |
| 247 | - if ((pDataFlash->pDataFlashDesc->state) != IDLE) | |
| 248 | - return DATAFLASH_BUSY; | |
| 249 | - | |
| 250 | - /* Send first Write Command */ | |
| 251 | - pDataFlash->pDataFlashDesc->command[0] = BufferCommand; | |
| 252 | - pDataFlash->pDataFlashDesc->command[1] = 0; | |
| 253 | - if (pDataFlash->pDevice->pages_number >= 16384) { | |
| 254 | - pDataFlash->pDataFlashDesc->command[2] = 0; | |
| 255 | - pDataFlash->pDataFlashDesc->command[3] = | |
| 256 | - (unsigned char)(((unsigned int)(bufferAddress & | |
| 257 | - pDataFlash->pDevice-> | |
| 258 | - byte_mask)) >> 8); | |
| 259 | - pDataFlash->pDataFlashDesc->command[4] = | |
| 260 | - (unsigned char)((unsigned int)bufferAddress & 0x00FF); | |
| 261 | - cmdsize = 5; | |
| 262 | - } else { | |
| 263 | - pDataFlash->pDataFlashDesc->command[2] = | |
| 264 | - (unsigned char)(((unsigned int)(bufferAddress & | |
| 265 | - pDataFlash->pDevice-> | |
| 266 | - byte_mask)) >> 8); | |
| 267 | - pDataFlash->pDataFlashDesc->command[3] = | |
| 268 | - (unsigned char)((unsigned int)bufferAddress & 0x00FF); | |
| 269 | - pDataFlash->pDataFlashDesc->command[4] = 0; | |
| 270 | - cmdsize = 4; | |
| 271 | - } | |
| 272 | - | |
| 273 | - pDataFlash->pDataFlashDesc->tx_cmd_pt = | |
| 274 | - pDataFlash->pDataFlashDesc->command; | |
| 275 | - pDataFlash->pDataFlashDesc->tx_cmd_size = cmdsize; | |
| 276 | - pDataFlash->pDataFlashDesc->rx_cmd_pt = | |
| 277 | - pDataFlash->pDataFlashDesc->command; | |
| 278 | - pDataFlash->pDataFlashDesc->rx_cmd_size = cmdsize; | |
| 279 | - | |
| 280 | - pDataFlash->pDataFlashDesc->rx_data_pt = dataBuffer; | |
| 281 | - pDataFlash->pDataFlashDesc->tx_data_pt = dataBuffer; | |
| 282 | - pDataFlash->pDataFlashDesc->rx_data_size = SizeToWrite; | |
| 283 | - pDataFlash->pDataFlashDesc->tx_data_size = SizeToWrite; | |
| 284 | - | |
| 285 | - return AT91F_SpiWrite(pDataFlash->pDataFlashDesc); | |
| 286 | -} | |
| 287 | - | |
| 288 | -/*---------------------------------------------------------------------------*/ | |
| 289 | -/* Function Name : AT91F_PageErase */ | |
| 290 | -/* Object : Erase a page */ | |
| 291 | -/* Input Parameters : DataFlash Service */ | |
| 292 | -/* : Page concerned */ | |
| 293 | -/* : */ | |
| 294 | -/* Return value : State of the dataflash */ | |
| 295 | -/*---------------------------------------------------------------------------*/ | |
| 296 | -AT91S_DataFlashStatus AT91F_PageErase( | |
| 297 | - AT91PS_DataFlash pDataFlash, | |
| 298 | - unsigned int page) | |
| 299 | -{ | |
| 300 | - int cmdsize; | |
| 301 | - /* Test if the buffer command is legal */ | |
| 302 | - /* no data to transmit or receive */ | |
| 303 | - pDataFlash->pDataFlashDesc->tx_data_size = 0; | |
| 304 | - | |
| 305 | - cmdsize = 4; | |
| 306 | - if (pDataFlash->pDevice->pages_number >= 16384) | |
| 307 | - cmdsize = 5; | |
| 308 | - return (AT91F_DataFlashSendCommand(pDataFlash, | |
| 309 | - DB_PAGE_ERASE, cmdsize, | |
| 310 | - page * pDataFlash->pDevice->pages_size)); | |
| 311 | -} | |
| 312 | - | |
| 313 | -/*---------------------------------------------------------------------------*/ | |
| 314 | -/* Function Name : AT91F_BlockErase */ | |
| 315 | -/* Object : Erase a Block */ | |
| 316 | -/* Input Parameters : DataFlash Service */ | |
| 317 | -/* : Page concerned */ | |
| 318 | -/* : */ | |
| 319 | -/* Return value : State of the dataflash */ | |
| 320 | -/*---------------------------------------------------------------------------*/ | |
| 321 | -AT91S_DataFlashStatus AT91F_BlockErase( | |
| 322 | - AT91PS_DataFlash pDataFlash, | |
| 323 | - unsigned int block) | |
| 324 | -{ | |
| 325 | - int cmdsize; | |
| 326 | - /* Test if the buffer command is legal */ | |
| 327 | - /* no data to transmit or receive */ | |
| 328 | - pDataFlash->pDataFlashDesc->tx_data_size = 0; | |
| 329 | - cmdsize = 4; | |
| 330 | - if (pDataFlash->pDevice->pages_number >= 16384) | |
| 331 | - cmdsize = 5; | |
| 332 | - return (AT91F_DataFlashSendCommand(pDataFlash, DB_BLOCK_ERASE, cmdsize, | |
| 333 | - block * 8 * | |
| 334 | - pDataFlash->pDevice->pages_size)); | |
| 335 | -} | |
| 336 | - | |
| 337 | -/*---------------------------------------------------------------------------*/ | |
| 338 | -/* Function Name : AT91F_WriteBufferToMain */ | |
| 339 | -/* Object : Write buffer to the main memory */ | |
| 340 | -/* Input Parameters : DataFlash Service */ | |
| 341 | -/* : <BufferCommand> = command to send to buffer1 or buffer2 */ | |
| 342 | -/* : <dest> = main memory address */ | |
| 343 | -/* Return value : State of the dataflash */ | |
| 344 | -/*---------------------------------------------------------------------------*/ | |
| 345 | -AT91S_DataFlashStatus AT91F_WriteBufferToMain(AT91PS_DataFlash pDataFlash, | |
| 346 | - unsigned char BufferCommand, | |
| 347 | - unsigned int dest) | |
| 348 | -{ | |
| 349 | - int cmdsize; | |
| 350 | - /* Test if the buffer command is correct */ | |
| 351 | - if ((BufferCommand != DB_BUF1_PAGE_PGM) && | |
| 352 | - (BufferCommand != DB_BUF1_PAGE_ERASE_PGM) && | |
| 353 | - (BufferCommand != DB_BUF2_PAGE_PGM) && | |
| 354 | - (BufferCommand != DB_BUF2_PAGE_ERASE_PGM)) | |
| 355 | - return DATAFLASH_BAD_COMMAND; | |
| 356 | - | |
| 357 | - /* no data to transmit or receive */ | |
| 358 | - pDataFlash->pDataFlashDesc->tx_data_size = 0; | |
| 359 | - | |
| 360 | - cmdsize = 4; | |
| 361 | - if (pDataFlash->pDevice->pages_number >= 16384) | |
| 362 | - cmdsize = 5; | |
| 363 | - /* Send the command to the dataflash */ | |
| 364 | - return (AT91F_DataFlashSendCommand(pDataFlash, BufferCommand, | |
| 365 | - cmdsize, dest)); | |
| 366 | -} | |
| 367 | - | |
| 368 | -/*---------------------------------------------------------------------------*/ | |
| 369 | -/* Function Name : AT91F_PartialPageWrite */ | |
| 370 | -/* Object : Erase partielly a page */ | |
| 371 | -/* Input Parameters : <page> = page number */ | |
| 372 | -/* : <AdrInpage> = adr to begin the fading */ | |
| 373 | -/* : <length> = Number of bytes to erase */ | |
| 374 | -/*---------------------------------------------------------------------------*/ | |
| 375 | -AT91S_DataFlashStatus AT91F_PartialPageWrite(AT91PS_DataFlash pDataFlash, | |
| 376 | - unsigned char *src, | |
| 377 | - unsigned int dest, | |
| 378 | - unsigned int size) | |
| 379 | -{ | |
| 380 | - unsigned int page; | |
| 381 | - unsigned int AdrInPage; | |
| 382 | - | |
| 383 | - page = dest / (pDataFlash->pDevice->pages_size); | |
| 384 | - AdrInPage = dest % (pDataFlash->pDevice->pages_size); | |
| 385 | - | |
| 386 | - /* Read the contents of the page in the Sram Buffer */ | |
| 387 | - AT91F_MainMemoryToBufferTransfert(pDataFlash, DB_PAGE_2_BUF1_TRF, page); | |
| 388 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 389 | - AT91C_TIMEOUT_WRDY); | |
| 390 | - /*Update the SRAM buffer */ | |
| 391 | - AT91F_DataFlashWriteBuffer(pDataFlash, DB_BUF1_WRITE, src, | |
| 392 | - AdrInPage, size); | |
| 393 | - | |
| 394 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 395 | - AT91C_TIMEOUT_WRDY); | |
| 396 | - | |
| 397 | - /* Erase page if a 128 Mbits device */ | |
| 398 | - if (pDataFlash->pDevice->pages_number >= 16384) { | |
| 399 | - AT91F_PageErase(pDataFlash, page); | |
| 400 | - /* Rewrite the modified Sram Buffer in the main memory */ | |
| 401 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 402 | - AT91C_TIMEOUT_WRDY); | |
| 403 | - } | |
| 404 | - | |
| 405 | - /* Rewrite the modified Sram Buffer in the main memory */ | |
| 406 | - return (AT91F_WriteBufferToMain(pDataFlash, DB_BUF1_PAGE_ERASE_PGM, | |
| 407 | - (page * | |
| 408 | - pDataFlash->pDevice->pages_size))); | |
| 409 | -} | |
| 410 | - | |
| 411 | -/*---------------------------------------------------------------------------*/ | |
| 412 | -/* Function Name : AT91F_DataFlashWrite */ | |
| 413 | -/* Object : */ | |
| 414 | -/* Input Parameters : <*src> = Source buffer */ | |
| 415 | -/* : <dest> = dataflash adress */ | |
| 416 | -/* : <size> = data buffer size */ | |
| 417 | -/*---------------------------------------------------------------------------*/ | |
| 418 | -AT91S_DataFlashStatus AT91F_DataFlashWrite(AT91PS_DataFlash pDataFlash, | |
| 419 | - unsigned char *src, | |
| 420 | - int dest, int size) | |
| 421 | -{ | |
| 422 | - unsigned int length; | |
| 423 | - unsigned int page; | |
| 424 | - unsigned int status; | |
| 425 | - | |
| 426 | - AT91F_SpiEnable(pDataFlash->pDevice->cs); | |
| 427 | - | |
| 428 | - if ((dest + size) > (pDataFlash->pDevice->pages_size * | |
| 429 | - (pDataFlash->pDevice->pages_number))) | |
| 430 | - return DATAFLASH_MEMORY_OVERFLOW; | |
| 431 | - | |
| 432 | - /* If destination does not fit a page start address */ | |
| 433 | - if ((dest % ((unsigned int)(pDataFlash->pDevice->pages_size))) != 0) { | |
| 434 | - length = | |
| 435 | - pDataFlash->pDevice->pages_size - | |
| 436 | - (dest % ((unsigned int)(pDataFlash->pDevice->pages_size))); | |
| 437 | - | |
| 438 | - if (size < length) | |
| 439 | - length = size; | |
| 440 | - | |
| 441 | - if (!AT91F_PartialPageWrite(pDataFlash, src, dest, length)) | |
| 442 | - return DATAFLASH_ERROR; | |
| 443 | - | |
| 444 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 445 | - AT91C_TIMEOUT_WRDY); | |
| 446 | - | |
| 447 | - /* Update size, source and destination pointers */ | |
| 448 | - size -= length; | |
| 449 | - dest += length; | |
| 450 | - src += length; | |
| 451 | - } | |
| 452 | - | |
| 453 | - while ((size - pDataFlash->pDevice->pages_size) >= 0) { | |
| 454 | - /* program dataflash page */ | |
| 455 | - page = (unsigned int)dest / (pDataFlash->pDevice->pages_size); | |
| 456 | - | |
| 457 | - status = AT91F_DataFlashWriteBuffer(pDataFlash, | |
| 458 | - DB_BUF1_WRITE, src, 0, | |
| 459 | - pDataFlash->pDevice-> | |
| 460 | - pages_size); | |
| 461 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 462 | - AT91C_TIMEOUT_WRDY); | |
| 463 | - | |
| 464 | - status = AT91F_PageErase(pDataFlash, page); | |
| 465 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 466 | - AT91C_TIMEOUT_WRDY); | |
| 467 | - if (!status) | |
| 468 | - return DATAFLASH_ERROR; | |
| 469 | - | |
| 470 | - status = AT91F_WriteBufferToMain(pDataFlash, | |
| 471 | - DB_BUF1_PAGE_PGM, dest); | |
| 472 | - if (!status) | |
| 473 | - return DATAFLASH_ERROR; | |
| 474 | - | |
| 475 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 476 | - AT91C_TIMEOUT_WRDY); | |
| 477 | - | |
| 478 | - /* Update size, source and destination pointers */ | |
| 479 | - size -= pDataFlash->pDevice->pages_size; | |
| 480 | - dest += pDataFlash->pDevice->pages_size; | |
| 481 | - src += pDataFlash->pDevice->pages_size; | |
| 482 | - } | |
| 483 | - | |
| 484 | - /* If still some bytes to read */ | |
| 485 | - if (size > 0) { | |
| 486 | - /* program dataflash page */ | |
| 487 | - if (!AT91F_PartialPageWrite(pDataFlash, src, dest, size)) | |
| 488 | - return DATAFLASH_ERROR; | |
| 489 | - | |
| 490 | - AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 491 | - AT91C_TIMEOUT_WRDY); | |
| 492 | - } | |
| 493 | - return DATAFLASH_OK; | |
| 494 | -} | |
| 495 | - | |
| 496 | -/*---------------------------------------------------------------------------*/ | |
| 497 | -/* Function Name : AT91F_DataFlashRead */ | |
| 498 | -/* Object : Read a block in dataflash */ | |
| 499 | -/* Input Parameters : */ | |
| 500 | -/* Return value : */ | |
| 501 | -/*---------------------------------------------------------------------------*/ | |
| 502 | -int AT91F_DataFlashRead(AT91PS_DataFlash pDataFlash, | |
| 503 | - unsigned long addr, unsigned long size, char *buffer) | |
| 504 | -{ | |
| 505 | - unsigned long SizeToRead; | |
| 506 | - | |
| 507 | - AT91F_SpiEnable(pDataFlash->pDevice->cs); | |
| 508 | - | |
| 509 | - if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 510 | - AT91C_TIMEOUT_WRDY) != DATAFLASH_OK) | |
| 511 | - return -1; | |
| 512 | - | |
| 513 | - while (size) { | |
| 514 | - SizeToRead = (size < 0x8000) ? size : 0x8000; | |
| 515 | - | |
| 516 | - if (AT91F_DataFlashWaitReady(pDataFlash->pDataFlashDesc, | |
| 517 | - AT91C_TIMEOUT_WRDY) != | |
| 518 | - DATAFLASH_OK) | |
| 519 | - return -1; | |
| 520 | - | |
| 521 | - if (AT91F_DataFlashContinuousRead(pDataFlash, addr, | |
| 522 | - (uchar *) buffer, | |
| 523 | - SizeToRead) != DATAFLASH_OK) | |
| 524 | - return -1; | |
| 525 | - | |
| 526 | - size -= SizeToRead; | |
| 527 | - addr += SizeToRead; | |
| 528 | - buffer += SizeToRead; | |
| 529 | - } | |
| 530 | - | |
| 531 | - return DATAFLASH_OK; | |
| 532 | -} | |
| 533 | - | |
| 534 | -/*---------------------------------------------------------------------------*/ | |
| 535 | -/* Function Name : AT91F_DataflashProbe */ | |
| 536 | -/* Object : */ | |
| 537 | -/* Input Parameters : */ | |
| 538 | -/* Return value : Dataflash status register */ | |
| 539 | -/*---------------------------------------------------------------------------*/ | |
| 540 | -int AT91F_DataflashProbe(int cs, AT91PS_DataflashDesc pDesc) | |
| 541 | -{ | |
| 542 | - AT91F_SpiEnable(cs); | |
| 543 | - AT91F_DataFlashGetStatus(pDesc); | |
| 544 | - return ((pDesc->command[1] == 0xFF) ? 0 : pDesc->command[1] & 0x3C); | |
| 545 | -} |
drivers/mtd/dataflash.c
| 1 | -/* | |
| 2 | - * LowLevel function for ATMEL DataFlash support | |
| 3 | - * Author : Hamid Ikdoumi (Atmel) | |
| 4 | - * | |
| 5 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 6 | - */ | |
| 7 | -#include <common.h> | |
| 8 | -#include <config.h> | |
| 9 | -#include <asm/hardware.h> | |
| 10 | -#include <dataflash.h> | |
| 11 | - | |
| 12 | -static AT91S_DataFlash DataFlashInst; | |
| 13 | - | |
| 14 | -extern void AT91F_SpiInit (void); | |
| 15 | -extern int AT91F_DataflashProbe (int i, AT91PS_DataflashDesc pDesc); | |
| 16 | -extern int AT91F_DataFlashRead (AT91PS_DataFlash pDataFlash, | |
| 17 | - unsigned long addr, | |
| 18 | - unsigned long size, char *buffer); | |
| 19 | -extern int AT91F_DataFlashWrite( AT91PS_DataFlash pDataFlash, | |
| 20 | - unsigned char *src, | |
| 21 | - int dest, | |
| 22 | - int size ); | |
| 23 | - | |
| 24 | -int AT91F_DataflashInit (void) | |
| 25 | -{ | |
| 26 | - int i, j; | |
| 27 | - int dfcode; | |
| 28 | - int part; | |
| 29 | - int found[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 30 | - unsigned char protected; | |
| 31 | - | |
| 32 | - AT91F_SpiInit (); | |
| 33 | - | |
| 34 | - for (i = 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) { | |
| 35 | - found[i] = 0; | |
| 36 | - dataflash_info[i].Desc.state = IDLE; | |
| 37 | - dataflash_info[i].id = 0; | |
| 38 | - dataflash_info[i].Device.pages_number = 0; | |
| 39 | - dfcode = AT91F_DataflashProbe (cs[i].cs, | |
| 40 | - &dataflash_info[i].Desc); | |
| 41 | - | |
| 42 | - switch (dfcode) { | |
| 43 | - case AT45DB021: | |
| 44 | - dataflash_info[i].Device.pages_number = 1024; | |
| 45 | - dataflash_info[i].Device.pages_size = 264; | |
| 46 | - dataflash_info[i].Device.page_offset = 9; | |
| 47 | - dataflash_info[i].Device.byte_mask = 0x300; | |
| 48 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 49 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 50 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 51 | - dataflash_info[i].id = dfcode; | |
| 52 | - found[i] += dfcode; | |
| 53 | - break; | |
| 54 | - | |
| 55 | - case AT45DB081: | |
| 56 | - dataflash_info[i].Device.pages_number = 4096; | |
| 57 | - dataflash_info[i].Device.pages_size = 264; | |
| 58 | - dataflash_info[i].Device.page_offset = 9; | |
| 59 | - dataflash_info[i].Device.byte_mask = 0x300; | |
| 60 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 61 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 62 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 63 | - dataflash_info[i].id = dfcode; | |
| 64 | - found[i] += dfcode; | |
| 65 | - break; | |
| 66 | - | |
| 67 | - case AT45DB161: | |
| 68 | - dataflash_info[i].Device.pages_number = 4096; | |
| 69 | - dataflash_info[i].Device.pages_size = 528; | |
| 70 | - dataflash_info[i].Device.page_offset = 10; | |
| 71 | - dataflash_info[i].Device.byte_mask = 0x300; | |
| 72 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 73 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 74 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 75 | - dataflash_info[i].id = dfcode; | |
| 76 | - found[i] += dfcode; | |
| 77 | - break; | |
| 78 | - | |
| 79 | - case AT45DB321: | |
| 80 | - dataflash_info[i].Device.pages_number = 8192; | |
| 81 | - dataflash_info[i].Device.pages_size = 528; | |
| 82 | - dataflash_info[i].Device.page_offset = 10; | |
| 83 | - dataflash_info[i].Device.byte_mask = 0x300; | |
| 84 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 85 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 86 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 87 | - dataflash_info[i].id = dfcode; | |
| 88 | - found[i] += dfcode; | |
| 89 | - break; | |
| 90 | - | |
| 91 | - case AT45DB642: | |
| 92 | - dataflash_info[i].Device.pages_number = 8192; | |
| 93 | - dataflash_info[i].Device.pages_size = 1056; | |
| 94 | - dataflash_info[i].Device.page_offset = 11; | |
| 95 | - dataflash_info[i].Device.byte_mask = 0x700; | |
| 96 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 97 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 98 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 99 | - dataflash_info[i].id = dfcode; | |
| 100 | - found[i] += dfcode; | |
| 101 | - break; | |
| 102 | - | |
| 103 | - case AT45DB128: | |
| 104 | - dataflash_info[i].Device.pages_number = 16384; | |
| 105 | - dataflash_info[i].Device.pages_size = 1056; | |
| 106 | - dataflash_info[i].Device.page_offset = 11; | |
| 107 | - dataflash_info[i].Device.byte_mask = 0x700; | |
| 108 | - dataflash_info[i].Device.cs = cs[i].cs; | |
| 109 | - dataflash_info[i].Desc.DataFlash_state = IDLE; | |
| 110 | - dataflash_info[i].logical_address = cs[i].addr; | |
| 111 | - dataflash_info[i].id = dfcode; | |
| 112 | - found[i] += dfcode; | |
| 113 | - break; | |
| 114 | - | |
| 115 | - default: | |
| 116 | - dfcode = 0; | |
| 117 | - break; | |
| 118 | - } | |
| 119 | - /* set the last area end to the dataflash size*/ | |
| 120 | - dataflash_info[i].end_address = | |
| 121 | - (dataflash_info[i].Device.pages_number * | |
| 122 | - dataflash_info[i].Device.pages_size) - 1; | |
| 123 | - | |
| 124 | - part = 0; | |
| 125 | - /* set the area addresses */ | |
| 126 | - for(j = 0; j < NB_DATAFLASH_AREA; j++) { | |
| 127 | - if(found[i]!=0) { | |
| 128 | - dataflash_info[i].Device.area_list[j].start = | |
| 129 | - area_list[part].start + | |
| 130 | - dataflash_info[i].logical_address; | |
| 131 | - if(area_list[part].end == 0xffffffff) { | |
| 132 | - dataflash_info[i].Device.area_list[j].end = | |
| 133 | - dataflash_info[i].end_address + | |
| 134 | - dataflash_info[i].logical_address; | |
| 135 | - } else { | |
| 136 | - dataflash_info[i].Device.area_list[j].end = | |
| 137 | - area_list[part].end + | |
| 138 | - dataflash_info[i].logical_address; | |
| 139 | - } | |
| 140 | - protected = area_list[part].protected; | |
| 141 | - /* Set the environment according to the label...*/ | |
| 142 | - if(protected == FLAG_PROTECT_INVALID) { | |
| 143 | - dataflash_info[i].Device.area_list[j].protected = | |
| 144 | - FLAG_PROTECT_INVALID; | |
| 145 | - } else { | |
| 146 | - dataflash_info[i].Device.area_list[j].protected = | |
| 147 | - protected; | |
| 148 | - } | |
| 149 | - strcpy((char*)(dataflash_info[i].Device.area_list[j].label), | |
| 150 | - (const char *)area_list[part].label); | |
| 151 | - } | |
| 152 | - part++; | |
| 153 | - } | |
| 154 | - } | |
| 155 | - return found[0]; | |
| 156 | -} | |
| 157 | - | |
| 158 | -void AT91F_Dataflashenv_set(void) | |
| 159 | -{ | |
| 160 | - int i, j; | |
| 161 | - int part; | |
| 162 | - unsigned char env; | |
| 163 | - unsigned char s[32]; /* Will fit a long int in hex */ | |
| 164 | - unsigned long start; | |
| 165 | - | |
| 166 | - for (i = 0, part= 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) { | |
| 167 | - for(j = 0; j < NB_DATAFLASH_AREA; j++) { | |
| 168 | - env = area_list[part].setenv; | |
| 169 | - /* Set the environment according to the label...*/ | |
| 170 | - if((env & FLAG_SETENV) == FLAG_SETENV) { | |
| 171 | - start = dataflash_info[i].Device.area_list[j].start; | |
| 172 | - sprintf((char *)s, "%lX", start); | |
| 173 | - env_set((char *)area_list[part].label, | |
| 174 | - (char *)s); | |
| 175 | - } | |
| 176 | - part++; | |
| 177 | - } | |
| 178 | - } | |
| 179 | -} | |
| 180 | - | |
| 181 | -void dataflash_print_info (void) | |
| 182 | -{ | |
| 183 | - int i, j; | |
| 184 | - | |
| 185 | - for (i = 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) { | |
| 186 | - if (dataflash_info[i].id != 0) { | |
| 187 | - printf("DataFlash:"); | |
| 188 | - switch (dataflash_info[i].id) { | |
| 189 | - case AT45DB021: | |
| 190 | - printf("AT45DB021\n"); | |
| 191 | - break; | |
| 192 | - case AT45DB161: | |
| 193 | - printf("AT45DB161\n"); | |
| 194 | - break; | |
| 195 | - | |
| 196 | - case AT45DB321: | |
| 197 | - printf("AT45DB321\n"); | |
| 198 | - break; | |
| 199 | - | |
| 200 | - case AT45DB642: | |
| 201 | - printf("AT45DB642\n"); | |
| 202 | - break; | |
| 203 | - case AT45DB128: | |
| 204 | - printf("AT45DB128\n"); | |
| 205 | - break; | |
| 206 | - } | |
| 207 | - | |
| 208 | - printf("Nb pages: %6d\n" | |
| 209 | - "Page Size: %6d\n" | |
| 210 | - "Size=%8d bytes\n" | |
| 211 | - "Logical address: 0x%08X\n", | |
| 212 | - (unsigned int) dataflash_info[i].Device.pages_number, | |
| 213 | - (unsigned int) dataflash_info[i].Device.pages_size, | |
| 214 | - (unsigned int) dataflash_info[i].Device.pages_number * | |
| 215 | - dataflash_info[i].Device.pages_size, | |
| 216 | - (unsigned int) dataflash_info[i].logical_address); | |
| 217 | - for (j = 0; j < NB_DATAFLASH_AREA; j++) { | |
| 218 | - switch(dataflash_info[i].Device.area_list[j].protected) { | |
| 219 | - case FLAG_PROTECT_SET: | |
| 220 | - case FLAG_PROTECT_CLEAR: | |
| 221 | - printf("Area %i:\t%08lX to %08lX %s", j, | |
| 222 | - dataflash_info[i].Device.area_list[j].start, | |
| 223 | - dataflash_info[i].Device.area_list[j].end, | |
| 224 | - (dataflash_info[i].Device.area_list[j].protected==FLAG_PROTECT_SET) ? "(RO)" : " "); | |
| 225 | - printf(" %s\n", dataflash_info[i].Device.area_list[j].label); | |
| 226 | - break; | |
| 227 | - case FLAG_PROTECT_INVALID: | |
| 228 | - break; | |
| 229 | - } | |
| 230 | - } | |
| 231 | - } | |
| 232 | - } | |
| 233 | -} | |
| 234 | - | |
| 235 | -/*---------------------------------------------------------------------------*/ | |
| 236 | -/* Function Name : AT91F_DataflashSelect */ | |
| 237 | -/* Object : Select the correct device */ | |
| 238 | -/*---------------------------------------------------------------------------*/ | |
| 239 | -AT91PS_DataFlash AT91F_DataflashSelect (AT91PS_DataFlash pFlash, | |
| 240 | - unsigned long *addr) | |
| 241 | -{ | |
| 242 | - char addr_valid = 0; | |
| 243 | - int i; | |
| 244 | - | |
| 245 | - for (i = 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) | |
| 246 | - if ( dataflash_info[i].id | |
| 247 | - && ((((int) *addr) & 0xFF000000) == | |
| 248 | - dataflash_info[i].logical_address)) { | |
| 249 | - addr_valid = 1; | |
| 250 | - break; | |
| 251 | - } | |
| 252 | - if (!addr_valid) { | |
| 253 | - pFlash = (AT91PS_DataFlash) 0; | |
| 254 | - return pFlash; | |
| 255 | - } | |
| 256 | - pFlash->pDataFlashDesc = &(dataflash_info[i].Desc); | |
| 257 | - pFlash->pDevice = &(dataflash_info[i].Device); | |
| 258 | - *addr -= dataflash_info[i].logical_address; | |
| 259 | - return (pFlash); | |
| 260 | -} | |
| 261 | - | |
| 262 | -/*---------------------------------------------------------------------------*/ | |
| 263 | -/* Function Name : addr_dataflash */ | |
| 264 | -/* Object : Test if address is valid */ | |
| 265 | -/*---------------------------------------------------------------------------*/ | |
| 266 | -int addr_dataflash (unsigned long addr) | |
| 267 | -{ | |
| 268 | - int addr_valid = 0; | |
| 269 | - int i; | |
| 270 | - | |
| 271 | - for (i = 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) { | |
| 272 | - if ((((int) addr) & 0xFF000000) == | |
| 273 | - dataflash_info[i].logical_address) { | |
| 274 | - addr_valid = 1; | |
| 275 | - break; | |
| 276 | - } | |
| 277 | - } | |
| 278 | - | |
| 279 | - return addr_valid; | |
| 280 | -} | |
| 281 | - | |
| 282 | -/*---------------------------------------------------------------------------*/ | |
| 283 | -/* Function Name : size_dataflash */ | |
| 284 | -/* Object : Test if address is valid regarding the size */ | |
| 285 | -/*---------------------------------------------------------------------------*/ | |
| 286 | -int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, | |
| 287 | - unsigned long size) | |
| 288 | -{ | |
| 289 | - /* is outside the dataflash */ | |
| 290 | - if (((int)addr & 0x0FFFFFFF) > (pdataFlash->pDevice->pages_size * | |
| 291 | - pdataFlash->pDevice->pages_number)) return 0; | |
| 292 | - /* is too large for the dataflash */ | |
| 293 | - if (size > ((pdataFlash->pDevice->pages_size * | |
| 294 | - pdataFlash->pDevice->pages_number) - | |
| 295 | - ((int)addr & 0x0FFFFFFF))) return 0; | |
| 296 | - | |
| 297 | - return 1; | |
| 298 | -} | |
| 299 | - | |
| 300 | -/*---------------------------------------------------------------------------*/ | |
| 301 | -/* Function Name : prot_dataflash */ | |
| 302 | -/* Object : Test if destination area is protected */ | |
| 303 | -/*---------------------------------------------------------------------------*/ | |
| 304 | -int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr) | |
| 305 | -{ | |
| 306 | - int area; | |
| 307 | - | |
| 308 | - /* find area */ | |
| 309 | - for (area = 0; area < NB_DATAFLASH_AREA; area++) { | |
| 310 | - if ((addr >= pdataFlash->pDevice->area_list[area].start) && | |
| 311 | - (addr < pdataFlash->pDevice->area_list[area].end)) | |
| 312 | - break; | |
| 313 | - } | |
| 314 | - if (area == NB_DATAFLASH_AREA) | |
| 315 | - return -1; | |
| 316 | - | |
| 317 | - /*test protection value*/ | |
| 318 | - if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_SET) | |
| 319 | - return 0; | |
| 320 | - if (pdataFlash->pDevice->area_list[area].protected == FLAG_PROTECT_INVALID) | |
| 321 | - return 0; | |
| 322 | - | |
| 323 | - return 1; | |
| 324 | -} | |
| 325 | - | |
| 326 | -/*--------------------------------------------------------------------------*/ | |
| 327 | -/* Function Name : dataflash_real_protect */ | |
| 328 | -/* Object : protect/unprotect area */ | |
| 329 | -/*--------------------------------------------------------------------------*/ | |
| 330 | -int dataflash_real_protect (int flag, unsigned long start_addr, | |
| 331 | - unsigned long end_addr) | |
| 332 | -{ | |
| 333 | - int i,j, area1, area2, addr_valid = 0; | |
| 334 | - | |
| 335 | - /* find dataflash */ | |
| 336 | - for (i = 0; i < CONFIG_SYS_MAX_DATAFLASH_BANKS; i++) { | |
| 337 | - if ((((int) start_addr) & 0xF0000000) == | |
| 338 | - dataflash_info[i].logical_address) { | |
| 339 | - addr_valid = 1; | |
| 340 | - break; | |
| 341 | - } | |
| 342 | - } | |
| 343 | - if (!addr_valid) { | |
| 344 | - return -1; | |
| 345 | - } | |
| 346 | - /* find start area */ | |
| 347 | - for (area1 = 0; area1 < NB_DATAFLASH_AREA; area1++) { | |
| 348 | - if (start_addr == dataflash_info[i].Device.area_list[area1].start) | |
| 349 | - break; | |
| 350 | - } | |
| 351 | - if (area1 == NB_DATAFLASH_AREA) return -1; | |
| 352 | - /* find end area */ | |
| 353 | - for (area2 = 0; area2 < NB_DATAFLASH_AREA; area2++) { | |
| 354 | - if (end_addr == dataflash_info[i].Device.area_list[area2].end) | |
| 355 | - break; | |
| 356 | - } | |
| 357 | - if (area2 == NB_DATAFLASH_AREA) | |
| 358 | - return -1; | |
| 359 | - | |
| 360 | - /*set protection value*/ | |
| 361 | - for(j = area1; j < area2 + 1 ; j++) | |
| 362 | - if(dataflash_info[i].Device.area_list[j].protected | |
| 363 | - != FLAG_PROTECT_INVALID) { | |
| 364 | - if (flag == 0) { | |
| 365 | - dataflash_info[i].Device.area_list[j].protected | |
| 366 | - = FLAG_PROTECT_CLEAR; | |
| 367 | - } else { | |
| 368 | - dataflash_info[i].Device.area_list[j].protected | |
| 369 | - = FLAG_PROTECT_SET; | |
| 370 | - } | |
| 371 | - } | |
| 372 | - | |
| 373 | - return (area2 - area1 + 1); | |
| 374 | -} | |
| 375 | - | |
| 376 | -/*---------------------------------------------------------------------------*/ | |
| 377 | -/* Function Name : read_dataflash */ | |
| 378 | -/* Object : dataflash memory read */ | |
| 379 | -/*---------------------------------------------------------------------------*/ | |
| 380 | -int read_dataflash (unsigned long addr, unsigned long size, char *result) | |
| 381 | -{ | |
| 382 | - unsigned long AddrToRead = addr; | |
| 383 | - AT91PS_DataFlash pFlash = &DataFlashInst; | |
| 384 | - | |
| 385 | - pFlash = AT91F_DataflashSelect (pFlash, &AddrToRead); | |
| 386 | - | |
| 387 | - if (pFlash == 0) | |
| 388 | - return ERR_UNKNOWN_FLASH_TYPE; | |
| 389 | - | |
| 390 | - if (size_dataflash(pFlash,addr,size) == 0) | |
| 391 | - return ERR_INVAL; | |
| 392 | - | |
| 393 | - return (AT91F_DataFlashRead (pFlash, AddrToRead, size, result)); | |
| 394 | -} | |
| 395 | - | |
| 396 | -/*---------------------------------------------------------------------------*/ | |
| 397 | -/* Function Name : write_dataflash */ | |
| 398 | -/* Object : write a block in dataflash */ | |
| 399 | -/*---------------------------------------------------------------------------*/ | |
| 400 | -int write_dataflash (unsigned long addr_dest, unsigned long addr_src, | |
| 401 | - unsigned long size) | |
| 402 | -{ | |
| 403 | - unsigned long AddrToWrite = addr_dest; | |
| 404 | - AT91PS_DataFlash pFlash = &DataFlashInst; | |
| 405 | - | |
| 406 | - pFlash = AT91F_DataflashSelect (pFlash, &AddrToWrite); | |
| 407 | - | |
| 408 | - if (pFlash == 0) | |
| 409 | - return ERR_UNKNOWN_FLASH_TYPE; | |
| 410 | - | |
| 411 | - if (size_dataflash(pFlash,addr_dest,size) == 0) | |
| 412 | - return ERR_INVAL; | |
| 413 | - | |
| 414 | - if (prot_dataflash(pFlash,addr_dest) == 0) | |
| 415 | - return ERR_PROTECTED; | |
| 416 | - | |
| 417 | - if (AddrToWrite == -1) | |
| 418 | - return -1; | |
| 419 | - | |
| 420 | - return AT91F_DataFlashWrite (pFlash, (uchar *)addr_src, | |
| 421 | - AddrToWrite, size); | |
| 422 | -} | |
| 423 | - | |
| 424 | -void dataflash_perror (int err) | |
| 425 | -{ | |
| 426 | - switch (err) { | |
| 427 | - case ERR_OK: | |
| 428 | - break; | |
| 429 | - case ERR_TIMOUT: | |
| 430 | - printf("Timeout writing to DataFlash\n"); | |
| 431 | - break; | |
| 432 | - case ERR_PROTECTED: | |
| 433 | - printf("Can't write to protected/invalid DataFlash sectors\n"); | |
| 434 | - break; | |
| 435 | - case ERR_INVAL: | |
| 436 | - printf("Outside available DataFlash\n"); | |
| 437 | - break; | |
| 438 | - case ERR_UNKNOWN_FLASH_TYPE: | |
| 439 | - printf("Unknown Type of DataFlash\n"); | |
| 440 | - break; | |
| 441 | - case ERR_PROG_ERROR: | |
| 442 | - printf("General DataFlash Programming Error\n"); | |
| 443 | - break; | |
| 444 | - default: | |
| 445 | - printf("%s[%d] FIXME: rc=%d\n", __FILE__, __LINE__, err); | |
| 446 | - break; | |
| 447 | - } | |
| 448 | -} |
include/dataflash.h
| 1 | -/* | |
| 2 | - * (C) Copyright 2003 | |
| 3 | - * Data Flash Atmel Description File | |
| 4 | - * Author : Hamid Ikdoumi (Atmel) | |
| 5 | - * | |
| 6 | - * SPDX-License-Identifier: GPL-2.0+ | |
| 7 | - */ | |
| 8 | - | |
| 9 | -/* File Name : dataflash.h */ | |
| 10 | -/* Object : Data Flash Atmel Description File */ | |
| 11 | -/* Translator : */ | |
| 12 | -/* */ | |
| 13 | -/* 1.0 03/04/01 HI : Creation */ | |
| 14 | -/* 1.2 20/10/02 FB : Adapatation Service and Lib v3 */ | |
| 15 | -/*----------------------------------------------------------------------*/ | |
| 16 | - | |
| 17 | -#ifndef _DataFlash_h | |
| 18 | -#define _DataFlash_h | |
| 19 | - | |
| 20 | - | |
| 21 | -#include "config.h" | |
| 22 | - | |
| 23 | -/*number of protected area*/ | |
| 24 | -#define NB_DATAFLASH_AREA 5 | |
| 25 | - | |
| 26 | -#ifndef CONFIG_MTD_NOR_FLASH | |
| 27 | - | |
| 28 | -/*----------------------------------------------------------------------- | |
| 29 | - * return codes from flash_write(): | |
| 30 | - */ | |
| 31 | -# define ERR_OK 0 | |
| 32 | -# define ERR_TIMOUT 1 | |
| 33 | -# define ERR_NOT_ERASED 2 | |
| 34 | -# define ERR_PROTECTED 4 | |
| 35 | -# define ERR_INVAL 8 | |
| 36 | -# define ERR_ALIGN 16 | |
| 37 | -# define ERR_UNKNOWN_FLASH_VENDOR 32 | |
| 38 | -# define ERR_UNKNOWN_FLASH_TYPE 64 | |
| 39 | -# define ERR_PROG_ERROR 128 | |
| 40 | - | |
| 41 | -/*----------------------------------------------------------------------- | |
| 42 | - * Protection Flags for flash_protect(): | |
| 43 | - */ | |
| 44 | -# define FLAG_PROTECT_SET 0x01 | |
| 45 | -# define FLAG_PROTECT_CLEAR 0x02 | |
| 46 | -# define FLAG_PROTECT_INVALID 0x03 | |
| 47 | - | |
| 48 | -/*----------------------------------------------------------------------- | |
| 49 | - * Set Environment according to label: | |
| 50 | - */ | |
| 51 | -# define FLAG_SETENV 0x80 | |
| 52 | -#endif /* CONFIG_MTD_NOR_FLASH */ | |
| 53 | - | |
| 54 | -/*define the area structure*/ | |
| 55 | -typedef struct { | |
| 56 | - unsigned long start; | |
| 57 | - unsigned long end; | |
| 58 | - unsigned char protected; | |
| 59 | - unsigned char setenv; | |
| 60 | - unsigned char label[20]; | |
| 61 | -} dataflash_protect_t; | |
| 62 | - | |
| 63 | -typedef unsigned int AT91S_DataFlashStatus; | |
| 64 | - | |
| 65 | -/*----------------------------------------------------------------------*/ | |
| 66 | -/* DataFlash Structures */ | |
| 67 | -/*----------------------------------------------------------------------*/ | |
| 68 | - | |
| 69 | -/*---------------------------------------------*/ | |
| 70 | -/* DataFlash Descriptor Structure Definition */ | |
| 71 | -/*---------------------------------------------*/ | |
| 72 | -typedef struct _AT91S_DataflashDesc { | |
| 73 | - unsigned char *tx_cmd_pt; | |
| 74 | - unsigned int tx_cmd_size; | |
| 75 | - unsigned char *rx_cmd_pt; | |
| 76 | - unsigned int rx_cmd_size; | |
| 77 | - unsigned char *tx_data_pt; | |
| 78 | - unsigned int tx_data_size; | |
| 79 | - unsigned char *rx_data_pt; | |
| 80 | - unsigned int rx_data_size; | |
| 81 | - volatile unsigned char state; | |
| 82 | - volatile unsigned char DataFlash_state; | |
| 83 | - unsigned char command[8]; | |
| 84 | -} AT91S_DataflashDesc, *AT91PS_DataflashDesc; | |
| 85 | - | |
| 86 | -/*---------------------------------------------*/ | |
| 87 | -/* DataFlash device definition structure */ | |
| 88 | -/*---------------------------------------------*/ | |
| 89 | -typedef struct _AT91S_Dataflash { | |
| 90 | - int pages_number; /* dataflash page number */ | |
| 91 | - int pages_size; /* dataflash page size */ | |
| 92 | - int page_offset; /* page offset in command */ | |
| 93 | - int byte_mask; /* byte mask in command */ | |
| 94 | - int cs; | |
| 95 | - dataflash_protect_t area_list[NB_DATAFLASH_AREA]; /* area protection status */ | |
| 96 | -} AT91S_DataflashFeatures, *AT91PS_DataflashFeatures; | |
| 97 | - | |
| 98 | -/*---------------------------------------------*/ | |
| 99 | -/* DataFlash Structure Definition */ | |
| 100 | -/*---------------------------------------------*/ | |
| 101 | -typedef struct _AT91S_DataFlash { | |
| 102 | - AT91PS_DataflashDesc pDataFlashDesc; /* dataflash descriptor */ | |
| 103 | - AT91PS_DataflashFeatures pDevice; /* Pointer on a dataflash features array */ | |
| 104 | -} AT91S_DataFlash, *AT91PS_DataFlash; | |
| 105 | - | |
| 106 | - | |
| 107 | -typedef struct _AT91S_DATAFLASH_INFO { | |
| 108 | - | |
| 109 | - AT91S_DataflashDesc Desc; | |
| 110 | - AT91S_DataflashFeatures Device; /* Pointer on a dataflash features array */ | |
| 111 | - unsigned long logical_address; | |
| 112 | - unsigned long end_address; | |
| 113 | - unsigned int id; /* device id */ | |
| 114 | -} AT91S_DATAFLASH_INFO, *AT91PS_DATAFLASH_INFO; | |
| 115 | - | |
| 116 | -struct dataflash_addr { | |
| 117 | - unsigned long addr; | |
| 118 | - int cs; | |
| 119 | -}; | |
| 120 | -/*-------------------------------------------------------------------------------------------------*/ | |
| 121 | -#define AT45DB161 0x2c | |
| 122 | -#define AT45DB021 0x14 | |
| 123 | -#define AT45DB081 0x24 | |
| 124 | -#define AT45DB321 0x34 | |
| 125 | -#define AT45DB642 0x3c | |
| 126 | -#define AT45DB128 0x10 | |
| 127 | -#define PAGES_PER_BLOCK 8 | |
| 128 | - | |
| 129 | -#define AT91C_DATAFLASH_TIMEOUT 10000 /* For AT91F_DataFlashWaitReady */ | |
| 130 | - | |
| 131 | -/* DataFlash return value */ | |
| 132 | -#define DATAFLASH_BUSY 0x00 | |
| 133 | -#define DATAFLASH_OK 0x01 | |
| 134 | -#define DATAFLASH_ERROR 0x02 | |
| 135 | -#define DATAFLASH_MEMORY_OVERFLOW 0x03 | |
| 136 | -#define DATAFLASH_BAD_COMMAND 0x04 | |
| 137 | -#define DATAFLASH_BAD_ADDRESS 0x05 | |
| 138 | - | |
| 139 | - | |
| 140 | -/* Driver State */ | |
| 141 | -#define IDLE 0x0 | |
| 142 | -#define BUSY 0x1 | |
| 143 | -#define ERROR 0x2 | |
| 144 | - | |
| 145 | -/* DataFlash Driver State */ | |
| 146 | -#define GET_STATUS 0x0F | |
| 147 | - | |
| 148 | -/*-------------------------------------------------------------------------------------------------*/ | |
| 149 | -/* Command Definition */ | |
| 150 | -/*-------------------------------------------------------------------------------------------------*/ | |
| 151 | - | |
| 152 | -/* READ COMMANDS */ | |
| 153 | -#define DB_CONTINUOUS_ARRAY_READ 0xE8 /* Continuous array read */ | |
| 154 | -#define DB_BURST_ARRAY_READ 0xE8 /* Burst array read */ | |
| 155 | -#define DB_PAGE_READ 0xD2 /* Main memory page read */ | |
| 156 | -#define DB_BUF1_READ 0xD4 /* Buffer 1 read */ | |
| 157 | -#define DB_BUF2_READ 0xD6 /* Buffer 2 read */ | |
| 158 | -#define DB_STATUS 0xD7 /* Status Register */ | |
| 159 | - | |
| 160 | -/* PROGRAM and ERASE COMMANDS */ | |
| 161 | -#define DB_BUF1_WRITE 0x84 /* Buffer 1 write */ | |
| 162 | -#define DB_BUF2_WRITE 0x87 /* Buffer 2 write */ | |
| 163 | -#define DB_BUF1_PAGE_ERASE_PGM 0x83 /* Buffer 1 to main memory page program with built-In erase */ | |
| 164 | -#define DB_BUF1_PAGE_ERASE_FASTPGM 0x93 /* Buffer 1 to main memory page program with built-In erase, Fast program */ | |
| 165 | -#define DB_BUF2_PAGE_ERASE_PGM 0x86 /* Buffer 2 to main memory page program with built-In erase */ | |
| 166 | -#define DB_BUF2_PAGE_ERASE_FASTPGM 0x96 /* Buffer 1 to main memory page program with built-In erase, Fast program */ | |
| 167 | -#define DB_BUF1_PAGE_PGM 0x88 /* Buffer 1 to main memory page program without built-In erase */ | |
| 168 | -#define DB_BUF1_PAGE_FASTPGM 0x98 /* Buffer 1 to main memory page program without built-In erase, Fast program */ | |
| 169 | -#define DB_BUF2_PAGE_PGM 0x89 /* Buffer 2 to main memory page program without built-In erase */ | |
| 170 | -#define DB_BUF2_PAGE_FASTPGM 0x99 /* Buffer 1 to main memory page program without built-In erase, Fast program */ | |
| 171 | -#define DB_PAGE_ERASE 0x81 /* Page Erase */ | |
| 172 | -#define DB_BLOCK_ERASE 0x50 /* Block Erase */ | |
| 173 | -#define DB_PAGE_PGM_BUF1 0x82 /* Main memory page through buffer 1 */ | |
| 174 | -#define DB_PAGE_FASTPGM_BUF1 0x92 /* Main memory page through buffer 1, Fast program */ | |
| 175 | -#define DB_PAGE_PGM_BUF2 0x85 /* Main memory page through buffer 2 */ | |
| 176 | -#define DB_PAGE_FastPGM_BUF2 0x95 /* Main memory page through buffer 2, Fast program */ | |
| 177 | - | |
| 178 | -/* ADDITIONAL COMMANDS */ | |
| 179 | -#define DB_PAGE_2_BUF1_TRF 0x53 /* Main memory page to buffer 1 transfert */ | |
| 180 | -#define DB_PAGE_2_BUF2_TRF 0x55 /* Main memory page to buffer 2 transfert */ | |
| 181 | -#define DB_PAGE_2_BUF1_CMP 0x60 /* Main memory page to buffer 1 compare */ | |
| 182 | -#define DB_PAGE_2_BUF2_CMP 0x61 /* Main memory page to buffer 2 compare */ | |
| 183 | -#define DB_AUTO_PAGE_PGM_BUF1 0x58 /* Auto page rewrite throught buffer 1 */ | |
| 184 | -#define DB_AUTO_PAGE_PGM_BUF2 0x59 /* Auto page rewrite throught buffer 2 */ | |
| 185 | - | |
| 186 | -/*-------------------------------------------------------------------------------------------------*/ | |
| 187 | - | |
| 188 | -extern int size_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr, unsigned long size); | |
| 189 | -extern int prot_dataflash (AT91PS_DataFlash pdataFlash, unsigned long addr); | |
| 190 | -extern int addr2ram(ulong addr); | |
| 191 | -extern int dataflash_real_protect (int flag, unsigned long start_addr, unsigned long end_addr); | |
| 192 | -extern int addr_dataflash (unsigned long addr); | |
| 193 | -extern int read_dataflash (unsigned long addr, unsigned long size, char *result); | |
| 194 | -extern int write_dataflash(unsigned long addr_dest, unsigned long addr_src, | |
| 195 | - unsigned long size); | |
| 196 | -extern int AT91F_DataflashInit(void); | |
| 197 | - | |
| 198 | -extern void dataflash_print_info (void); | |
| 199 | -extern void dataflash_perror (int err); | |
| 200 | -extern void AT91F_Dataflashenv_set(void); | |
| 201 | - | |
| 202 | -extern struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS]; | |
| 203 | -extern dataflash_protect_t area_list[NB_DATAFLASH_AREA]; | |
| 204 | -extern AT91S_DATAFLASH_INFO dataflash_info[]; | |
| 205 | -#endif |
scripts/config_whitelist.txt
| ... | ... | @@ -875,7 +875,6 @@ |
| 875 | 875 | CONFIG_H264_FREQ |
| 876 | 876 | CONFIG_H8300 |
| 877 | 877 | CONFIG_HARD_SPI |
| 878 | -CONFIG_HAS_DATAFLASH | |
| 879 | 878 | CONFIG_HAS_ETH0 |
| 880 | 879 | CONFIG_HAS_ETH1 |
| 881 | 880 | CONFIG_HAS_ETH2 |
| ... | ... | @@ -2609,9 +2608,6 @@ |
| 2609 | 2608 | CONFIG_SYS_DA850_PLL1_PLLM |
| 2610 | 2609 | CONFIG_SYS_DA850_PLL1_POSTDIV |
| 2611 | 2610 | CONFIG_SYS_DA850_SYSCFG_SUSPSRC |
| 2612 | -CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1 | |
| 2613 | -CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS2 | |
| 2614 | -CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3 | |
| 2615 | 2611 | CONFIG_SYS_DAVINCI_EMAC_PHY_COUNT |
| 2616 | 2612 | CONFIG_SYS_DAVINCI_I2C_SLAVE |
| 2617 | 2613 | CONFIG_SYS_DAVINCI_I2C_SLAVE1 |
| ... | ... | @@ -3721,7 +3717,6 @@ |
| 3721 | 3717 | CONFIG_SYS_MATRIX_EBICSA_VAL |
| 3722 | 3718 | CONFIG_SYS_MATRIX_MCFG_REMAP |
| 3723 | 3719 | CONFIG_SYS_MAXARGS |
| 3724 | -CONFIG_SYS_MAX_DATAFLASH_BANKS | |
| 3725 | 3720 | CONFIG_SYS_MAX_DDR_BAT_SIZE |
| 3726 | 3721 | CONFIG_SYS_MAX_FLASH_BANKS |
| 3727 | 3722 | CONFIG_SYS_MAX_FLASH_BANKS_DETECT |