1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

53 Commits

Author SHA1 Message Date
Benjamin Valentin
1e1244042e drivers/mtd_spi_nor: make use of busy_wait() 2024-01-15 14:56:35 +01:00
Benjamin Valentin
ea105d34ec drivers/mtd_spi_nor: drop .write()
The old .write() function is only used as a fall-back if .write_page()
is not implemented.
We can drop it.
2023-12-13 16:50:41 +01:00
Benjamin Valentin
4f2f412c39 drivers/mtd_spi_nor: improve fallback when no timer is used 2023-08-31 15:22:33 +02:00
Benjamin Valentin
6e290fbace drivers/mtd_spi_nor: fix init when only ztimer_msec is used 2023-08-31 14:37:55 +02:00
Joshua DeWeese
ff450cd7f4 drivers/mtd_spi_nor: fix hang
This patch releases the SPI bus when the memory devices is not found.
This frees the bus for other devices to use the bus. It also allows
future attempts to init the device.
2023-05-22 12:22:01 -04:00
Joshua DeWeese
33cb2f489b drivers/mtd_spi_nor: fix debug msg
This patch adds some missing newline chars to debug output ensuring the
lines get flushed and don't run together.
2023-05-22 12:21:59 -04:00
Marian Buschsieweke
86fdbd7054
core/lib: Add macros/utils.h header
The macros CONCAT(), MIN(), and MAX() are defined over and over again in
RIOT's code base. This de-duplicates the code by moving the macros to a
common place.
2023-01-07 09:47:44 +01:00
chrysn
dc7bc9f854
Merge pull request #17683 from chrysn-pull-requests/mtd-granularity
mtd: Introduce write granularity
2022-05-20 11:52:03 +02:00
Marian Buschsieweke
c2e029b427
drivers/mtd_spi_nor: fix off by one bug
The boolean expression to detect when 32 bit address mode are needed
was off by one, this fixes the issue.
2022-04-13 17:24:39 +02:00
chrysn
88f4f7c6e8 drivers/mtd_spi_nor: Storage is byte-writable
See-Also: https://github.com/RIOT-OS/RIOT/pull/17683#discussion_r815362737
2022-03-31 10:58:52 +02:00
Karl Fessel
f8607ecc28 driver/mtd_spi_nor: clearup sleep timming 2022-03-30 11:58:58 +02:00
Francisco
c078fdeb70
Merge pull request #17836 from fjmolinas/pr_xtimer_backoff_cleanups
drivers/mtd_spi_nor: add ztimer_usec alternative
2022-03-28 21:39:50 +02:00
Francisco Molina
3017020bc9 drivers/mtd_spi_nor: add ztimer_usec alternative 2022-03-28 09:08:31 +02:00
Benjamin Valentin
628855fead drivers/mtd_spi_nor: fix Atmel size calculation
Lower bits of the device ID are not the capacity in bytes but in sectors:

 4 - 4 Mb -> 32k << 4
 5 - 8 Mb -> 32k << 5
 …
2022-03-27 23:01:14 +02:00
Benjamin Valentin
67417ce5a9 drivers/mtd_spi_nor: drop addr_width from mtd_spi_nor_params_t
This is now always determined at run-time.
2022-02-04 12:17:17 +01:00
Benjamin Valentin
4c282a3a41 drivers/mtd_spi_nor: set address width at run-time 2022-02-04 12:17:17 +01:00
Benjamin Valentin
1795785a92 drivers/mtd_spi_nor: add support for Microchip (SST) flash 2022-02-04 12:17:17 +01:00
Benjamin Valentin
8c5b898ed4 drivers/mtd_spi_nor: add ; after DEBUG() 2021-12-08 18:30:43 +01:00
Francisco Molina
14ef09b8b4 drivers/mtd: fix Kconfig dependencies
Currently implementations of the MTD api are selecting the module,
this makes it easy for default backends to be selected. But the
correct modeling is simply selecting the MTD api and then selecting
a backend. BOARDs providing one of the backends can expose this and
then that backend can be selected by default.

There is also currently nothing preventing from using the MTD api
with no backend since a mock backend can easily be provided as is
done in all mtd tests.
2021-09-22 09:22:51 +02:00
Benjamin Valentin
c1348c80a0 drivers/mtd_spi_nor: fix poll on init
The while condition for polling the chip ID is broken, it will always
poll for the max ammount of retries.

Change the condition from `or` to `and` to fix the logic.

