blob: dcaac05c6fccd52c5e18ebf938451e410f99292e [file] [log] [blame]
Edward O'Callaghanda29ca82020-10-20 00:49:47 +11001/*
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 */
28static int ec_alias_path = 0;
29
30int programming_ec(void)
31{
32 return ec_alias_path;
33}
34
35int 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'Callaghanda29ca82020-10-20 00:49:47 +110043 return 0;
44 }
Edward O'Callaghan82502c52020-11-18 11:53:35 +110045
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110046#if defined(__i386__) || defined(__x86_64__)
Edward O'Callaghan82502c52020-11-18 11:53:35 +110047/* TODO: wpce775x needs CONFIG_ guards. */
48 if (!wpce775x_probe_spi_flash(NULL)) {
49 msg_cdbg("legacy x86 EC: wpce775x found!\n");
50 return 0;
51 }
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110052#if CONFIG_MEC1308 == 1
Edward O'Callaghan82502c52020-11-18 11:53:35 +110053 if (!mec1308_init()) {
54 msg_cdbg("legacy x86 EC: mec1308 found!\n");
55 return 0;
56 }
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110057#endif
58#if CONFIG_ENE_LPC == 1
Edward O'Callaghan82502c52020-11-18 11:53:35 +110059 if (!ene_lpc_init()) {
60 msg_cdbg("legacy x86 EC: ene_lpc found!\n");
61 return 0;
62 }
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110063#endif
Edward O'Callaghan82502c52020-11-18 11:53:35 +110064 msg_cdbg("legacy x86 EC not found!\n");
65 return 1; /* EC not found */
66#else
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110067 return 0;
Edward O'Callaghan82502c52020-11-18 11:53:35 +110068#endif /* !__i386__ || __x86_64__ */
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110069}
Edward O'Callaghan5b16a082020-10-20 16:30:16 +110070
71int cros_host_alias_init(void)
72{
73 msg_pdbg("%s(): Redirecting dispatch -> internal_init().\n", __func__);
74 return internal_init();
75}