From patchwork Sat Jan 16 21:52:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1427609 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=EPH1krX/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DJBgJ4h1Tz9s24 for ; Sun, 17 Jan 2021 08:55:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DF39E829F3; Sat, 16 Jan 2021 22:53:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="EPH1krX/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E2D46829EC; Sat, 16 Jan 2021 22:52:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 18EEA829E4 for ; Sat, 16 Jan 2021 22:52:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd2a.google.com with SMTP id y19so25409358iov.2 for ; Sat, 16 Jan 2021 13:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qd/OqDxy3na0kMPTPDIxgbiRvIt9tYXAC6Fc7pcbX8E=; b=EPH1krX/Hn1cHA0N+1xhjutRMEChtZBVnU/ZCbw+s2A+Dz6h/1BPK8umse1uudZ40D /KJsmOz7tw6dI14MnCjl80rrTAWva8qYaOgOBcZxxYMQWKnUe5/0c690by1SO5Z+tTUI UqV1qz4Q+yVZEhfEOFL3xbZJ+AwvCL+HaVMWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qd/OqDxy3na0kMPTPDIxgbiRvIt9tYXAC6Fc7pcbX8E=; b=oRMoITqDs6zievAiTkcRVrcKqW/maNu0JBZG0LJTg94h5UjCQJqK+cd3B79hA7hJGL 9zKKVzJ6mPp+Syb8F12bYkcP21PTXYVvLpULCpgf0WRbRAUV+5XWREtcz7bYOx5ysQK5 r5xMydsQFS/otUocYSL9MXEyhJpnfiEheDGKEXY3mDO8K0Y5buu6vwoRdB22koiWed14 B1J4f3pdO+aWlEsOFYy7Kawsjm51moPVCmhRFWLEoGzA/8iKl9PE1koFAZg6LgsMqKDG uX836Q7K4dfyMsLFTjuwfCz56sFk5SgIabMfTOBoluyZyWbbvsJl82zWhKI/jwbJvXSJ 7VgQ== X-Gm-Message-State: AOAM533nS8HH9AylTiv9guWeQnRpt8elZsBUwwE8ARhDlEWPXe8dj8Nr 6ZZR142MUNSgNrIzces+VAy9mQ+YlGU3FfsA X-Google-Smtp-Source: ABdhPJxYzMEi/dGQ3M6SiTHmOt9TXICsJ19OTfpqhbD/fMG6AyQwRirvyHLyPmSkq/vVGhDTt5rvxA== X-Received: by 2002:a5e:840d:: with SMTP id h13mr13072311ioj.23.1610833960720; Sat, 16 Jan 2021 13:52:40 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id r1sm3356359iot.8.2021.01.16.13.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jan 2021 13:52:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Alper Nebi Yasak Subject: [PATCH 06/10] cros_ec: Add documentation for cros_ec driver operations Date: Sat, 16 Jan 2021 14:52:27 -0700 Message-Id: <20210116145217.6.I412e5d05d279e8f763eb90b2c4b3d54310f47578@changeid> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog In-Reply-To: <20210116215231.1220196-1-sjg@chromium.org> References: <20210116215231.1220196-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Add comments to these methods so it is documented in this central place, not just in each driver. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- include/cros_ec.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/cros_ec.h b/include/cros_ec.h index 338878c3bed..26e3f3ba0cb 100644 --- a/include/cros_ec.h +++ b/include/cros_ec.h @@ -234,10 +234,50 @@ int cros_ec_flash_update_rw(struct udevice *dev, const uint8_t *image, struct udevice *board_get_cros_ec_dev(void); struct dm_cros_ec_ops { + /** + * check_version() - Check the protocol version being used (optional) + * + * If provided, this function should check that the EC can be supported + * by the driver. If not provided, HELLO messages will be sent to try + * to determine the protocol version. + * + * @dev: Device to check + * @return 0 if the protocol is valid, -ve if not supported + */ int (*check_version)(struct udevice *dev); + + /** + * command() - Old-style command interface + * + * This sends a command and receives a response (deprecated, use + * packet()) + * + * @dev: Device to use + * @cmd: Command to send (only supports 0-0xff) + * @cmd_version: Version of command to send (often 0) + * @dout: Output data (may be NULL If dout_len=0) + * @dout_len: Length of output data excluding 4-byte header + * @dinp: On input, set to point to input data, often struct + * cros_ec_dev->din - typically this is left alone but may be + * updated by the driver + * @din_len: Maximum length of response + * @return number of bytes in response, or -ve on error + */ int (*command)(struct udevice *dev, uint8_t cmd, int cmd_version, const uint8_t *dout, int dout_len, uint8_t **dinp, int din_len); + + /** + * packet() - New-style command interface + * + * This interface is preferred over command(), since it is typically + * easier to implement. + * + * @dev: Device to use + * @out_bytes: Number of bytes to send (from struct cros_ec_dev->dout) + * @in_bytes: Maximum number of bytes to expect in response + * @return number of bytes in response, or -ve on error + */ int (*packet)(struct udevice *dev, int out_bytes, int in_bytes); };