Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 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 |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <console/console.h> |
| 17 | #include <spi-generic.h> |
| 18 | #include <spi_flash.h> |
| 19 | |
| 20 | #include "s3_resume.h" |
| 21 | |
| 22 | void spi_SaveS3info(u32 pos, u32 size, u8 *buf, u32 len) |
| 23 | { |
| 24 | struct spi_flash *flash; |
| 25 | |
| 26 | spi_init(); |
| 27 | flash = spi_flash_probe(0, 0); |
| 28 | if (!flash) { |
| 29 | printk(BIOS_DEBUG, "Could not find SPI device\n"); |
| 30 | /* Dont make flow stop. */ |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | flash->spi->rw = SPI_WRITE_FLAG; |
| 35 | spi_claim_bus(flash->spi); |
| 36 | |
| 37 | flash->erase(flash, pos, size); |
| 38 | flash->write(flash, pos, sizeof(len), &len); |
| 39 | flash->write(flash, pos + sizeof(len), len, buf); |
| 40 | |
| 41 | flash->spi->rw = SPI_WRITE_FLAG; |
| 42 | spi_release_bus(flash->spi); |
| 43 | |
| 44 | return; |
| 45 | } |