| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 msg_perr("%s(): failed to enter passthru mode, result=%02x\n", | 300 msg_perr("%s(): failed to enter passthru mode, result=%02x\n", |
| 301 __func__, tmp8); | 301 __func__, tmp8); |
| 302 return 1; | 302 return 1; |
| 303 } | 303 } |
| 304 msg_pdbg("%s(): start passthru mode return code: 0x%02x\n", | 304 msg_pdbg("%s(): start passthru mode return code: 0x%02x\n", |
| 305 __func__, tmp8); | 305 __func__, tmp8); |
| 306 | 306 |
| 307 return 0; | 307 return 0; |
| 308 } | 308 } |
| 309 | 309 |
| 310 static void mec1308_shutdown(void *data) |
| 311 { |
| 312 if (spi_controller != SPI_CONTROLLER_MEC1308) |
| 313 return; |
| 314 |
| 315 /* Exit passthru mode before performing commands which do not affect |
| 316 the SPI ROM */ |
| 317 mec1308_exit_passthru_mode(); |
| 318 |
| 319 /* Re-enable SMI and ACPI. |
| 320 FIXME: is there an ordering dependency? */ |
| 321 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_ENABLE); |
| 322 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_ENABLE); |
| 323 } |
| 324 |
| 310 /* Called by internal_init() */ | 325 /* Called by internal_init() */ |
| 311 int mec1308_probe_spi_flash(const char *name) | 326 int mec1308_probe_spi_flash(const char *name) |
| 312 { | 327 { |
| 313 uint16_t sio_port; | 328 uint16_t sio_port; |
| 314 uint8_t device_id; | 329 uint8_t device_id; |
| 315 uint8_t tmp8; | 330 uint8_t tmp8; |
| 316 | 331 |
| 317 msg_pdbg("%s(): entered\n", __func__); | 332 msg_pdbg("%s(): entered\n", __func__); |
| 318 | 333 |
| 319 if (mec1308_get_sio_index(&sio_port) < 0) { | 334 if (mec1308_get_sio_index(&sio_port) < 0) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 if (mbx_wait() != 0) { | 369 if (mbx_wait() != 0) { |
| 355 msg_perr("%s: mailbox is not available\n", __func__); | 370 msg_perr("%s: mailbox is not available\n", __func__); |
| 356 return 1; | 371 return 1; |
| 357 } | 372 } |
| 358 | 373 |
| 359 /* Further setup -- disable SMI and ACPI. | 374 /* Further setup -- disable SMI and ACPI. |
| 360 FIXME: is there an ordering dependency? */ | 375 FIXME: is there an ordering dependency? */ |
| 361 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE); | 376 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_DISABLE); |
| 362 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE); | 377 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_DISABLE); |
| 363 | 378 |
| 379 if (register_shutdown(mec1308_shutdown, NULL)) |
| 380 return 1; |
| 381 |
| 364 /* | 382 /* |
| 365 * Enter SPI Pass-Thru Mode after commands which do not require access | 383 * 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 | 384 * 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. | 385 * sequence, which is benign if the EC is already in passthru mode. |
| 368 */ | 386 */ |
| 369 mec1308_exit_passthru_mode(); | 387 mec1308_exit_passthru_mode(); |
| 388 |
| 370 if (enter_passthru_mode()) | 389 if (enter_passthru_mode()) |
| 371 return 1; | 390 return 1; |
| 372 | 391 |
| 373 msg_pdbg("%s(): successfully initialized mec1308\n", __func__); | 392 msg_pdbg("%s(): successfully initialized mec1308\n", __func__); |
| 374 return 0; | 393 return 0; |
| 375 } | 394 } |
| 376 | 395 |
| 377 int mec1308_shutdown(void) | |
| 378 { | |
| 379 if (spi_controller != SPI_CONTROLLER_MEC1308) | |
| 380 return 0; | |
| 381 | |
| 382 /* Exit passthru mode before performing commands which do not affect | |
| 383 the SPI ROM */ | |
| 384 mec1308_exit_passthru_mode(); | |
| 385 | |
| 386 /* Re-enable SMI and ACPI. | |
| 387 FIXME: is there an ordering dependency? */ | |
| 388 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_SMI_ENABLE); | |
| 389 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_ACPI_ENABLE); | |
| 390 | |
| 391 return 0; | |
| 392 } | |
| 393 | |
| 394 int mec1308_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len) | 396 int mec1308_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len) |
| 395 { | 397 { |
| 396 return spi_read_chunked(flash, buf, start, len, flash->page_size); | 398 return spi_read_chunked(flash, buf, start, len, flash->page_size); |
| 397 } | 399 } |
| 398 | 400 |
| 399 int mec1308_spi_write_256(struct flashchip *flash, | 401 int mec1308_spi_write_256(struct flashchip *flash, |
| 400 uint8_t *buf, int start, int len) | 402 uint8_t *buf, int start, int len) |
| 401 { | 403 { |
| 402 return spi_write_chunked(flash, buf, start, len, flash->page_size); | 404 return spi_write_chunked(flash, buf, start, len, flash->page_size); |
| 403 } | 405 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_PASSTHRU_READ); | 438 mbx_write(MEC1308_MBX_CMD, MEC1308_CMD_PASSTHRU_READ); |
| 437 readarr[i] = mbx_read(MEC1308_MBX_DATA_START); | 439 readarr[i] = mbx_read(MEC1308_MBX_DATA_START); |
| 438 } | 440 } |
| 439 | 441 |
| 440 if (mec1308_chip_deselect()) | 442 if (mec1308_chip_deselect()) |
| 441 return 1; | 443 return 1; |
| 442 | 444 |
| 443 return 0; | 445 return 0; |
| 444 } | 446 } |
| 445 #endif | 447 #endif |
| OLD | NEW |