2012-05-10 20:27:32 +02:00
|
|
|
/*
|
|
|
|
* Interface to SPI flash
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Atmel Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-02-20 13:21:20 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-05-10 20:27:32 +02:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
#ifndef _SPI_FLASH_H_
|
|
|
|
#define _SPI_FLASH_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <console/console.h>
|
2013-02-07 10:30:23 +01:00
|
|
|
#include <spi-generic.h>
|
2015-01-08 19:29:19 +01:00
|
|
|
#include <boot/coreboot_tables.h>
|
2012-05-10 20:27:32 +02:00
|
|
|
|
|
|
|
struct spi_flash {
|
|
|
|
struct spi_slave *spi;
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
u32 size;
|
|
|
|
|
|
|
|
u32 sector_size;
|
|
|
|
|
2015-01-08 19:29:19 +01:00
|
|
|
u8 erase_cmd;
|
|
|
|
|
2015-01-16 00:28:46 +01:00
|
|
|
u8 status_cmd;
|
|
|
|
|
2015-05-14 21:46:59 +02:00
|
|
|
/* All callbacks return 0 on success and != 0 on error. */
|
2012-05-10 20:27:32 +02:00
|
|
|
int (*read)(struct spi_flash *flash, u32 offset,
|
|
|
|
size_t len, void *buf);
|
|
|
|
int (*write)(struct spi_flash *flash, u32 offset,
|
|
|
|
size_t len, const void *buf);
|
|
|
|
int (*erase)(struct spi_flash *flash, u32 offset,
|
|
|
|
size_t len);
|
2015-01-16 00:28:46 +01:00
|
|
|
int (*status)(struct spi_flash *flash, u8 *reg);
|
2012-05-10 20:27:32 +02:00
|
|
|
};
|
|
|
|
|
2014-03-28 04:37:03 +01:00
|
|
|
struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs);
|
2012-05-10 20:27:32 +02:00
|
|
|
|
2015-01-08 19:29:19 +01:00
|
|
|
void lb_spi_flash(struct lb_header *header);
|
|
|
|
|
2012-05-10 20:27:32 +02:00
|
|
|
#endif /* _SPI_FLASH_H_ */
|