mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
bdk: reg 5v: fix a hang with T210B01 and Hoag/Aula
- Hoag and Aula do not have a USB based 5V bus source, so do not touch CC4 pin. - More importantly, in T210B01 the GPIO AO IO rail seems to be working properly from boot. Plus it also seems that is needed by various components. That was found when running on Aula. It was causing an immediate hang. Probably SoC wide. Only allow control of it on T210 to avoid such issues.
This commit is contained in:
parent
9a17ca2628
commit
31d6c7d85d
1 changed files with 50 additions and 18 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 CTCaer
|
* Copyright (c) 2019-2021 CTCaer
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
@ -14,7 +14,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <soc/fuse.h>
|
||||||
#include <soc/gpio.h>
|
#include <soc/gpio.h>
|
||||||
|
#include <soc/hw_init.h>
|
||||||
#include <soc/pinmux.h>
|
#include <soc/pinmux.h>
|
||||||
#include <soc/pmc.h>
|
#include <soc/pmc.h>
|
||||||
#include <soc/t210.h>
|
#include <soc/t210.h>
|
||||||
|
@ -34,17 +36,30 @@ void regulator_5v_enable(u8 dev)
|
||||||
gpio_output_enable(GPIO_PORT_A, GPIO_PIN_5, GPIO_OUTPUT_ENABLE);
|
gpio_output_enable(GPIO_PORT_A, GPIO_PIN_5, GPIO_OUTPUT_ENABLE);
|
||||||
gpio_write(GPIO_PORT_A, GPIO_PIN_5, GPIO_HIGH);
|
gpio_write(GPIO_PORT_A, GPIO_PIN_5, GPIO_HIGH);
|
||||||
|
|
||||||
|
// Only Icosa and Iowa have USB 5V VBUS rails. Skip on Hoag/Aula.
|
||||||
|
u32 hw_type = fuse_read_hw_type();
|
||||||
|
if (hw_type == FUSE_NX_HW_TYPE_ICOSA ||
|
||||||
|
hw_type == FUSE_NX_HW_TYPE_IOWA)
|
||||||
|
{
|
||||||
// Fan and Rail power from USB 5V VBUS.
|
// Fan and Rail power from USB 5V VBUS.
|
||||||
PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN0) = PINMUX_LPDR | 1;
|
PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN0) = PINMUX_LPDR | 1;
|
||||||
gpio_config(GPIO_PORT_CC, GPIO_PIN_4, GPIO_MODE_GPIO);
|
gpio_config(GPIO_PORT_CC, GPIO_PIN_4, GPIO_MODE_GPIO);
|
||||||
gpio_output_enable(GPIO_PORT_CC, GPIO_PIN_4, GPIO_OUTPUT_ENABLE);
|
gpio_output_enable(GPIO_PORT_CC, GPIO_PIN_4, GPIO_OUTPUT_ENABLE);
|
||||||
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_LOW);
|
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_LOW);
|
||||||
usb_src = false;
|
}
|
||||||
|
|
||||||
|
// Enable GPIO AO IO rail for T210.
|
||||||
|
if (hw_get_chip_id() == GP_HIDREV_MAJOR_T210)
|
||||||
|
{
|
||||||
// Make sure GPIO power is enabled.
|
// Make sure GPIO power is enabled.
|
||||||
PMC(APBDEV_PMC_NO_IOPOWER) &= ~PMC_NO_IOPOWER_GPIO_IO_EN;
|
PMC(APBDEV_PMC_NO_IOPOWER) &= ~PMC_NO_IOPOWER_GPIO_IO_EN;
|
||||||
|
(void)PMC(APBDEV_PMC_NO_IOPOWER); // Commit write.
|
||||||
|
|
||||||
// Override power detect for GPIO AO IO rails.
|
// Override power detect for GPIO AO IO rails.
|
||||||
PMC(APBDEV_PMC_PWR_DET_VAL) &= ~PMC_PWR_DET_GPIO_IO_EN;
|
PMC(APBDEV_PMC_PWR_DET_VAL) &= ~PMC_PWR_DET_GPIO_IO_EN;
|
||||||
|
(void)PMC(APBDEV_PMC_PWR_DET_VAL); // Commit write.
|
||||||
|
}
|
||||||
|
usb_src = false;
|
||||||
}
|
}
|
||||||
reg_5v_dev |= dev;
|
reg_5v_dev |= dev;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +76,11 @@ void regulator_5v_disable(u8 dev)
|
||||||
gpio_config(GPIO_PORT_A, GPIO_PIN_5, GPIO_MODE_SPIO);
|
gpio_config(GPIO_PORT_A, GPIO_PIN_5, GPIO_MODE_SPIO);
|
||||||
PINMUX_AUX(PINMUX_AUX_SATA_LED_ACTIVE) = PINMUX_PARKED | PINMUX_INPUT_ENABLE;
|
PINMUX_AUX(PINMUX_AUX_SATA_LED_ACTIVE) = PINMUX_PARKED | PINMUX_INPUT_ENABLE;
|
||||||
|
|
||||||
|
// Only Icosa and Iowa have USB 5V VBUS rails. Skip on Hoag/Aula.
|
||||||
|
u32 hw_type = fuse_read_hw_type();
|
||||||
|
if (hw_type == FUSE_NX_HW_TYPE_ICOSA ||
|
||||||
|
hw_type == FUSE_NX_HW_TYPE_IOWA)
|
||||||
|
{
|
||||||
// Rail power from USB 5V VBUS.
|
// Rail power from USB 5V VBUS.
|
||||||
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_LOW);
|
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_LOW);
|
||||||
gpio_output_enable(GPIO_PORT_CC, GPIO_PIN_4, GPIO_OUTPUT_DISABLE);
|
gpio_output_enable(GPIO_PORT_CC, GPIO_PIN_4, GPIO_OUTPUT_DISABLE);
|
||||||
|
@ -68,8 +88,14 @@ void regulator_5v_disable(u8 dev)
|
||||||
PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN0) = PINMUX_IO_HV | PINMUX_LPDR | PINMUX_PARKED | PINMUX_INPUT_ENABLE;
|
PINMUX_AUX(PINMUX_AUX_USB_VBUS_EN0) = PINMUX_IO_HV | PINMUX_LPDR | PINMUX_PARKED | PINMUX_INPUT_ENABLE;
|
||||||
usb_src = false;
|
usb_src = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// GPIO AO IO rails.
|
// GPIO AO IO rails.
|
||||||
|
if (hw_get_chip_id() == GP_HIDREV_MAJOR_T210)
|
||||||
|
{
|
||||||
PMC(APBDEV_PMC_PWR_DET_VAL) |= PMC_PWR_DET_GPIO_IO_EN;
|
PMC(APBDEV_PMC_PWR_DET_VAL) |= PMC_PWR_DET_GPIO_IO_EN;
|
||||||
|
(void)PMC(APBDEV_PMC_PWR_DET_VAL); // Commit write.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +106,12 @@ bool regulator_5v_get_dev_enabled(u8 dev)
|
||||||
|
|
||||||
void regulator_5v_usb_src_enable(bool enable)
|
void regulator_5v_usb_src_enable(bool enable)
|
||||||
{
|
{
|
||||||
|
// Only for Icosa/Iowa. Skip on Hoag/Aula.
|
||||||
|
u32 hw_type = fuse_read_hw_type();
|
||||||
|
if (hw_type != FUSE_NX_HW_TYPE_ICOSA &&
|
||||||
|
hw_type != FUSE_NX_HW_TYPE_IOWA)
|
||||||
|
return;
|
||||||
|
|
||||||
if (enable && !usb_src)
|
if (enable && !usb_src)
|
||||||
{
|
{
|
||||||
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_HIGH);
|
gpio_write(GPIO_PORT_CC, GPIO_PIN_4, GPIO_HIGH);
|
||||||
|
|
Loading…
Reference in a new issue