From patchwork Mon Oct 1 18:22:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 977398 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42PBBy1T6pz9s3l for ; Tue, 2 Oct 2018 04:48:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EC7D0C21FBC; Mon, 1 Oct 2018 18:43:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8DF10C22056; Mon, 1 Oct 2018 18:25:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DA01FC22084; Mon, 1 Oct 2018 18:24:14 +0000 (UTC) Received: from mail-oi1-f202.google.com (mail-oi1-f202.google.com [209.85.167.202]) by lists.denx.de (Postfix) with ESMTPS id D5DA3C22038 for ; Mon, 1 Oct 2018 18:24:05 +0000 (UTC) Received: by mail-oi1-f202.google.com with SMTP id x194-v6so6286755oix.10 for ; Mon, 01 Oct 2018 11:24:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tUzp7i/7KYG51IIfnC0C9Vz1+0usuyiJoGRuOXHhelI=; b=B44NWW1g6/PDaeNytaQ3iEB72PeeN13m/OKakZEJLYTOru6tsal/vGJ3ZRmu7vTDdi epiVYGPV9XiAatZ29rWmxHUHkVpvmcMOkBlQfG6zYHByYdT68l7x4vUxbsPLE9PcAuDd JzqhDehVFadeYTICxsENALR2ueFOEDY/R3UTWpww6mzmDOjLzMQIviAzUZ3sF+6XWrUY Juy+KEOzu08kSbgb7qASQoidj5q2ghT9oEpfOjYZn22G0UYcPCif9gmgH5UwPbTwr5y9 4q94q3bSJ3qZPw4+5Hm3pgn/ISgyAQeLcpVnVOH/q04Y+EU1/bxooHDc93mKyVDBI4Bw rHlA== X-Gm-Message-State: ABuFfoi5FjtqI0bfn4ZtOwTLWPyJvlXb5hnSRAs5Mkzs4AOIsYuA25CE EwCW7WI3RdnvUEabwbg5fuJg0uI= X-Google-Smtp-Source: ACcGV60XR0uftj3jTZPW58iqDWhk0O8k95dGoo1ODnXhedEhZEntPrrfpFsHLdJD+U6sLuB1ptXaMb8= X-Received: by 2002:a9d:4685:: with SMTP id z5-v6mr9766257ote.53.1538418244889; Mon, 01 Oct 2018 11:24:04 -0700 (PDT) Date: Mon, 1 Oct 2018 12:22:39 -0600 In-Reply-To: <20181001182249.129565-1-sjg@chromium.org> Message-Id: <20181001182249.129565-36-sjg@chromium.org> Mime-Version: 1.0 References: <20181001182249.129565-1-sjg@chromium.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 35/45] cros_ec: Add support for v3 messages on LPC X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" At present version 3 messages are only supported on SPI. Add support for using LPC as well, as used on samus. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/misc/cros_ec_lpc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/misc/cros_ec_lpc.c b/drivers/misc/cros_ec_lpc.c index be17adcc5ac..71d03bfba2b 100644 --- a/drivers/misc/cros_ec_lpc.c +++ b/drivers/misc/cros_ec_lpc.c @@ -40,6 +40,38 @@ static int wait_for_sync(struct cros_ec_dev *dev) return 0; } +int cros_ec_lpc_packet(struct udevice *udev, int out_bytes, int in_bytes) +{ + struct cros_ec_dev *dev = dev_get_uclass_priv(udev); + uint8_t *d; + int i; + + if (out_bytes > EC_LPC_HOST_PACKET_SIZE) + return log_msg_ret("Cannot send that many bytes\n", -E2BIG); + + if (in_bytes > EC_LPC_HOST_PACKET_SIZE) + return log_msg_ret("Cannot receive that many bytes\n", -E2BIG); + + if (wait_for_sync(dev)) + return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT); + + /* Write data */ + for (i = 0, d = (uint8_t *)dev->dout; i < out_bytes; i++, d++) + outb(*d, EC_LPC_ADDR_HOST_PACKET + i); + + /* Start the command */ + outb(EC_COMMAND_PROTOCOL_3, EC_LPC_ADDR_HOST_CMD); + + if (wait_for_sync(dev)) + return log_msg_ret("Timeout waiting ready\n", -ETIMEDOUT); + + /* Read back args */ + for (i = 0, d = dev->din; i < in_bytes; i++, d++) + *d = inb(EC_LPC_ADDR_HOST_PACKET + i); + + return in_bytes; +} + int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len) @@ -200,6 +232,7 @@ static int cros_ec_probe(struct udevice *dev) } static struct dm_cros_ec_ops cros_ec_ops = { + .packet = cros_ec_lpc_packet, .command = cros_ec_lpc_command, .check_version = cros_ec_lpc_check_version, };