Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Reset driver for the StarFive JH7110 SoC
4 *
5 * Copyright (C) 2022 StarFive Technology Co., Ltd.
6 */
7
8#include <linux/auxiliary_bus.h>
9
10#include <soc/starfive/reset-starfive-jh71x0.h>
11
12#include "reset-starfive-jh71x0.h"
13
14#include <dt-bindings/reset/starfive,jh7110-crg.h>
15
16struct jh7110_reset_info {
17 unsigned int nr_resets;
18 unsigned int assert_offset;
19 unsigned int status_offset;
20};
21
22static const struct jh7110_reset_info jh7110_sys_info = {
23 .nr_resets = JH7110_SYSRST_END,
24 .assert_offset = 0x2F8,
25 .status_offset = 0x308,
26};
27
28static const struct jh7110_reset_info jh7110_aon_info = {
29 .nr_resets = JH7110_AONRST_END,
30 .assert_offset = 0x38,
31 .status_offset = 0x3C,
32};
33
34static int jh7110_reset_probe(struct auxiliary_device *adev,
35 const struct auxiliary_device_id *id)
36{
37 struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
38 struct jh71x0_reset_adev *rdev = to_jh71x0_reset_adev(adev);
39 void __iomem *base = rdev->base;
40
41 if (!info || !base)
42 return -ENODEV;
43
44 return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
45 base + info->assert_offset,
46 base + info->status_offset,
47 NULL,
48 info->nr_resets,
49 NULL);
50}
51
52static const struct auxiliary_device_id jh7110_reset_ids[] = {
53 {
54 .name = "clk_starfive_jh7110_sys.rst-sys",
55 .driver_data = (kernel_ulong_t)&jh7110_sys_info,
56 },
57 {
58 .name = "clk_starfive_jh7110_sys.rst-aon",
59 .driver_data = (kernel_ulong_t)&jh7110_aon_info,
60 },
61 { /* sentinel */ }
62};
63MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
64
65static struct auxiliary_driver jh7110_reset_driver = {
66 .probe = jh7110_reset_probe,
67 .id_table = jh7110_reset_ids,
68};
69module_auxiliary_driver(jh7110_reset_driver);
70
71MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
72MODULE_DESCRIPTION("StarFive JH7110 reset driver");
73MODULE_LICENSE("GPL");