blob: ba9018f736300db10c6ba148af2b0117809e4da1 [file] [log] [blame]
Uwe Hermann34eae342009-09-02 23:27:45 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2009 TURBO J <turboj@web.de>
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 <stdlib.h>
22#include <string.h>
23#include <sys/types.h>
24#include "flash.h"
25
26#define PCI_VENDOR_ID_DRKAISER 0x1803
27
28#define PCI_MAGIC_DRKAISER_ADDR 0x50
29#define PCI_MAGIC_DRKAISER_VALUE 0xa971
30
31struct pcidev_status drkaiser_pcidev[] = {
32 {0x1803, 0x5057, PCI_OK, "Dr. Kaiser", "PC-Waechter (Actel FPGA)"},
33 {},
34};
35
36uint8_t *drkaiser_bar;
37
38int drkaiser_init(void)
39{
40 uint32_t addr;
41
42 get_io_perms();
43 pcidev_init(PCI_VENDOR_ID_DRKAISER, PCI_BASE_ADDRESS_2,
44 drkaiser_pcidev, programmer_param);
45
46 /* Write magic register to enable flash write. */
47 pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR,
48 PCI_MAGIC_DRKAISER_VALUE);
49
50 /* TODO: Mask lower bits? How many? 3? 7? */
51 addr = pci_read_long(pcidev_dev, PCI_BASE_ADDRESS_2) & ~0x03;
52
53 /* Map 128KB flash memory window. */
54 drkaiser_bar = physmap("Dr. Kaiser PC-Waechter flash memory",
55 addr, 128 * 1024);
56
57 buses_supported = CHIP_BUSTYPE_PARALLEL;
58 return 0;
59}
60
61int drkaiser_shutdown(void)
62{
63 /* Write protect the flash again. */
64 pci_write_word(pcidev_dev, PCI_MAGIC_DRKAISER_ADDR, 0);
65 free(programmer_param);
66 pci_cleanup(pacc);
67 release_io_perms();
68 return 0;
69};
70
71void drkaiser_chip_writeb(uint8_t val, chipaddr addr)
72{
73 mmio_writeb(val, drkaiser_bar + addr);
74}
75
76uint8_t drkaiser_chip_readb(const chipaddr addr)
77{
78 return mmio_readb(drkaiser_bar + addr);
79}