From patchwork Mon Dec 18 12:41:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10119499 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 3327260327 for ; Mon, 18 Dec 2017 12:45:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23B6928E7B for ; Mon, 18 Dec 2017 12:45:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 172B228FD4; Mon, 18 Dec 2017 12:45:07 +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 860D028E7B for ; Mon, 18 Dec 2017 12:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759382AbdLRMnm (ORCPT ); Mon, 18 Dec 2017 07:43:42 -0500 Received: from mail1.bemta5.messagelabs.com ([195.245.231.143]:56682 "EHLO mail1.bemta5.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759204AbdLRMln (ORCPT ); Mon, 18 Dec 2017 07:41:43 -0500 Received: from [85.158.139.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-7.bemta-5.messagelabs.com id 09/17-08891-487B73A5; Mon, 18 Dec 2017 12:41:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleJIrShJLcpLzFFi42KJ27nUWLdlu3m UwYMVKhbNi9ezWbw5Pp3Jomv1ThaLy7vmsFl87j3CaLFoWSuzxZOFZ5gsGhe8Z7E4vbvE4s/z W2wOXB47Z91l99i0qpPNY97JQI/9c9ewe7zfd5XNY+f3BnaPz5vkAtijWDPzkvIrElgzXv66z l7wj7di3ZMpLA2Mi3m6GDk5hATWM0rsu8oMYVdItDUcZQKxeQUyJWaves0IYnMKuEtsXX8FKM 4BVOMm8XahP0iYTcBCYvKJB2wgNouAqsTnFwfByoUF/CRuL37F3sXIxSEiMI9J4tWGu2BFzAJ 1Er2/37JAzBeUODnzCQtEXELi4IsXUDcYSJxe0AgWlxCwl5j+HuQ2DiBbX6LxWCxE2FDi+6xv LBBhc4m2J/4TGAVnIRk6C8nQBYxMqxjVi1OLylKLdM31kooy0zNKchMzc3QNDUz1clOLixPTU 3MSk4r1kvNzNzEC44QBCHYwHpvsfIhRkoNJSZR3JrdZlBBfUn5KZUZicUZ8UWlOavEhRhkODi UJ3spt5lFCgkWp6akVaZk5wIiFSUtw8CiJ8BqBpHmLCxJzizPTIVKnGHU5ns183cAsxJKXn5c qJc7rBlIkAFKUUZoHNwKWPC4xykoJ8zICHSXEU5BalJtZgir/ilGcg1FJmHcbyBSezLwSuE2v gI5gAjpiagTYESWJCCmpBsasMFY+dfvPl2YtOTFTscLV7pLwS+t5HFUz+Xt8hI/w8GgwMDcbb vQ4uqz2/rX03RP82jr/20j6+orlC6YpWdvZGcrHZ0bVelUHHhNy2BlYtChQWp3fnlFd5fWRdg Hd7/8namvsSl07R8za/cW9J+GFf2cVtsxNuHtNZsuZe9P/8bNPnO/Er8RSnJFoqMVcVJwIAA5 8aS0ZAwAA X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-13.tower-179.messagelabs.com!1513600899!106262486!3 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17344 invoked from network); 18 Dec 2017 12:41:40 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-13.tower-179.messagelabs.com with AES128-SHA encrypted SMTP; 18 Dec 2017 12:41:40 -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; Mon, 18 Dec 2017 12:41:38 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id E29183FBE3; Mon, 18 Dec 2017 12:41:37 +0000 (GMT) Message-ID: <025e03a306ab7bfc8d763ae61ca6c97f2fb765de.1513599506.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Mon, 18 Dec 2017 12:41:37 +0000 Subject: [PATCH v3 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: 18/12/2017 09:33: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 --- 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 */