From patchwork Mon Jun 3 18:33:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 10973895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E901076 for ; Mon, 3 Jun 2019 18:58:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42F228688 for ; Mon, 3 Jun 2019 18:58:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C44E9286B2; Mon, 3 Jun 2019 18:58:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BA6428688 for ; Mon, 3 Jun 2019 18:58:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E53F383A; Mon, 3 Jun 2019 20:49:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E53F383A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1559587826; bh=MLDW2oENGeGWF+2KvRczCfvo4bopia2EwrxPClxglIs=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=a068OC8el0UJYrop1PIMrpzFfzKuGVe2Ul4Qvm7WP72kmHlT9PB0wq1Pu243kWlQr rdt5euSRMysDynNf/0SF/ic6Zlqn3cRuHiPlNAzfEd/Us/MpfbzYSQV4tLGigBAy0M PMJwDkShwy8x8ADXF8bTXe71lXCBkazCLv15fFb4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D51F7F897B1; Mon, 3 Jun 2019 20:35:01 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 46ADBF8977A; Mon, 3 Jun 2019 20:34:46 +0200 (CEST) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 29863F8976B for ; Mon, 3 Jun 2019 20:34:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 29863F8976B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="n006p07L" Received: by mail-pf1-x441.google.com with SMTP id a186so10396413pfa.5 for ; Mon, 03 Jun 2019 11:34:42 -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=PPnzB4+ekdR6MgK0N6rYp72AUYX34yF3bdFMrhiS2nI=; b=n006p07LUn1rqIDZLl97/sH1SmE4SUCOdWEGI7tIS673YMHQxXxpFf9PC2OxSj+Cxy g9Ol6K51u3N2QQOV7YeAwN+RLk/EfQFZaazOlFqryCx1F69eiMEdLUS9pFD8DRpIbUdq X8stQSGNm1z8Porz0ZLouQ77PllVbSP6T1KqY= 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=PPnzB4+ekdR6MgK0N6rYp72AUYX34yF3bdFMrhiS2nI=; b=OLzqsLapKW51F4stAzbx7fdEmhTAKwyF4uIogXJxOIjqZJUlnGkLiz24wkRM2wURtz 3nHt2XaaXyFWMf3ZPTo7Uxam2RyHuHpfKpcM+QkuEK9T85vRElUoRawYlUCfTX4pYnMo Yl/IL8+6CMXogKA9DZkDIXPD14SBPsfOlxGw42lPs0FkxlT4dUCHhlw22MOkE+DmQm/v Km40maN8TC0rmchKNdbBaupUo4uIsL64+mUhe/+RzbFwgiy+clL2Z2B9oB3wZW+ckQIs f0dQION9k9rT6ZDlABwbAd98vzDgm1IprLs5mRth5xsFIcbi8T1XPBHAzbbBcBnj/Pbk 0ZeA== X-Gm-Message-State: APjAAAW7NiC3MNX6cMcKdOkGBP6gsmVoBUuOfzc28m3tiR5VSM+X8W74 6H9KLByd648+pDFK6EDHigWgcw== X-Google-Smtp-Source: APXvYqxGEh4codWtYzCotWUDRWC62TxiynvejvyuxhVMDNLhv1lkKK4pOz6vKvp8FlURm1CUMvFW+Q== X-Received: by 2002:a63:87c8:: with SMTP id i191mr30553912pge.131.1559586881467; Mon, 03 Jun 2019 11:34:41 -0700 (PDT) Received: from localhost ([2620:15c:202:1:3c8f:512b:3522:dfaf]) by smtp.gmail.com with ESMTPSA id b2sm6165098pgk.50.2019.06.03.11.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 11:34:40 -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, fabien.lahoudere@collabora.com Date: Mon, 3 Jun 2019 11:33:53 -0700 Message-Id: <20190603183401.151408-23-gwendal@chromium.org> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog In-Reply-To: <20190603183401.151408-1-gwendal@chromium.org> References: <20190603183401.151408-1-gwendal@chromium.org> MIME-Version: 1.0 Cc: linux-iio@vger.kernel.org, Gwendal Grignou , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [RESEND PATCH v3 22/30] mfd: cros_ec: Add Smart Battery Firmware update API X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add API to update battery firmware. Acked-by: Enric Balletbo i Serra Acked-by: Benson Leung Reviewed-by: Fabien Lahoudere Signed-off-by: Gwendal Grignou --- include/linux/mfd/cros_ec_commands.h | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 7f98c6e63ad1..49ea905cfd18 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -4243,6 +4243,79 @@ struct ec_response_battery_vendor_param { uint32_t value; } __ec_align4; +/*****************************************************************************/ +/* + * Smart Battery Firmware Update Commands + */ +#define EC_CMD_SB_FW_UPDATE 0x00B5 + +enum ec_sb_fw_update_subcmd { + EC_SB_FW_UPDATE_PREPARE = 0x0, + EC_SB_FW_UPDATE_INFO = 0x1, /*query sb info */ + EC_SB_FW_UPDATE_BEGIN = 0x2, /*check if protected */ + EC_SB_FW_UPDATE_WRITE = 0x3, /*check if protected */ + EC_SB_FW_UPDATE_END = 0x4, + EC_SB_FW_UPDATE_STATUS = 0x5, + EC_SB_FW_UPDATE_PROTECT = 0x6, + EC_SB_FW_UPDATE_MAX = 0x7, +}; + +#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 32 +#define SB_FW_UPDATE_CMD_STATUS_SIZE 2 +#define SB_FW_UPDATE_CMD_INFO_SIZE 8 + +struct ec_sb_fw_update_header { + uint16_t subcmd; /* enum ec_sb_fw_update_subcmd */ + uint16_t fw_id; /* firmware id */ +} __ec_align4; + +struct ec_params_sb_fw_update { + struct ec_sb_fw_update_header hdr; + union { + /* EC_SB_FW_UPDATE_PREPARE = 0x0 */ + /* EC_SB_FW_UPDATE_INFO = 0x1 */ + /* EC_SB_FW_UPDATE_BEGIN = 0x2 */ + /* EC_SB_FW_UPDATE_END = 0x4 */ + /* EC_SB_FW_UPDATE_STATUS = 0x5 */ + /* EC_SB_FW_UPDATE_PROTECT = 0x6 */ + /* Those have no args */ + + /* EC_SB_FW_UPDATE_WRITE = 0x3 */ + struct __ec_align4 { + uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE]; + } write; + }; +} __ec_align4; + +struct ec_response_sb_fw_update { + union { + /* EC_SB_FW_UPDATE_INFO = 0x1 */ + struct __ec_align1 { + uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE]; + } info; + + /* EC_SB_FW_UPDATE_STATUS = 0x5 */ + struct __ec_align1 { + uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE]; + } status; + }; +} __ec_align1; + +/* + * Entering Verified Boot Mode Command + * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command. + * Valid Modes are: normal, developer, and recovery. + */ +#define EC_CMD_ENTERING_MODE 0x00B6 + +struct ec_params_entering_mode { + int vboot_mode; +} __ec_align4; + +#define VBOOT_MODE_NORMAL 0 +#define VBOOT_MODE_DEVELOPER 1 +#define VBOOT_MODE_RECOVERY 2 + /*****************************************************************************/ /* * HDMI CEC commands