starfive: refresh patches
[openwrt/staging/ansuel.git] / target / linux / starfive / patches-6.1 / 1022-reset-starfive-Add-JH7100-audio-reset-driver.patch
1 From ff806bda9b04bcf73350e319f3efde5cd049b77a Mon Sep 17 00:00:00 2001
2 From: Emil Renner Berthing <kernel@esmil.dk>
3 Date: Sat, 20 Nov 2021 19:30:49 +0100
4 Subject: [PATCH 1022/1024] reset: starfive: Add JH7100 audio reset driver
5
6 The audio resets are almost identical to the system resets, there are
7 just fewer of them. So factor out and export a generic probe function,
8 so most of the reset controller implementation can be shared.
9
10 Signed-off-by: Emil Renner Berthing <kernel@esmil.dk>
11 ---
12 MAINTAINERS | 2 +-
13 drivers/reset/starfive/Kconfig | 7 ++
14 drivers/reset/starfive/Makefile | 2 +
15 .../starfive/reset-starfive-jh7100-audio.c | 66 +++++++++++++++++++
16 .../reset/starfive/reset-starfive-jh7100.h | 16 +++++
17 5 files changed, 92 insertions(+), 1 deletion(-)
18 create mode 100644 drivers/reset/starfive/reset-starfive-jh7100-audio.c
19 create mode 100644 drivers/reset/starfive/reset-starfive-jh7100.h
20
21 --- a/MAINTAINERS
22 +++ b/MAINTAINERS
23 @@ -19711,7 +19711,7 @@ STARFIVE JH71X0 RESET CONTROLLER DRIVERS
24 M: Emil Renner Berthing <kernel@esmil.dk>
25 M: Hal Feng <hal.feng@starfivetech.com>
26 S: Maintained
27 -F: Documentation/devicetree/bindings/reset/starfive,jh7100-reset.yaml
28 +F: Documentation/devicetree/bindings/reset/starfive,jh7100-*.yaml
29 F: drivers/reset/starfive/reset-starfive-jh71*
30 F: include/dt-bindings/reset/starfive?jh71*.h
31
32 --- a/drivers/reset/starfive/Kconfig
33 +++ b/drivers/reset/starfive/Kconfig
34 @@ -11,6 +11,13 @@ config RESET_STARFIVE_JH7100
35 help
36 This enables the reset controller driver for the StarFive JH7100 SoC.
37
38 +config RESET_STARFIVE_JH7100_AUDIO
39 + tristate "StarFive JH7100 Audio Reset Driver"
40 + depends on RESET_STARFIVE_JH7100
41 + default m if SOC_STARFIVE
42 + help
43 + This enables the audio reset driver for the StarFive JH7100 SoC.
44 +
45 config RESET_STARFIVE_JH7110
46 bool "StarFive JH7110 Reset Driver"
47 depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS
48 --- a/drivers/reset/starfive/Makefile
49 +++ b/drivers/reset/starfive/Makefile
50 @@ -2,4 +2,6 @@
51 obj-$(CONFIG_RESET_STARFIVE_JH71X0) += reset-starfive-jh71x0.o
52
53 obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
54 +obj-$(CONFIG_RESET_STARFIVE_JH7100_AUDIO) += reset-starfive-jh7100-audio.o
55 +
56 obj-$(CONFIG_RESET_STARFIVE_JH7110) += reset-starfive-jh7110.o
57 --- /dev/null
58 +++ b/drivers/reset/starfive/reset-starfive-jh7100-audio.c
59 @@ -0,0 +1,66 @@
60 +// SPDX-License-Identifier: GPL-2.0-or-later
61 +/*
62 + * Audio reset driver for the StarFive JH7100 SoC
63 + *
64 + * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
65 + */
66 +
67 +#include <linux/mod_devicetable.h>
68 +#include <linux/module.h>
69 +#include <linux/platform_device.h>
70 +
71 +#include "reset-starfive-jh71x0.h"
72 +
73 +#include <dt-bindings/reset/starfive-jh7100-audio.h>
74 +
75 +/* register offsets */
76 +#define JH7100_AUDRST_ASSERT0 0x00
77 +#define JH7100_AUDRST_STATUS0 0x04
78 +
79 +/*
80 + * Writing a 1 to the n'th bit of the ASSERT register asserts
81 + * line n, and writing a 0 deasserts the same line.
82 + * Most reset lines have their status inverted so a 0 bit in the STATUS
83 + * register means the line is asserted and a 1 means it's deasserted. A few
84 + * lines don't though, so store the expected value of the status registers when
85 + * all lines are asserted.
86 + */
87 +static const u32 jh7100_audrst_asserted[1] = {
88 + BIT(JH7100_AUDRST_USB_AXI) |
89 + BIT(JH7100_AUDRST_USB_PWRUP_RST_N) |
90 + BIT(JH7100_AUDRST_USB_PONRST)
91 +};
92 +
93 +static int jh7100_audrst_probe(struct platform_device *pdev)
94 +{
95 + void __iomem *base = devm_platform_ioremap_resource(pdev, 0);
96 +
97 + if (IS_ERR(base))
98 + return PTR_ERR(base);
99 +
100 + return reset_starfive_jh71x0_register(&pdev->dev, pdev->dev.of_node,
101 + base + JH7100_AUDRST_ASSERT0,
102 + base + JH7100_AUDRST_STATUS0,
103 + jh7100_audrst_asserted,
104 + JH7100_AUDRSTN_END,
105 + THIS_MODULE);
106 +}
107 +
108 +static const struct of_device_id jh7100_audrst_dt_ids[] = {
109 + { .compatible = "starfive,jh7100-audrst" },
110 + { /* sentinel */ }
111 +};
112 +MODULE_DEVICE_TABLE(of, jh7100_audrst_dt_ids);
113 +
114 +static struct platform_driver jh7100_audrst_driver = {
115 + .probe = jh7100_audrst_probe,
116 + .driver = {
117 + .name = "jh7100-reset-audio",
118 + .of_match_table = jh7100_audrst_dt_ids,
119 + },
120 +};
121 +module_platform_driver(jh7100_audrst_driver);
122 +
123 +MODULE_AUTHOR("Emil Renner Berthing");
124 +MODULE_DESCRIPTION("StarFive JH7100 audio reset driver");
125 +MODULE_LICENSE("GPL");
126 --- /dev/null
127 +++ b/drivers/reset/starfive/reset-starfive-jh7100.h
128 @@ -0,0 +1,16 @@
129 +// SPDX-License-Identifier: GPL-2.0-or-later
130 +/*
131 + * Copyright (C) 2021 Emil Renner Berthing <kernel@esmil.dk>
132 + */
133 +
134 +#ifndef _RESET_STARFIVE_JH7100_H_
135 +#define _RESET_STARFIVE_JH7100_H_
136 +
137 +#include <linux/platform_device.h>
138 +
139 +int reset_starfive_jh7100_generic_probe(struct platform_device *pdev,
140 + const u32 *asserted,
141 + unsigned int status_offset,
142 + unsigned int nr_resets);
143 +
144 +#endif