Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 24 matching lines...) Expand all Loading... | |
| 35 #if defined(__i386__) || defined(__x86_64__) | 35 #if defined(__i386__) || defined(__x86_64__) |
| 36 #include <inttypes.h> | 36 #include <inttypes.h> |
| 37 #include <string.h> | 37 #include <string.h> |
| 38 #include <unistd.h> | 38 #include <unistd.h> |
| 39 | 39 |
| 40 #include "flash.h" | 40 #include "flash.h" |
| 41 #include "chipdrivers.h" | 41 #include "chipdrivers.h" |
| 42 #include "programmer.h" | 42 #include "programmer.h" |
| 43 #include "spi.h" | 43 #include "spi.h" |
| 44 | 44 |
| 45 void mec1308_shutdown(void *); | |
|
Stefan Reinauer
2011/04/27 20:34:05
Please,
1. no function prototypes in .c files
2.
dhendrix
2011/04/27 21:15:05
Yeah, that's ugly. I just did it to reduce diffs e
| |
| 46 | |
| 45 #define MEC1308_SIO_PORT1 0x2e | 47 #define MEC1308_SIO_PORT1 0x2e |
| 46 #define MEC1308_SIO_PORT2 0x4e | 48 #define MEC1308_SIO_PORT2 0x4e |
| 47 #define MEC1308_SIO_ENTRY_KEY 0x55 | 49 #define MEC1308_SIO_ENTRY_KEY 0x55 |
| 48 #define MEC1308_SIO_EXIT_KEY 0xaa | 50 #define MEC1308_SIO_EXIT_KEY 0xaa |
| 49 | 51 |
| 50 #define MEC1308_SIOCFG_LDN 0x07 /* LDN Bank Selector */ | 52 #define MEC1308_SIOCFG_LDN 0x07 /* LDN Bank Selector */ |
| 51 #define MEC1308_DEVICE_ID_REG 0x20 /* Device ID Register */ | 53 #define MEC1308_DEVICE_ID_REG 0x20 /* Device ID Register */ |
| 52 #define MEC1308_DEVICE_ID_VAL 0x4d /* Device ID Value */ | 54 #define MEC1308_DEVICE_ID_VAL 0x4d /* Device ID Value */ |
| 53 #define MEC1308_DEVICE_REV 0x21 /* Device Revision ID Register */ | 55 #define MEC1308_DEVICE_REV 0x21 /* Device Revision ID Register */ |
| 54 | 56 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 if (mbx_wait() != 0) { | 356 if (mbx_wait() != 0) { |
| 355 msg_perr("%s: mailbox is not available\n", __func__); | 357 msg_perr("%s: mailbox is not available\n", __func__); |
| 356 return 1; | 358 return 1; |
| 357 } | 359 } |
| 358 | 360 |
| 359 /* Further setup -- disable SMI and ACPI. | 361 /* Further setup -- disable SMI and ACPI. |
| 360 FIXME: is there an ordering dependency? */ | 362 FIXME: is there an ordering dependency? */ |
| 361 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE); | 363 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE); |
| 362 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE); | 364 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE); |
| 363 | 365 |
| 366 if (register_shutdown(mec1308_shutdown, NULL)) | |
| 367 return 1; | |
| 368 | |
| 364 /* | 369 /* |
| 365 * Enter SPI Pass-Thru Mode after commands which do not require access | 370 * Enter SPI Pass-Thru Mode after commands which do not require access |
| 366 * to SPI ROM are complete. We'll start by doing the exit_passthru_mode | 371 * to SPI ROM are complete. We'll start by doing the exit_passthru_mode |
| 367 * sequence, which is benign if the EC is already in passthru mode. | 372 * sequence, which is benign if the EC is already in passthru mode. |
| 368 */ | 373 */ |
| 369 mec1308_exit_passthru_mode(); | 374 mec1308_exit_passthru_mode(); |
| 375 | |
| 370 if (enter_passthru_mode()) | 376 if (enter_passthru_mode()) |
| 371 return 1; | 377 return 1; |
| 372 | 378 |
| 373 msg_pdbg("%s(): successfully initialized mec1308\n", __func__); | 379 msg_pdbg("%s(): successfully initialized mec1308\n", __func__); |
| 374 return 0; | 380 return 0; |
| 375 } | 381 } |
| 376 | 382 |
| 377 int mec1308_shutdown(void) | 383 void mec1308_shutdown(void *data) |
|
Stefan Reinauer
2011/04/27 20:34:05
make static and move upstairs.
dhendrix
2011/04/27 21:15:05
Done.
| |
| 378 { | 384 { |
| 379 if (spi_controller != SPI_CONTROLLER_MEC1308) | 385 if (spi_controller != SPI_CONTROLLER_MEC1308) |
| 380 » » return 0; | 386 » » return; |
| 381 | 387 |
| 382 /* Exit passthru mode before performing commands which do not affect | 388 /* Exit passthru mode before performing commands which do not affect |
| 383 the SPI ROM */ | 389 the SPI ROM */ |
| 384 mec1308_exit_passthru_mode(); | 390 mec1308_exit_passthru_mode(); |
| 385 | 391 |
| 386 /* Re-enable SMI and ACPI. | 392 /* Re-enable SMI and ACPI. |
| 387 FIXME: is there an ordering dependency? */ | 393 FIXME: is there an ordering dependency? */ |
| 388 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_ENABLE); | 394 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_ENABLE); |
| 389 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_ENABLE); | 395 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_ENABLE); |
| 390 | |
| 391 return 0; | |
| 392 } | 396 } |
| 393 | 397 |
| 394 int mec1308_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len) | 398 int mec1308_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len) |
| 395 { | 399 { |
| 396 return spi_read_chunked(flash, buf, start, len, flash->page_size); | 400 return spi_read_chunked(flash, buf, start, len, flash->page_size); |
| 397 } | 401 } |
| 398 | 402 |
| 399 int mec1308_spi_write_256(struct flashchip *flash, | 403 int mec1308_spi_write_256(struct flashchip *flash, |
| 400 uint8_t *buf, int start, int len) | 404 uint8_t *buf, int start, int len) |
| 401 { | 405 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_PASSTHRU_READ); | 440 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_PASSTHRU_READ); |
| 437 readarr[i] = mbx_read(MEC1308_MBX_DATA_START); | 441 readarr[i] = mbx_read(MEC1308_MBX_DATA_START); |
| 438 } | 442 } |
| 439 | 443 |
| 440 if (mec1308_chip_deselect()) | 444 if (mec1308_chip_deselect()) |
| 441 return 1; | 445 return 1; |
| 442 | 446 |
| 443 return 0; | 447 return 0; |
| 444 } | 448 } |
| 445 #endif | 449 #endif |
| OLD | NEW |