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 | } |
Edward O'Callaghan | 82502c5 | 2020-11-18 11:53:35 +1100 | [diff] [blame] | 45 | |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 46 | #if defined(__i386__) || defined(__x86_64__) |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 47 | #if CONFIG_MEC1308 == 1 |
Edward O'Callaghan | 82502c5 | 2020-11-18 11:53:35 +1100 | [diff] [blame] | 48 | if (!mec1308_init()) { |
| 49 | msg_cdbg("legacy x86 EC: mec1308 found!\n"); |
| 50 | return 0; |
| 51 | } |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 52 | #endif |
| 53 | #if CONFIG_ENE_LPC == 1 |
Edward O'Callaghan | 82502c5 | 2020-11-18 11:53:35 +1100 | [diff] [blame] | 54 | if (!ene_lpc_init()) { |
| 55 | msg_cdbg("legacy x86 EC: ene_lpc found!\n"); |
| 56 | return 0; |
| 57 | } |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 58 | #endif |
Edward O'Callaghan | 82502c5 | 2020-11-18 11:53:35 +1100 | [diff] [blame] | 59 | msg_cdbg("legacy x86 EC not found!\n"); |
| 60 | return 1; /* EC not found */ |
| 61 | #else |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 62 | return 0; |
Edward O'Callaghan | 82502c5 | 2020-11-18 11:53:35 +1100 | [diff] [blame] | 63 | #endif /* !__i386__ || __x86_64__ */ |
Edward O'Callaghan | da29ca8 | 2020-10-20 00:49:47 +1100 | [diff] [blame] | 64 | } |
Edward O'Callaghan | 5b16a08 | 2020-10-20 16:30:16 +1100 | [diff] [blame] | 65 | |
| 66 | int cros_host_alias_init(void) |
| 67 | { |
| 68 | msg_pdbg("%s(): Redirecting dispatch -> internal_init().\n", __func__); |
| 69 | return internal_init(); |
| 70 | } |