Skip to content

Commit c6735cd

Browse files
Leo Yu-Chi LiangMina-Chou
authored andcommitted
smu: andes: atcsmu: Add Andes ATCSMU driver support (torvalds#195)
Add basic atcsmu driver support for AE350 platform. Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com> Reviewed-on: https://gitea.andestech.com/RD-SW/linux/pulls/195 Reviewed-by: Tim Shih-Ting OuYang <tim609@andestech.com> Reviewed-by: Charles Ci-Jyun Wu <dminus@andestech.com> Co-authored-by: Leo Yu-Chi Liang <ycliang@andestech.com> Co-committed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
1 parent 5545b8a commit c6735cd

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

arch/riscv/configs/andes-support.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ CONFIG_I2C_ATCIIC100=y
2020
CONFIG_ATCIIC_IRQ=y
2121

2222
CONFIG_GPIO_ATCGPIO100=y
23+
CONFIG_ANDES_ATCSMU=y

drivers/soc/andes/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,12 @@ config ANDES_PPMA
1111
Andes programmable physical memory attributes (PPMA)
1212
can map memory as non-cacheable bufferable PMA region.
1313

14+
config ANDES_ATCSMU
15+
bool "Andes ATCSMU Support"
16+
depends on RISCV && ARCH_ANDES
17+
help
18+
Enable the driver for Andes System Management
19+
Unit (SMU) to support light/deep sleep and
20+
hotplug utilities.
21+
1422
endmenu

drivers/soc/andes/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ obj-y += andes_sbi.o
55
obj-y += inject_init.o
66
obj-y += dcause.o
77
obj-$(CONFIG_ANDES_PPMA) += ppma.o
8+
obj-$(CONFIG_ANDES_ATCSMU) += atcsmu.o

drivers/soc/andes/atcsmu.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2024 Andes Technology Corporation.
4+
*/
5+
#define pr_fmt(fmt) "atcsmu: " fmt
6+
#include <linux/module.h>
7+
#include <linux/kernel.h>
8+
#include <linux/init.h>
9+
#include <linux/platform_device.h>
10+
#include <linux/io.h>
11+
#include <linux/of.h>
12+
#include <linux/soc/andes/smu.h>
13+
14+
static struct atcsmu atcsmu = { 0 };
15+
16+
void __iomem *atcsmu_get_address(void)
17+
{
18+
struct atcsmu *smu = &atcsmu;
19+
return smu->base;
20+
}
21+
22+
static int atcsmu_probe(struct platform_device *pdev)
23+
{
24+
struct atcsmu *smu = &atcsmu;
25+
unsigned int cpu;
26+
27+
smu->base = devm_platform_ioremap_resource(pdev, 0);
28+
if (IS_ERR(smu->base))
29+
return PTR_ERR(smu->base);
30+
31+
for_each_possible_cpu(cpu)
32+
writel(0x0, (void *)(smu->base + PCSm_WE_OFF(cpu)));
33+
34+
pr_info("ATCSMU driver probed\n");
35+
36+
return 0;
37+
}
38+
39+
static int __exit atcsmu_remove(struct platform_device *pdev)
40+
{
41+
pr_info("ATCSMU driver removed\n");
42+
return 0;
43+
}
44+
45+
static const struct of_device_id atcsmu_of_id_table[] = {
46+
{ .compatible = "andestech,atcsmu" },
47+
{}
48+
};
49+
MODULE_DEVICE_TABLE(of, atcsmu_of_id_table);
50+
51+
static struct platform_driver atcsmu_driver = {
52+
.probe = atcsmu_probe,
53+
.remove = __exit_p(atcsmu_remove),
54+
.driver = {
55+
.name = "atcsmu",
56+
.of_match_table = of_match_ptr(atcsmu_of_id_table),
57+
},
58+
};
59+
60+
static int __init atcsmu_init(void)
61+
{
62+
int ret = platform_driver_register(&atcsmu_driver);
63+
64+
return ret;
65+
}
66+
subsys_initcall(atcsmu_init);

include/linux/soc/andes/smu.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2024 Andes Technology Corporation.
4+
*/
5+
6+
#ifndef _LINUX_SOC_ANDES_SMU_H
7+
#define _LINUX_SOC_ANDES_SMU_H
8+
9+
#include <linux/suspend.h>
10+
11+
/*
12+
* PCS0 --> Always on power domain, includes the JTAG tap and
13+
* DMI_AHB bus in NCEJDTM200
14+
* PCS1 --> Power domain for debug subsystem
15+
* PCS2 --> Main power domain, includes the system bus and
16+
* AHB, APB peripheral IPs
17+
* PCS3 --> Power domain for Core0 and L2C
18+
* PCSm --> Power domain for Core (m-3)
19+
*/
20+
21+
#define PCS0_SCRATCH_OFF 0x84
22+
#define PCS0_WE_OFF 0x90
23+
#define PCS0_CTL_OFF 0x94
24+
#define PCS0_STATUS_OFF 0x98
25+
26+
#define PCSm_SCRATCH_OFF(n) ((n + 3) * 0x20 + PCS0_SCRATCH_OFF)
27+
#define PCSm_WE_OFF(n) ((n + 3) * 0x20 + PCS0_WE_OFF)
28+
#define PCSm_STATUS_OFF(n) ((n + 3) * 0x20 + PCS0_STATUS_OFF)
29+
#define PCSm_CTL_OFF(n) ((n + 3) * 0x20 + PCS0_CTL_OFF)
30+
31+
struct atcsmu {
32+
void __iomem *base;
33+
};
34+
35+
extern unsigned long *andes_wake_event;
36+
37+
void __iomem *atcsmu_get_address(void);
38+
39+
#endif

0 commit comments

Comments
 (0)