From 2ec9d171bc5ee8c9bba78d9f35d61d2473467f66 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 18 May 2017 20:09:23 -0600 Subject: cros_ec: Convert to support live tree Convert this driver to support the live device tree and remove the old fdtdec support. The keyboard is not yet converted. Signed-off-by: Simon Glass --- drivers/misc/cros_ec_sandbox.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'drivers/misc/cros_ec_sandbox.c') diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c index 848c67bc23..c96e26e6b7 100644 --- a/drivers/misc/cros_ec_sandbox.c +++ b/drivers/misc/cros_ec_sandbox.c @@ -188,18 +188,16 @@ static int get_image_used(struct ec_state *ec, struct fmap_entry *entry) * RR=Row CC=Column KKKK=Key Code * * @param ec Current emulated EC state - * @param blob Device tree blob containing keyscan information * @param node Keyboard node of device tree containing keyscan information * @return 0 if ok, -1 on error */ -static int keyscan_read_fdt_matrix(struct ec_state *ec, const void *blob, - int node) +static int keyscan_read_fdt_matrix(struct ec_state *ec, ofnode node) { const u32 *cell; int upto; int len; - cell = fdt_getprop(blob, node, "linux,keymap", &len); + cell = ofnode_read_prop(node, "linux,keymap", &len); ec->matrix_count = len / 4; ec->matrix = calloc(ec->matrix_count, sizeof(*ec->matrix)); if (!ec->matrix) { @@ -516,28 +514,29 @@ int cros_ec_probe(struct udevice *dev) { struct ec_state *ec = dev->priv; struct cros_ec_dev *cdev = dev->uclass_priv; - const void *blob = gd->fdt_blob; struct udevice *keyb_dev; - int node; + ofnode node; int err; memcpy(ec, &s_state, sizeof(*ec)); - err = cros_ec_decode_ec_flash(blob, dev_of_offset(dev), &ec->ec_config); - if (err) + err = cros_ec_decode_ec_flash(dev, &ec->ec_config); + if (err) { + debug("%s: Cannot device EC flash\n", __func__); return err; + } - node = -1; + node = ofnode_null(); for (device_find_first_child(dev, &keyb_dev); keyb_dev; device_find_next_child(&keyb_dev)) { if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) { - node = dev_of_offset(keyb_dev); + node = dev_ofnode(keyb_dev); break; } } - if (node < 0) { + if (!ofnode_valid(node)) { debug("%s: No cros_ec keyboard found\n", __func__); - } else if (keyscan_read_fdt_matrix(ec, blob, node)) { + } else if (keyscan_read_fdt_matrix(ec, node)) { debug("%s: Could not read key matrix\n", __func__); return -1; } -- cgit v1.2.3