David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 21 | #ifndef __CROS_EC_H_ |
| 22 | #define __CROS_EC_H_ |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 23 | |
| 24 | /* FIXME: We should be able to forward declare enum ec_current_image here |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 25 | * instead of including cros_ec_ec_commands.h */ |
David Hendricks | a5c5cf8 | 2014-08-11 16:40:17 -0700 | [diff] [blame] | 26 | #include "cros_ec_commands.h" |
Puthikorn Voravootivat | c0993cf | 2014-08-28 16:04:58 -0700 | [diff] [blame^] | 27 | #include "programmer.h" |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 28 | |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 29 | struct cros_ec_priv { |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 30 | int detected; |
Simon Glass | 01c1167 | 2013-07-01 18:03:33 +0900 | [diff] [blame] | 31 | enum ec_current_image current_image; |
Simon Glass | c453a64 | 2013-07-01 18:08:53 +0900 | [diff] [blame] | 32 | struct ec_response_flash_region_info *region; |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 33 | int (*ec_command)(int command, int ver, const void *indata, int insize, |
| 34 | void *outdata, int outsize); |
David Hendricks | 14935fe | 2014-08-14 17:38:24 -0700 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * Starting in version 3.0, the EC can act as a bridge to pass along |
| 38 | * messages from the host to up to 3 attached devices (device 0 is the |
| 39 | * EC itself) which also use the CrOS EC protocol. The devices can be |
| 40 | * attached to any bus on the EC and the EC will abstract bus details. |
| 41 | * Bits 14 and 15 in the command word indicate the device index. |
| 42 | */ |
| 43 | unsigned int dev_index; |
David Hendricks | fbd5e6d | 2014-08-21 15:01:43 -0700 | [diff] [blame] | 44 | |
| 45 | /* |
| 46 | * Some CrOS ECs support page write mode for their flash memory. This |
| 47 | * represents the ideal size of a data payload to write to flash. |
| 48 | */ |
| 49 | unsigned int ideal_write_size; |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 52 | int cros_ec_test(struct cros_ec_priv *priv); |
Puthikorn Voravootivat | c0993cf | 2014-08-28 16:04:58 -0700 | [diff] [blame^] | 53 | void cros_ec_set_max_size(struct cros_ec_priv *priv, |
| 54 | struct opaque_programmer *op); |
David Hendricks | 14935fe | 2014-08-14 17:38:24 -0700 | [diff] [blame] | 55 | int cros_ec_parse_param(struct cros_ec_priv *priv); |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 56 | int cros_ec_probe_size(struct flashchip *flash); |
| 57 | int cros_ec_block_erase(struct flashchip *flash, |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 58 | unsigned int blockaddr, unsigned int len); |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 59 | int cros_ec_read(struct flashchip *flash, uint8_t *readarr, |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 60 | unsigned int blockaddr, unsigned int readcnt); |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 61 | int cros_ec_write(struct flashchip *flash, uint8_t *buf, unsigned int addr, |
David Hendricks | a915131 | 2013-07-01 12:21:01 -0700 | [diff] [blame] | 62 | unsigned int nbytes); |
| 63 | |
David Hendricks | b907de3 | 2014-08-11 16:47:09 -0700 | [diff] [blame] | 64 | #endif /* __CROS_EC_H_ */ |