blob: c708225a4d9cb99f3ed764fb15744792c631de64 [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'Callaghanda29ca82020-10-20 00:49:47 +110047#if CONFIG_MEC1308 == 1
Edward O'Callaghan82502c52020-11-18 11:53:35 +110048 if (!mec1308_init()) {
49 msg_cdbg("legacy x86 EC: mec1308 found!\n");
50 return 0;
51 }
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110052#endif
53#if CONFIG_ENE_LPC == 1
Edward O'Callaghan82502c52020-11-18 11:53:35 +110054 if (!ene_lpc_init()) {
55 msg_cdbg("legacy x86 EC: ene_lpc found!\n");
56 return 0;
57 }
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110058#endif
Edward O'Callaghan82502c52020-11-18 11:53:35 +110059 msg_cdbg("legacy x86 EC not found!\n");
60 return 1; /* EC not found */
61#else
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110062 return 0;
Edward O'Callaghan82502c52020-11-18 11:53:35 +110063#endif /* !__i386__ || __x86_64__ */
Edward O'Callaghanda29ca82020-10-20 00:49:47 +110064}
Edward O'Callaghan5b16a082020-10-20 16:30:16 +110065
66int cros_host_alias_init(void)
67{
68 msg_pdbg("%s(): Redirecting dispatch -> internal_init().\n", __func__);
69 return internal_init();
70}