Skip to content

Commit 42ec4cc

Browse files
authored
Merge pull request #733 from FrameworkComputer/azalea.PL_v0716_fan_v0719
Azalea.pl v0716 fan v0719
2 parents 7343d12 + 74ee5bb commit 42ec4cc

File tree

5 files changed

+99
-43
lines changed

5 files changed

+99
-43
lines changed

zephyr/program/lotus/azalea/overlay.dtsi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
named-temp-sensors {
1515
compatible = "cros-ec,temp-sensors";
1616
local-f75303 {
17-
temp_host_warn = <52>;
18-
temp_host_high = <70>;
17+
temp_host_warn = <70>;
18+
temp_host_high = <80>;
1919
temp_host_halt = <120>;
20-
temp_host_release_warn = <45>;
20+
temp_host_release_warn = <50>;
2121
temp_host_release_high = <55>;
2222
temp_host_release_halt = <115>;
2323
temp_fan_off = <40>;
@@ -26,10 +26,10 @@
2626
sensor = <&local_f75303>;
2727
};
2828
cpu-f75303 {
29-
temp_host_warn = <61>;
30-
temp_host_high = <70>;
29+
temp_host_warn = <70>;
30+
temp_host_high = <80>;
3131
temp_host_halt = <120>;
32-
temp_host_release_warn = <50>;
32+
temp_host_release_warn = <53>;
3333
temp_host_release_high = <55>;
3434
temp_host_release_halt = <115>;
3535
temp_fan_off = <46>;
@@ -38,10 +38,10 @@
3838
sensor = <&cpu_f75303>;
3939
};
4040
ddr-f75303 {
41-
temp_host_warn = <49>;
42-
temp_host_high = <70>;
41+
temp_host_warn = <70>;
42+
temp_host_high = <80>;
4343
temp_host_halt = <120>;
44-
temp_host_release_warn = <45>;
44+
temp_host_release_warn = <50>;
4545
temp_host_release_high = <55>;
4646
temp_host_release_halt = <115>;
4747
temp_fan_off = <128>;

zephyr/program/lotus/azalea/src/cpu_power.c

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,54 +74,64 @@ static void set_pl_limits(uint32_t spl, uint32_t fppt, uint32_t sppt, uint32_t p
7474
update_peak_package_power_limit(p3t);
7575
}
7676

77-
static void update_os_power_slider(int mode, int with_dc, int active_mpower)
77+
static void update_os_power_slider(int mode, int active_mpower)
7878
{
7979
switch (mode) {
8080
case EC_DC_BEST_PERFORMANCE:
8181
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 30000;
8282
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 35000;
83-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = battery_mwatt_type - POWER_ROP;
83+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
84+
((battery_mwatt_type == BATTERY_61mW) ? 46000 : 40000);
85+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] =
86+
((battery_mwatt_type == BATTERY_61mW) ? 70000 : 80000);
8487
CPRINTS("DC BEST PERFORMANCE");
8588
break;
8689
case EC_DC_BALANCED:
8790
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 28000;
8891
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 33000;
89-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = battery_mwatt_type - POWER_ROP;
92+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
93+
((battery_mwatt_type == BATTERY_61mW) ? 41000 : 35000);
94+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] =
95+
((battery_mwatt_type == BATTERY_61mW) ? 70000 : 80000);
9096
CPRINTS("DC BALANCED");
9197
break;
9298
case EC_DC_BEST_EFFICIENCY:
9399
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 15000;
94100
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 20000;
95101
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 30000;
102+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] =
103+
((battery_mwatt_type == BATTERY_61mW) ? 70000 : 80000);
96104
CPRINTS("DC BEST EFFICIENCY");
97105
break;
98106
case EC_DC_BATTERY_SAVER:
99107
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 15000;
100108
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 15000;
101109
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 30000;
110+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] = battery_mwatt_type;
102111
CPRINTS("DC BATTERY SAVER");
103112
break;
104113
case EC_AC_BEST_PERFORMANCE:
105114
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 30000;
106-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
107-
(with_dc ? 35000 : (MIN(35000, ((active_mpower - 15000) * 9 / 10))));
115+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 35000;
108116
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 53000;
117+
/* p3t is for minimum power table */
118+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] = 30000;
109119
CPRINTS("AC BEST PERFORMANCE");
110120
break;
111121
case EC_AC_BALANCED:
112122
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 28000;
113-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
114-
(with_dc ? 33000 : (MIN(33000, ((active_mpower - 15000) * 9 / 10))));
115-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
116-
(with_dc ? 51000 : (MIN(51000, (active_mpower - 15000))));
123+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 33000;
124+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 51000;
125+
/* p3t is for minimum power table */
126+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] = 28000;
117127
CPRINTS("AC BALANCED");
118128
break;
119129
case EC_AC_BEST_EFFICIENCY:
120-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = (with_dc ? 15000 : 28000);
121-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] =
122-
(with_dc ? 25000 : (MIN(33000, ((active_mpower - 15000) * 9 / 10))));
123-
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
124-
(with_dc ? 30000 : (MIN(51000, (active_mpower - 15000))));
130+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 15000;
131+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 25000;
132+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] = 30000;
133+
/* p3t is for minimum power table */
134+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] = 28000;
125135
CPRINTS("AC BEST EFFICIENCY");
126136
break;
127137
default:
@@ -130,33 +140,50 @@ static void update_os_power_slider(int mode, int with_dc, int active_mpower)
130140
}
131141
}
132142

