1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Reset driver for the StarFive JH7110 SoC
5 * Copyright (C) 2022 StarFive Technology Co., Ltd.
8 #include <linux/auxiliary_bus.h>
10 #include "reset-starfive-jh71x0.h"
12 #include <dt-bindings/reset/starfive,jh7110-crg.h>
14 struct jh7110_reset_info {
15 unsigned int nr_resets;
16 unsigned int assert_offset;
17 unsigned int status_offset;
20 static const struct jh7110_reset_info jh7110_sys_info = {
21 .nr_resets = JH7110_SYSRST_END,
22 .assert_offset = 0x2F8,
23 .status_offset = 0x308,
26 static const struct jh7110_reset_info jh7110_aon_info = {
27 .nr_resets = JH7110_AONRST_END,
28 .assert_offset = 0x38,
29 .status_offset = 0x3C,
32 static const struct jh7110_reset_info jh7110_stg_info = {
33 .nr_resets = JH7110_STGRST_END,
34 .assert_offset = 0x74,
35 .status_offset = 0x78,
38 static const struct jh7110_reset_info jh7110_isp_info = {
39 .nr_resets = JH7110_ISPRST_END,
40 .assert_offset = 0x38,
41 .status_offset = 0x3C,
44 static int jh7110_reset_probe(struct auxiliary_device *adev,
45 const struct auxiliary_device_id *id)
47 struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
48 void __iomem **base = (void __iomem **)dev_get_drvdata(adev->dev.parent);
53 return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
54 *base + info->assert_offset,
55 *base + info->status_offset,
61 static const struct auxiliary_device_id jh7110_reset_ids[] = {
63 .name = "clk_starfive_jh71x0.reset-sys",
64 .driver_data = (kernel_ulong_t)&jh7110_sys_info,
67 .name = "clk_starfive_jh71x0.reset-aon",
68 .driver_data = (kernel_ulong_t)&jh7110_aon_info,
71 .name = "clk_starfive_jh71x0.reset-stg",
72 .driver_data = (kernel_ulong_t)&jh7110_stg_info,
75 .name = "clk_starfive_jh71x0.reset-isp",
76 .driver_data = (kernel_ulong_t)&jh7110_isp_info,
80 MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
82 static struct auxiliary_driver jh7110_reset_driver = {
83 .probe = jh7110_reset_probe,
84 .id_table = jh7110_reset_ids,
86 module_auxiliary_driver(jh7110_reset_driver);
88 MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
89 MODULE_DESCRIPTION("StarFive JH7110 reset driver");
90 MODULE_LICENSE("GPL");