Skip to content

Commit

Permalink
Remove main_cycle variable
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed Nov 22, 2024
1 parent 1e46f80 commit 328936c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
4 changes: 1 addition & 3 deletions src/board/system76/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ void timer_1(void) __interrupt(3) {}
void serial(void) __interrupt(4) {}
void timer_2(void) __interrupt(5) {}

uint8_t main_cycle = 0;

#define INTERVAL_1MS 1U
#define INTERVAL_5MS 5U
#define INTERVAL_100MS 100U
Expand Down Expand Up @@ -113,7 +111,7 @@ void main(void) {
systick_t last_time_500ms = 0;
systick_t last_time_1sec = 0;

for (main_cycle = 0;; main_cycle++) {
while (1) {
systick_t time = time_get();

if ((time - last_time_1ms) >= INTERVAL_1MS) {
Expand Down
35 changes: 15 additions & 20 deletions src/board/system76/common/power/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
#define HAVE_XLP_OUT 1
#endif

extern uint8_t main_cycle;

// VccRTC stable (55%) to RTCRST# high
#define tPCH01 delay_ms(9)
// VccDSW stable (95%) to RSMRST# high
Expand Down Expand Up @@ -201,7 +199,7 @@ void power_on(void) {
// Configure WLAN GPIOs before powering on
wireless_power(true);

DEBUG("%02X: power_on\n", main_cycle);
DEBUG("power_on\n");

// See Figure 12-19 in Whiskey Lake Platform Design Guide
// TODO - signal timing graph
Expand Down Expand Up @@ -278,7 +276,7 @@ void power_on(void) {
}

void power_off(void) {
DEBUG("%02X: power_off\n", main_cycle);
DEBUG("power_off\n");

#if HAVE_PCH_PWROK_EC
// De-assert SYS_PWROK
Expand Down Expand Up @@ -388,9 +386,6 @@ void power_event(void) {
}
battery_debug();

// Reset main loop cycle to force reading PECI and battery
main_cycle = 0;

// Send SCI to update AC and battery information
ac_send_sci = true;
}
Expand Down Expand Up @@ -419,7 +414,7 @@ void power_event(void) {
for (uint8_t i = 100; i != 0; i--) {
delay_ms(1);
if (gpio_get(&PWR_SW_N) != ps_new) {
DEBUG("%02X: Spurious press\n", main_cycle);
DEBUG("Spurious press\n");
ps_new = ps_last;
break;
} else if (power_button_disabled()) {
Expand All @@ -430,7 +425,7 @@ void power_event(void) {
}

if (ps_new != ps_last) {
DEBUG("%02X: Power switch press\n", main_cycle);
DEBUG("Power switch press\n");

// Enable S5 power if necessary, before sending PWR_BTN
update_power_state();
Expand All @@ -446,7 +441,7 @@ void power_event(void) {
}
#if LEVEL >= LEVEL_DEBUG
else if (ps_new && !ps_last) {
DEBUG("%02X: Power switch release\n", main_cycle);
DEBUG("Power switch release\n");
}
#endif
ps_last = ps_new;
Expand All @@ -461,7 +456,7 @@ void power_event(void) {
static bool pg_last = false;
bool pg_new = gpio_get(&ALL_SYS_PWRGD);
if (pg_new && !pg_last) {
DEBUG("%02X: ALL_SYS_PWRGD asserted\n", main_cycle);
DEBUG("ALL_SYS_PWRGD asserted\n");

//TODO: tPLT04;

Expand All @@ -478,7 +473,7 @@ void power_event(void) {
GPIO_SET_DEBUG(PCH_PWROK_EC, true);
#endif // HAVE_PCH_PWROK_EC
} else if (!pg_new && pg_last) {
DEBUG("%02X: ALL_SYS_PWRGD de-asserted\n", main_cycle);
DEBUG("ALL_SYS_PWRGD de-asserted\n");

#if HAVE_PCH_PWROK_EC
// De-assert SYS_PWROK
Expand All @@ -496,11 +491,11 @@ void power_event(void) {
bool rst_new = gpio_get(&BUF_PLT_RST_N);
#if LEVEL >= LEVEL_DEBUG
if (!rst_new && rst_last) {
DEBUG("%02X: PLT_RST# asserted\n", main_cycle);
DEBUG("PLT_RST# asserted\n");
} else
#endif
if (rst_new && !rst_last) {
DEBUG("%02X: PLT_RST# de-asserted\n", main_cycle);
DEBUG("PLT_RST# de-asserted\n");
#if CONFIG_BUS_ESPI
espi_reset();
#else // CONFIG_BUS_ESPI
Expand All @@ -514,9 +509,9 @@ void power_event(void) {
static bool sus_last = true;
bool sus_new = gpio_get(&SLP_SUS_N);
if (!sus_new && sus_last) {
DEBUG("%02X: SLP_SUS# asserted\n", main_cycle);
DEBUG("SLP_SUS# asserted\n");
} else if (sus_new && !sus_last) {
DEBUG("%02X: SLP_SUS# de-asserted\n", main_cycle);
DEBUG("SLP_SUS# de-asserted\n");
}
sus_last = sus_new;
#endif
Expand All @@ -532,9 +527,9 @@ void power_event(void) {
bool ack_new = gpio_get(&SUSWARN_N);
#if LEVEL >= LEVEL_DEBUG
if (ack_new && !ack_last) {
DEBUG("%02X: SUSPWRDNACK asserted\n", main_cycle);
DEBUG("SUSPWRDNACK asserted\n");
} else if (!ack_new && ack_last) {
DEBUG("%02X: SUSPWRDNACK de-asserted\n", main_cycle);
DEBUG("SUSPWRDNACK de-asserted\n");
}
#endif
ack_last = ack_new;
Expand All @@ -560,14 +555,14 @@ void power_event(void) {
bool wake_new = gpio_get(&LAN_WAKEUP_N);
if (!wake_new && wake_last) {
update_power_state();
DEBUG("%02X: LAN_WAKEUP# asserted\n", main_cycle);
DEBUG("LAN_WAKEUP# asserted\n");
if (power_state == POWER_STATE_OFF) {
power_on();
}
}
#if LEVEL >= LEVEL_DEBUG
else if (wake_new && !wake_last) {
DEBUG("%02X: LAN_WAKEUP# de-asserted\n", main_cycle);
DEBUG("LAN_WAKEUP# de-asserted\n");
}
#endif
wake_last = wake_new;
Expand Down

0 comments on commit 328936c

Please sign in to comment.