BCM270X_DT: Add midi-uart1 overlay
authorPhil Elwell <phil@raspberrypi.org>
Fri, 26 May 2017 12:03:41 +0000 (13:03 +0100)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:54:18 +0000 (15:54 +0100)
Add a scaler to the ttyS0 clock so that requesting 38400 baud results
in an approximately 31250 baud signal. This is analagous to
midi-uart0, except for ttyS0, which may be useful on Pi3 and also
may avoid an issue with ttyAMA0 failing to synchronise to an active
data stream.

See: https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=183860

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
arch/arm/boot/dts/overlays/Makefile
arch/arm/boot/dts/overlays/README
arch/arm/boot/dts/overlays/midi-uart1-overlay.dts [new file with mode: 0644]

index f19e06055dec6760205ebccde31f65b4d5793fca..eca81982c0f19988abd05165fc62a80d26f539cb 100644 (file)
@@ -58,6 +58,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
        mcp2515-can1.dtbo \
        mcp3008.dtbo \
        midi-uart0.dtbo \
+       midi-uart1.dtbo \
        mmc.dtbo \
        mpu6050.dtbo \
        mz61581.dtbo \
index 984a0f1c4240cc30806a9a596e038ab2ae4fa4ab..19df6883be4277240283d5f63f27e34a22a2eec5 100644 (file)
@@ -892,6 +892,13 @@ Load:   dtoverlay=midi-uart0
 Params: <None>
 
 
+Name:   midi-uart1
+Info:   Configures UART1 (ttyS0) so that a requested 38.4kbaud actually gets
+        31.25kbaud, the frequency required for MIDI
+Load:   dtoverlay=midi-uart1
+Params: <None>
+
+
 Name:   mmc
 Info:   Selects the bcm2835-mmc SD/MMC driver, optionally with overclock
 Load:   dtoverlay=mmc,<param>=<val>
diff --git a/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts b/arch/arm/boot/dts/overlays/midi-uart1-overlay.dts
new file mode 100644 (file)
index 0000000..e0bc410
--- /dev/null
@@ -0,0 +1,43 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/clock/bcm2835-aux.h>
+
+/*
+ * Fake a higher clock rate to get a larger divisor, and thereby a lower
+ * baudrate. The real clock is 48MHz, which we scale so that requesting
+ * 38.4kHz results in an actual 31.25kHz.
+ *
+ *   48000000*38400/31250 = 58982400
+ */
+
+/{
+       compatible = "brcm,bcm2835";
+
+       fragment@0 {
+               target-path = "/clocks";
+               __overlay__ {
+                       midi_clk: clock@5 {
+                               compatible = "fixed-factor-clock";
+                               #clock-cells = <0>;
+                               clocks = <&aux BCM2835_AUX_CLOCK_UART>;
+                               clock-mult = <38400>;
+                               clock-div  = <31250>;
+                       };
+               };
+       };
+
+       fragment@1 {
+               target = <&uart1>;
+               __overlay__ {
+                       clocks = <&midi_clk>;
+               };
+       };
+
+       fragment@2 {
+               target = <&aux>;
+               __overlay__ {
+                       clock-output-names = "aux_uart", "aux_spi1", "aux_spi2";
+               };
+       };
+};