Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Interface to SPI flash |
| 3 | * |
| 4 | * Copyright (C) 2008 Atmel Corporation |
| 5 | * |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * version 2 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Paul Menzel | a8ae1c6 | 2013-02-20 13:21:20 +0100 | [diff] [blame] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 13 | * GNU General Public License for more details. |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 14 | */ |
| 15 | #ifndef _SPI_FLASH_H_ |
| 16 | #define _SPI_FLASH_H_ |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | #include <stddef.h> |
| 20 | #include <console/console.h> |
Zheng Bao | 600784e | 2013-02-07 17:30:23 +0800 | [diff] [blame] | 21 | #include <spi-generic.h> |
Dan Ehrenberg | a5aac76 | 2015-01-08 10:29:19 -0800 | [diff] [blame] | 22 | #include <boot/coreboot_tables.h> |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 23 | |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 24 | struct spi_flash { |
| 25 | struct spi_slave *spi; |
| 26 | |
| 27 | const char *name; |
| 28 | |
| 29 | u32 size; |
| 30 | |
| 31 | u32 sector_size; |
| 32 | |
Dan Ehrenberg | a5aac76 | 2015-01-08 10:29:19 -0800 | [diff] [blame] | 33 | u8 erase_cmd; |
| 34 | |
Duncan Laurie | fb03239 | 2015-01-15 15:28:46 -0800 | [diff] [blame] | 35 | u8 status_cmd; |
| 36 | |
Aaron Durbin | a3565ae | 2015-05-14 14:46:59 -0500 | [diff] [blame] | 37 | /* All callbacks return 0 on success and != 0 on error. */ |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 38 | int (*read)(struct spi_flash *flash, u32 offset, |
| 39 | size_t len, void *buf); |
| 40 | int (*write)(struct spi_flash *flash, u32 offset, |
| 41 | size_t len, const void *buf); |
| 42 | int (*erase)(struct spi_flash *flash, u32 offset, |
| 43 | size_t len); |
Duncan Laurie | fb03239 | 2015-01-15 15:28:46 -0800 | [diff] [blame] | 44 | int (*status)(struct spi_flash *flash, u8 *reg); |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Gabe Black | 1e18735 | 2014-03-27 20:37:03 -0700 | [diff] [blame] | 47 | struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs); |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 48 | |
Dan Ehrenberg | a5aac76 | 2015-01-08 10:29:19 -0800 | [diff] [blame] | 49 | void lb_spi_flash(struct lb_header *header); |
| 50 | |
Stefan Reinauer | 1c56d9b | 2012-05-10 11:27:32 -0700 | [diff] [blame] | 51 | #endif /* _SPI_FLASH_H_ */ |