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
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Signed-off-by: Giedrius Trainavičius <giedrius@blokas.io>
12 sound/soc/bcm/pisound.c | 31 ++++++++++++++++++++++++++-----
13 1 file changed, 26 insertions(+), 5 deletions(-)
15 --- a/sound/soc/bcm/pisound.c
16 +++ b/sound/soc/bcm/pisound.c
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
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
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,
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;
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;
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;
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));
63 + g_spi_speed_hz = 150000;
65 + struct device_node *spi_node;
67 + spi_node = of_parse_phandle(
74 + ret = of_property_read_u32(spi_node, "spi-speed-hz", &g_spi_speed_hz);
76 + printe("Failed reading spi-speed-hz! (%d)\n", ret);
78 + of_node_put(spi_node);
81 + printi("Using SPI speed: %u\n", g_spi_speed_hz);
83 spi = pisnd_spi_find_device();
86 @@ -950,7 +971,7 @@ static int pisnd_startup(struct snd_pcm_
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,