diff options
| author | Sameer Nanda <snanda@chromium.org> | 2018-05-02 11:44:16 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2018-07-04 02:09:58 -0400 |
| commit | 06635894a371be69373fcb5484f559284c8d1ac3 (patch) | |
| tree | d91a59cea3b0a3cb58c7d43f2ed6c72e8a4f05e1 /include/linux/mfd | |
| parent | ce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff) | |
mfd: cros_ec: Add USBPD charger commands and struct definitions.
The USBPD charger driver gets information from the ChromeOS EC, this
patch adds the USBPD charger definitions needed by this driver.
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/cros_ec_commands.h | 132 |
1 files changed, 128 insertions, 4 deletions
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index f2edd9969b40..0d926492ac3a 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h | |||
| @@ -2593,14 +2593,18 @@ struct ec_params_current_limit { | |||
| 2593 | } __packed; | 2593 | } __packed; |
| 2594 | 2594 | ||
| 2595 | /* | 2595 | /* |
| 2596 | * Set maximum external power current. | 2596 | * Set maximum external voltage / current. |
| 2597 | */ | 2597 | */ |
| 2598 | #define EC_CMD_EXT_POWER_CURRENT_LIMIT 0xa2 | 2598 | #define EC_CMD_EXTERNAL_POWER_LIMIT 0x00A2 |
| 2599 | 2599 | ||
| 2600 | struct ec_params_ext_power_current_limit { | 2600 | /* Command v0 is used only on Spring and is obsolete + unsupported */ |
| 2601 | uint32_t limit; /* in mA */ | 2601 | struct ec_params_external_power_limit_v1 { |
| 2602 | uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */ | ||
| 2603 | uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */ | ||
| 2602 | } __packed; | 2604 | } __packed; |
| 2603 | 2605 | ||
| 2606 | #define EC_POWER_LIMIT_NONE 0xffff | ||
| 2607 | |||
| 2604 | /* Inform the EC when entering a sleep state */ | 2608 | /* Inform the EC when entering a sleep state */ |
| 2605 | #define EC_CMD_HOST_SLEEP_EVENT 0xa9 | 2609 | #define EC_CMD_HOST_SLEEP_EVENT 0xa9 |
| 2606 | 2610 | ||
| @@ -2974,6 +2978,12 @@ enum usb_chg_type { | |||
| 2974 | USB_CHG_TYPE_VBUS, | 2978 | USB_CHG_TYPE_VBUS, |
| 2975 | USB_CHG_TYPE_UNKNOWN, | 2979 | USB_CHG_TYPE_UNKNOWN, |
| 2976 | }; | 2980 | }; |
| 2981 | enum usb_power_roles { | ||
| 2982 | USB_PD_PORT_POWER_DISCONNECTED, | ||
| 2983 | USB_PD_PORT_POWER_SOURCE, | ||
| 2984 | USB_PD_PORT_POWER_SINK, | ||
| 2985 | USB_PD_PORT_POWER_SINK_NOT_CHARGING, | ||
| 2986 | }; | ||
| 2977 | 2987 | ||
| 2978 | struct usb_chg_measures { | 2988 | struct usb_chg_measures { |
| 2979 | uint16_t voltage_max; | 2989 | uint16_t voltage_max; |
| @@ -2991,6 +3001,120 @@ struct ec_response_usb_pd_power_info { | |||
| 2991 | uint32_t max_power; | 3001 | uint32_t max_power; |
| 2992 | } __packed; | 3002 | } __packed; |
| 2993 | 3003 | ||
| 3004 | struct ec_params_usb_pd_info_request { | ||
| 3005 | uint8_t port; | ||
| 3006 | } __packed; | ||
| 3007 | |||
| 3008 | /* Read USB-PD Device discovery info */ | ||
| 3009 | #define EC_CMD_USB_PD_DISCOVERY 0x0113 | ||
| 3010 | struct ec_params_usb_pd_discovery_entry { | ||
| 3011 | uint16_t vid; /* USB-IF VID */ | ||
| 3012 | uint16_t pid; /* USB-IF PID */ | ||
| 3013 | uint8_t ptype; /* product type (hub,periph,cable,ama) */ | ||
| 3014 | } __packed; | ||
| 3015 | |||
| 3016 | /* Override default charge behavior */ | ||
| 3017 | #define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114 | ||
| 3018 | |||
| 3019 | /* Negative port parameters have special meaning */ | ||
| 3020 | enum usb_pd_override_ports { | ||
| 3021 | OVERRIDE_DONT_CHARGE = -2, | ||
| 3022 | OVERRIDE_OFF = -1, | ||
| 3023 | /* [0, CONFIG_USB_PD_PORT_COUNT): Port# */ | ||
| 3024 | }; | ||
| 3025 | |||
| 3026 | struct ec_params_charge_port_override { | ||
| 3027 | int16_t override_port; /* Override port# */ | ||
| 3028 | } __packed; | ||
| 3029 | |||
| 3030 | /* Read (and delete) one entry of PD event log */ | ||
| 3031 | #define EC_CMD_PD_GET_LOG_ENTRY 0x0115 | ||
| 3032 | |||
| 3033 | struct ec_response_pd_log { | ||
| 3034 | uint32_t timestamp; /* relative timestamp in milliseconds */ | ||
| 3035 | uint8_t type; /* event type : see PD_EVENT_xx below */ | ||
| 3036 | uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */ | ||
| 3037 | uint16_t data; /* type-defined data payload */ | ||
| 3038 | uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */ | ||
| 3039 | } __packed; | ||
| 3040 | |||
| 3041 | /* The timestamp is the microsecond counter shifted to get about a ms. */ | ||
| 3042 | #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */ | ||
| 3043 | |||
| 3044 | #define PD_LOG_SIZE_MASK 0x1f | ||
| 3045 | #define PD_LOG_PORT_MASK 0xe0 | ||
| 3046 | #define PD_LOG_PORT_SHIFT 5 | ||
| 3047 | #define PD_LOG_PORT_SIZE(port, size) (((port) << PD_LOG_PORT_SHIFT) | \ | ||
| 3048 | ((size) & PD_LOG_SIZE_MASK)) | ||
| 3049 | #define PD_LOG_PORT(size_port) ((size_port) >> PD_LOG_PORT_SHIFT) | ||
| 3050 | #define PD_LOG_SIZE(size_port) ((size_port) & PD_LOG_SIZE_MASK) | ||
| 3051 | |||
| 3052 | /* PD event log : entry types */ | ||
| 3053 | /* PD MCU events */ | ||
| 3054 | #define PD_EVENT_MCU_BASE 0x00 | ||
| 3055 | #define PD_EVENT_MCU_CHARGE (PD_EVENT_MCU_BASE+0) | ||
| 3056 | #define PD_EVENT_MCU_CONNECT (PD_EVENT_MCU_BASE+1) | ||
| 3057 | /* Reserved for custom board event */ | ||
| 3058 | #define PD_EVENT_MCU_BOARD_CUSTOM (PD_EVENT_MCU_BASE+2) | ||
| 3059 | /* PD generic accessory events */ | ||
| 3060 | #define PD_EVENT_ACC_BASE 0x20 | ||
| 3061 | #define PD_EVENT_ACC_RW_FAIL (PD_EVENT_ACC_BASE+0) | ||
| 3062 | #define PD_EVENT_ACC_RW_ERASE (PD_EVENT_ACC_BASE+1) | ||
| 3063 | /* PD power supply events */ | ||
| 3064 | #define PD_EVENT_PS_BASE 0x40 | ||
| 3065 | #define PD_EVENT_PS_FAULT (PD_EVENT_PS_BASE+0) | ||
| 3066 | /* PD video dongles events */ | ||
| 3067 | #define PD_EVENT_VIDEO_BASE 0x60 | ||
| 3068 | #define PD_EVENT_VIDEO_DP_MODE (PD_EVENT_VIDEO_BASE+0) | ||
| 3069 | #define PD_EVENT_VIDEO_CODEC (PD_EVENT_VIDEO_BASE+1) | ||
| 3070 | /* Returned in the "type" field, when there is no entry available */ | ||
| 3071 | #define PD_EVENT_NO_ENTRY 0xff | ||
| 3072 | |||
| 3073 | /* | ||
| 3074 | * PD_EVENT_MCU_CHARGE event definition : | ||
| 3075 | * the payload is "struct usb_chg_measures" | ||
| 3076 | * the data field contains the port state flags as defined below : | ||
| 3077 | */ | ||
| 3078 | /* Port partner is a dual role device */ | ||
| 3079 | #define CHARGE_FLAGS_DUAL_ROLE BIT(15) | ||
| 3080 | /* Port is the pending override port */ | ||
| 3081 | #define CHARGE_FLAGS_DELAYED_OVERRIDE BIT(14) | ||
| 3082 | /* Port is the override port */ | ||
| 3083 | #define CHARGE_FLAGS_OVERRIDE BIT(13) | ||
| 3084 | /* Charger type */ | ||
| 3085 | #define CHARGE_FLAGS_TYPE_SHIFT 3 | ||
| 3086 | #define CHARGE_FLAGS_TYPE_MASK (0xf << CHARGE_FLAGS_TYPE_SHIFT) | ||
| 3087 | /* Power delivery role */ | ||
| 3088 | #define CHARGE_FLAGS_ROLE_MASK (7 << 0) | ||
| 3089 | |||
| 3090 | /* | ||
| 3091 | * PD_EVENT_PS_FAULT data field flags definition : | ||
| 3092 | */ | ||
| 3093 | #define PS_FAULT_OCP 1 | ||
| 3094 | #define PS_FAULT_FAST_OCP 2 | ||
| 3095 | #define PS_FAULT_OVP 3 | ||
| 3096 | #define PS_FAULT_DISCH 4 | ||
| 3097 | |||
| 3098 | /* | ||
| 3099 | * PD_EVENT_VIDEO_CODEC payload is "struct mcdp_info". | ||
| 3100 | */ | ||
| 3101 | struct mcdp_version { | ||
| 3102 | uint8_t major; | ||
| 3103 | uint8_t minor; | ||
| 3104 | uint16_t build; | ||
| 3105 | } __packed; | ||
| 3106 | |||
| 3107 | struct mcdp_info { | ||
| 3108 | uint8_t family[2]; | ||
| 3109 | uint8_t chipid[2]; | ||
| 3110 | struct mcdp_version irom; | ||
| 3111 | struct mcdp_version fw; | ||
| 3112 | } __packed; | ||
| 3113 | |||
| 3114 | /* struct mcdp_info field decoding */ | ||
| 3115 | #define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1]) | ||
| 3116 | #define MCDP_FAMILY(family) ((family[0] << 8) | family[1]) | ||
| 3117 | |||
| 2994 | /* Get info about USB-C SS muxes */ | 3118 | /* Get info about USB-C SS muxes */ |
| 2995 | #define EC_CMD_USB_PD_MUX_INFO 0x11a | 3119 | #define EC_CMD_USB_PD_MUX_INFO 0x11a |
| 2996 | 3120 | ||
