Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2020 The Chromium OS Authors. All rights reserved. |
| 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 | |
| 17 | #include <stdio.h> |
| 18 | #include <strings.h> |
| 19 | #include <string.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <stdarg.h> |
| 22 | |
| 23 | #include "flash.h" |
| 24 | #include "programmer.h" |
| 25 | #include "hwaccess.h" |
| 26 | |
| 27 | /* ugly singleton to work around cros layering violations in action_descriptor.c */ |
| 28 | static int ec_alias_path = 0; |
| 29 | |
| 30 | int programming_ec(void) |
| 31 | { |
| 32 | return ec_alias_path; |
| 33 | } |
| 34 | |
| 35 | int cros_ec_alias_init(void) |
| 36 | { |
| 37 | /* User called '-p ec' and so toggle ec-alias path detection on. */ |
| 38 | ec_alias_path = 1; |
| 39 | |
| 40 | /* probe for programmers that bridge LPC <--> SPI */ |
| 41 | /* Try to probe via kernel device first */ |
| 42 | if (!cros_ec_probe_dev()) { |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 43 | return 0; |
| 44 | } |
| 45 | #if defined(__i386__) || defined(__x86_64__) |
| 46 | if (wpce775x_probe_spi_flash(NULL) |
| 47 | #if CONFIG_MEC1308 == 1 |
| 48 | && mec1308_init() |
| 49 | #endif |
| 50 | #if CONFIG_ENE_LPC == 1 |
| 51 | && ene_lpc_init() |
| 52 | #endif |
| 53 | ) |
| 54 | return 1; /* EC not found */ |
| 55 | #endif /* __i386__ || __x86_64__ */ |
| 56 | |
| 57 | return 0; |
| 58 | } |
Edward O'Callaghan | 5b16a08 | 2020-10-20 16:30:16 +1100 | [diff] [blame] | 59 | |
| 60 | int cros_host_alias_init(void) |
| 61 | { |
| 62 | msg_pdbg("%s(): Redirecting dispatch -> internal_init().\n", __func__); |
| 63 | return internal_init(); |
| 64 | } |