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 <soc/starfive/reset-starfive-jh71x0.h>
12 #include "reset-starfive-jh71x0.h"
14 #include <dt-bindings/reset/starfive,jh7110-crg.h>
16 struct jh7110_reset_info
{
17 unsigned int nr_resets
;
18 unsigned int assert_offset
;
19 unsigned int status_offset
;
22 static const struct jh7110_reset_info jh7110_sys_info
= {
23 .nr_resets
= JH7110_SYSRST_END
,
24 .assert_offset
= 0x2F8,
25 .status_offset
= 0x308,
28 static const struct jh7110_reset_info jh7110_aon_info
= {
29 .nr_resets
= JH7110_AONRST_END
,
30 .assert_offset
= 0x38,
31 .status_offset
= 0x3C,
34 static const struct jh7110_reset_info jh7110_stg_info
= {
35 .nr_resets
= JH7110_STGRST_END
,
36 .assert_offset
= 0x74,
37 .status_offset
= 0x78,
40 static const struct jh7110_reset_info jh7110_isp_info
= {
41 .nr_resets
= JH7110_ISPRST_END
,
42 .assert_offset
= 0x38,
43 .status_offset
= 0x3C,
46 static const struct jh7110_reset_info jh7110_vout_info
= {
47 .nr_resets
= JH7110_VOUTRST_END
,
48 .assert_offset
= 0x48,
49 .status_offset
= 0x4C,
52 static int jh7110_reset_probe(struct auxiliary_device
*adev
,
53 const struct auxiliary_device_id
*id
)
55 struct jh7110_reset_info
*info
= (struct jh7110_reset_info
*)(id
->driver_data
);
56 struct jh71x0_reset_adev
*rdev
= to_jh71x0_reset_adev(adev
);
57 void __iomem
*base
= rdev
->base
;
62 return reset_starfive_jh71x0_register(&adev
->dev
, adev
->dev
.parent
->of_node
,
63 base
+ info
->assert_offset
,
64 base
+ info
->status_offset
,
70 static const struct auxiliary_device_id jh7110_reset_ids
[] = {
72 .name
= "clk_starfive_jh7110_sys.rst-sys",
73 .driver_data
= (kernel_ulong_t
)&jh7110_sys_info
,
76 .name
= "clk_starfive_jh7110_sys.rst-aon",
77 .driver_data
= (kernel_ulong_t
)&jh7110_aon_info
,
80 .name
= "clk_starfive_jh7110_sys.rst-stg",
81 .driver_data
= (kernel_ulong_t
)&jh7110_stg_info
,
84 .name
= "clk_starfive_jh7110_sys.rst-isp",
85 .driver_data
= (kernel_ulong_t
)&jh7110_isp_info
,
88 .name
= "clk_starfive_jh7110_sys.rst-vo",
89 .driver_data
= (kernel_ulong_t
)&jh7110_vout_info
,
93 MODULE_DEVICE_TABLE(auxiliary
, jh7110_reset_ids
);
95 static struct auxiliary_driver jh7110_reset_driver
= {
96 .probe
= jh7110_reset_probe
,
97 .id_table
= jh7110_reset_ids
,
99 module_auxiliary_driver(jh7110_reset_driver
);
101 MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
102 MODULE_DESCRIPTION("StarFive JH7110 reset driver");
103 MODULE_LICENSE("GPL");