bcm27xx: update 6.1 patches from RPi foundation
[openwrt/staging/xback.git] / target / linux / bcm27xx / patches-6.1 / 950-1250-Pisound-Read-out-the-SPI-speed-to-use-from-the-Devic.patch
1 From 273139b285f7a1a825eb689943626a0172b8802b Mon Sep 17 00:00:00 2001
2 From: Giedrius <giedrius@blokas.io>
3 Date: Mon, 22 Jan 2024 13:26:58 +0000
4 Subject: [PATCH 1250/1295] Pisound: Read out the SPI speed to use from the
5 Device Tree.
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Signed-off-by: Giedrius Trainavičius <giedrius@blokas.io>
11 ---
12 sound/soc/bcm/pisound.c | 31 ++++++++++++++++++++++++++-----
13 1 file changed, 26 insertions(+), 5 deletions(-)
14
15 --- a/sound/soc/bcm/pisound.c
16 +++ b/sound/soc/bcm/pisound.c
17 @@ -1,6 +1,6 @@
18 /*
19 * Pisound Linux kernel module.
20 - * Copyright (C) 2016-2020 Vilniaus Blokas UAB, https://blokas.io/pisound
21 + * Copyright (C) 2016-2024 Vilniaus Blokas UAB, https://blokas.io/pisound
22 *
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25 @@ -142,14 +142,14 @@ static void pisnd_input_trigger(struct s
26 }
27 }
28
29 -static struct snd_rawmidi_ops pisnd_output_ops = {
30 +static const struct snd_rawmidi_ops pisnd_output_ops = {
31 .open = pisnd_output_open,
32 .close = pisnd_output_close,
33 .trigger = pisnd_output_trigger,
34 .drain = pisnd_output_drain,
35 };
36
37 -static struct snd_rawmidi_ops pisnd_input_ops = {
38 +static const struct snd_rawmidi_ops pisnd_input_ops = {
39 .open = pisnd_input_open,
40 .close = pisnd_input_close,
41 .trigger = pisnd_input_trigger,
42 @@ -226,6 +226,7 @@ static char g_id[25];
43 enum { MAX_VERSION_STR_LEN = 6 };
44 static char g_fw_version[MAX_VERSION_STR_LEN];
45 static char g_hw_version[MAX_VERSION_STR_LEN];
46 +static u32 g_spi_speed_hz;
47
48 static uint8_t g_ledFlashDuration;
49 static bool g_ledFlashDurationChanged;
50 @@ -329,7 +330,7 @@ static void spi_transfer(const uint8_t *
51 transfer.tx_buf = txbuf;
52 transfer.rx_buf = rxbuf;
53 transfer.len = len;
54 - transfer.speed_hz = 150000;
55 + transfer.speed_hz = g_spi_speed_hz;
56 transfer.delay.value = 10;
57 transfer.delay.unit = SPI_DELAY_UNIT_USECS;
58
59 @@ -646,6 +647,26 @@ static int pisnd_spi_init(struct device
60 memset(g_fw_version, 0, sizeof(g_fw_version));
61 memset(g_hw_version, 0, sizeof(g_hw_version));
62
63 + g_spi_speed_hz = 150000;
64 + if (dev->of_node) {
65 + struct device_node *spi_node;
66 +
67 + spi_node = of_parse_phandle(
68 + dev->of_node,
69 + "spi-controller",
70 + 0
71 + );
72 +
73 + if (spi_node) {
74 + ret = of_property_read_u32(spi_node, "spi-speed-hz", &g_spi_speed_hz);
75 + if (ret != 0)
76 + printe("Failed reading spi-speed-hz! (%d)\n", ret);
77 +
78 + of_node_put(spi_node);
79 + }
80 + }
81 + printi("Using SPI speed: %u\n", g_spi_speed_hz);
82 +
83 spi = pisnd_spi_find_device();
84
85 if (spi != NULL) {
86 @@ -950,7 +971,7 @@ static int pisnd_startup(struct snd_pcm_
87 return 0;
88 }
89
90 -static struct snd_soc_ops pisnd_ops = {
91 +static const struct snd_soc_ops pisnd_ops = {
92 .startup = pisnd_startup,
93 .hw_params = pisnd_hw_params,
94 };