1456ebb4fSAdam Thomson // SPDX-License-Identifier: GPL-2.0+ 2456ebb4fSAdam Thomson /* 3456ebb4fSAdam Thomson * Copyright (c) 2017 Dialog Semiconductor 4456ebb4fSAdam Thomson * 5456ebb4fSAdam Thomson * Author: Adam Thomson <Adam.Thomson.Opensource@diasemi.com> 6456ebb4fSAdam Thomson */ 7456ebb4fSAdam Thomson 8456ebb4fSAdam Thomson #ifndef __LINUX_USB_PD_ADO_H 9456ebb4fSAdam Thomson #define __LINUX_USB_PD_ADO_H 10456ebb4fSAdam Thomson 11456ebb4fSAdam Thomson /* ADO : Alert Data Object */ 12456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_SHIFT 24 13456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_MASK 0xff 14456ebb4fSAdam Thomson #define USB_PD_ADO_FIXED_BATT_SHIFT 20 15456ebb4fSAdam Thomson #define USB_PD_ADO_FIXED_BATT_MASK 0xf 16456ebb4fSAdam Thomson #define USB_PD_ADO_HOT_SWAP_BATT_SHIFT 16 17456ebb4fSAdam Thomson #define USB_PD_ADO_HOT_SWAP_BATT_MASK 0xf 18456ebb4fSAdam Thomson 19456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_BATT_STATUS_CHANGE BIT(1) 20456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_OCP BIT(2) 21456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_OTP BIT(3) 22456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_OP_COND_CHANGE BIT(4) 23456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_SRC_INPUT_CHANGE BIT(5) 24456ebb4fSAdam Thomson #define USB_PD_ADO_TYPE_OVP BIT(6) 25456ebb4fSAdam Thomson usb_pd_ado_type(u32 ado)26456ebb4fSAdam Thomsonstatic inline unsigned int usb_pd_ado_type(u32 ado) 27456ebb4fSAdam Thomson { 28456ebb4fSAdam Thomson return (ado >> USB_PD_ADO_TYPE_SHIFT) & USB_PD_ADO_TYPE_MASK; 29456ebb4fSAdam Thomson } 30456ebb4fSAdam Thomson usb_pd_ado_fixed_batt(u32 ado)31456ebb4fSAdam Thomsonstatic inline unsigned int usb_pd_ado_fixed_batt(u32 ado) 32456ebb4fSAdam Thomson { 33456ebb4fSAdam Thomson return (ado >> USB_PD_ADO_FIXED_BATT_SHIFT) & 34456ebb4fSAdam Thomson USB_PD_ADO_FIXED_BATT_MASK; 35456ebb4fSAdam Thomson } 36456ebb4fSAdam Thomson usb_pd_ado_hot_swap_batt(u32 ado)37456ebb4fSAdam Thomsonstatic inline unsigned int usb_pd_ado_hot_swap_batt(u32 ado) 38456ebb4fSAdam Thomson { 39456ebb4fSAdam Thomson return (ado >> USB_PD_ADO_HOT_SWAP_BATT_SHIFT) & 40456ebb4fSAdam Thomson USB_PD_ADO_HOT_SWAP_BATT_MASK; 41456ebb4fSAdam Thomson } 42456ebb4fSAdam Thomson #endif /* __LINUX_USB_PD_ADO_H */ 43