From ca35998d291e451587ba9beaf47e9bd49d519165 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 4 Nov 2019 18:45:17 -0700 Subject: [PATCH] Set USB power plane to off during restart Change-Id: I9d722b7b74dac1ccb7f0a80559cbdf763f4c6c1f --- src/mainboard/system76/cml-u/ramstage.c | 37 +++++++++++++++++++++++++ src/mainboard/system76/whl-u/ramstage.c | 37 +++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/mainboard/system76/cml-u/ramstage.c b/src/mainboard/system76/cml-u/ramstage.c index 133627d150..430645b008 100644 --- a/src/mainboard/system76/cml-u/ramstage.c +++ b/src/mainboard/system76/cml-u/ramstage.c @@ -29,6 +29,32 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) { cnl_configure_pads(gpio_table, ARRAY_SIZE(gpio_table)); } +static int ec_cmd(u8 value) { + int i = 1000000; + while ((inb(0x66) & 2) == 2 && i > 0) { + i -= 1; + } + if (i == 0) { + return 1; + } else { + outb(value, 0x66); + return 0; + } +} + +static int ec_write(u8 value) { + int i = 1000000; + while ((inb(0x66) & 2) == 2 && i > 0) { + i -= 1; + } + if (i == 0) { + return 1; + } else { + outb(value, 0x62); + return 0; + } +} + static u8 superio_read(u8 reg) { outb(reg, 0x2E); return inb(0x2F); @@ -67,6 +93,17 @@ static void mainboard_init(struct device *dev) { printk(BIOS_INFO, "system76: EC init\n"); + // Set USB power plane to off during restart + if (!ec_cmd(0x96)) { + if (!ec_write(0x00)) { + printk(BIOS_INFO, "system76: set USB power plane to off during restart\n"); + } else { + printk(BIOS_INFO, "system76: failed to send USB power plane data\n"); + } + } else { + printk(BIOS_INFO, "system76: failed to send USB power plane command\n"); + } + // Black magic - force enable camera toggle u16 addr = 0x01CA; u8 value = i2ec_read(addr); diff --git a/src/mainboard/system76/whl-u/ramstage.c b/src/mainboard/system76/whl-u/ramstage.c index 133627d150..430645b008 100644 --- a/src/mainboard/system76/whl-u/ramstage.c +++ b/src/mainboard/system76/whl-u/ramstage.c @@ -29,6 +29,32 @@ void mainboard_silicon_init_params(FSP_S_CONFIG *params) { cnl_configure_pads(gpio_table, ARRAY_SIZE(gpio_table)); } +static int ec_cmd(u8 value) { + int i = 1000000; + while ((inb(0x66) & 2) == 2 && i > 0) { + i -= 1; + } + if (i == 0) { + return 1; + } else { + outb(value, 0x66); + return 0; + } +} + +static int ec_write(u8 value) { + int i = 1000000; + while ((inb(0x66) & 2) == 2 && i > 0) { + i -= 1; + } + if (i == 0) { + return 1; + } else { + outb(value, 0x62); + return 0; + } +} + static u8 superio_read(u8 reg) { outb(reg, 0x2E); return inb(0x2F); @@ -67,6 +93,17 @@ static void mainboard_init(struct device *dev) { printk(BIOS_INFO, "system76: EC init\n"); + // Set USB power plane to off during restart + if (!ec_cmd(0x96)) { + if (!ec_write(0x00)) { + printk(BIOS_INFO, "system76: set USB power plane to off during restart\n"); + } else { + printk(BIOS_INFO, "system76: failed to send USB power plane data\n"); + } + } else { + printk(BIOS_INFO, "system76: failed to send USB power plane command\n"); + } + // Black magic - force enable camera toggle u16 addr = 0x01CA; u8 value = i2ec_read(addr);