Skip to content

Commit c8754c7

Browse files
sverdlininochisa
authored andcommitted
soc: sophgo: cv1800: rtcsys: New driver (handling RTC only)
Add driver for Sophgo CV1800 series SoC RTC subsystem. The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module, HW state machine to control chip power-on, power-off and reset. Furthermore, the 8051 subsystem is located within RTCSYS including associated SRAM block. This patch only populates RTC sub-device. Signed-off-by: Alexander Sverdlin <[email protected]> Reviewed-by: Inochi Amaoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Inochi Amaoto <[email protected]> Signed-off-by: Chen Wang <[email protected]> Signed-off-by: Chen Wang <[email protected]>
1 parent 7651742 commit c8754c7

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

drivers/soc/sophgo/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
if ARCH_SOPHGO || COMPILE_TEST
77
menu "Sophgo SoC drivers"
88

9+
config SOPHGO_CV1800_RTCSYS
10+
tristate "Sophgo CV1800 RTC MFD"
11+
select MFD_CORE
12+
help
13+
If you say yes here you get support the RTC MFD driver for Sophgo
14+
CV1800 series SoC. The RTC module comprises a 32kHz oscillator,
15+
Power-on-Reset (PoR) sub-module, HW state machine to control chip
16+
power-on, power-off and reset. Furthermore, the 8051 subsystem is
17+
located within RTCSYS including associated SRAM block.
18+
19+
This driver can also be built as a module. If so, the module will be
20+
called cv1800-rtcsys.
21+
922
config SOPHGO_SG2044_TOPSYS
1023
tristate "Sophgo SG2044 TOP syscon driver"
1124
select MFD_CORE

drivers/soc/sophgo/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3+
obj-$(CONFIG_SOPHGO_CV1800_RTCSYS) += cv1800-rtcsys.o
34
obj-$(CONFIG_SOPHGO_SG2044_TOPSYS) += sg2044-topsys.o

drivers/soc/sophgo/cv1800-rtcsys.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Driver for Sophgo CV1800 series SoC RTC subsystem
4+
*
5+
* The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module,
6+
* HW state machine to control chip power-on, power-off and reset. Furthermore,
7+
* the 8051 subsystem is located within RTCSYS including associated SRAM block.
8+
*
9+
* Copyright (C) 2025 Alexander Sverdlin <[email protected]>
10+
*
11+
*/
12+
13+
#include <linux/mfd/core.h>
14+
#include <linux/module.h>
15+
#include <linux/of.h>
16+
#include <linux/property.h>
17+
18+
static struct resource cv1800_rtcsys_irq_resources[] = {
19+
DEFINE_RES_IRQ_NAMED(0, "alarm"),
20+
};
21+
22+
static const struct mfd_cell cv1800_rtcsys_subdev[] = {
23+
{
24+
.name = "cv1800b-rtc",
25+
.num_resources = 1,
26+
.resources = &cv1800_rtcsys_irq_resources[0],
27+
},
28+
};
29+
30+
static int cv1800_rtcsys_probe(struct platform_device *pdev)
31+
{
32+
int irq;
33+
34+
irq = platform_get_irq_byname(pdev, "alarm");
35+
if (irq < 0)
36+
return irq;
37+
cv1800_rtcsys_irq_resources[0].start = irq;
38+
cv1800_rtcsys_irq_resources[0].end = irq;
39+
40+
return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
41+
cv1800_rtcsys_subdev,
42+
ARRAY_SIZE(cv1800_rtcsys_subdev),
43+
NULL, 0, NULL);
44+
}
45+
46+
static const struct of_device_id cv1800_rtcsys_of_match[] = {
47+
{ .compatible = "sophgo,cv1800b-rtc" },
48+
{ /* sentinel */ }
49+
};
50+
MODULE_DEVICE_TABLE(of, cv1800_rtcsys_of_match);
51+
52+
static struct platform_driver cv1800_rtcsys_mfd = {
53+
.probe = cv1800_rtcsys_probe,
54+
.driver = {
55+
.name = "cv1800_rtcsys",
56+
.of_match_table = cv1800_rtcsys_of_match,
57+
},
58+
};
59+
module_platform_driver(cv1800_rtcsys_mfd);
60+
61+
MODULE_AUTHOR("Alexander Sverdlin <[email protected]>");
62+
MODULE_DESCRIPTION("Sophgo CV1800 series SoC RTC subsystem driver");
63+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)