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