133-
static void update_adapter_power_limit(int battery_percent, int active_mpower)
143+
static void update_adapter_power_limit(int battery_percent,
144+
int active_mpower, bool with_dc, int ports_cost)
134145
{
135146
if ((active_mpower < 55000)) {
136-
/* dc mode (active_mpower == 0) or AC < 55W (active_mpower == 0) */
147+
/* DC mode (active_mpower == 0) or AC < 55W (active_mpower == 0) */
137148
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 30000;
138-
power_limit[FUNCTION_POWER].mwatt[TYPE_SPPT] = battery_mwatt_type - POWER_ROP;
139-
power_limit[FUNCTION_POWER].mwatt[TYPE_FPPT] = battery_mwatt_type - POWER_ROP;
149+
power_limit[FUNCTION_POWER].mwatt[TYPE_SPPT] = 35000;
150+
power_limit[FUNCTION_POWER].mwatt[TYPE_FPPT] =
151+
((battery_mwatt_type == BATTERY_61mW) ? 46000 : 40000);
140152
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] =
141-
battery_mwatt_p3t - POWER_ROP - POWER_PORT_COST;
142-
} else if (battery_percent > 40) {
143-
/* ADP > 55W and Battery percentage > 40% */
153+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T];
154+
} else if (!with_dc) {
155+
/* AC only and AC >= 55W */
144156
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 30000;
145157
power_limit[FUNCTION_POWER].mwatt[TYPE_SPPT] =
146-
MIN(43000, (active_mpower * 85 / 100) + battery_mwatt_type - POWER_ROP);
158+
MIN(power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT],
159+
(active_mpower - 15000 - ports_cost));
147160
power_limit[FUNCTION_POWER].mwatt[TYPE_FPPT] =
148-
MIN(53000, (active_mpower * 85 / 100) + battery_mwatt_type - POWER_ROP);
149-
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] = (active_mpower * 95 / 100)
150-
+ battery_mwatt_type - POWER_ROP - POWER_PORT_COST;
161+
MIN(power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT],
162+
(active_mpower - 15000 - ports_cost));
163+
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] =
164+
MAX(power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T],
165+
((active_mpower * 95 / 100) - 20000));
166+
} else if (battery_percent > 40) {
167+
/* ADP > 55W and Battery percentage > 40% */
168+
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 30000;
169+
power_limit[FUNCTION_POWER].mwatt[TYPE_SPPT] = 35000;
170+
power_limit[FUNCTION_POWER].mwatt[TYPE_FPPT] = 53000;
171+
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] =
172+
MAX(power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T],
173+
((active_mpower * 95 / 100) - 20000
174+
- (ports_cost ? 5000 : 0)) + battery_mwatt_type);
151175
} else {
152176
/* ADP > 55W and Battery percentage <= 40% */
153177
power_limit[FUNCTION_POWER].mwatt[TYPE_SPL] = 30000;
154178
power_limit[FUNCTION_POWER].mwatt[TYPE_SPPT] =
155-
MIN(43000, (active_mpower * 85 / 100) - POWER_ROP);
179+
MIN(power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT],
180+
(active_mpower * 85 / 100) - 20000 - ports_cost);
156181
power_limit[FUNCTION_POWER].mwatt[TYPE_FPPT] =
157-
MIN(53000, (active_mpower * 85 / 100) - POWER_ROP);
182+
MIN(power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT],
183+
(active_mpower * 85 / 100) - 20000 - ports_cost);
158184
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] =
159-
(active_mpower * 95 / 100) - POWER_ROP - POWER_PORT_COST;
185+
MAX(power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T],
186+
((active_mpower * 95 / 100) - 20000 - (ports_cost ? 5000 : 0)));
160187
}
161188
}
162189

@@ -251,6 +278,9 @@ void update_soc_power_limit(bool force_update, bool force_no_adapter)
251278
int active_mpower = charge_manager_get_power_limit_uw() / 1000;
252279
bool with_dc = ((battery_is_present() == BP_YES) ? true : false);
253280
int battery_percent = charge_get_percent();
281+
int ports_cost;
282+
283+
ports_cost = cypd_get_port_cost();
254284

