2 * Gigadevice SPI flash driver
3 * Copyright 2013, Samsung Electronics Co., Ltd.
4 * Author: Banajit Goswami <banajit.g@samsung.com>
6 * SPDX-License-Identifier: GPL-2.0+
11 #include <spi_flash.h>
13 #include "spi_flash_internal.h"
15 struct gigadevice_spi_flash_params {
21 static const struct gigadevice_spi_flash_params gigadevice_spi_flash_table[] = {
34 struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode)
36 const struct gigadevice_spi_flash_params *params;
37 struct spi_flash *flash;
40 for (i = 0; i < ARRAY_SIZE(gigadevice_spi_flash_table); i++) {
41 params = &gigadevice_spi_flash_table[i];
42 if (params->id == ((idcode[1] << 8) | idcode[2]))
46 if (i == ARRAY_SIZE(gigadevice_spi_flash_table)) {
47 debug("SF: Unsupported Gigadevice ID %02x%02x\n",
48 idcode[1], idcode[2]);
52 flash = spi_flash_alloc_base(spi, params->name);
54 debug("SF: Failed to allocate memory\n");
58 flash->page_size = 256;
59 /* sector_size = page_size * pages_per_sector */
60 flash->sector_size = flash->page_size * 16;
61 /* size = sector_size * sector_per_block * number of blocks */
62 flash->size = flash->sector_size * 16 * params->nr_blocks;