-
Notifications
You must be signed in to change notification settings - Fork 10
drivers: qcom: Add QRNG and secure watchdog drivers for Bobcat family #15
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
Open
thariaruchamy-bit
wants to merge
4
commits into
qualcomm-linux:qcom-next
Choose a base branch
from
thariaruchamy-bit:drivers-qcom-qrng-wdog
base: qcom-next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bfc0f1a
drivers: qcom: rng: Consolidate PRNG into generic RNG driver
0428df9
plat-qcom: Enable consolidated RNG driver for QCOM platforms
7c42f97
drivers: qcom: wdog: Add secure watchdog driver for Bobcat family
c33815d
plat-qcom: Enable sec wdog config for Bobcat family
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # SPDX-License-Identifier: BSD-2-Clause | ||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
|
|
||
| CFG_QCOM_SEC_WDOG ?= y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # SPDX-License-Identifier: BSD-2-Clause | ||
| # | ||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| # | ||
|
|
||
| global-incdirs-y += . | ||
| srcs-$(CFG_QCOM_RNG) += qcom-rng.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // SPDX-License-Identifier: BSD-2-Clause | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| * | ||
| * QCOM Secure Watchdog Driver | ||
| * | ||
| */ | ||
|
|
||
| #include <arm.h> | ||
| #include <initcall.h> | ||
| #include <io.h> | ||
| #include <kernel/interrupt.h> | ||
| #include <kernel/panic.h> | ||
| #include <mm/core_memprot.h> | ||
| #include <platform_config.h> | ||
| #include <trace.h> | ||
| #include <util.h> | ||
|
|
||
| register_phys_mem_pgdir(MEM_AREA_IO_SEC, WDT_TMR_BASE, | ||
|
thariaruchamy-bit marked this conversation as resolved.
|
||
| CORE_MMU_PGDIR_SIZE); | ||
|
|
||
| #define WDT_CTL_OFFSET 0x08 | ||
| #define WDT_BARK_TIME_OFFSET 0x10 | ||
| #define WDT_BITE_TIME_OFFSET 0x14 | ||
|
|
||
| #define WDT_CTL_INT_ENABLE_SHFT 0 | ||
| #define WDT_CTL_UNMASKED_INT_ENABLE_SHFT 1 | ||
|
|
||
| #define WDT_BARK_TIME_RMSK 0xFFFFFU | ||
| #define WDT_BITE_TIME_RMSK 0xFFFFFU | ||
|
|
||
| #define WDT_CLK_HZ 32000U | ||
|
|
||
| #define WDT_BARK_TIME_MS 6000U | ||
| #define WDT_BITE_TIME_MS 22000U | ||
|
|
||
| static vaddr_t wdt_base; | ||
|
|
||
| static uint32_t ms_to_ticks_wdt(uint32_t ms) | ||
| { | ||
| return (uint32_t)(((uint64_t)ms * WDT_CLK_HZ) / 1000U); | ||
| } | ||
|
|
||
| static void wdt_enable(bool enable) | ||
| { | ||
| io_write32(wdt_base + WDT_CTL_OFFSET, | ||
| UINT32_C(1) << WDT_CTL_UNMASKED_INT_ENABLE_SHFT | ||
| | (enable ? UINT32_C(1) : UINT32_C(0)) | ||
| << WDT_CTL_INT_ENABLE_SHFT); | ||
| } | ||
|
|
||
| static void wdt_reset(void) | ||
| { | ||
| io_write32(wdt_base + WDT_RESET_REG_OFFSET, 1); | ||
| } | ||
|
|
||
| static void wdt_start(uint32_t bark_timeout, uint32_t bite_timeout) | ||
| { | ||
| /* Zero timeouts are not allowed, ensure timeouts are > 0. */ | ||
| bark_timeout = MAX(bark_timeout, 0x1U); | ||
| bite_timeout = MAX(bite_timeout, 0x1U); | ||
|
|
||
| bark_timeout = ms_to_ticks_wdt(bark_timeout); | ||
| bite_timeout = ms_to_ticks_wdt(bite_timeout); | ||
|
|
||
| /* Timeouts have a ceiling value */ | ||
| bark_timeout = MIN(bark_timeout, (uint32_t)(WDT_BARK_TIME_RMSK)); | ||
| bite_timeout = MIN(bite_timeout, (uint32_t)(WDT_BITE_TIME_RMSK)); | ||
|
|
||
| wdt_enable(false); | ||
|
|
||
| io_write32(wdt_base + WDT_BARK_TIME_OFFSET, bark_timeout); | ||
| io_write32(wdt_base + WDT_BITE_TIME_OFFSET, bite_timeout); | ||
|
|
||
| wdt_enable(true); | ||
|
|
||
| wdt_reset(); | ||
| } | ||
|
|
||
| static enum itr_return | ||
| wdt_bark_handler(struct itr_handler *h __unused) | ||
| { | ||
| io_write32(wdt_base + WDT_RESET_REG_OFFSET, 1); | ||
|
|
||
| return ITRR_HANDLED; | ||
| } | ||
|
|
||
| static TEE_Result wdt_init(void) | ||
| { | ||
| TEE_Result res = TEE_SUCCESS; | ||
| struct itr_handler *handler = NULL; | ||
|
|
||
| wdt_base = (vaddr_t)phys_to_virt(WDT_TMR_BASE, | ||
| MEM_AREA_IO_SEC, 1); | ||
| if (!wdt_base) { | ||
| EMSG("wdt: Failed to map watchdog registers"); | ||
| return TEE_ERROR_GENERIC; | ||
| } | ||
|
|
||
| wdt_start(WDT_BARK_TIME_MS, WDT_BITE_TIME_MS); | ||
|
|
||
| res = interrupt_create_handler(interrupt_get_main_chip(), | ||
| WDT_BARK_INT_ID, | ||
| wdt_bark_handler, | ||
| 0u, 0u, &handler); | ||
| if (res != TEE_SUCCESS) { | ||
| EMSG("wdt: Failed to register bark handler (err=0x%x)", | ||
| res); | ||
| return res; | ||
| } | ||
|
|
||
| return TEE_SUCCESS; | ||
| } | ||
|
|
||
| driver_init(wdt_init); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.