255285
/* azalea take 55W and lower adp as no ac */
256286
if (force_no_adapter || (!extpower_is_present()) || (active_mpower < 55000)) {
@@ -261,10 +291,10 @@ void update_soc_power_limit(bool force_update, bool force_no_adapter)
261291

262292
if (old_slider_mode != mode) {
263293
old_slider_mode = mode;
264-
update_os_power_slider(mode, with_dc, active_mpower);
294+
update_os_power_slider(mode, active_mpower);
265295
}
266296

267-
update_adapter_power_limit(battery_percent, active_mpower);
297+
update_adapter_power_limit(battery_percent, active_mpower, with_dc, ports_cost);
268298

269299
if (active_mpower == 0)
270300
update_dc_safety_power_limit();
@@ -341,11 +371,11 @@ static void initial_soc_power_limit(void)
341371
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPL] = 28000;
342372
power_limit[FUNCTION_SLIDER].mwatt[TYPE_SPPT] = 33000;
343373
power_limit[FUNCTION_SLIDER].mwatt[TYPE_FPPT] =
344-
battery_mwatt_type - POWER_ROP - POWER_PORT_COST;
374+
((battery_mwatt_type == BATTERY_61mW) ? 41000 : 35000);
345375
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T] =
346-
battery_mwatt_p3t - POWER_ROP - POWER_PORT_COST;
376+
((battery_mwatt_type == BATTERY_61mW) ? 70000 : 80000);
347377
power_limit[FUNCTION_POWER].mwatt[TYPE_P3T] =
348-
battery_mwatt_p3t - POWER_ROP - POWER_PORT_COST;
378+
power_limit[FUNCTION_SLIDER].mwatt[TYPE_P3T];
349379
}
350380
DECLARE_HOOK(HOOK_INIT, initial_soc_power_limit, HOOK_PRIO_INIT_I2C);
351381

@@ -357,8 +387,8 @@ static int cmd_cpupower(int argc, const char **argv)
357387
CPRINTF("Now SOC Power Limit:\n FUNC = %d, SPL %dmW,\n",
358388
target_func[TYPE_SPL], power_limit[target_func[TYPE_SPL]].mwatt[TYPE_SPL]);
359389
CPRINTF("FUNC = %d, fPPT %dmW,\n FUNC = %d, sPPT %dmW,\n FUNC = %d, p3T %dmW\n",
360-
target_func[TYPE_SPPT], power_limit[target_func[TYPE_SPPT]].mwatt[TYPE_SPPT],
361390
target_func[TYPE_FPPT], power_limit[target_func[TYPE_FPPT]].mwatt[TYPE_FPPT],
391+
target_func[TYPE_SPPT], power_limit[target_func[TYPE_SPPT]].mwatt[TYPE_SPPT],
362392
target_func[TYPE_P3T], power_limit[target_func[TYPE_P3T]].mwatt[TYPE_P3T]);
363393

364394
if (argc >= 2) {

zephyr/program/lotus/include/cpu_power.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ struct power_limit_details {
4343
void update_soc_power_limit(bool force_update, bool force_no_adapter);
4444

4545
extern bool thermal_warn_trigger(void);
46+
extern int cypd_get_port_cost(void);
4647

4748
#endif /* __CROS_EC_CPU_POWER_H */

zephyr/program/lotus/include/cypress_pd_common.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,11 @@ int active_charge_pd_chip(void);
505505
*/
506506
int cypd_vbus_state_check(void);
507507

508+
/**
509+
* Return total ports cost, return by mW.
510+
*
511+
* @return int
512+
*/
513+
int cypd_get_port_cost(void);
514+
508515
#endif /* __CROS_EC_CYPRESS_PD_COMMON_H */

zephyr/program/lotus/src/cypress_pd_common.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,24 @@ void cypd_reinitialize(void)
15691569
}
15701570
}
15711571

1572+
/*****************************************************************************/
1573+
/* project function */
1574+
1575+
int cypd_get_port_cost(void)
1576+
{
1577+
int cost_sum = 0;
1578+
1579+
/* assume per port cost 5W */
1580+
for (int port_idx = 0; port_idx < PD_PORT_COUNT; port_idx++) {
1581+
if ((pd_port_states[port_idx].c_state == CCG_STATUS_SINK) ||
1582+
((pd_port_states[port_idx].pd_state)
1583+
&& (pd_port_states[port_idx].power_role == PD_ROLE_SOURCE)))
1584+
cost_sum = cost_sum + 5000000;
1585+
}
1586+
1587+
return (cost_sum / 1000);
1588+
}
1589+
15721590
/*****************************************************************************/
15731591
/* Host command */
15741592

0 commit comments

Comments
 (0)