mtd: spi-nor: add SNOR_ID() and SNOR_OTP()

After all the preparation, it is now time to introduce the new macros to
specify flashes in our database: SNOR_ID() and SNOR_OTP(). An flash_info
entry might now look like:
    {
        .id = SNOR_ID(0xef, 0x60, 0x16),
        .otp = SNOR_OTP(256, 3, 0x1000, 0x1000),
        .flags = SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB,
    }

Signed-off-by: Michael Walle <mwalle@kernel.org>
Link: https://lore.kernel.org/r/20230807-mtd-flash-info-db-rework-v3-15-e60548861b10@kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
This commit is contained in:
Michael Walle 2023-09-08 12:16:33 +02:00 committed by Tudor Ambarus
parent 83e62ffa7d
commit 3e85be9887
No known key found for this signature in database
GPG Key ID: 4B554F47A58D14E9

View File

@ -561,6 +561,20 @@ struct flash_info {
const struct spi_nor_fixups *fixups;
};
#define SNOR_ID(...) \
(&(const struct spi_nor_id){ \
.bytes = (const u8[]){ __VA_ARGS__ }, \
.len = sizeof((u8[]){ __VA_ARGS__ }), \
})
#define SNOR_OTP(_len, _n_regions, _base, _offset) \
(&(const struct spi_nor_otp_organization){ \
.len = (_len), \
.base = (_base), \
.offset = (_offset), \
.n_regions = (_n_regions), \
})
#define SPI_NOR_ID_2ITEMS(_id) ((_id) >> 8) & 0xff, (_id) & 0xff
#define SPI_NOR_ID_3ITEMS(_id) ((_id) >> 16) & 0xff, SPI_NOR_ID_2ITEMS(_id)