[coreboot-gerrit] Change in coreboot[master]: ec/google/wilco: Add devicetree chip infrastructure

Duncan Laurie (Code Review) gerrit at coreboot.org
Tue Oct 16 00:54:33 CEST 2018


Duncan Laurie has uploaded this change for review. ( https://review.coreboot.org/29117


Change subject: ec/google/wilco: Add devicetree chip infrastructure
......................................................................

ec/google/wilco: Add devicetree chip infrastructure

Add a chip_operations structure for Wilco EC and hook it into the device
tree so it can be initialized at boot.

Reserve the device resources specified in Kconfig, which will also
create the device IO windows if they have not been created in bootblock.
If the IO windows already exist (becauase they were specified in the
mainboard devicetree.cb) then this will find the existing entry instead.

During device init stage prepare the keyboard for use, which is required
for it to be functional in firmware and OS with this EC.  Also send a
command to the EC telling it to pass the power button through to the
host for processing.

Change-Id: I0adb01cf394f939f4a28aeb47fe4d0bcda5957d9
Signed-off-by: Duncan Laurie <dlaurie at google.com>
---
M src/ec/google/wilco/Makefile.inc
A src/ec/google/wilco/chip.c
A src/ec/google/wilco/chip.h
3 files changed, 107 insertions(+), 1 deletion(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/29117/1

diff --git a/src/ec/google/wilco/Makefile.inc b/src/ec/google/wilco/Makefile.inc
index 68172e3..c011ebf 100644
--- a/src/ec/google/wilco/Makefile.inc
+++ b/src/ec/google/wilco/Makefile.inc
@@ -1,5 +1,5 @@
 ifeq ($(CONFIG_EC_GOOGLE_WILCO),y)
 
-ramstage-y += commands.c mailbox.c
+ramstage-y += chip.c commands.c mailbox.c
 
 endif
diff --git a/src/ec/google/wilco/chip.c b/src/ec/google/wilco/chip.c
new file mode 100644
index 0000000..4e6f4af
--- /dev/null
+++ b/src/ec/google/wilco/chip.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <device/pnp.h>
+#include <pc80/keyboard.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "commands.h"
+#include "ec.h"
+#include "chip.h"
+
+static void wilco_ec_init(struct device *dev)
+{
+	if (!dev->enabled)
+		return;
+
+	/* Print EC firmware information */
+	wilco_ec_print_info();
+
+	/* Initialize keyboard, ignore emulated PS/2 mouse */
+	pc_keyboard_init(NO_AUX_DEVICE);
+
+	/* Direct power button to the host for processing */
+	wilco_ec_send(KB_POWER_BUTTON_TO_HOST, 1);
+}
+
+static void wilco_ec_resource(struct device *dev, int index,
+			      size_t base, size_t size)
+{
+	struct resource *res = new_resource(dev, index);
+	res->flags = IORESOURCE_IO | IORESOURCE_ASSIGNED | IORESOURCE_FIXED;
+	res->base = base;
+	res->size = size;
+}
+
+static void wilco_ec_read_resources(struct device *dev)
+{
+	/* ACPI command and data regions */
+	wilco_ec_resource(dev, 0, CONFIG_EC_BASE_ACPI_DATA, 8);
+
+	/* Host command and data regions */
+	wilco_ec_resource(dev, 1, CONFIG_EC_BASE_HOST_DATA, 8);
+
+	/* Packet region */
+	wilco_ec_resource(dev, 2, CONFIG_EC_BASE_PACKET, 16);
+}
+
+static struct device_operations ops = {
+	.init			= wilco_ec_init,
+	.read_resources		= wilco_ec_read_resources,
+	.enable_resources	= DEVICE_NOOP,
+	.set_resources		= DEVICE_NOOP,
+};
+
+static struct pnp_info info[] = {
+	{ NULL, 0, 0, 0, }
+};
+
+static void wilco_ec_enable_dev(struct device *dev)
+{
+	pnp_enable_devices(dev, &ops, ARRAY_SIZE(info), info);
+}
+
+struct chip_operations ec_google_wilco_ops = {
+	CHIP_NAME("Google Wilco EC")
+	.enable_dev = wilco_ec_enable_dev,
+};
diff --git a/src/ec/google/wilco/chip.h b/src/ec/google/wilco/chip.h
new file mode 100644
index 0000000..9b02ee3
--- /dev/null
+++ b/src/ec/google/wilco/chip.h
@@ -0,0 +1,26 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef EC_GOOGLE_WILCO_CHIP_H
+#define EC_GOOGLE_WILCO_CHIP_H
+
+#include <device/device.h>
+
+extern struct chip_operations ec_google_wilco_ops;
+
+struct ec_google_wilco_config {
+};
+
+#endif /* EC_GOOGLE_WILCO_CHIP_H */

-- 
To view, visit https://review.coreboot.org/29117
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0adb01cf394f939f4a28aeb47fe4d0bcda5957d9
Gerrit-Change-Number: 29117
Gerrit-PatchSet: 1
Gerrit-Owner: Duncan Laurie <dlaurie at chromium.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20181015/56792dba/attachment-0001.html>


More information about the coreboot-gerrit mailing list