Skip to content

Commit 6333f29

Browse files
committed
Merge tag 'riscv-sophgo-soc-for-v6.16' of https://github.com/sophgo/linux into soc/drivers
RISC-V SoC for v6.16 Sophgo: Add support for SG2044 TOP syscon device. The SG2044 TOP device provide PLL clock function in its area. Add RTC support for CV1800 series SoC. The device is called RTC, but contains control registers of other HW blocks in its address space, most notably of Power-on-Reset (PoR) module, DW8051 IP (MCU core), accompanying SRAM, hence putting it in SoC subsystem. Signed-off-by: Chen Wang <[email protected]> * tag 'riscv-sophgo-soc-for-v6.16' of https://github.com/sophgo/linux: soc: sophgo: cv1800: rtcsys: New driver (handling RTC only) dt-bindings: soc: sophgo: add RTC support for Sophgo CV1800 series soc: sophgo: sg2044: Add support for SG2044 TOP syscon device Link: https://lore.kernel.org/r/MA0P287MB2262B041A26A0F5EAD1E296CFE91A@MA0P287MB2262.INDP287.PROD.OUTLOOK.COM Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 3fc5aea + c8754c7 commit 6333f29

File tree

7 files changed

+234
-0
lines changed

7 files changed

+234
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sophgo/sophgo,cv1800b-rtc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Real Time Clock of the Sophgo CV1800 SoC
8+
9+
description:
10+
The RTC (Real Time Clock) is an independently powered module in the chip. It
11+
contains a 32KHz oscillator and a Power-On-Reset (POR) sub-module, which can
12+
be used for time display and scheduled alarm produce. In addition, the
13+
hardware state machine provides triggering and timing control for chip
14+
power-on, power-off and reset.
15+
16+
Furthermore, the 8051 subsystem is located within RTCSYS and is independently
17+
powered. System software can use the 8051 to manage wake conditions and wake
18+
the system while the system is asleep, and communicate with external devices
19+
through peripheral controllers.
20+
21+
Technical Reference Manual available at
22+
https://github.com/sophgo/sophgo-doc/tree/main/SG200X/TRM
23+
24+
maintainers:
25+
26+
27+
allOf:
28+
- $ref: /schemas/rtc/rtc.yaml#
29+
30+
properties:
31+
compatible:
32+
items:
33+
- const: sophgo,cv1800b-rtc
34+
- const: syscon
35+
36+
reg:
37+
maxItems: 1
38+
39+
interrupts:
40+
items:
41+
- description: RTC Alarm
42+
- description: RTC Longpress
43+
- description: VBAT DET
44+
45+
interrupt-names:
46+
items:
47+
- const: alarm
48+
- const: longpress
49+
- const: vbat
50+
51+
clocks:
52+
items:
53+
- description: RTC clock source
54+
- description: DW8051 MCU clock source
55+
56+
clock-names:
57+
items:
58+
- const: rtc
59+
- const: mcu
60+
61+
required:
62+
- compatible
63+
- reg
64+
- interrupts
65+
- interrupt-names
66+
- clocks
67+
- clock-names
68+
69+
unevaluatedProperties: false
70+
71+
examples:
72+
- |
73+
#include <dt-bindings/clock/sophgo,cv1800.h>
74+
#include <dt-bindings/interrupt-controller/irq.h>
75+
76+
rtc@5025000 {
77+
compatible = "sophgo,cv1800b-rtc", "syscon";
78+
reg = <0x5025000 0x2000>;
79+
interrupts = <17 IRQ_TYPE_LEVEL_HIGH>,
80+
<18 IRQ_TYPE_LEVEL_HIGH>,
81+
<19 IRQ_TYPE_LEVEL_HIGH>;
82+
interrupt-names = "alarm", "longpress", "vbat";
83+
clocks = <&clk CLK_RTC_25M>,
84+
<&clk CLK_SRC_RTC_SYS_0>;
85+
clock-names = "rtc", "mcu";
86+
};

drivers/soc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ source "drivers/soc/qcom/Kconfig"
2323
source "drivers/soc/renesas/Kconfig"
2424
source "drivers/soc/rockchip/Kconfig"
2525
source "drivers/soc/samsung/Kconfig"
26+
source "drivers/soc/sophgo/Kconfig"
2627
source "drivers/soc/sunxi/Kconfig"
2728
source "drivers/soc/tegra/Kconfig"
2829
source "drivers/soc/ti/Kconfig"

drivers/soc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ obj-y += qcom/
2929
obj-y += renesas/
3030
obj-y += rockchip/
3131
obj-$(CONFIG_SOC_SAMSUNG) += samsung/
32+
obj-y += sophgo/
3233
obj-y += sunxi/
3334
obj-$(CONFIG_ARCH_TEGRA) += tegra/
3435
obj-y += ti/

drivers/soc/sophgo/Kconfig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
#
3+
# Sophgo SoC drivers
4+
#
5+
6+
if ARCH_SOPHGO || COMPILE_TEST
7+
menu "Sophgo SoC drivers"
8+
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+
22+
config SOPHGO_SG2044_TOPSYS
23+
tristate "Sophgo SG2044 TOP syscon driver"
24+
select MFD_CORE
25+
help
26+
This is the core driver for the Sophgo SG2044 TOP system
27+
controller device. This driver provide PLL clock device
28+
for the SoC.
29+
30+
This driver can also be built as a module. If so, the module
31+
will be called sg2044-topsys.
32+
33+
endmenu
34+
endif

drivers/soc/sophgo/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
obj-$(CONFIG_SOPHGO_CV1800_RTCSYS) += cv1800-rtcsys.o
4+
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");

drivers/soc/sophgo/sg2044-topsys.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Sophgo SG2044 multi-function system controller driver
4+
*
5+
* Copyright (C) 2025 Inochi Amaoto <[email protected]>
6+
*/
7+
8+
#include <linux/mfd/core.h>
9+
#include <linux/mod_devicetable.h>
10+
#include <linux/module.h>
11+
#include <linux/property.h>
12+
#include <linux/resource.h>
13+
14+
static const struct mfd_cell sg2044_topsys_subdev[] = {
15+
{
16+
.name = "sg2044-pll",
17+
},
18+
};
19+
20+
static int sg2044_topsys_probe(struct platform_device *pdev)
21+
{
22+
return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
23+
sg2044_topsys_subdev,
24+
ARRAY_SIZE(sg2044_topsys_subdev),
25+
NULL, 0, NULL);
26+
}
27+
28+
static const struct of_device_id sg2044_topsys_of_match[] = {
29+
{ .compatible = "sophgo,sg2044-top-syscon" },
30+
{ /* sentinel */ }
31+
};
32+
MODULE_DEVICE_TABLE(of, sg2044_topsys_of_match);
33+
34+
static struct platform_driver sg2044_topsys_driver = {
35+
.probe = sg2044_topsys_probe,
36+
.driver = {
37+
.name = "sg2044-topsys",
38+
.of_match_table = sg2044_topsys_of_match,
39+
},
40+
};
41+
module_platform_driver(sg2044_topsys_driver);
42+
43+
MODULE_AUTHOR("Inochi Amaoto <[email protected]>");
44+
MODULE_DESCRIPTION("Sophgo SG2044 multi-function system controller driver");
45+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)