blob: 4f54d960ac2648c69b690f26b8c0aea1eee406d7 [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()) {
43 buses_supported &= ~(BUS_LPC|BUS_SPI);
44 return 0;
45 }
46#if defined(__i386__) || defined(__x86_64__)
47 if (wpce775x_probe_spi_flash(NULL)
48#if CONFIG_MEC1308 == 1
49 && mec1308_init()
50#endif
51#if CONFIG_ENE_LPC == 1
52 && ene_lpc_init()
53#endif
54 )
55 return 1; /* EC not found */
56#endif /* __i386__ || __x86_64__ */
57
58 return 0;
59}