Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2009 Carl-Daniel Hailfinger |
| 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; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <string.h> |
| 23 | #include <stdlib.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <sys/types.h> |
| 26 | #include <sys/stat.h> |
| 27 | #include <errno.h> |
| 28 | #include <pci/pci.h> |
| 29 | #include "flash.h" |
| 30 | |
| 31 | int dummy_init(void) |
| 32 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 33 | printf_debug("%s\n", __func__); |
Carl-Daniel Hailfinger | bfe2e0c | 2009-05-14 12:59:36 +0000 | [diff] [blame] | 34 | flashbus = BUS_TYPE_DUMMY_SPI; |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | int dummy_shutdown(void) |
| 39 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 40 | printf_debug("%s\n", __func__); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 41 | return 0; |
| 42 | } |
| 43 | |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 44 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len) |
| 45 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 46 | printf_debug("%s: Mapping %s, 0x%lx bytes at 0x%08lx\n", |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 47 | __func__, descr, (unsigned long)len, phys_addr); |
| 48 | return (void *)phys_addr; |
| 49 | } |
| 50 | |
| 51 | void dummy_unmap(void *virt_addr, size_t len) |
| 52 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 53 | printf_debug("%s: Unmapping 0x%lx bytes at %p\n", |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 54 | __func__, (unsigned long)len, virt_addr); |
| 55 | } |
| 56 | |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 57 | void dummy_chip_writeb(uint8_t val, volatile void *addr) |
| 58 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 59 | printf_debug("%s: addr=%p, val=0x%02x\n", __func__, addr, val); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void dummy_chip_writew(uint16_t val, volatile void *addr) |
| 63 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 64 | printf_debug("%s: addr=%p, val=0x%04x\n", __func__, addr, val); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | void dummy_chip_writel(uint32_t val, volatile void *addr) |
| 68 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 69 | printf_debug("%s: addr=%p, val=0x%08x\n", __func__, addr, val); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | uint8_t dummy_chip_readb(const volatile void *addr) |
| 73 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 74 | printf_debug("%s: addr=%p, returning 0xff\n", __func__, addr); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 75 | return 0xff; |
| 76 | } |
| 77 | |
| 78 | uint16_t dummy_chip_readw(const volatile void *addr) |
| 79 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 80 | printf_debug("%s: addr=%p, returning 0xffff\n", __func__, addr); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 81 | return 0xffff; |
| 82 | } |
| 83 | |
| 84 | uint32_t dummy_chip_readl(const volatile void *addr) |
| 85 | { |
Carl-Daniel Hailfinger | 1e334e6 | 2009-05-11 15:46:43 +0000 | [diff] [blame] | 86 | printf_debug("%s: addr=%p, returning 0xffffffff\n", __func__, addr); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 87 | return 0xffffffff; |
| 88 | } |
| 89 | |
Carl-Daniel Hailfinger | bfe2e0c | 2009-05-14 12:59:36 +0000 | [diff] [blame] | 90 | int dummy_spi_command(unsigned int writecnt, unsigned int readcnt, |
| 91 | const unsigned char *writearr, unsigned char *readarr) |
| 92 | { |
| 93 | int i; |
| 94 | |
| 95 | printf_debug("%s:", __func__); |
| 96 | |
| 97 | printf_debug(" writing %u bytes:", writecnt); |
| 98 | for (i = 0; i < writecnt; i++) |
| 99 | printf_debug(" 0x%02x", writearr[i]); |
| 100 | |
| 101 | printf_debug(" reading %u bytes:", readcnt); |
| 102 | for (i = 0; i < readcnt; i++) { |
| 103 | printf_debug(" 0xff"); |
| 104 | readarr[i] = 0xff; |
| 105 | } |
| 106 | |
| 107 | printf_debug("\n"); |
| 108 | return 0; |
| 109 | } |