[U-Boot,v2,5/9] dm: misc: add stm32 rcc driver

Message ID 1505318412-27121-6-git-send-email-patrice.chotard@st.com
State New
Delegated to: Tom Rini
Headers show
Series
  • Add STM32H7 SoC, Discovery and Evaluation board support
Related show

Commit Message

Patrice CHOTARD Sept. 13, 2017, 4 p.m.
From: Christophe Kerello <christophe.kerello@st.com>

This patch adds the support of reset and clock control
block (rcc) found on STM32 SoCs.
This driver is similar to a MFD linux driver.

This driver supports currently STM32H7 only.
STM32F4 and STM32F7 will be migrated to this rcc MFD driver
in the future to uniformize all STM32 SoCs already upstreamed.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
---

v2: _ merge peripheral and kernel clocks arrays
	_ add voltage scaling support needed for Evaluation board

 drivers/misc/Kconfig     |  9 +++++++++
 drivers/misc/Makefile    |  1 +
 drivers/misc/stm32_rcc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)
 create mode 100644 drivers/misc/stm32_rcc.c

Comments

Simon Glass Sept. 17, 2017, 5:53 p.m. | #1
On 13 September 2017 at 10:00,  <patrice.chotard@st.com> wrote:
> From: Christophe Kerello <christophe.kerello@st.com>
>
> This patch adds the support of reset and clock control
> block (rcc) found on STM32 SoCs.
> This driver is similar to a MFD linux driver.
>
> This driver supports currently STM32H7 only.
> STM32F4 and STM32F7 will be migrated to this rcc MFD driver
> in the future to uniformize all STM32 SoCs already upstreamed.
>
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Vikas Manocha <vikas.manocha@st.com>
> ---
>
> v2: _ merge peripheral and kernel clocks arrays
>         _ add voltage scaling support needed for Evaluation board
>
>  drivers/misc/Kconfig     |  9 +++++++++
>  drivers/misc/Makefile    |  1 +
>  drivers/misc/stm32_rcc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 55 insertions(+)
>  create mode 100644 drivers/misc/stm32_rcc.c

Reviewed-by: Simon Glass <sjg@chromium.org>

Patch

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4133017..f1c15cb 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -158,6 +158,15 @@  config PCA9551_I2C_ADDR
 	help
 	  The I2C address of the PCA9551 LED controller.
 
+config STM32_RCC
+	bool "Enable RCC driver for the STM32 SoC's family"
+	depends on STM32 && MISC
+	help
+	  Enable the STM32 RCC driver. The RCC block (Reset and Clock Control
+	  block) is responsible of the management of the clock and reset
+	  generation.
+	  This driver is similar to an MFD driver in the Linux kernel.
+
 config TEGRA_CAR
 	bool "Enable support for the Tegra CAR driver"
 	depends on TEGRA_NO_BPMP
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 21f7e6c..ada7624 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -52,3 +52,4 @@  obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
 obj-$(CONFIG_QFW) += qfw.o
 obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o
+obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
diff --git a/drivers/misc/stm32_rcc.c b/drivers/misc/stm32_rcc.c
new file mode 100644
index 0000000..a6c2a75
--- /dev/null
+++ b/drivers/misc/stm32_rcc.c
@@ -0,0 +1,45 @@ 
+/*
+ * Copyright (C) STMicroelectronics SA 2017
+ * Author(s): Patrice CHOTARD, <patrice.chotard@st.com> for STMicroelectronics.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <misc.h>
+#include <dm/lists.h>
+
+static int stm32_rcc_bind(struct udevice *dev)
+{
+	int ret;
+	struct udevice *child;
+
+	debug("%s(dev=%p)\n", __func__, dev);
+
+	ret = device_bind_driver_to_node(dev, "stm32h7_rcc_clock",
+					 "stm32h7_rcc_clock",
+					 dev_ofnode(dev), &child);
+	if (ret)
+		return ret;
+
+	return device_bind_driver_to_node(dev, "stm32_rcc_reset",
+					  "stm32_rcc_reset",
+					  dev_ofnode(dev), &child);
+}
+
+static const struct misc_ops stm32_rcc_ops = {
+};
+
+static const struct udevice_id stm32_rcc_ids[] = {
+	{.compatible = "st,stm32h743-rcc"},
+	{ }
+};
+
+U_BOOT_DRIVER(stm32_rcc) = {
+	.name		= "stm32-rcc",
+	.id		= UCLASS_MISC,
+	.of_match	= stm32_rcc_ids,
+	.bind		= stm32_rcc_bind,
+	.ops		= &stm32_rcc_ops,
+};