From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE1FCC04AB1 for ; Thu, 9 May 2019 21:14:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88A0921744 for ; Thu, 9 May 2019 21:14:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="k4AET8e0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727471AbfEIVOv (ORCPT ); Thu, 9 May 2019 17:14:51 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34255 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726903AbfEIVOs (ORCPT ); Thu, 9 May 2019 17:14:48 -0400 Received: by mail-pg1-f195.google.com with SMTP id c13so1848990pgt.1 for ; Thu, 09 May 2019 14:14:47 -0700 (PDT) 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=hiRsVnFkoaKdWe3RTNwSS2O9WyZw6tAbpUeMzGn2gBU=; b=k4AET8e0CEUJCdG3XMbYtHfngoRH29y57NEPjcyQ1ZRf0Qulf45ap44Qxuu6A8OFXP nI3thRaZkI4kgdUg96lw5Pb8pxz2ppWbUdTFL6vR1nXTnVgB0ltQTI//oFXqKTjrLPRg J7wdF7o1I/quQGBNUuzfpK3DVrp5eNRcQd2w4= 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=hiRsVnFkoaKdWe3RTNwSS2O9WyZw6tAbpUeMzGn2gBU=; b=VTLfveGN8HAKxlwCKWGnogsDiEwj23v/OB7oTyYyBZWzk43kUyvLckyhQeuPZUO+ic fk4tkKdXo/MYmXQOGox9X1qWjnyEJgBGb7BKIQ/daEUS8WXkUom+porM+sjwR75qRwIo 4Pd57zcLed3yIqMYITJ+Oe3buSxxU+G2nCsRhXbepsd5oxL+/VqxkxAlGgO3JgE3X2jB FHe3pTHSd1SLJmzu1hwOsqOKbaQaF6dhrxMpY3HquQV5xG//nV2uWFhr/0GIN866Wl+t NKjtYnGN/6XKo86nLU4yB1Br5sTnxtv5dCVnyOWqvYyntoj9PG0amqGlBjP8EU3ZXl6M whSw== X-Gm-Message-State: APjAAAUIfbbVlF4FKcRU36yDjcaoWM9GIanBRghmXAqAos7kfPtY+7bR k1vyJewTID+pMo/7kJj3PHBVYg== X-Google-Smtp-Source: APXvYqzDqLIxCyKyXFHtmN2WxwUd+Y4m0NdE4zowfAFAyu0RmB1SkDroWBx3LwUwq/qBuK9Adgh1ww== X-Received: by 2002:a63:2c4a:: with SMTP id s71mr8524088pgs.373.1557436487374; Thu, 09 May 2019 14:14:47 -0700 (PDT) Received: from localhost ([2620:15c:202:1:3c8f:512b:3522:dfaf]) by smtp.gmail.com with ESMTPSA id z19sm3649946pgk.28.2019.05.09.14.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 14:14:46 -0700 (PDT) From: Gwendal Grignou To: enric.balletbo@collabora.com, bleung@chromium.org, groeck@chromium.org, lee.jones@linaro.org, jic23@kernel.org, broonie@kernel.org, cychiang@chromium.org, tiwai@suse.com Cc: linux-iio@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Gwendal Grignou Subject: [PATCH v3 29/30] mfd: cros_ec: Add Management API entry points Date: Thu, 9 May 2019 14:13:52 -0700 Message-Id: <20190509211353.213194-30-gwendal@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190509211353.213194-1-gwendal@chromium.org> References: <20190509211353.213194-1-gwendal@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add commands for test and management. Add command space for future development. Acked-by: Enric Balletbo i Serra Acked-by: Benson Leung Signed-off-by: Gwendal Grignou --- include/linux/mfd/cros_ec_commands.h | 113 +++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 860a76274334..fc8babce1576 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -5176,6 +5176,119 @@ struct ec_params_set_cbi { uint8_t data[]; /* For string and raw data */ } __ec_align1; +/* + * Information about resets of the AP by the EC and the EC's own uptime. + */ +#define EC_CMD_GET_UPTIME_INFO 0x0121 + +struct ec_response_uptime_info { + /* + * Number of milliseconds since the last EC boot. Sysjump resets + * typically do not restart the EC's time_since_boot epoch. + * + * WARNING: The EC's sense of time is much less accurate than the AP's + * sense of time, in both phase and frequency. This timebase is similar + * to CLOCK_MONOTONIC_RAW, but with 1% or more frequency error. + */ + uint32_t time_since_ec_boot_ms; + + /* + * Number of times the AP was reset by the EC since the last EC boot. + * Note that the AP may be held in reset by the EC during the initial + * boot sequence, such that the very first AP boot may count as more + * than one here. + */ + uint32_t ap_resets_since_ec_boot; + + /* + * The set of flags which describe the EC's most recent reset. See + * include/system.h RESET_FLAG_* for details. + */ + uint32_t ec_reset_flags; + + /* Empty log entries have both the cause and timestamp set to zero. */ + struct ap_reset_log_entry { + /* + * See include/chipset.h: enum chipset_{reset,shutdown}_reason + * for details. + */ + uint16_t reset_cause; + + /* Reserved for protocol growth. */ + uint16_t reserved; + + /* + * The time of the reset's assertion, in milliseconds since the + * last EC boot, in the same epoch as time_since_ec_boot_ms. + * Set to zero if the log entry is empty. + */ + uint32_t reset_time_ms; + } recent_ap_reset[4]; +} __ec_align4; + +/* + * Add entropy to the device secret (stored in the rollback region). + * + * Depending on the chip, the operation may take a long time (e.g. to erase + * flash), so the commands are asynchronous. + */ +#define EC_CMD_ADD_ENTROPY 0x0122 + +enum add_entropy_action { + /* Add entropy to the current secret. */ + ADD_ENTROPY_ASYNC = 0, + /* + * Add entropy, and also make sure that the previous secret is erased. + * (this can be implemented by adding entropy multiple times until + * all rolback blocks have been overwritten). + */ + ADD_ENTROPY_RESET_ASYNC = 1, + /* Read back result from the previous operation. */ + ADD_ENTROPY_GET_RESULT = 2, +}; + +struct ec_params_rollback_add_entropy { + uint8_t action; +} __ec_align1; + +/* + * Perform a single read of a given ADC channel. + */ +#define EC_CMD_ADC_READ 0x0123 + +struct ec_params_adc_read { + uint8_t adc_channel; +} __ec_align1; + +struct ec_response_adc_read { + int32_t adc_value; +} __ec_align4; + +/* + * Read back rollback info + */ +#define EC_CMD_ROLLBACK_INFO 0x0124 + +struct ec_response_rollback_info { + int32_t id; /* Incrementing number to indicate which region to use. */ + int32_t rollback_min_version; + int32_t rw_rollback_version; +} __ec_align4; + + +/* Issue AP reset */ +#define EC_CMD_AP_RESET 0x0125 + +/*****************************************************************************/ +/* The command range 0x200-0x2FF is reserved for Rotor. */ + +/*****************************************************************************/ +/* + * Reserve a range of host commands for the CR51 firmware. + */ +#define EC_CMD_CR51_BASE 0x0300 +#define EC_CMD_CR51_LAST 0x03FF + /*****************************************************************************/ /* Fingerprint MCU commands: range 0x0400-0x040x */ -- 2.21.0.1020.gf2820cf01a-goog