Skip to content

Commit ec28c55

Browse files
author
stefanct
committed
Add IT8212F as programmer.
This PCI PATA controller can use 3V parallel flash up to 128 kB. My card was identified as: PCI 1283:8212, subsystem 1283:0001. and labelled as: Innovision Multimedia LTD. EIO ATA133 RAID (DM-8401 Ver A) This particular card did not require setting of any GPIO signals to enable flash writing. My card has Pm39LV512 in PLCC32 package without socket. Rebased by Stefan (automatic cleanup, some PCI changes, changed enable bit handling). Committed with test state NT because the rebased version was not tested on real hardware (yet). Signed-off-by: Kyösti Mälkki <[email protected]> Signed-off-by: Stefan Tauner <[email protected]> Acked-by: Carl-Daniel Hailfinger <[email protected]> git-svn-id: svn://flashrom.org/flashrom/trunk@1812 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
1 parent 9b3b0be commit ec28c55

File tree

5 files changed

+125
-2
lines changed

5 files changed

+125
-2
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ UNSUPPORTED_FEATURES += CONFIG_ATAVIA=yes
197197
else
198198
override CONFIG_ATAVIA = no
199199
endif
200+
ifeq ($(CONFIG_IT8212), yes)
201+
UNSUPPORTED_FEATURES += CONFIG_IT8212=yes
202+
else
203+
override CONFIG_IT8212 = no
204+
endif
200205
ifeq ($(CONFIG_DRKAISER), yes)
201206
UNSUPPORTED_FEATURES += CONFIG_DRKAISER=yes
202207
else
@@ -431,6 +436,9 @@ CONFIG_SATAMV ?= yes
431436
# Enable Linux spidev interface by default. We disable it on non-Linux targets.
432437
CONFIG_LINUX_SPI ?= yes
433438

439+
# Always enable ITE IT8212F PATA controllers for now.
440+
CONFIG_IT8212 ?= yes
441+
434442
# Disable wiki printing by default. It is only useful if you have wiki access.
435443
CONFIG_PRINT_WIKI ?= no
436444

@@ -549,6 +557,12 @@ PROGRAMMER_OBJS += atavia.o
549557
NEED_PCI := yes
550558
endif
551559

560+
ifeq ($(CONFIG_IT8212), yes)
561+
FEATURE_CFLAGS += -D'CONFIG_IT8212=1'
562+
PROGRAMMER_OBJS += it8212.o
563+
NEED_PCI := yes
564+
endif
565+
552566
ifeq ($(CONFIG_FT2232_SPI), yes)
553567
# This is a totally ugly hack.
554568
FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'CONFIG_FT2232_SPI=1'")

flashrom.8.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ cards)"
194194
.sp
195195
.BR "* atavia" " (for flash ROMs on VIA VT6421A SATA controllers)"
196196
.sp
197+
.BR "* it8212" " (for flash ROMs on ITE IT8212F ATA/RAID controller)"
198+
.sp
197199
.BR "* ft2232_spi" " (for SPI flash ROMs attached to an FT2232/FT4232H/FT232H family \
198200
based USB SPI programmer), including the DLP Design DLP-USB1232H, \
199201
FTDI FT2232H Mini-Module, FTDI FT4232H Mini-Module, openbiosprog-spi, Amontec \
@@ -591,7 +593,7 @@ is an 8-bit hexadecimal value.
591593
.SS
592594
.BR "nic3com" , " nicrealtek" , " nicnatsemi" , " nicintel"\
593595
, " nicintel_spi" , " gfxnvidia" , " ogp_spi" , " drkaiser" , " satasii"\
594-
, " satamv" , " atahpt" ", and " atavia " programmers
596+
, " satamv" , " atahpt" ", " atavia " and " it8212 " programmers
595597
These programmers have an option to specify the PCI address of the card
596598
your want to use, which must be specified if more than one card supported
597599
by the selected programmer is installed in your system. The syntax is
@@ -914,7 +916,7 @@ need PCI configuration space read access and raw I/O port access.
914916
.B atahpt
915917
needs PCI configuration space access and raw I/O port access.
916918
.sp
917-
.BR gfxnvidia " and " drkaiser
919+
.BR gfxnvidia ", " drkaiser " and " it8212
918920
need PCI configuration space access and raw memory access.
919921
.sp
920922
.B rayer_spi

flashrom.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,18 @@ const struct programmer_entry programmer_table[] = {
184184
},
185185
#endif
186186

