Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: wpce775x.c

Issue 6897014: Do not call EC programmer shutdown functions explicitly. (Closed) Base URL: svn://coreboot.org/flashrom/trunk
Patch Set: Fix code as per Stefan's comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « programmer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the flashrom project. 2 * This file is part of the flashrom project.
3 * 3 *
4 * Copyright (C) 2010 Google, Inc. 4 * Copyright (C) 2010 Google, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * Redistributions of source code must retain the above copyright 10 * Redistributions of source code must retain the above copyright
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 * 0x21 is used for EC F/W changed. Goto EC F/W, wait system reboot. 533 * 0x21 is used for EC F/W changed. Goto EC F/W, wait system reboot.
534 * 0x22 is used for EC F/W changed, Goto EC Watchdog reset. */ 534 * 0x22 is used for EC F/W changed, Goto EC Watchdog reset. */
535 int ExitFlashUpdateFirmwareNoChange(void) { 535 int ExitFlashUpdateFirmwareNoChange(void) {
536 return ExitFlashUpdate(0x20); 536 return ExitFlashUpdate(0x20);
537 } 537 }
538 538
539 int ExitFlashUpdateFirmwareChanged(void) { 539 int ExitFlashUpdateFirmwareChanged(void) {
540 return ExitFlashUpdate(0x21); 540 return ExitFlashUpdate(0x21);
541 } 541 }
542 542
543 static void wpce775x_shutdown(void *data)
544 {
545 if (spi_controller != SPI_CONTROLLER_WPCE775X)
546 return;
547
548 msg_pdbg("%s(): firmware %s\n", __func__,
549 firmware_changed ? "changed" : "not changed");
550
551 msg_pdbg("%s: in_flash_update_mode: %d\n", __func__, in_flash_update_mod e);
552 if (in_flash_update_mode) {
553 if (firmware_changed)
554 ExitFlashUpdateFirmwareChanged();
555 else
556 ExitFlashUpdateFirmwareNoChange();
557
558 in_flash_update_mode = 0;
559 }
560
561 if (initflash_cfg)
562 free(initflash_cfg);
563 else
564 msg_perr("%s(): No initflash_cfg to free?!?\n", __func__);
565 }
566
543 int wpce775x_spi_common_init(void) 567 int wpce775x_spi_common_init(void)
544 { 568 {
545 uint16_t sio_port; 569 uint16_t sio_port;
546 uint8_t srid; 570 uint8_t srid;
547 uint8_t fwh_id; 571 uint8_t fwh_id;
548 572
549 msg_pdbg("%s(): entered\n", __func__); 573 msg_pdbg("%s(): entered\n", __func__);
550 574
551 /* detect if wpce775x exists */ 575 /* detect if wpce775x exists */
552 if (nuvoton_get_sio_index(&sio_port) < 0) { 576 if (nuvoton_get_sio_index(&sio_port) < 0) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 609
586 if (get_fwh_id(&fwh_id) < 0) { 610 if (get_fwh_id(&fwh_id) < 0) {
587 msg_pdbg("Cannot get fwh_id value.\n"); 611 msg_pdbg("Cannot get fwh_id value.\n");
588 return 0; 612 return 0;
589 } 613 }
590 msg_pdbg("get fwh_id: 0x%02x\n", fwh_id); 614 msg_pdbg("get fwh_id: 0x%02x\n", fwh_id);
591 615
592 /* TODO: set fwh_idsel of chipset. 616 /* TODO: set fwh_idsel of chipset.
593 Currently, we employ "-p internal:fwh_idsel=0x0000223e". */ 617 Currently, we employ "-p internal:fwh_idsel=0x0000223e". */
594 618
619 if (register_shutdown(wpce775x_shutdown, NULL))
620 return 1;
621
595 /* Enter flash update mode unconditionally. This is required even 622 /* Enter flash update mode unconditionally. This is required even
596 for reading. */ 623 for reading. */
597 if (EnterFlashUpdate()) return 1; 624 if (EnterFlashUpdate()) return 1;
598 625
599 spi_controller = SPI_CONTROLLER_WPCE775X; 626 spi_controller = SPI_CONTROLLER_WPCE775X;
600 msg_pdbg("%s(): successfully initialized wpce775x\n", __func__); 627 msg_pdbg("%s(): successfully initialized wpce775x\n", __func__);
601 return 0; 628 return 0;
602
603 }
604
605 int wpce775x_shutdown(void)
606 {
607 if (spi_controller != SPI_CONTROLLER_WPCE775X)
608 return 0;
609
610 msg_pdbg("%s(): firmware %s\n", __func__,
611 firmware_changed ? "changed" : "not changed");
612
613 msg_pdbg("%s: in_flash_update_mode: %d\n", __func__, in_flash_update_mod e);
614 if (in_flash_update_mode) {
615 if (firmware_changed)
616 ExitFlashUpdateFirmwareChanged();
617 else
618 ExitFlashUpdateFirmwareNoChange();
619
620 in_flash_update_mode = 0;
621 }
622
623 if (initflash_cfg)
624 free(initflash_cfg);
625 else
626 msg_perr("%s(): No initflash_cfg to free?!?\n", __func__);
627
628 return 0;
629 } 629 }
630 630
631 /* Called by internal_init() */ 631 /* Called by internal_init() */
632 int wpce775x_probe_spi_flash(const char *name) 632 int wpce775x_probe_spi_flash(const char *name)
633 { 633 {
634 int ret; 634 int ret;
635 635
636 if (!(buses_supported & CHIP_BUSTYPE_FWH)) { 636 if (!(buses_supported & CHIP_BUSTYPE_FWH)) {
637 msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__); 637 msg_pdbg("%s():%d buses not support FWH\n", __func__, __LINE__);
638 return 1; 638 return 1;
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 /* unsupported opcodes */ 976 /* unsupported opcodes */
977 msg_pdbg("unsupported SPI opcode: %02x\n", opcode); 977 msg_pdbg("unsupported SPI opcode: %02x\n", opcode);
978 rc = 1; 978 rc = 1;
979 break; 979 break;
980 } 980 }
981 981
982 msg_pdbg("%s: opcode: 0x%02x\n", __func__, opcode); 982 msg_pdbg("%s: opcode: 0x%02x\n", __func__, opcode);
983 return rc; 983 return rc;
984 } 984 }
985 #endif 985 #endif
OLDNEW
« no previous file with comments | « programmer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698