Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / arch / arm / boot / dts / overlays / ghost-amp-overlay.dts
1 // Overlay for the PCM5122-based Ghost amplifier using gpio-fsm
2 /dts-v1/;
3 /plugin/;
4
5 #include <dt-bindings/gpio/gpio-fsm.h>
6
7 #define ENABLE   GF_SW(0)
8 #define FAULT    GF_IP(0) // GPIO5
9 #define RELAY1   GF_OP(0) // GPIO22
10 #define RELAY2   GF_OP(1) // GPIO23
11 #define RELAYSSR GF_OP(2) // GPIO24
12
13 / {
14         compatible = "brcm,bcm2835";
15
16         fragment@0 {
17                 target = <&i2s>;
18                 __overlay__ {
19                         status = "okay";
20                 };
21         };
22
23         fragment@1 {
24                 target = <&i2c1>;
25                 __overlay__ {
26                         #address-cells = <1>;
27                         #size-cells = <0>;
28                         status = "okay";
29
30                         pcm5122@4c {
31                                 #sound-dai-cells = <0>;
32                                 compatible = "ti,pcm5122";
33                                 reg = <0x4c>;
34                                 AVDD-supply = <&vdd_3v3_reg>;
35                                 DVDD-supply = <&vdd_3v3_reg>;
36                                 CPVDD-supply = <&vdd_3v3_reg>;
37                                 status = "okay";
38                         };
39                 };
40         };
41
42         fragment@2 {
43                 target = <&sound>;
44                 iqaudio_dac: __overlay__ {
45                         compatible = "iqaudio,iqaudio-dac";
46                         i2s-controller = <&i2s>;
47                         mute-gpios = <&amp 0 0>;
48                         iqaudio-dac,auto-mute-amp;
49                         status = "okay";
50                 };
51         };
52
53         fragment@3 {
54                 target-path = "/";
55                 __overlay__ {
56                         amp: ghost-amp {
57                                 compatible = "rpi,gpio-fsm";
58                                 pinctrl-names = "default";
59                                 pinctrl-0 = <&ghost_amp_pins>;
60
61                                 debug = <0>;
62                                 gpio-controller;
63                                 #gpio-cells = <2>;
64                                 num-swgpios = <1>;
65                                 gpio-line-names = "enable";
66                                 input-gpios  = <&gpio 5 1>;  // FAULT (active low)
67                                 output-gpios = <&gpio 22 0>, // RELAY1
68                                                <&gpio 23 0>, // RELAY2
69                                                <&gpio 24 0>; // RELAYSSR
70                                 shutdown-timeout-ms = <1000>;
71
72                                 amp_off {
73                                         start_state;
74                                         shutdown_state;
75
76                                         set = <RELAYSSR 0>,
77                                               <RELAY2 0>,
78                                               <RELAY1 0>;
79                                         amp_on_1 = <ENABLE 1>;
80                                         fault = <FAULT 1>;
81                                 };
82
83                                 amp_on_1 {
84                                         set = <RELAY1 1>;
85                                         amp_on_2 = <GF_DELAY 1000>;
86                                         amp_off = <GF_SHUTDOWN 0>;
87                                         fault = <FAULT 1>;
88                                 };
89
90                                 amp_on_2 {
91                                         set = <RELAY2 1>;
92                                         amp_on_wait = <ENABLE 0>;
93                                         amp_on = <GF_DELAY 1>;
94                                         fault = <FAULT 1>;
95                                 };
96
97                                 amp_on {
98                                         set = <RELAYSSR 1>;
99                                         amp_on_wait = <ENABLE 0>;
100                                         fault = <FAULT 1>;
101                                 };
102
103                                 amp_on_wait {
104                                         set = <RELAYSSR 0>;
105                                         amp_off_1 = <GF_DELAY (30*60*1000)>,
106                                                     <GF_SHUTDOWN 0>;
107                                         amp_on = <ENABLE 1>;
108                                         fault = <FAULT 1>;
109                                 };
110
111                                 amp_off_1 {
112                                         set = <RELAY2 0>;
113                                         amp_on = <ENABLE 1>;
114                                         amp_off = <GF_DELAY 100>;
115                                         fault = <FAULT 1>;
116                                 };
117
118                                 // Keep this a distinct state to prevent
119                                 // changes and for the diagnostic output
120                                 fault {
121                                         set = <RELAYSSR 0>,
122                                               <RELAY2 0>,
123                                               <RELAY1 0>;
124                                         amp_off = <FAULT 0>;
125                                         shutdown_state;
126                                 };
127                         };
128                 };
129         };
130
131         fragment@4 {
132                 target = <&gpio>;
133                 __overlay__ {
134                         ghost_amp_pins: ghost_amp_pins {
135                                 brcm,pins = <5 22 23 24>;
136                                 brcm,function = <0 1 1 1>; /* in out out out */
137                                 brcm,pull = <2 0 0 0>; /* up none none none */
138                         };
139                 };
140         };
141
142         __overrides__ {
143                 fsm_debug = <&amp>,"debug:0";
144         };
145 };