From patchwork Tue Jan 2 15:50:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10140955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 707196035E for ; Tue, 2 Jan 2018 15:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 588AF283AD for ; Tue, 2 Jan 2018 15:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D491285E1; Tue, 2 Jan 2018 15:52:44 +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=-4.4 required=2.0 tests=BAYES_00,FROM_WORDY, RCVD_IN_DNSWL_HI autolearn=unavailable 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 EEDB4283AD for ; Tue, 2 Jan 2018 15:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751409AbeABPuz (ORCPT ); Tue, 2 Jan 2018 10:50:55 -0500 Received: from mail1.bemta3.messagelabs.com ([195.245.230.165]:49519 "EHLO mail1.bemta3.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751261AbeABPuy (ORCPT ); Tue, 2 Jan 2018 10:50:54 -0500 Received: from [85.158.137.99] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-5.bemta-3.messagelabs.com id 34/2D-09120-B5AAB4A5; Tue, 02 Jan 2018 15:50:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCKsWRWlGSWpSXmKPExsUSt3OpsW70Ku8 og+eX+S2aF69ns3hzfDqTRdfqnSwWl3fNYbP43HuE0WLRslZmiycLzzBZNC54z2JxeneJxZ/n t9gcuDx2zrrL7rFpVSebx7yTgR77565h93i/7yqbx87vDewenzfJBbBHsWbmJeVXJLBmvPx1n b3gH2/FuidTWBoYF/N0MXJxCAmsY5RYfuo5excjJ5BTITHp0h5GEJtXIFNi9c/TLF2MHBycAu 4SWz8xg5hCAm4Ss97WgVSwCVhITD7xgA3EZhFQkbh1cykriC0s4Cdxp/09C8h4EYF5TBKvNtw FK2IWqJPo/f2WBWK8oMTJmU9YIOISEgdfvGCGOMFA4vSCRrC4hIC9xPT3V8H2SgjoSzQei4UI G0p8n/UNqsRcYsftG6wTGAVnIZk6C8nUBYxMqxg1ilOLylKLdA3N9ZKKMtMzSnITM3N0DQ2M9 XJTi4sT01NzEpOK9ZLzczcxAmOFAQh2ML487XmIUZKDSUmUNyfVO0qILyk/pTIjsTgjvqg0J7 X4EKMGB4dAy8WTB5mkWPLy81KVJHgjVwLVCRalpqdWpGXmAKMZplSCg0dJhDcDJM1bXJCYW5y ZDpE6xajL8Wzm6wZmIbAZUuIQRQIgRRmleXAjYInlEqOslDAvI9CBQjwFqUW5mSWo8q8YxTkY lYR580Gm8GTmlcBtegV0BBPQEX/Oe4IcUZKIkJJqYBTTOXRjMtsrhvtfq+eUXeGvvZq5vPPU7 13CZU+eXRe4pPzt5vnEn4eU9V9ILLe8bh54VND4l9BVndVu5599Zq8RtJ1Wy9W1wcJILd00kT ez9FOJMVNa8PKZvLJdqRPD/NZcFHI6pdah8vj5nHaP3EMbltydFec55+OJ+MUFknkrK4/GT0w NS1BiKc5INNRiLipOBABjcrvbJwMAAA== X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-3.tower-217.messagelabs.com!1514908250!103422941!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12555 invoked from network); 2 Jan 2018 15:50:51 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-3.tower-217.messagelabs.com with AES128-SHA encrypted SMTP; 2 Jan 2018 15:50:51 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.248.2; Tue, 2 Jan 2018 15:50:50 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 7B72E3FBF2; Tue, 2 Jan 2018 15:50:50 +0000 (GMT) Message-ID: <00dbaa0d4c1033166a55278ce8c24ffa2711d7bb.1514904982.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Tue, 2 Jan 2018 15:50:50 +0000 Subject: [PATCH v4 2/7] typec: tcpm: Add ADO header for Alert message handling To: Heikki Krogerus , Guenter Roeck , Greg Kroah-Hartman , Sebastian Reichel , Hans de Goede , Yueyao Zhu , Rui Miguel Silva CC: , , , MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 02/01/2018 11:56:00 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit adds a header providing definitions for handling Alert messages. Currently the header only focuses on handling incoming alerts. Signed-off-by: Adam Thomson Acked-by: Heikki Krogerus --- include/linux/usb/pd_ado.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/linux/usb/pd_ado.h diff --git a/include/linux/usb/pd_ado.h b/include/linux/usb/pd_ado.h new file mode 100644 index 0000000..9aa1cf3 --- /dev/null +++ b/include/linux/usb/pd_ado.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2017 Dialog Semiconductor + * + * Author: Adam Thomson + */ + +#ifndef __LINUX_USB_PD_ADO_H +#define __LINUX_USB_PD_ADO_H + +/* ADO : Alert Data Object */ +#define USB_PD_ADO_TYPE_SHIFT 24 +#define USB_PD_ADO_TYPE_MASK 0xff +#define USB_PD_ADO_FIXED_BATT_SHIFT 20 +#define USB_PD_ADO_FIXED_BATT_MASK 0xf +#define USB_PD_ADO_HOT_SWAP_BATT_SHIFT 16 +#define USB_PD_ADO_HOT_SWAP_BATT_MASK 0xf + +#define USB_PD_ADO_TYPE_BATT_STATUS_CHANGE BIT(1) +#define USB_PD_ADO_TYPE_OCP BIT(2) +#define USB_PD_ADO_TYPE_OTP BIT(3) +#define USB_PD_ADO_TYPE_OP_COND_CHANGE BIT(4) +#define USB_PD_ADO_TYPE_SRC_INPUT_CHANGE BIT(5) +#define USB_PD_ADO_TYPE_OVP BIT(6) + +static inline unsigned int usb_pd_ado_type(u32 ado) +{ + return (ado >> USB_PD_ADO_TYPE_SHIFT) & USB_PD_ADO_TYPE_MASK; +} + +static inline unsigned int usb_pd_ado_fixed_batt(u32 ado) +{ + return (ado >> USB_PD_ADO_FIXED_BATT_SHIFT) & + USB_PD_ADO_FIXED_BATT_MASK; +} + +static inline unsigned int usb_pd_ado_hot_swap_batt(u32 ado) +{ + return (ado >> USB_PD_ADO_HOT_SWAP_BATT_SHIFT) & + USB_PD_ADO_HOT_SWAP_BATT_MASK; +} +#endif /* __LINUX_USB_PD_ADO_H */