From patchwork Wed Nov 1 17:03:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10036799 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 593E66032D for ; Wed, 1 Nov 2017 17:04:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4377428A52 for ; Wed, 1 Nov 2017 17:04:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37EB328A6D; Wed, 1 Nov 2017 17:04:59 +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 B92D828A52 for ; Wed, 1 Nov 2017 17:04:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932196AbdKAREn (ORCPT ); Wed, 1 Nov 2017 13:04:43 -0400 Received: from mail1.bemta5.messagelabs.com ([195.245.231.142]:62442 "EHLO mail1.bemta5.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755013AbdKARDP (ORCPT ); Wed, 1 Nov 2017 13:03:15 -0400 Received: from [85.158.139.51] by server-6.bemta-5.messagelabs.com id 2D/3C-15231-05EF9F95; Wed, 01 Nov 2017 17:03:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkleJIrShJLcpLzFFi42KJ27nUWNf/389 Ig1urjS2aF69ns3hzfDqTRdfqnSwWl3fNYbP43HuE0WLRslZmiycLzzBZNC54z2JxeneJxZ/n t9gcuDx2zrrL7rFpVSebx7yTgR77565h93i/7yqbx87vDewenzfJBbBHsWbmJeVXJLBmTNx0j r1gp0DF873bmBoYe/m6GLk4hATWMUqcOvOepYuRA8ipkLjakNTFyMnBK5Ap8fBLKwuIzSngLv Hk8F9GEFtIwE1i75FeMJtNwEJi8okHbCA2i4CKxJL3/1hBbGEBf4kLPROZQOaLCMxjkni14S5 YEbNAnUTv77csEAsEJU7OfMICEZeQOPjiBTPEAgOJ0wsaweISAvYS099fZQa5TUJAX6LxWCxE 2FDi+6xvUCXmEu0b9zFPYBSchWTqLCRTFzAyrWLUKE4tKkst0jU010sqykzPKMlNzMzRNTQw1 ctNLS5OTE/NSUwq1kvOz93ECIwWBiDYwXjxtOchRkkOJiVRXs37PyOF+JLyUyozEosz4otKc1 KLDzHKcHAoSfBe+wOUEyxKTU+tSMvMAcYtTFqCg0dJhPcbSJq3uCAxtzgzHSJ1ilGX49nM1w3 MQix5+XmpUuK8un+BigRAijJK8+BGwFLIJUZZKWFeRqCjhHgKUotyM0tQ5V8xinMwKgnz8oBM 4cnMK4Hb9AroCCagI7wkfoAcUZKIkJJqYJT83iYc5FXPM5Pjvsnun4yB2Tf/HV7RLXyyuP/N/ qny88p/bDl2ON1w647CQw4FneoNBvc/es7a3JHZudSr8KHVe7OEO1aZvF2vJrouK2nd+nIb13 kencCStZGSxhEWlyO+b2LJjMq5vIonb/pJm/qVVYu/7ztTZDf9/Jnf0yIZqx/2qVqknFZiKc5 INNRiLipOBADMH41EHAMAAA== X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-12.tower-180.messagelabs.com!1509555791!78033089!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9688 invoked from network); 1 Nov 2017 17:03:11 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-12.tower-180.messagelabs.com with AES128-SHA encrypted SMTP; 1 Nov 2017 17:03:11 -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; Wed, 1 Nov 2017 17:03:10 +0000 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 89C9D3FBE7; Wed, 1 Nov 2017 17:03:10 +0000 (GMT) Message-ID: In-Reply-To: References: From: Adam Thomson Date: Wed, 1 Nov 2017 17:03:10 +0000 Subject: [RFC PATCH 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: 01/11/2017 12:45: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 | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 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..edcbcfa --- /dev/null +++ b/include/linux/usb/pd_ado.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 Dialog Semiconductor + * + * Author: Adam Thomson + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __LINUX_USB_PD_ADO_H +#define __LINUX_USB_PD_ADO_H + +/* ADO : Alert Data Object */ +#define ADO_TYPE_SHIFT 24 +#define ADO_TYPE_MASK 0xff +#define ADO_FIXED_BATT_SHIFT 20 +#define ADO_FIXED_BATT_MASK 0xf +#define ADO_HOT_SWAP_BATT_SHIFT 16 +#define ADO_HOT_SWAP_BATT_MASK 0xf + +#define ADO_TYPE_BATT_STATUS_CHANGE BIT(1) +#define ADO_TYPE_OCP BIT(2) +#define ADO_TYPE_OTP BIT(3) +#define ADO_TYPE_OP_COND_CHANGE BIT(4) +#define ADO_TYPE_SRC_INPUT_CHANGE BIT(5) +#define ADO_TYPE_OVP BIT(6) + +static inline unsigned int ado_type(u32 ado) +{ + return (ado >> ADO_TYPE_SHIFT) & ADO_TYPE_MASK; +} + +static inline unsigned int ado_fixed_batt(u32 ado) +{ + return (ado >> ADO_FIXED_BATT_SHIFT) & ADO_FIXED_BATT_MASK; +} + +static inline unsigned int ado_hot_swap_batt(u32 ado) +{ + return (ado >> ADO_HOT_SWAP_BATT_SHIFT) & ADO_HOT_SWAP_BATT_MASK; +} +#endif /* __LINUX_USB_PD_ADO_H */