Hi everyone,<div>Lately we've been looking into <a href="http://flashrom.org/trac/flashrom/changeset/1232" target="_blank">reverse PCI</a> and <a href="http://patchwork.coreboot.org/patch/2331/" target="_blank">MMIO</a> writes, along with the shutdown callback mechanism.</div>



<div><br></div><div>The main usage case for Flashrom makes this a pretty simple matter, since most users only worry about a single programmer being used. However, when external devices are used which depend on internal programmer settings, things can get messy.</div>



<div><br></div><div>Consider the case of a laptop with an x86 southbridge and an EC -- To communicate with the EC thru the LPC/FWH interface, some register settings in the southbridge might need to be changed. The code flow should be:</div>



<div>1. Set up SB, use rpci_* and rmmio_* to register reverse PCI and MMIO callbacks wherever necessary.</div><div>2. Set up EC.</div><div>3. Run code.</div><div>4. Call EC shutdown routine.</div><div>5. Reverse SB PCI/MMIO writes.</div>



<div><br></div><div>However, the current code calls the programmer shutdown routine in step 4 <i>after</i> doing all shutdown callbacks in step 5. This causes southbridge registers to be reverted before the EC's shutdown routine is called, potentially making the EC unreachable.</div>



<div><br></div><div>The attached patch addresses this by using programmer shutdown functions the same as any other shutdown callback. The internal_shutdown function is registered early in the internal_init() function so that newly discovered external programmers (ie SuperIO/EC LPC -> SPI bridges) can be discovered and have their shutdown callbacks added in the correct order.</div>



<div><br></div><div>If this seems useful, we should make necessary changes to other programmers as well before committing this patch.</div><div><div><br></div><div>Signed-off-by: David Hendricks <<a href="mailto:dhendrix@google.com" target="_blank">dhendrix@google.com</a>><br>



<div><br>-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>
</div></div></div>