|
@@ -117,6 +117,41 @@ bool pdbs_dpm_evaluate_capability(struct pdb_config *cfg,
|
117
|
117
|
/* Update requested voltage */
|
118
|
118
|
dpm_data->_requested_voltage = PD_PRV2MV(PD_MV2PRV(scfg->v));
|
119
|
119
|
|
|
120
|
+ dpm_data->_capability_match = true;
|
|
121
|
+ return true;
|
|
122
|
+ }
|
|
123
|
+ }
|
|
124
|
+ /* Look at the PDOs a second time to see if one falls in our voltage
|
|
125
|
+ * range. */
|
|
126
|
+ for (uint8_t i = 0; i < numobj; i++) {
|
|
127
|
+ /* If we have a fixed PDO, its V equals our desired V, and its I is
|
|
128
|
+ * at least our desired I */
|
|
129
|
+ if ((capabilities->obj[i] & PD_PDO_TYPE) == PD_PDO_TYPE_FIXED
|
|
130
|
+ && PD_PDO_SRC_FIXED_CURRENT_GET(capabilities, i) >= scfg->i
|
|
131
|
+ && PD_PDO_SRC_FIXED_VOLTAGE_GET(capabilities, i) >= PD_MV2PDV(scfg->vmin)
|
|
132
|
+ && PD_PDO_SRC_FIXED_VOLTAGE_GET(capabilities, i) <= PD_MV2PDV(scfg->vmax)) {
|
|
133
|
+ /* We got what we wanted, so build a request for that */
|
|
134
|
+ request->hdr = cfg->pe.hdr_template | PD_MSGTYPE_REQUEST
|
|
135
|
+ | PD_NUMOBJ(1);
|
|
136
|
+ if (scfg->flags & PDBS_CONFIG_FLAGS_GIVEBACK) {
|
|
137
|
+ /* GiveBack enabled */
|
|
138
|
+ request->obj[0] = PD_RDO_FV_MIN_CURRENT_SET(DPM_MIN_CURRENT)
|
|
139
|
+ | PD_RDO_FV_CURRENT_SET(scfg->i)
|
|
140
|
+ | PD_RDO_NO_USB_SUSPEND | PD_RDO_GIVEBACK
|
|
141
|
+ | PD_RDO_OBJPOS_SET(i + 1);
|
|
142
|
+ } else {
|
|
143
|
+ /* GiveBack disabled */
|
|
144
|
+ request->obj[0] = PD_RDO_FV_MAX_CURRENT_SET(scfg->i)
|
|
145
|
+ | PD_RDO_FV_CURRENT_SET(scfg->i)
|
|
146
|
+ | PD_RDO_NO_USB_SUSPEND | PD_RDO_OBJPOS_SET(i + 1);
|
|
147
|
+ }
|
|
148
|
+ if (dpm_data->usb_comms) {
|
|
149
|
+ request->obj[0] |= PD_RDO_USB_COMMS;
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ /* Update requested voltage */
|
|
153
|
+ dpm_data->_requested_voltage = PD_PDV2MV(PD_PDO_SRC_FIXED_VOLTAGE_GET(capabilities, i));
|
|
154
|
+
|
120
|
155
|
dpm_data->_capability_match = true;
|
121
|
156
|
return true;
|
122
|
157
|
}
|