mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-08 11:31:44 +00:00
pmc: Move rail power function to its own object
This commit is contained in:
parent
88fa4fa861
commit
45ca2938f5
5 changed files with 65 additions and 41 deletions
2
Makefile
2
Makefile
|
@ -32,7 +32,7 @@ OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
||||||
# Hardware.
|
# Hardware.
|
||||||
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
||||||
bpmp.o ccplex.o clock.o di.o gpio.o i2c.o irq.o mc.o sdram.o \
|
bpmp.o ccplex.o clock.o di.o gpio.o i2c.o irq.o mc.o sdram.o \
|
||||||
pinmux.o se.o smmu.o tsec.o uart.o \
|
pinmux.o pmc.o se.o smmu.o tsec.o uart.o \
|
||||||
fuse.o kfuse.o minerva.o \
|
fuse.o kfuse.o minerva.o \
|
||||||
sdmmc.o sdmmc_driver.o emummc.o nx_emmc.o nx_sd.o \
|
sdmmc.o sdmmc_driver.o emummc.o nx_emmc.o nx_sd.o \
|
||||||
bq24193.o max17050.o max7762x.o max77620-rtc.o \
|
bq24193.o max17050.o max7762x.o max77620-rtc.o \
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#include <soc/ccplex.h>
|
#include <soc/ccplex.h>
|
||||||
#include <soc/i2c.h>
|
#include <soc/i2c.h>
|
||||||
#include <soc/clock.h>
|
#include <soc/clock.h>
|
||||||
#include <utils/util.h>
|
|
||||||
#include <soc/pmc.h>
|
#include <soc/pmc.h>
|
||||||
#include <soc/t210.h>
|
#include <soc/t210.h>
|
||||||
#include <power/max77620.h>
|
#include <power/max77620.h>
|
||||||
#include <power/max7762x.h>
|
#include <power/max7762x.h>
|
||||||
|
#include <utils/util.h>
|
||||||
|
|
||||||
void _ccplex_enable_power()
|
void _ccplex_enable_power()
|
||||||
{
|
{
|
||||||
|
@ -40,39 +40,6 @@ void _ccplex_enable_power()
|
||||||
i2c_send_byte(I2C_5, MAX77621_CPU_I2C_ADDR, MAX77621_VOUT_DVS_REG, MAX77621_VOUT_ENABLE | MAX77621_VOUT_0_95V);
|
i2c_send_byte(I2C_5, MAX77621_CPU_I2C_ADDR, MAX77621_VOUT_DVS_REG, MAX77621_VOUT_ENABLE | MAX77621_VOUT_0_95V);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _ccplex_pmc_enable_partition(u32 part, int enable)
|
|
||||||
{
|
|
||||||
u32 part_mask = 1 << part;
|
|
||||||
u32 desired_state = enable << part;
|
|
||||||
|
|
||||||
// Check if the partition has the state we want.
|
|
||||||
if ((PMC(APBDEV_PMC_PWRGATE_STATUS) & part_mask) == desired_state)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
u32 i = 5001;
|
|
||||||
while (PMC(APBDEV_PMC_PWRGATE_TOGGLE) & 0x100)
|
|
||||||
{
|
|
||||||
usleep(1);
|
|
||||||
i--;
|
|
||||||
if (i < 1)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle power gating.
|
|
||||||
PMC(APBDEV_PMC_PWRGATE_TOGGLE) = part | 0x100;
|
|
||||||
|
|
||||||
i = 5001;
|
|
||||||
while (i > 0)
|
|
||||||
{
|
|
||||||
if ((PMC(APBDEV_PMC_PWRGATE_STATUS) & part_mask) == desired_state)
|
|
||||||
break;
|
|
||||||
usleep(1);
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ccplex_boot_cpu0(u32 entry)
|
void ccplex_boot_cpu0(u32 entry)
|
||||||
{
|
{
|
||||||
// Set ACTIVE_CLUSER to FAST.
|
// Set ACTIVE_CLUSER to FAST.
|
||||||
|
@ -107,11 +74,11 @@ void ccplex_boot_cpu0(u32 entry)
|
||||||
CLOCK(CLK_RST_CONTROLLER_CPU_SOFTRST_CTRL2) &= 0xFFFFF000;
|
CLOCK(CLK_RST_CONTROLLER_CPU_SOFTRST_CTRL2) &= 0xFFFFF000;
|
||||||
|
|
||||||
// Enable CPU rail.
|
// Enable CPU rail.
|
||||||
_ccplex_pmc_enable_partition(0, 1);
|
pmc_enable_partition(0, 1);
|
||||||
// Enable cluster 0 non-CPU.
|
// Enable cluster 0 non-CPU rail.
|
||||||
_ccplex_pmc_enable_partition(15, 1);
|
pmc_enable_partition(15, 1);
|
||||||
// Enable CE0.
|
// Enable CE0 rail.
|
||||||
_ccplex_pmc_enable_partition(14, 1);
|
pmc_enable_partition(14, 1);
|
||||||
|
|
||||||
// Request and wait for RAM repair.
|
// Request and wait for RAM repair.
|
||||||
FLOW_CTLR(FLOW_CTLR_RAM_REPAIR) = 1;
|
FLOW_CTLR(FLOW_CTLR_RAM_REPAIR) = 1;
|
||||||
|
|
52
bdk/soc/pmc.c
Normal file
52
bdk/soc/pmc.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 CTCaer
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms and conditions of the GNU General Public License,
|
||||||
|
* version 2, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <soc/pmc.h>
|
||||||
|
#include <soc/t210.h>
|
||||||
|
#include <utils/util.h>
|
||||||
|
|
||||||
|
int pmc_enable_partition(u32 part, int enable)
|
||||||
|
{
|
||||||
|
u32 part_mask = 1 << part;
|
||||||
|
u32 desired_state = enable << part;
|
||||||
|
|
||||||
|
// Check if the partition has the state we want.
|
||||||
|
if ((PMC(APBDEV_PMC_PWRGATE_STATUS) & part_mask) == desired_state)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
u32 i = 5001;
|
||||||
|
while (PMC(APBDEV_PMC_PWRGATE_TOGGLE) & 0x100)
|
||||||
|
{
|
||||||
|
usleep(1);
|
||||||
|
i--;
|
||||||
|
if (i < 1)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle power gating.
|
||||||
|
PMC(APBDEV_PMC_PWRGATE_TOGGLE) = part | 0x100;
|
||||||
|
|
||||||
|
i = 5001;
|
||||||
|
while (i > 0)
|
||||||
|
{
|
||||||
|
if ((PMC(APBDEV_PMC_PWRGATE_STATUS) & part_mask) == desired_state)
|
||||||
|
break;
|
||||||
|
usleep(1);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018 naehrwert
|
* Copyright (c) 2018 naehrwert
|
||||||
* Copyright (c) 2018 st4rk
|
* Copyright (c) 2018 st4rk
|
||||||
|
* Copyright (c) 2018-2020 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,
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
#ifndef _PMC_H_
|
#ifndef _PMC_H_
|
||||||
#define _PMC_H_
|
#define _PMC_H_
|
||||||
|
|
||||||
|
#include <utils/types.h>
|
||||||
|
|
||||||
/*! PMC registers. */
|
/*! PMC registers. */
|
||||||
#define APBDEV_PMC_CNTRL 0x0
|
#define APBDEV_PMC_CNTRL 0x0
|
||||||
#define PMC_CNTRL_MAIN_RST (1 << 4)
|
#define PMC_CNTRL_MAIN_RST (1 << 4)
|
||||||
|
@ -84,4 +87,6 @@
|
||||||
#define APBDEV_PMC_SCRATCH190 0x818
|
#define APBDEV_PMC_SCRATCH190 0x818
|
||||||
#define APBDEV_PMC_SCRATCH200 0x840
|
#define APBDEV_PMC_SCRATCH200 0x840
|
||||||
|
|
||||||
|
int pmc_enable_partition(u32 part, int enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,7 +33,7 @@ OBJS = $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
||||||
|
|
||||||
# Hardware.
|
# Hardware.
|
||||||
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
OBJS += $(addprefix $(BUILDDIR)/$(TARGET)/, \
|
||||||
bpmp.o ccplex.o clock.o di.o gpio.o i2c.o irq.o pinmux.o se.o smmu.o tsec.o uart.o \
|
bpmp.o ccplex.o clock.o di.o gpio.o i2c.o irq.o pinmux.o pmc.o se.o smmu.o tsec.o uart.o \
|
||||||
fuse.o kfuse.o \
|
fuse.o kfuse.o \
|
||||||
mc.o sdram.o minerva.o ramdisk.o \
|
mc.o sdram.o minerva.o ramdisk.o \
|
||||||
sdmmc.o sdmmc_driver.o nx_emmc.o nx_emmc_bis.o nx_sd.o \
|
sdmmc.o sdmmc_driver.o nx_emmc.o nx_emmc_bis.o nx_sd.o \
|
||||||
|
|
Loading…
Reference in a new issue