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) 2007, 2008, 2009 Carl-Daniel Hailfinger | 4 * Copyright (C) 2007, 2008, 2009 Carl-Daniel Hailfinger |
5 * Copyright (C) 2008 Ronald Hoogenboom <ronald@zonnet.nl> | 5 * Copyright (C) 2008 Ronald Hoogenboom <ronald@zonnet.nl> |
6 * Copyright (C) 2008 coresystems GmbH | 6 * Copyright (C) 2008 coresystems GmbH |
7 * Copyright (C) 2010 Google Inc. | 7 * Copyright (C) 2010 Google Inc. |
8 * | 8 * |
9 * This program is free software; you can redistribute it and/or modify | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | 10 * it under the terms of the GNU General Public License as published by |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #ifdef LPC_IO | 72 #ifdef LPC_IO |
73 /* macro to fill in indirect-access registers. */ | 73 /* macro to fill in indirect-access registers. */ |
74 #define INDIRECT_A0(base, value) OUTB(value, (base) + 0) /* little-endian */ | 74 #define INDIRECT_A0(base, value) OUTB(value, (base) + 0) /* little-endian */ |
75 #define INDIRECT_A1(base, value) OUTB(value, (base) + 1) | 75 #define INDIRECT_A1(base, value) OUTB(value, (base) + 1) |
76 #define INDIRECT_A2(base, value) OUTB(value, (base) + 2) | 76 #define INDIRECT_A2(base, value) OUTB(value, (base) + 2) |
77 #define INDIRECT_A3(base, value) OUTB(value, (base) + 3) | 77 #define INDIRECT_A3(base, value) OUTB(value, (base) + 3) |
78 #define INDIRECT_READ(base) INB((base) + 4) | 78 #define INDIRECT_READ(base) INB((base) + 4) |
79 #define INDIRECT_WRITE(base, value) OUTB(value, (base) + 4) | 79 #define INDIRECT_WRITE(base, value) OUTB(value, (base) + 4) |
80 #endif /* LPC_IO */ | 80 #endif /* LPC_IO */ |
81 | 81 |
| 82 void it85xx_shutdown(void *); |
| 83 |
82 #ifdef LPC_IO | 84 #ifdef LPC_IO |
83 unsigned int shm_io_base; | 85 unsigned int shm_io_base; |
84 #endif | 86 #endif |
85 unsigned char *ce_high, *ce_low; | 87 unsigned char *ce_high, *ce_low; |
86 static int it85xx_scratch_rom_reenter = 0; | 88 static int it85xx_scratch_rom_reenter = 0; |
87 | 89 |
88 uint16_t probe_id_ite85(uint16_t port) | 90 uint16_t probe_id_ite85(uint16_t port) |
89 { | 91 { |
90 uint16_t id; | 92 uint16_t id; |
91 | 93 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 264 |
263 int it85xx_spi_common_init(void) | 265 int it85xx_spi_common_init(void) |
264 { | 266 { |
265 chipaddr base; | 267 chipaddr base; |
266 | 268 |
267 msg_pdbg("%s():%d superio.vendor=0x%02x\n", __func__, __LINE__, | 269 msg_pdbg("%s():%d superio.vendor=0x%02x\n", __func__, __LINE__, |
268 superio.vendor); | 270 superio.vendor); |
269 if (superio.vendor != SUPERIO_VENDOR_ITE) | 271 if (superio.vendor != SUPERIO_VENDOR_ITE) |
270 return 1; | 272 return 1; |
271 | 273 |
| 274 if (register_shutdown(it85xx_shutdown, NULL)) |
| 275 return 1; |
| 276 |
272 #ifdef LPC_IO | 277 #ifdef LPC_IO |
273 /* Get LPCPNP of SHM. That's big-endian */ | 278 /* Get LPCPNP of SHM. That's big-endian */ |
274 sio_write(superio.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */ | 279 sio_write(superio.port, LDNSEL, 0x0F); /* Set LDN to SHM (0x0F) */ |
275 shm_io_base = (sio_read(superio.port, SHM_IO_BAD0) << 8) + | 280 shm_io_base = (sio_read(superio.port, SHM_IO_BAD0) << 8) + |
276 sio_read(superio.port, SHM_IO_BAD1); | 281 sio_read(superio.port, SHM_IO_BAD1); |
277 msg_pdbg("%s():%d shm_io_base=0x%04x\n", __func__, __LINE__, | 282 msg_pdbg("%s():%d shm_io_base=0x%04x\n", __func__, __LINE__, |
278 shm_io_base); | 283 shm_io_base); |
279 | 284 |
280 /* These pointers are not used directly. They will be send to EC's | 285 /* These pointers are not used directly. They will be send to EC's |
281 * register for indirect access. */ | 286 * register for indirect access. */ |
(...skipping 11 matching lines...) Expand all Loading... |
293 base = (chipaddr)programmer_map_flash_region("flash base", 0xFFFFF000, | 298 base = (chipaddr)programmer_map_flash_region("flash base", 0xFFFFF000, |
294 0x1000); | 299 0x1000); |
295 msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__, | 300 msg_pdbg("%s():%d base=0x%08x\n", __func__, __LINE__, |
296 (unsigned int)base); | 301 (unsigned int)base); |
297 ce_high = (unsigned char*)(base + 0xE00); /* 0xFFFFFE00 */ | 302 ce_high = (unsigned char*)(base + 0xE00); /* 0xFFFFFE00 */ |
298 ce_low = (unsigned char*)(base + 0xD00); /* 0xFFFFFD00 */ | 303 ce_low = (unsigned char*)(base + 0xD00); /* 0xFFFFFD00 */ |
299 #endif | 304 #endif |
300 | 305 |
301 /* Set this as spi controller. */ | 306 /* Set this as spi controller. */ |
302 spi_controller = SPI_CONTROLLER_IT85XX; | 307 spi_controller = SPI_CONTROLLER_IT85XX; |
303 | |
304 return 0; | 308 return 0; |
305 } | 309 } |
306 | 310 |
307 /* Called by programmer_entry .init */ | 311 /* Called by programmer_entry .init */ |
308 int it85xx_spi_init(void) | 312 int it85xx_spi_init(void) |
309 { | 313 { |
310 int ret; | 314 int ret; |
311 | 315 |
312 get_io_perms(); | 316 get_io_perms(); |
313 /* Probe for the Super I/O chip and fill global struct superio. */ | 317 /* Probe for the Super I/O chip and fill global struct superio. */ |
(...skipping 21 matching lines...) Expand all Loading... |
335 if (!ret) { | 339 if (!ret) { |
336 msg_pdbg("%s():%d buses_supported=0x%x\n", __func__, __LINE__, | 340 msg_pdbg("%s():%d buses_supported=0x%x\n", __func__, __LINE__, |
337 buses_supported); | 341 buses_supported); |
338 if (buses_supported & CHIP_BUSTYPE_FWH) | 342 if (buses_supported & CHIP_BUSTYPE_FWH) |
339 msg_pdbg("Overriding chipset SPI with IT85 FWH|SPI.\n"); | 343 msg_pdbg("Overriding chipset SPI with IT85 FWH|SPI.\n"); |
340 buses_supported |= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI; | 344 buses_supported |= CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI; |
341 } | 345 } |
342 return ret; | 346 return ret; |
343 } | 347 } |
344 | 348 |
345 int it85xx_shutdown(void) | 349 void it85xx_shutdown(void *data) |
346 { | 350 { |
347 msg_pdbg("%s():%d\n", __func__, __LINE__); | 351 msg_pdbg("%s():%d\n", __func__, __LINE__); |
348 it85xx_exit_scratch_rom(); | 352 it85xx_exit_scratch_rom(); |
349 return 0; | |
350 } | 353 } |
351 | 354 |
352 /* According to ITE 8502 document, the procedure to follow mode is following: | 355 /* According to ITE 8502 document, the procedure to follow mode is following: |
353 * 1. write 0x00 to LPC/FWH address 0xffff_fexxh (drive CE# high) | 356 * 1. write 0x00 to LPC/FWH address 0xffff_fexxh (drive CE# high) |
354 * 2. write data to LPC/FWH address 0xffff_fdxxh (drive CE# low and MOSI | 357 * 2. write data to LPC/FWH address 0xffff_fdxxh (drive CE# low and MOSI |
355 * with data) | 358 * with data) |
356 * 3. read date from LPC/FWH address 0xffff_fdxxh (drive CE# low and get | 359 * 3. read date from LPC/FWH address 0xffff_fdxxh (drive CE# low and get |
357 * data from MISO) | 360 * data from MISO) |
358 */ | 361 */ |
359 int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt, | 362 int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 INDIRECT_WRITE(shm_io_base, 0xFF); /* Write anything to this address.*/ | 397 INDIRECT_WRITE(shm_io_base, 0xFF); /* Write anything to this address.*/ |
395 #endif | 398 #endif |
396 #ifdef LPC_MEMORY | 399 #ifdef LPC_MEMORY |
397 *ce_high = 0; | 400 *ce_high = 0; |
398 #endif | 401 #endif |
399 | 402 |
400 return 0; | 403 return 0; |
401 } | 404 } |
402 | 405 |
403 #endif | 406 #endif |
OLD | NEW |