From patchwork Tue Nov 14 11:44:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10057423 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 74D5D6023A for ; Tue, 14 Nov 2017 11:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6454E29716 for ; Tue, 14 Nov 2017 11:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5907129720; Tue, 14 Nov 2017 11:45:12 +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=-6.9 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 0BF4D29716 for ; Tue, 14 Nov 2017 11:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753882AbdKNLow (ORCPT ); Tue, 14 Nov 2017 06:44:52 -0500 Received: from mail1.bemta6.messagelabs.com ([193.109.254.113]:9865 "EHLO mail1.bemta6.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753988AbdKNLop (ORCPT ); Tue, 14 Nov 2017 06:44:45 -0500 Received: from [85.158.140.211] by server-9.bemta-6.messagelabs.com id 16/60-29052-C27DA0A5; Tue, 14 Nov 2017 11:44:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkleJIrShJLcpLzFFi42KJ27nUWFf7Ole UweSPlhbNi9ezWbw5Pp3Jomv1ThaLy7vmsFl87j3CaLFoWSuzxZOFZ5gsGhe8Z7E4vbvE4s/z W2wOXB47Z91l99i0qpPNY97JQI/9c9ewe7zfd5XNY+f3BnaPz5vkAtijWDPzkvIrElgzXv66z l7wj7di3ZMpLA2Mi3m6GLk4hATWM0rsbrrG1MXICeRUSHQ9W8rcxcjBwSuQKfF/cRZImFPAXW Jp21VWiBI3ieMr3zGC2GwCFhKTTzxgA7FZBFQl5jyezgJiCwsESRyceZIVZL6IwDwmiVcb7oI VMQvUSfT+fgtWxCsgKHFy5hMWiLiExMEXL5ghFhhInF7QCBaXELCXmP7+Ktg9EgL6Eo3HYiHC hhLfZ32DKjGXOLNsIuMERsFZSKbOQjJ1ASPTKkaN4tSistQiXWMDvaSizPSMktzEzBxdQwMzv dzU4uLE9NScxKRiveT83E2MwGhhAIIdjH/XBh5ilORgUhLlVfnMHiXEl5SfUpmRWJwRX1Sak1 p8iFGGg0NJgjfuGleUkGBRanpqRVpmDjBuYdISHDxKIrzKIGne4oLE3OLMdIjUKUZdjmczXzc wC7Hk5eelSonzmoEUCYAUZZTmwY2ApZBLjLJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEub1BpnC k5lXArfpFdARTEBHSIHcz1tckoiQkmpgzL02Q3fWtaxT/Ey7vt38lFylMt1L/rVYqLOAPtNmb a1T98U4nL0dLdeG6icpnXLgftpT8Gsma/exF3LvLf5/Dq/vWBZtyctfdexyhqX/+uqa+yU835 M4j70yOvU9bVoZQ7/Qh0W3dnVs+Cv6+eixE+Hnqxw+Hpq3I8zh5z8BveXGx3r99PqtlFiKMxI NtZiLihMB/sKPrhwDAAA= X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-9.tower-194.messagelabs.com!1510659883!112655921!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18935 invoked from network); 14 Nov 2017 11:44:43 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-9.tower-194.messagelabs.com with AES128-SHA encrypted SMTP; 14 Nov 2017 11:44:43 -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, 14 Nov 2017 11:44:43 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 4A3303FBD7; Tue, 14 Nov 2017 11:44:43 +0000 (GMT) Message-ID: <7310082fc65e2effa48a065d3e4755d7cd75595c.1510657748.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Tue, 14 Nov 2017 11:44:43 +0000 Subject: [RFC PATCH v2 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: 14/11/2017 09:42: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 */