path: root/nicintel_spi.c
Commit message (Collapse)AuthorAgeFilesLines
* Add additional error handling to pcidev_readbar() callersNiklas Söderlund2013-08-231-0/+3
| | | | | | | | | | | This is mostly a leftover of Niklas' "remove exit call from pcidev_init" patch. While not explicitly necessary detecting errors early is usually a good idea. Corresponding to flashrom svn r1718. Signed-off-by: Niklas Söderlund <> Signed-off-by: Stefan Tauner <> Acked-by: Stefan Tauner <>
* Automatically unmap physmap()sStefan Tauner2013-08-141-7/+2
| | | | | | | | | | | | Similarly to the previous PCI self-clean up patch this one allows to get rid of a huge number of programmer shutdown functions and makes introducing bugs harder. It adds a new function rphysmap() that takes care of unmapping at shutdown. Callers are changed where it makes sense. Corresponding to flashrom svn r1714. Signed-off-by: Stefan Tauner <> Acked-by: Carl-Daniel Hailfinger <>
* Decouple BAR reading from pci device init, handle errors gracefullyCarl-Daniel Hailfinger2013-01-051-2/+5
| | | | | | | | | | | | | | | Pcidev_init() now returns struct pci_device * instead of a BAR stored in PCI config space. This allows for real error checking instead of having exit(1) everywhere in pcidev.c. Thanks to Niklas Söderlund for coming up with the original error handling patch which was slightly modified and folded into this patch. Move the declaration of struct pci_device in programmer.h before the first user. Corresponding to flashrom svn r1644. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Stefan Tauner <>
* Unify PCI init and let pcidev clean itself upStefan Tauner2013-01-041-1/+1
| | | | | | | | | | | | | | | | | | | Previously the internal programmer used its own code to initialize pcilib. This patch extracts the common code from the internal programmer and pcidev_init() into pcidev_init_common(). This fixes the non-existent PCI cleanup of the internal programmer and adds an additional safety by checking for an already existing PCI context. We got a nice shutdown function registration infrastructure, but did not use it very wisely. Instead we added shutdown functions to a myriad of programmers unnecessarily. In this patch we get rid of those that do only call pci_cleanup(pacc) by adding a shutdown function the pcidev.c itself that gets registered by pcidev_init(). Corresponding to flashrom svn r1642. Signed-off-by: Stefan Tauner <> Acked-by: Carl-Daniel Hailfinger <>
* Unify usbdev_status and pcidev_status into dev_entryStefan Tauner2012-12-271-1/+1
| | | | | | | | | | | | | | | | | | | Once upon a time usbdev_status was created for the ft2232 programmer. Its IDs are semantically different to pcidev_status because they indicate USB instead of PCI IDs, but apart from that both data structures are equal. This change makes life easier for everything involved in handling and printing the status of devices that is noted in those structures by combining them into dev_entry. It is still possible to distinguish between PCI and USB devices indirectly by using the struct programmer's type field. Also, add a programmer column to the PCI and USB devices lists. Corresponding to flashrom svn r1632. Signed-off-by: Stefan Tauner <> Acked-by: Carl-Daniel Hailfinger <>
* Some ISO C fixesCarl-Daniel Hailfinger2012-08-271-1/+1
| | | | | | | | | | | | | | | | | This patch just fixes a limited number of bits not conforming to c99 by using - __asm__ instead of just asm - {0} instead of {} for struct initialization - h_addr_list[0] instead of h_addr to access the host address in struct hostent - #include <strings.h> where needed (for ffs and strcasecmp) Based on a previous patch by Carl-Daniel. Corresponding to flashrom svn r1585. Signed-off-by: Carl-Daniel Hailfinger <> Signed-off-by: Stefan Tauner <> Acked-by: Carl-Daniel Hailfinger <>
* Use getpagesize() to determine the physmap's length in nicintel_spi.cStefan Tauner2012-08-261-2/+4
| | | | | | | Corresponding to flashrom svn r1584. Signed-off-by: Stefan Tauner <> Acked-by: Stefan Tauner <>
* Automatically release I/O permissions on shutdownCarl-Daniel Hailfinger2012-07-211-2/+2
| | | | | | | | | | | | | | | | | | | | | Get_io_perms() is renamed to rget_io_perms() and automatically registers a function to release I/O permissions on shutdown. Actually release I/O permissions on Solaris and iopl()-supporting operating systems like Linux. This patch fixes quite a few programmers which forgot to release I/O permissions on shutdown, and it simplifies the shutdown and error handling code for all others. Do not call exit(1) if I/O permissions are denied and return an error instead. This part of the patch was written by Niklas Söderlund. Corresponding to flashrom svn r1551. Signed-off-by: Carl-Daniel Hailfinger <> Signed-off-by: Niklas Söderlund <> Acked-by: Michael Karcher <>
* Hide hwaccess.h from public APIPatrick Georgi2012-07-201-0/+1
| | | | | | | | | | | | | Move hwaccess.h #include from flash.h to individual drivers. libflashrom users need flash.h, but they do not care about hwaccess.h and should not see its definitions because they may conflict with other hardware access functions and #defines used by the libflashrom user. Corresponding to flashrom svn r1549. Signed-off-by: Patrick Georgi <> Acked-by: Carl-Daniel Hailfinger <>
* nicintel_spi.c: check if write enable is really set (and minor comment changes)Stefan Tauner2012-02-271-3/+14
| | | | | | | Corresponding to flashrom svn r1510. Signed-off-by: Stefan Tauner <> Acked-by: Idwer Vollering <>
* Have all programmer init functions register bus masters/programmersCarl-Daniel Hailfinger2011-12-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | All programmer types (Parallel, SPI, Opaque) now register themselves into a generic programmer list and probing is now programmer-centric instead of chip-centric. Registering multiple SPI/... masters at the same time is now possible without any problems. Handling multiple flash chips is still unchanged, but now we have the infrastructure to deal with "dual BIOS" and "one flash behind southbridge and one flash behind EC" sanely. A nice side effect is that this patch kills quite a few global variables and improves the situation for libflashrom. Hint for developers: struct {spi,par,opaque}_programmer now have a void *data pointer to store any additional programmer-specific data, e.g. hardware configuration info. Note: flashrom -f -c FOO -r forced_read.bin does not work anymore. We have to find an architecturally clean way to solve this. Corresponding to flashrom svn r1475. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Michael Karcher <>
* Use shutdown callback mechanism to shutdown programmersDavid Hendricks2011-06-141-19/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch attempts to resolve some programmer shutdown ordering issues by having the programmer init functions register shutdown callbacks explicitly wherever it makes most sense. Before, assumptions were made that could lead to the internal programmer's state changing before the external programmer could be shut down properly. Now, each programmer cleans up after itself and (hopefully) performs each operation in the correct order. As a side-effect, this patch gives us a better usage model for reverse operations such as rpci_* and rmmio_*. In the long-run, this should make reversing the initialization process easier to understand, less tedious, and less error-prone. In short, this patch does the following: - Registers a shutdown callback during initialization for each programmer. - Kills the .shutdown function pointer from programmer_entry struct. Also, make most shutdown functions static. - Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls). TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff) Corresponding to flashrom svn r1338. Signed-off-by: David Hendricks <> Acked-by: Carl-Daniel Hailfinger <>
* Add support for 8086:1076 (82541GI) to nicintel_spi.cStefan Tauner2011-05-181-0/+1
| | | | | | | Corresponding to flashrom svn r1306. Signed-off-by: Stefan Tauner <> Acked-by: Idwer Vollering <>
* Kill central list of SPI programmersMichael Karcher2011-05-111-3/+0
| | | | | | | | | | | | | | | | | | Remove the array spi_programmer, replace it by dynamic registration instead. Also initially start with no busses supported, and switch to the default non-SPI only for the internal programmer. Also this patch changes the initialization for the buses_supported variable from "everything-except-SPI" to "nothing". All programmers have to set the bus type on their own, and this enables register_spi_programmer to just add the SPI both for on-board SPI interfaces (where the internal programmer already detected the other bus types), as well as for external programmers (where we have the default "none"). Corresponding to flashrom svn r1299. Signed-off-by: Michael Karcher <> Acked-by: Carl-Daniel Hailfinger <>
* Revert MMIO space writes on shutdown as neededCarl-Daniel Hailfinger2011-05-031-0/+8
| | | | | | | | | | | | | | | | | | Reversible MMIO space writes now use rmmio_write*(). Reversible PCI MMIO space writes now use pci_rmmio_write*(). If a MMIO value needs to be queued for restore without writing it, use rmmio_val*(). MMIO space writes which are one-shot (e.g. communication with some chip) should continue to use the permanent mmio_write* variants. Corresponding to flashrom svn r1292. Signed-off-by: Carl-Daniel Hailfinger <> David tested it successfully on some NM10/ICH7 platforms which switch between SPI and LPC targets (x86 BIOS ROM vs. EC firmware ROM). Acked-by: David Hendricks <>
* Remove vendorid parameter from pcidev_init()Carl-Daniel Hailfinger2011-03-071-2/+1
| | | | | | | | | | | | | | | Simplify pcidev_init by killing the vendorid parameter which was pretty useless anyway since it was present in the pcidevs parameter as well. This also allows us to handle multiple programmers with different vendor IDs in the same driver. Fix compilation of flashrom with only the nicrealtek driver. Corresponding to flashrom svn r1274. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Michael Karcher <>
* Add Intel 82571EB and 82572EI Gigabit NICs to the supported listIdwer Vollering2010-10-051-0/+2
| | | | | | | | Corresponding to flashrom svn r1185. Signed-off-by: Idwer Vollering <> Tested-by: Iain Paton <> Acked-by: Carl-Daniel Hailfinger <>
* SPI bitbanging: request/release busCarl-Daniel Hailfinger2010-09-151-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | SPI bitbanging on devices which speak SPI natively has a dual-use problem: We need to shut down normal SPI operations to do the bitbanging ourselves. Once we're done, it makes a lot of sense to reenable "normal" SPI operations again. Add request_bus/release_bus functions to struct bitbang_spi_master. Add a bitbang shutdown function (not used yet). Change MCP SPI and Intel NIC SPI to use the new request/release bus infrastructure. Cosmetic changes to a few error messages (80 column limit). There are multiple possible strategies for bus request/release: - Request at the start of a SPI command, release immediately afterwards. - Request at the start of a SPI multicommand, release once all commands of the multicommand are done. - Request on programmer init, release on shutdown. Each strategy has its own advantages. For now, we will stay with the first strategy which worked fine so far. Corresponding to flashrom svn r1171. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Uwe Hermann <>
* Add Intel Gigabit NIC SPI flashing supportIdwer Vollering2010-09-031-0/+187
Tested on a 82541PI (0x8086, 0x107c) using 32-bit hardware. The last line in nicintel_request_spibus() could be changed so that FL_BUSY is used instead. Shortened sample log: [...] Found "Intel 82541PI Gigabit Ethernet Controller" (8086:107c, BDF 01:03.0). Found chip "ST M25P10.RES" (128 KB, SPI) at physical address 0xfffe0000. Multiple flash chips were detected: M25P05.RES M25P10.RES Please specify which chip to use with the -c <chipname> option. [...] Corresponding to flashrom svn r1151. Signed-off-by: Idwer Vollering <> Acked-by: Uwe Hermann <>
OpenPOWER on IntegriCloud