187+
#if CONFIG_IT8212 == 1
188+
{
189+
.name = "it8212",
190+
.type = PCI,
191+
.devs.dev = devs_it8212,
192+
.init = it8212_init,
193+
.map_flash_region = fallback_map,
194+
.unmap_flash_region = fallback_unmap,
195+
.delay = internal_delay,
196+
},
197+
#endif
198+
187199
#if CONFIG_FT2232_SPI == 1
188200
{
189201
.name = "ft2232_spi",

it8212.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* This file is part of the flashrom project.
3+
*
4+
* Copyright (C) 2011 Carl-Daniel Hailfinger
5+
* Copyright (C) 2012 Kyösti Mälkki <[email protected]>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; version 2 of the License.
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 "flash.h"
23+
#include "programmer.h"
24+
#include "hwaccess.h"
25+
26+
static uint8_t *it8212_bar = NULL;
27+
28+
#define PCI_VENDOR_ID_ITE 0x1283
29+
30+
const struct dev_entry devs_it8212[] = {
31+
{PCI_VENDOR_ID_ITE, 0x8212, OK, "ITE", "8212F PATA RAID"},
32+
33+
{},
34+
};
35+
36+
#define IT8212_MEMMAP_SIZE (128 * 1024)
37+
#define IT8212_MEMMAP_MASK (IT8212_MEMMAP_SIZE - 1)
38+
39+
static void it8212_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr);
40+
static uint8_t it8212_chip_readb(const struct flashctx *flash, const chipaddr addr);
41+
static const struct par_programmer par_programmer_it8212 = {
42+
.chip_readb = it8212_chip_readb,
43+
.chip_readw = fallback_chip_readw,
44+
.chip_readl = fallback_chip_readl,
45+
.chip_readn = fallback_chip_readn,
46+
.chip_writeb = it8212_chip_writeb,
47+
.chip_writew = fallback_chip_writew,
48+
.chip_writel = fallback_chip_writel,
49+
.chip_writen = fallback_chip_writen,
50+
};
51+
52+
int it8212_init(void)
53+
{
54+
if (rget_io_perms())
55+
return 1;
56+
57+
struct pci_dev *dev = pcidev_init(devs_it8212, PCI_ROM_ADDRESS);
58+
if (!dev)
59+
return 1;
60+
61+
/* Bit 0 is address decode enable, 17-31 the base address, everything else reserved/zero. */
62+
io_base_addr = pcidev_readbar(dev, PCI_ROM_ADDRESS) & 0xFFFFFFFE;
63+
if (!io_base_addr)
64+
return 1;
65+
66+
it8212_bar = rphysmap("IT8212F flash", io_base_addr, IT8212_MEMMAP_SIZE);
67+
if (it8212_bar == ERROR_PTR)
68+
return 1;
69+
70+
/* Restore ROM BAR decode state automatically at shutdown. */
71+
rpci_write_long(dev, PCI_ROM_ADDRESS, io_base_addr | 0x01);
72+
73+
max_rom_decode.parallel = IT8212_MEMMAP_SIZE;
74+
register_par_programmer(&par_programmer_it8212, BUS_PARALLEL);
75+
return 0;
76+
}
77+
78+
static void it8212_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr)
79+
{
80+
pci_mmio_writeb(val, it8212_bar + (addr & IT8212_MEMMAP_MASK));
81+
}
82+
83+
static uint8_t it8212_chip_readb(const struct flashctx *flash, const chipaddr addr)
84+
{
85+
return pci_mmio_readb(it8212_bar + (addr & IT8212_MEMMAP_MASK));
86+
}

programmer.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ enum programmer {
5757
#if CONFIG_ATAVIA == 1
5858
PROGRAMMER_ATAVIA,
5959
#endif
60+
#if CONFIG_IT8212 == 1
61+
PROGRAMMER_IT8212,
62+
#endif
6063
#if CONFIG_FT2232_SPI == 1
6164
PROGRAMMER_FT2232_SPI,
6265
#endif
@@ -444,6 +447,12 @@ void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len);
444447
extern const struct dev_entry ata_via[];
445448
#endif
446449

450+
/* it8212.c */
451+
#if CONFIG_IT8212 == 1
452+
int it8212_init(void);
453+
extern const struct dev_entry devs_it8212[];
454+
#endif
455+
447456
/* ft2232_spi.c */
448457
#if CONFIG_FT2232_SPI == 1
449458
int ft2232_spi_init(void);

0 commit comments

Comments
 (0)