-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Am62l lpm #8
base: ti-master
Are you sure you want to change the base?
Am62l lpm #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Sebin,
Thanks for the PR. We will still need some more rework when we go upstream with this but for now I have only left recommendations for minor improvements.
plat/ti/k3/common/am62l_psci.c
Outdated
#include <gtc.h> | ||
#include <plat_scmi_def.h> | ||
#include <rtc.h> | ||
#include <k3_console.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort the includes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review Dhruva.
Updated the PR
plat/ti/k3/common/am62l_psci.c
Outdated
/* TODO: create a static carvout for TIFS context save and restore */ | ||
uint64_t context_save_addr = 0x90000000; | ||
/* Pass 6 for RTC only + DDR mode */ | ||
uint32_t mode = 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there no provision in this code to select mode at runtime?
Can we please have a TODO on what the actual plan for the mode selection logic will be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to a separate commit
plat/ti/k3/common/k3_bl1_setup.c
Outdated
@@ -34,7 +34,8 @@ const mmap_region_t plat_k3_mmap[] = { | |||
#define MAIN_PLL_MMR_BASE (0x04060000UL) | |||
#define MAIN_PLL_MMR_CFG_PLL8_HSDIV_CTRL0 (0x00008080UL) | |||
#define CTL_MMR_BASE_CFG5 (0x43050000U) | |||
#define CANUART_WAKE_OFF_MODE_STA (0x1318U) | |||
#define CANUART_WAKE_OFF_MODE_STAT (0x1318U) | |||
#define RTC_ONLY_PLUS_DDR_MAGIC_WORD (0x6D555555U) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Check tabs here and align
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR
plat/ti/k3/common/k3_bl1_setup.c
Outdated
|
||
msg.buf = (uint8_t *)&a53_rom_msg_obj; | ||
msg.len = sizeof(a53_rom_msg_obj); | ||
ti_sci_transport_send(0, &msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately slipped through code review in PreBL PR, but this can easily be re-written as SP_NOTIFY
instead of 0 no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to SP_NOTIFY, but for 62l this is a unused parameter int he function
plat/ti/k3/common/k3_bl1_setup.c
Outdated
uart_ptr = (uint32_t *)(PADCONF_ADDR); | ||
*uart_ptr = 0x50000; | ||
uart_ptr = (uint32_t *)(PADCONF_ADDR + 0x4); | ||
*uart_ptr = 0x10000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, why TIFS can't do this if it's needed for TIFS logs?
Also, isn't this duplicate code from what's being done just above??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes removed the extra commit
plat/ti/k3/board/am62l/soc.c
Outdated
@@ -18,4 +22,12 @@ void ti_soc_init(void) | |||
{ | |||
generic_delay_timer_init(); | |||
ti_init_scmi_server(); | |||
#ifdef TI_AM62L_LPM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's anyway AM62L SOC specific. Do we still need this TI_AM62L_LPM ifdef?
IIRC this was more useful back when everything was in k3_* code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was not required, removed
plat/ti/k3/common/k3_bl31_setup.c
Outdated
@@ -19,6 +19,7 @@ | |||
#include <k3_gicv3.h> | |||
#include <ti_sci.h> | |||
#include <ti_sci_transport.h> | |||
#include <board_def.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Doesn't plat/ti/k3/include/platform_def.h
already include this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, removed this, Thanks for pointing it out
plat/ti/k3/board/am62l/lpm/gtc.c
Outdated
#include <lib/mmio.h> | ||
#include <plat/common/platform.h> | ||
#include "gtc.h" | ||
#include "rtc.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm honestly not a big fan of the include " "
convention. If your makefile includes are done correctly, this should just be <>
. Check once if easy enough to do.
1 file is fine generally file.c including file.h
But in this case it's "rtc.h" != file.c
gtc.h is fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the files
Thanks Dhruva
plat/ti/k3/board/am62l/lpm/gtc.c
Outdated
#define GTC_CFG1_CNTCR_EN BIT(0) | ||
|
||
#define GTC_CFG0_BASE (0xa80000UL) | ||
#define GTC_CFG1_BASE (0xA90000UL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move all these #defines
to the header file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
plat/ti/k3/board/am62l/lpm/rtc.c
Outdated
#define RELOAD_FROM_BBD BIT(31) | ||
|
||
#define RTC_BASE (0x2b1f0000UL) | ||
#define WKUP_CTRL_MMR_SEC_2_BASE (0x43020000UL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these base values will be SOC specific.
This is not the right place to #define
them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to soc specific file
Thanks
@@ -76,6 +76,8 @@ uint64_t ddr_ram_size = 0x80000000; | |||
#define DDR32SS_PMCTRL (0x1000U) | |||
#define CANUART_WAKE_OFF_MODE_STAT (0x1318U) | |||
#define RTC_ONLY_PLUS_DDR_MAGIC_WORD (0x6D555555U) | |||
#define WKUP_CTRL_MMR_SEC_4_BASE (0x43040000UL) | |||
#define WKUP_CTRL_MMR_SEC_5_BASE (0x43050000UL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No base values in drivers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to common file
plat/ti/k3/common/k3_bl1_setup.c
Outdated
#define CTL_MMR_BASE_CFG5 (0x43050000U) | ||
#define CANUART_WAKE_OFF_MODE_STAT (0x1318U) | ||
#define RTC_ONLY_PLUS_DDR_MAGIC_WORD (0x6D555555U) | ||
#define BL1_DONE_MSG_ID (0x810A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabs vs spaces issues here and few lines above... please fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it, Thanks
@@ -1789,3 +1789,44 @@ int ti_sci_lpm_get_next_sys_mode(uint8_t *next_mode) | |||
|
|||
return 0; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this commit, the $subject should probably mention TISCI... not just LPM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Dhruva, updated the commit message
During AM62L LPM sequence TFA needs to send prepare sleep message to TIFS. Add support to send prepare sleep message to TIFS Change-Id: I9e9ef8dd2cfe10ca27760420d01c12545665522c Signed-off-by: Sebin Francis <[email protected]>
Device needs to go through a differnt boot sequence during RTC + DDR low power mode resume. RTC only + DDR resume can be detected by checking the OFF_MODE magic word in WKUP CTRL MMR. During resume 1. Device needs to send CORE_RESUME message to TIFS compared to sending done message to SEC ROM. 2. DRR needs to go through few extra sequence in RTC only + DDR low power mode to initialize the DDR without losing it context. Update the DDR driver to do the extra sequence when device is resuming from RTC only + DDR low power mode. Change-Id: I85a56c0a5d4722852b635e302cab73b726717965 Signed-off-by: Sebin Francis <[email protected]>
Add drivers that are required during low power mode. 1. RTC: Init, suspend and resume support 2. GTC: Save and restore of GTC time 3. Trace: Trace support during LPM 4. PLL: Save and restore of PLLs 5. PSC: Turn off and ON of LPSCs 6. Stub: Low level LPM sequence implementation 7. call-sram.S: Assembly file for initial resume sequence before executing c code 8. plat.ld: Custom linker file for placing stub in WKUP SRAM Change-Id: I0b6cea5d30f66c8d8370b6114fc8336756f36c4c Signed-off-by: Sebin Francis <[email protected]>
RTC used as a wake up source. Initialize the RTC during boot. LPM STUB will be executing the low level LPM sequence. it will keep the DDR in self refresh. Because of which it cannot run from DDR. Copy the stub from DDR to wkup sram. Add wkup sram in the mmu map table. Increase the BL31 size to accommodate the LPM stub. Change-Id: Idfaa681394371afb489a96b083758d12a5910616 Signed-off-by: Sebin Francis <[email protected]>
Add PSCI handlers for LPM entry and exit. In the handlers call the low level LPM sequence handlers. Change-Id: I0bf32ddb9751866fcfa04c75e7a40d8c5e79c2d7 Signed-off-by: Sebin Francis <[email protected]>
*/ | ||
do { | ||
val = mmio_read_32(K3_WKUP_UART_BASE_ADDRESS + UART_16550_LSR); | ||
} while ((i++ < 10000U) && ((val & UART_16550_LSR_TX_FIFO_E) == 0U)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're trying to do some kind of timeout mechanism follow something similar to what has been done in ti_mailbox_poll_status
Use a #define like K3_UART_TIMEOUT_TX
or something better and take it from the plat/ti/k3/include/platform_def.h
/* Unlock RTC MMRs */ | ||
mmio_write_32(K3_RTC_BASE + RTC_KICK0, 0x83E70B13); | ||
mmio_write_32(K3_RTC_BASE + RTC_KICK1, 0x95A4F1E0); | ||
while ((mmio_read_32(K3_RTC_BASE + RTC_GENRAL_CTL) & BIT(23)) == 0U) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wherever possible please have some timeout mechanisms.
Any potential while(1) scenario does not look good.
mmio_write_32(K3_RTC_BASE + RTC_GENRAL_CTL, ctrl); | ||
|
||
/* Wait for read, write to finish */ | ||
while ((mmio_read_32(K3_RTC_BASE + RTC_SYNCPEND) & BIT(0)) != 0U) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some timeout mechanism with ERROR print
|
||
/* flush write; this causes a "write error" but removes SW_OFF condition */ | ||
while ((mmio_read_32(K3_RTC_BASE + RTC_SYNCPEND) & BIT(0)) != 0U) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
/* resync of lock status takes a 32k clock cycle because of O32K_OSC_DEP_EN */ | ||
while ((mmio_read_32(K3_RTC_BASE + RTC_SYNCPEND) & BIT(0)) != 0U) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeout mechanism please.
while ((mmio_read_32(K3_RTC_BASE + RTC_SYNCPEND) & BIT(2)) == 0U) { | ||
} | ||
while ((mmio_read_32(K3_RTC_BASE + RTC_SYNCPEND) & BIT(2)) != 0U) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here and above
mmio_write_32((WKUP_CTRL_MMR_SEC_4_BASE + DDR32SS_PMCTRL), 0x0); | ||
mmio_write_32((WKUP_CTRL_MMR_SEC_4_BASE + DDR32SS_PMCTRL), (0x1U << 31)); | ||
while ((mmio_read_32((WKUP_CTRL_MMR_SEC_4_BASE + DDR32SS_PMCTRL)) & 0x80000000) == 0x0) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add timeout
a53_tifs_msg_obj.req.hdr.seq = 0x12; | ||
a53_tifs_msg_obj.req.hdr.type = 0x0308; | ||
a53_tifs_msg_obj.req.ctx_lo = 0x90000000U; | ||
a53_tifs_msg_obj.req.ctx_hi = 0x00000000U; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these assignments need to move into a ti_sci_setup_one_xfer
kind of a function/ API. Please see if it can be done
@@ -0,0 +1,48 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file used somewhere else? I see it being added in common folder instead of am62l specific folders..
@@ -61,7 +61,7 @@ | |||
* defined as default for our platform. | |||
*/ | |||
#define BL31_BASE UL(0x00000000) /* PIE remapped on fly */ | |||
#define BL31_SIZE UL(0x00037000) /* For AM62L: Allow upto 225280 bytes */ | |||
#define BL31_SIZE UL(0x00050000) /* For AM62L: Allow up to 327680 bytes */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have this much allocated for our jacinto devices, I think we only reserve 128kb and the rest of the sram is used by c7x firmware and other things... Wondering if it makes sense to split this for am62l as well.
Adding Deepsleep and RTC only + DDR LPM sequence