|
| 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