reset: starfive: Add JH7100 audio reset driver
[platform/kernel/linux-starfive.git] / drivers / reset / starfive / reset-starfive-jh7100-audio.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Audio reset driver for the StarFive JH7100 SoC
4  *
5  * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
6  */
7
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/reset-controller.h>
12
13 #include <dt-bindings/reset/starfive-jh7100-audio.h>
14
15 #include "reset-starfive-jh7100.h"
16
17 /* register offsets */
18 #define JH7100_AUDRST_ASSERT0   0x00
19 #define JH7100_AUDRST_STATUS0   0x04
20
21 /*
22  * Writing a 1 to the n'th bit of the ASSERT register asserts
23  * line n, and writing a 0 deasserts the same line.
24  * Most reset lines have their status inverted so a 0 bit in the STATUS
25  * register means the line is asserted and a 1 means it's deasserted. A few
26  * lines don't though, so store the expected value of the status registers when
27  * all lines are asserted.
28  */
29 static const u32 jh7100_audrst_asserted[1] = {
30         BIT(JH7100_AUDRST_USB_AXI) |
31         BIT(JH7100_AUDRST_USB_PWRUP_RST_N) |
32         BIT(JH7100_AUDRST_USB_PONRST)
33 };
34
35 static int jh7100_audrst_probe(struct platform_device *pdev)
36 {
37         return reset_starfive_jh7100_generic_probe(pdev, jh7100_audrst_asserted,
38                                                    JH7100_AUDRST_STATUS0, JH7100_AUDRSTN_END);
39 }
40
41 static const struct of_device_id jh7100_audrst_dt_ids[] = {
42         { .compatible = "starfive,jh7100-audrst" },
43         { /* sentinel */ }
44 };
45 MODULE_DEVICE_TABLE(of, jh7100_audrst_dt_ids);
46
47 static struct platform_driver jh7100_audrst_driver = {
48         .probe = jh7100_audrst_probe,
49         .driver = {
50                 .name = "jh7100-reset-audio",
51                 .of_match_table = jh7100_audrst_dt_ids,
52         },
53 };
54 module_platform_driver(jh7100_audrst_driver);
55
56 MODULE_AUTHOR("Emil Renner Berthing");
57 MODULE_DESCRIPTION("StarFive JH7100 audio reset driver");
58 MODULE_LICENSE("GPL");