232 lines
7.5 KiB
Diff
232 lines
7.5 KiB
Diff
From 31ac3e358c9c6303d58c3f24fe33b6924a56bddd Mon Sep 17 00:00:00 2001
|
|
From: Christophe Priouzeau <christophe.priouzeau@st.com>
|
|
Date: Fri, 10 Apr 2020 14:39:52 +0200
|
|
Subject: [PATCH 04/23] ARM-stm32mp1-r1-RNG-DEBUG-NVMEM
|
|
|
|
---
|
|
arch/arm/Kconfig.debug | 42 +++++++++++++++++++++++++-----
|
|
arch/arm/include/debug/stm32.S | 9 +++----
|
|
drivers/char/hw_random/stm32-rng.c | 5 +++-
|
|
drivers/nvmem/core.c | 37 ++++++++++++++++++++++++++
|
|
include/linux/nvmem-consumer.h | 7 +++++
|
|
5 files changed, 88 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
|
|
index 8bcbd0cd7..3357e294a 100644
|
|
--- a/arch/arm/Kconfig.debug
|
|
+++ b/arch/arm/Kconfig.debug
|
|
@@ -1201,23 +1201,49 @@ choice
|
|
|
|
config STM32F4_DEBUG_UART
|
|
bool "Use STM32F4 UART for low-level debug"
|
|
- depends on ARCH_STM32
|
|
+ depends on MACH_STM32F429 || MACH_STM32F469
|
|
select DEBUG_STM32_UART
|
|
help
|
|
Say Y here if you want kernel low-level debugging support
|
|
on STM32F4 based platforms, which default UART is wired on
|
|
- USART1.
|
|
+ USART1, but another UART instance can be selected by modifying
|
|
+ CONFIG_DEBUG_UART_PHYS.
|
|
|
|
If unsure, say N.
|
|
|
|
config STM32F7_DEBUG_UART
|
|
bool "Use STM32F7 UART for low-level debug"
|
|
- depends on ARCH_STM32
|
|
+ depends on MACH_STM32F746 || MACH_STM32F769
|
|
select DEBUG_STM32_UART
|
|
help
|
|
Say Y here if you want kernel low-level debugging support
|
|
on STM32F7 based platforms, which default UART is wired on
|
|
- USART1.
|
|
+ USART1, but another UART instance can be selected by modifying
|
|
+ CONFIG_DEBUG_UART_PHYS.
|
|
+
|
|
+ If unsure, say N.
|
|
+
|
|
+ config STM32H7_DEBUG_UART
|
|
+ bool "Use STM32H7 UART for low-level debug"
|
|
+ depends on MACH_STM32H743
|
|
+ select DEBUG_STM32_UART
|
|
+ help
|
|
+ Say Y here if you want kernel low-level debugging support
|
|
+ on STM32H7 based platforms, which default UART is wired on
|
|
+ USART1, but another UART instance can be selected by modifying
|
|
+ CONFIG_DEBUG_UART_PHYS.
|
|
+
|
|
+ If unsure, say N.
|
|
+
|
|
+ config STM32MP1_DEBUG_UART
|
|
+ bool "Use STM32MP1 UART for low-level debug"
|
|
+ depends on MACH_STM32MP157
|
|
+ select DEBUG_STM32_UART
|
|
+ help
|
|
+ Say Y here if you want kernel low-level debugging support
|
|
+ on STM32MP1 based platforms, wich default UART is wired on
|
|
+ UART4, but another UART instance can be selected by modifying
|
|
+ CONFIG_DEBUG_UART_PHYS and CONFIG_DEBUG_UART_VIRT.
|
|
|
|
If unsure, say N.
|
|
|
|
@@ -1619,6 +1645,9 @@ config DEBUG_UART_PHYS
|
|
default 0x3e000000 if DEBUG_BCM_KONA_UART
|
|
default 0x3f201000 if DEBUG_BCM2836
|
|
default 0x4000e400 if DEBUG_LL_UART_EFM32
|
|
+ default 0x40010000 if STM32MP1_DEBUG_UART
|
|
+ default 0x40011000 if STM32F4_DEBUG_UART || STM32F7_DEBUG_UART || \
|
|
+ STM32H7_DEBUG_UART
|
|
default 0x40028000 if DEBUG_AT91_SAMV7_USART1
|
|
default 0x40081000 if DEBUG_LPC18XX_UART0
|
|
default 0x40090000 if DEBUG_LPC32XX
|
|
@@ -1713,7 +1742,7 @@ config DEBUG_UART_PHYS
|
|
DEBUG_S3C64XX_UART || \
|
|
DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
|
|
DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
|
|
- DEBUG_AT91_UART
|
|
+ DEBUG_AT91_UART || DEBUG_STM32_UART
|
|
|
|
config DEBUG_UART_VIRT
|
|
hex "Virtual base address of debug UART"
|
|
@@ -1779,6 +1808,7 @@ config DEBUG_UART_VIRT
|
|
default 0xfcfe8600 if DEBUG_BCM63XX_UART
|
|
default 0xfd000000 if DEBUG_SPEAR3XX || DEBUG_SPEAR13XX
|
|
default 0xfd883000 if DEBUG_ALPINE_UART0
|
|
+ default 0xfe010000 if STM32MP1_DEBUG_UART
|
|
default 0xfe017000 if DEBUG_MMP_UART2
|
|
default 0xfe018000 if DEBUG_MMP_UART3
|
|
default 0xfe100000 if DEBUG_IMX23_UART || DEBUG_IMX28_UART
|
|
@@ -1823,7 +1853,7 @@ config DEBUG_UART_VIRT
|
|
DEBUG_S3C64XX_UART || \
|
|
DEBUG_BCM63XX_UART || DEBUG_ASM9260_UART || \
|
|
DEBUG_SIRFSOC_UART || DEBUG_DIGICOLOR_UA0 || \
|
|
- DEBUG_AT91_UART
|
|
+ DEBUG_AT91_UART || DEBUG_STM32_UART
|
|
|
|
config DEBUG_UART_8250_SHIFT
|
|
int "Register offset shift for the 8250 debug UART"
|
|
diff --git a/arch/arm/include/debug/stm32.S b/arch/arm/include/debug/stm32.S
|
|
index 1abb32f68..6446e4692 100644
|
|
--- a/arch/arm/include/debug/stm32.S
|
|
+++ b/arch/arm/include/debug/stm32.S
|
|
@@ -4,14 +4,13 @@
|
|
* Author: Gerald Baeza <gerald.baeza@st.com> for STMicroelectronics.
|
|
*/
|
|
|
|
-#define STM32_UART_BASE 0x40011000 /* USART1 */
|
|
-
|
|
#ifdef CONFIG_STM32F4_DEBUG_UART
|
|
#define STM32_USART_SR_OFF 0x00
|
|
#define STM32_USART_TDR_OFF 0x04
|
|
#endif
|
|
|
|
-#ifdef CONFIG_STM32F7_DEBUG_UART
|
|
+#if defined(CONFIG_STM32F7_DEBUG_UART) || (CONFIG_STM32H7_DEBUG_UART) || \
|
|
+ defined(CONFIG_STM32MP1_DEBUG_UART)
|
|
#define STM32_USART_SR_OFF 0x1C
|
|
#define STM32_USART_TDR_OFF 0x28
|
|
#endif
|
|
@@ -20,8 +19,8 @@
|
|
#define STM32_USART_TXE (1 << 7) /* Tx data reg empty */
|
|
|
|
.macro addruart, rp, rv, tmp
|
|
- ldr \rp, =STM32_UART_BASE @ physical base
|
|
- ldr \rv, =STM32_UART_BASE @ virt base /* NoMMU */
|
|
+ ldr \rp, =CONFIG_DEBUG_UART_PHYS @ physical base
|
|
+ ldr \rv, =CONFIG_DEBUG_UART_VIRT @ virt base
|
|
.endm
|
|
|
|
.macro senduart,rd,rx
|
|
diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c
|
|
index 38324c2dd..a25c4b5c3 100644
|
|
--- a/drivers/char/hw_random/stm32-rng.c
|
|
+++ b/drivers/char/hw_random/stm32-rng.c
|
|
@@ -135,7 +135,10 @@ static int stm32_rng_probe(struct platform_device *ofdev)
|
|
return PTR_ERR(priv->clk);
|
|
|
|
priv->rst = devm_reset_control_get(&ofdev->dev, NULL);
|
|
- if (!IS_ERR(priv->rst)) {
|
|
+ if (IS_ERR(priv->rst)) {
|
|
+ if (PTR_ERR(priv->rst) != -ENOENT)
|
|
+ return PTR_ERR(priv->rst);
|
|
+ } else {
|
|
reset_control_assert(priv->rst);
|
|
udelay(2);
|
|
reset_control_deassert(priv->rst);
|
|
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
|
|
index 960542dea..8105fe423 100644
|
|
--- a/drivers/nvmem/core.c
|
|
+++ b/drivers/nvmem/core.c
|
|
@@ -1080,6 +1080,43 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
|
|
}
|
|
EXPORT_SYMBOL_GPL(nvmem_cell_write);
|
|
|
|
+/**
|
|
+ * nvmem_cell_read_u8() - Read a cell value as an u8
|
|
+ *
|
|
+ * @dev: Device that requests the nvmem cell.
|
|
+ * @cell_id: Name of nvmem cell to read.
|
|
+ * @val: pointer to output value.
|
|
+ *
|
|
+ * Return: 0 on success or negative errno.
|
|
+ */
|
|
+int nvmem_cell_read_u8(struct device *dev, const char *cell_id, u8 *val)
|
|
+{
|
|
+ struct nvmem_cell *cell;
|
|
+ void *buf;
|
|
+ size_t len;
|
|
+
|
|
+ cell = nvmem_cell_get(dev, cell_id);
|
|
+ if (IS_ERR(cell))
|
|
+ return PTR_ERR(cell);
|
|
+
|
|
+ buf = nvmem_cell_read(cell, &len);
|
|
+ if (IS_ERR(buf)) {
|
|
+ nvmem_cell_put(cell);
|
|
+ return PTR_ERR(buf);
|
|
+ }
|
|
+ if (len != sizeof(*val)) {
|
|
+ kfree(buf);
|
|
+ nvmem_cell_put(cell);
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ memcpy(val, buf, sizeof(*val));
|
|
+ kfree(buf);
|
|
+ nvmem_cell_put(cell);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(nvmem_cell_read_u8);
|
|
+
|
|
/**
|
|
* nvmem_cell_read_u16() - Read a cell value as an u16
|
|
*
|
|
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
|
|
index 5c17cb733..c3c53a63e 100644
|
|
--- a/include/linux/nvmem-consumer.h
|
|
+++ b/include/linux/nvmem-consumer.h
|
|
@@ -61,6 +61,7 @@ void nvmem_cell_put(struct nvmem_cell *cell);
|
|
void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
|
|
void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
|
|
int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
|
|
+int nvmem_cell_read_u8(struct device *dev, const char *cell_id, u8 *val);
|
|
int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val);
|
|
int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val);
|
|
|
|
@@ -123,6 +124,12 @@ static inline int nvmem_cell_write(struct nvmem_cell *cell,
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
+static inline int nvmem_cell_read_u8(struct device *dev,
|
|
+ const char *cell_id, u8 *val)
|
|
+{
|
|
+ return -EOPNOTSUPP;
|
|
+}
|
|
+
|
|
static inline int nvmem_cell_read_u16(struct device *dev,
|
|
const char *cell_id, u16 *val)
|
|
{
|
|
--
|
|
2.17.1
|
|
|