From patchwork Fri May 3 22:02:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gwendal Grignou X-Patchwork-Id: 10929287 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 1D3E61390 for ; Fri, 3 May 2019 22:03:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E6DF287CE for ; Fri, 3 May 2019 22:03:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C18287D1; Fri, 3 May 2019 22:03:20 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95812287CE for ; Fri, 3 May 2019 22:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbfECWDU (ORCPT ); Fri, 3 May 2019 18:03:20 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40913 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfECWDU (ORCPT ); Fri, 3 May 2019 18:03:20 -0400 Received: by mail-pg1-f195.google.com with SMTP id d31so3339220pgl.7 for ; Fri, 03 May 2019 15:03:19 -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=lxLZO/4ISZtGoVIWN9Kc9oyM9nBCPCMCt4kbgFkVnf8=; b=AxOMGj62vqtLEIw5xuQKj/4VxrT7xtpQy0vIG2vE1jf4VGHB/OV5PlG42KJw6GQ/bY GNgN6PCiVXnF3A5SZu4Z3ou5LMN6Kxh6Jm+Pn5Net6W6XjajzyS3CgbrsqUT3UH5gNdV Z5rc2NrBUpQlW9qvecX2ifbDPoEJ6ncLARoFI= 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=lxLZO/4ISZtGoVIWN9Kc9oyM9nBCPCMCt4kbgFkVnf8=; b=EYfpR0HU7Ti/ScqR2VkcRUB3BAsi0xnLqSR+JWddNhuL2tWipShAPluQ1V3OW6DzEp 2ZCWh4sejH/Ey3YbIHtahV/gubw+BaxE8Nech6SY1iyp4A+Kyyz66EaXNbd/zsQXP65q 2uyCeM33DyA+o9/mBU1zIpR8YLpL/p7wNhTcXqUID7uiWIf2LA1fnjKdu0D3qMh5MceF jq9jjY0fqT3PFG2ySOn3DQCOSVXuvja7kjj1MvSnABCQvn9QqX1JayBgnst9bpgEW+hf gS3dhmjf72+YjLzOlcvm+8UIWJtQaye3+/MTas9xoezkGEkYuPpf1zB3xzDl9qLc+AFF VHmQ== X-Gm-Message-State: APjAAAUXEjVYR8jTYMYy+Fymk7XyeUP3axw5+CysTbNdlt1o7BBXpekc xQ8CYvQXOM+e23tar50Krj6FxOli0Qg= X-Google-Smtp-Source: APXvYqw/XHZ72GtFKQcUPZWWf/9sHyinZWxSv5HSP6F2RFrwm54VMdy6r04t5LZp20l33mowhq1rQA== X-Received: by 2002:a63:cf:: with SMTP id 198mr13258139pga.228.1556920999413; Fri, 03 May 2019 15:03:19 -0700 (PDT) Received: from localhost ([2620:15c:202:1:3c8f:512b:3522:dfaf]) by smtp.gmail.com with ESMTPSA id 4sm3977071pfi.94.2019.05.03.15.03.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 15:03:18 -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, Gwendal Grignou Subject: [PATCH v2 22/30] mfd: cros_ec: Add Smart Battery Firmware update API Date: Fri, 3 May 2019 15:02:25 -0700 Message-Id: <20190503220233.64546-23-gwendal@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190503220233.64546-1-gwendal@chromium.org> References: <20190503220233.64546-1-gwendal@chromium.org> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add API to update battery firmware. Acked-by: Enric Balletbo i Serra 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