1/** @file
2 *
3 *  [DSDT] Serial devices (UART).
4 *
5 *  Copyright (c) 2021, ARM Limited. All rights reserved.
6 *  Copyright (c) 2020, Pete Batard <pete@akeo.ie>
7 *  Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
8 *  Copyright (c) Microsoft Corporation. All rights reserved.
9 *
10 *  SPDX-License-Identifier: BSD-2-Clause-Patent
11 *
12 **/
13
14#include <asm/arch/acpi/bcm2836.h>
15
16#include "acpitables.h"
17
18// PL011 based UART.
19Device (URT0)
20{
21  Name (_HID, "BCM2837")
22  Name (_CID, "ARMH0011")
23  Name (_UID, 0x4)
24  Name (_CCA, 0x0)
25
26  Name (RBUF, ResourceTemplate ()
27  {
28    MEMORY32FIXED (ReadWrite, 0, BCM2836_PL011_UART_LENGTH, RMEM)
29    Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { BCM2836_PL011_UART_INTERRUPT }
30  })
31  Method (_CRS, 0x0, Serialized)
32  {
33    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_PL011_UART_OFFSET)
34    Return (^RBUF)
35  }
36
37  Name (CLCK, 48000000)
38
39  Name (_DSD, Package ()
40  {
41    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package ()
42    {
43      Package (2) { "clock-frequency", CLCK },
44    }
45  })
46}
47
48//
49// UART Mini.
50//
51// This device is referenced in the DBG2 table, which will cause the system to
52// not start the driver when the debugger is enabled and to mark the device
53// with problem code 53 (CM_PROB_USED_BY_DEBUGGER).
54//
55
56Device (URTM)
57{
58  Name (_HID, "BCM2836")
59  Name (_CID, "BCM2836")
60  Name (_UID, 0x0)
61  Name (_CCA, 0x0)
62
63  Name (RBUF, ResourceTemplate ()
64  {
65    MEMORY32FIXED (ReadWrite, 0, BCM2836_MINI_UART_LENGTH, RMEM)
66    Interrupt(ResourceConsumer, Level, ActiveHigh, Shared) { BCM2836_MINI_UART_INTERRUPT }
67
68  })
69  Method (_CRS, 0x0, Serialized)
70  {
71    MEMORY32SETBASE (RBUF, RMEM, RBAS, BCM2836_MINI_UART_OFFSET)
72    Return (^RBUF)
73  }
74
75  //
76  // Mini Uart Clock Rate will be dynamically updated during boot
77  //
78  External (\_SB.URTM.MUCR, IntObj)
79
80  Name (_DSD, Package ()
81  {
82    ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), Package ()
83    {
84      Package (2) { "clock-frequency", MUCR },
85    }
86  })
87}
88
89//
90// Multifunction serial bus device to support Bluetooth function.
91//
92Device(BTH0)
93{
94  Name (_HID, "BCM2EA6")
95  Name (_CID, "BCM2EA6")
96
97  //
98  // UART In Use will be dynamically updated during boot
99  //
100  External (\_SB.BTH0.URIU, IntObj)
101
102  Method (_STA)
103  {
104    Return (0xf)
105  }
106
107  //
108  // Resource for URT0 (PL011)
109  //
110  Name (BTPL, ResourceTemplate ()
111  {
112    UARTSerialBus(
113      115200,        // InitialBaudRate: in BPS
114      ,              // BitsPerByte: default to 8 bits
115      ,              // StopBits: Defaults to one bit
116      0x00,          // LinesInUse: 8 1-bit flags to
117                    //   declare enabled control lines.
118                    //   Raspberry Pi does not exposed
119                    //   HW control signals -> not supported.
120                    //   Optional bits:
121                    //   - Bit 7 (0x80) Request To Send (RTS)
122                    //   - Bit 6 (0x40) Clear To Send (CTS)
123                    //   - Bit 5 (0x20) Data Terminal Ready (DTR)
124                    //   - Bit 4 (0x10) Data Set Ready (DSR)
125                    //   - Bit 3 (0x08) Ring Indicator (RI)
126                    //   - Bit 2 (0x04) Data Carrier Detect (DTD)
127                    //   - Bit 1 (0x02) Reserved. Must be 0.
128                    //   - Bit 0 (0x01) Reserved. Must be 0.
129      ,              // IsBigEndian:
130                    //   default to LittleEndian.
131      ,              // Parity: Defaults to no parity
132      ,              // FlowControl: Defaults to
133                    //   no flow control.
134      16,            // ReceiveBufferSize
135      16,            // TransmitBufferSize
136      "\\_SB.GDV0.URT0",  // ResourceSource:
137                    //   UART bus controller name
138      ,              // ResourceSourceIndex: assumed to be 0
139      ,              // ResourceUsage: assumed to be
140                    //   ResourceConsumer
141      UAR0,          // DescriptorName: creates name
142                    //   for offset of resource descriptor
143    )                // Vendor data
144  })
145
146  //
147  // Resource for URTM (miniUART)
148  //
149  Name (BTMN, ResourceTemplate ()
150  {
151    //
152    // BT UART: ResourceSource will be dynamically updated to
153    // either URT0 (PL011) or URTM (miniUART) during boot
154    //
155    UARTSerialBus(
156      115200,        // InitialBaudRate: in BPS
157      ,              // BitsPerByte: default to 8 bits
158      ,              // StopBits: Defaults to one bit
159      0x00,          // LinesInUse: 8 1-bit flags to
160                    //   declare enabled control lines.
161                    //   Raspberry Pi does not exposed
162                    //   HW control signals -> not supported.
163                    //   Optional bits:
164                    //   - Bit 7 (0x80) Request To Send (RTS)
165                    //   - Bit 6 (0x40) Clear To Send (CTS)
166                    //   - Bit 5 (0x20) Data Terminal Ready (DTR)
167                    //   - Bit 4 (0x10) Data Set Ready (DSR)
168                    //   - Bit 3 (0x08) Ring Indicator (RI)
169                    //   - Bit 2 (0x04) Data Carrier Detect (DTD)
170                    //   - Bit 1 (0x02) Reserved. Must be 0.
171                    //   - Bit 0 (0x01) Reserved. Must be 0.
172      ,              // IsBigEndian:
173                    //   default to LittleEndian.
174      ,              // Parity: Defaults to no parity
175      ,              // FlowControl: Defaults to
176                    //   no flow control.
177      16,            // ReceiveBufferSize
178      16,            // TransmitBufferSize
179      "\\_SB.GDV0.URTM",  // ResourceSource:
180                    //   UART bus controller name
181      ,              // ResourceSourceIndex: assumed to be 0
182      ,              // ResourceUsage: assumed to be
183                    //   ResourceConsumer
184      UARM,          // DescriptorName: creates name
185                    //   for offset of resource descriptor
186    )                // Vendor data
187  })
188
189  Method (_CRS, 0x0, Serialized)
190  {
191    if (URIU == 0)
192    {
193      //
194      // PL011 UART is configured for console output
195      // Return Mini UART for Bluetooth
196      //
197      return (^BTMN)
198    }
199    else
200    {
201      //
202      // Mini UART is configured for console output
203      // Return PL011 UART for Bluetooth
204      //
205      return (^BTPL)
206    }
207  }
208}
209