Skip to content

Commit 82327b1

Browse files
hal-fengConchuOD
authored andcommitted
reset: starfive: Add StarFive JH7110 reset driver
Add auxiliary driver to support StarFive JH7110 system and always-on resets. Tested-by: Tommaso Merciai <tomm.merciai@gmail.com> Reviewed-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Signed-off-by: Hal Feng <hal.feng@starfivetech.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent b2ab3c9 commit 82327b1

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

drivers/reset/starfive/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ config RESET_STARFIVE_JH7100
1010
default ARCH_STARFIVE
1111
help
1212
This enables the reset controller driver for the StarFive JH7100 SoC.
13+
14+
config RESET_STARFIVE_JH7110
15+
bool "StarFive JH7110 Reset Driver"
16+
depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS
17+
select RESET_STARFIVE_JH71X0
18+
default ARCH_STARFIVE
19+
help
20+
This enables the reset controller driver for the StarFive JH7110 SoC.

drivers/reset/starfive/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
obj-$(CONFIG_RESET_STARFIVE_JH71X0) += reset-starfive-jh71x0.o
33

44
obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
5+
obj-$(CONFIG_RESET_STARFIVE_JH7110) += reset-starfive-jh7110.o
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 "reset-starfive-jh71x0.h"
11+
12+
#include <dt-bindings/reset/starfive,jh7110-crg.h>
13+
14+
struct jh7110_reset_info {
15+
unsigned int nr_resets;
16+
unsigned int assert_offset;
17+
unsigned int status_offset;
18+
};
19+
20+
static const struct jh7110_reset_info jh7110_sys_info = {
21+
.nr_resets = JH7110_SYSRST_END,
22+
.assert_offset = 0x2F8,
23+
.status_offset = 0x308,
24+
};
25+
26+
static const struct jh7110_reset_info jh7110_aon_info = {
27+
.nr_resets = JH7110_AONRST_END,
28+
.assert_offset = 0x38,
29+
.status_offset = 0x3C,
30+
};
31+
32+
static int jh7110_reset_probe(struct auxiliary_device *adev,
33+
const struct auxiliary_device_id *id)
34+
{
35+
struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
36+
void __iomem **base = (void __iomem **)dev_get_drvdata(adev->dev.parent);
37+
38+
if (!info || !base)
39+
return -ENODEV;
40+
41+
return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
42+
*base + info->assert_offset,
43+
*base + info->status_offset,
44+
NULL,
45+
info->nr_resets,
46+
NULL);
47+
}
48+
49+
static const struct auxiliary_device_id jh7110_reset_ids[] = {
50+
{
51+
.name = "clk_starfive_jh7110_sys.rst-sys",
52+
.driver_data = (kernel_ulong_t)&jh7110_sys_info,
53+
},
54+
{
55+
.name = "clk_starfive_jh7110_sys.rst-aon",
56+
.driver_data = (kernel_ulong_t)&jh7110_aon_info,
57+
},
58+
{ /* sentinel */ }
59+
};
60+
MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
61+
62+
static struct auxiliary_driver jh7110_reset_driver = {
63+
.probe = jh7110_reset_probe,
64+
.id_table = jh7110_reset_ids,
65+
};
66+
module_auxiliary_driver(jh7110_reset_driver);
67+
68+
MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
69+
MODULE_DESCRIPTION("StarFive JH7110 reset driver");
70+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)