fixes #15894
2021-02-11 22:49:42 +01:00
Leandro Lanzieri
4ada286f89
drivers/mtd_spi_nor: add module to Kconfig 2021-01-18 10:42:35 +01:00
Benjamin Valentin
79c75300b1 drivers/mtd_spi_nor: enter 4-byte address mode needs write enable 2020-12-12 18:36:16 +01:00
Bas Stottelaar
e8cadc02d8
Merge pull request #15285 from basilfx/feature/optimize_debug
treewide: more cleanups of ENABLE_DEBUG
2020-11-03 11:13:53 +01:00
Bas Stottelaar
62994dfb16 drivers/*: replace #if ENABLE_DEBUG with IS_ACTIVE 2020-11-02 21:34:12 +01:00
Benjamin Valentin
98f88e849c drivers/mtd_spi_nor: check addr_width with assert() 2020-11-02 21:17:36 +01:00
Benjamin Valentin
53ca0dd1d0 drivers/mtd_spi_nor: define WP and HOLD pin
Hold and WP are not used by the driver, but if they are connected
to the flash they must be driven HIGH to enable writes and not stop
any flash operation.
2020-11-02 21:17:36 +01:00
Benjamin Valentin
dee3ae4ab7 drivers/mtd_spi_nor: enable 32 bit addressing 2020-11-02 17:03:34 +01:00
Benjamin Valentin
fde3026312 drivers/mtd_spi_nor: prevent data corruption on 'sector erase'
There is no difference between 4k erase and sector erase.
But sector erase would previously do `.block_erase` which would not
erase a sector (4k) but a whole block (64k).

Fortunately all boards declare `SPI_NOR_F_SECT_4K` and all file systems
don't try to erase anything smaller, so this was never triggered.

Add an `assert(0)` to crash instead of corrupting data.
2020-10-26 13:48:26 +01:00
Benjamin Valentin
783df5990b drivers/mtd_spi_nor: do address conversion in SPI function 2020-10-26 13:02:09 +01:00
Benjamin Valentin
27cf34d836 drivers/mtd_spi_nor: introduce helper function to get SPI device 2020-10-26 13:02:09 +01:00
Benjamin Valentin
0425325260 drivers/mtd_spi_nor: use single transfer to read JEDEC ID
Just read the JEDEC ID with a single SPI transfer, there can only
be 10 banks.

This makes adaption to QSPI much simpler because now flash functions
don't call the SPI API directly anymore.
2020-10-26 13:02:09 +01:00
Benjamin Valentin
2fa208e5ed drivers/mtd_spi_nor: cleanup
- remove forward declarations
- remove useless do { … } while (0); loops
- insert whitespace
2020-10-26 13:02:09 +01:00
Bas Stottelaar
92b1dfc703 drivers/*: realign ENABLE_DEBUG 2020-10-23 01:26:09 +02:00
Benjamin Valentin
68a47b63e3 drivers/mtd_spi_nor: implement mtd_spi_nor_write_page() 2020-08-18 17:25:39 +02:00
304bce3724
drivers: configure per driver dependency resolution 2020-07-20 14:32:16 +02:00
Benjamin Valentin
50914cbf96 drivers/mtd_spi_nor: move printing of flash debug info
Move printing the flash information after deriving the capacity.
2020-06-09 16:09:40 +02:00
Benjamin Valentin
585928f23d drivers/mtd_spi_nor: derive capacity from JEDEC ID
Most manufacturers (Spansion, Micron & ISSI) just encode the capacity
in the second ID byte.

Old Adesto (Atmel) chips use a different scheme here.
2020-06-09 16:09:40 +02:00
fabian18
a3a1c160ee mtd: Change API to return 0 on success
Returning the number of bytes written/read could return a negative integer
because a uint32_t is expected for the length in read()/write() operations.
2020-05-06 20:24:27 +02:00
Vincent Dupont
c077c07017 drivers/mrd_spi_nor: fix read spanning pages 2020-05-06 16:36:29 +02:00
Francisco Molina
61eecf6fe0
drivers/mtd_spi_nor: power up MTD on init 2020-04-21 11:09:40 +02:00
Francisco Molina
8a256eba12
drivers/mtd_spi_nor: return error on invalid manuf id 2020-04-21 11:09:40 +02:00
dc04b86d1b
mtd_spi_nor: Add wait timings to parameters 2020-03-03 09:49:00 +01:00
2dcf65d942
Merge pull request #13332 from bergzand/pr/mtd_spi_nor/params_struct
mtd_spi_nor: Move const params to separate struct
2020-02-26 09:43:18 +01:00
d40015a41a
mtd_spi_nor: Add chip wait timings to debug output 2020-02-25 11:21:20 +01:00
e5fa8921b3
mtd_spi_nor: Move const params to separate struct 2020-02-11 15:55:41 +01:00
Vincent Dupont
f11fac8811 mtd_spi_nor: remove sleep when waiting for write completed 2020-02-05 16:20:01 +01:00
Vincent Dupont
53b3d1af78 mtd_spi_nor: add 4-byte address flash support 2018-05-14 15:05:24 +02:00
Pieter Willemsen
372cd64547 mtd_spi_nor: run uncrustify 2018-03-05 15:54:29 +01:00
Pieter Willemsen
e4055d5cd5 mtd_spi_nor: make thread safe 2018-03-05 15:54:29 +01:00
Vincent Dupont
063a7835c4 driver/mtd_spi_nor: fix erase with unaligned addresses 2018-02-26 12:22:59 +01:00