Reset overview

来自百问网嵌入式Linux wiki
Zhouyuebiao讨论 | 贡献2020年5月7日 (四) 23:54的版本 (创建页面,内容为“The Linux<sup>®</sup> kernel reset framework offers a generic API for reset lines management at platform level.<br /> <br> == Framework purpose == The purpose o…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

The Linux® kernel reset framework offers a generic API for reset lines management at platform level.

Framework purpose

The purpose of this article is to introduce the Linux kernel Reset Framework. It provides general information and, based on concrete IP use cases, explains how to use it.


The Linux Reset framework offers a generic API for abstracting and controlling the different reset lines of the platform.
Reset lines can be internal system reset signals or external lines such as a GPIO to reset an external device.

System overview

错误: 图像不正确或者不存在

Component description

  • reset core: kernel reset framework designed for abstracting device reset handling via GPIOs or internal reset controller modules.
  • reset-stm32mp1: STM32MP1 RCC specific reset driver
  • RCC: Reset and clock controller that generates the different internal reset lines on STM32MP1.


API description

Documentation on the reset interface can be found in kernel documentation folder: https://www.kernel.org/doc/Documentation/devicetree/bindings/reset/reset.txt

  • Kernel reset API

To get the line reset from DT:

  • devm_reset_control_get_exclusive: looks up and obtains an exclusive reference to a reset controller (cannot be shared with another driver).
  • devm_reset_control_get_shared: looks up and obtains a shared reference to reset a controller (can be shared with another driver).
  • devm_reset_control_get: same as devm_reset_control_get_exclusive.
  • devm_reset_control_get_optional: same as devm_reset_control_get except that the reference name is optional.
  • devm_reset_control_get_optional_exclusive: same as devm_reset_control_get_exclusive except that the reference name is optional.
  • devm_reset_control_get_optional_shared: same as devm_reset_control_get_shared except that the reference name is optional.

To configure the reset line and retrieve its status from DT:

  • reset_control_assert: asserts the reset line
  • reset_control_deassert: deasserts the reset line
  • reset_control_status: returns if the line is asserted or not

Configuration

Kernel configuration

By default, the activation of the Reset framework configuration (CONFIG_RESET_CONTROLER) is selected in the kernel configuration, through the Linux Menuconfig tool: Menuconfig or how to configure kernel (CONFIG_ARCH_STM32=y, CONFIG_ARCH_MULTI_V7=y):

Device tree configuration

A detailed device tree configuration is described in Reset device tree configuration.

How to use the Reset framework

To control a peripheral reset line, a driver must first get a reference on the reset handler thanks to its device tree node.
The driver can then assert and deassert the reset line by calling the reset framework API.

Below an example:

	foo: foo@adcdefgh {
               compatible = "foo-driver";
               ...
		resets = <&rcc FOO_R>;
               ...
	};

Before using the reset specified in the device tree node, the foo driver has to request it at probe execution.

	static int foo_probe(struct platform_device *pdev)
	{
		struct reset_control *rst;
		...
		rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
		if (IS_ERR(rst)) {
			ret = PTR_ERR(rest);
			dev_err(&pdev->dev, "reset get failed: %d\n", ret);
			goto err_master_put;
		}
		...

The reset can then be asserted or deasserted using the reset framework API:

               ...
               reset_control_assert(rst);
               udelay(2);
               reset_control_deassert(rst);
               ...

Source code location

Reset core file [1]
STM32MP1 reset file [2]
STM32MP1 reset interface file [3]

References


<securetransclude src="ProtectedTemplate:ArticleBasedOnModel" params="Framework overview article model"></securetransclude> <securetransclude src="ProtectedTemplate:PublicationRequestId" params="10343 | 2019-01-21 | AnneJ"></securetransclude>