/*
* Pisound Linux kernel module.
- * Copyright (C) 2016-2020 Vilniaus Blokas UAB, https://blokas.io/pisound
+ * Copyright (C) 2016-2024 Vilniaus Blokas UAB, https://blokas.io/pisound
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
}
}
-static struct snd_rawmidi_ops pisnd_output_ops = {
+static const struct snd_rawmidi_ops pisnd_output_ops = {
.open = pisnd_output_open,
.close = pisnd_output_close,
.trigger = pisnd_output_trigger,
.drain = pisnd_output_drain,
};
-static struct snd_rawmidi_ops pisnd_input_ops = {
+static const struct snd_rawmidi_ops pisnd_input_ops = {
.open = pisnd_input_open,
.close = pisnd_input_close,
.trigger = pisnd_input_trigger,
enum { MAX_VERSION_STR_LEN = 6 };
static char g_fw_version[MAX_VERSION_STR_LEN];
static char g_hw_version[MAX_VERSION_STR_LEN];
+static u32 g_spi_speed_hz;
static uint8_t g_ledFlashDuration;
static bool g_ledFlashDurationChanged;
transfer.tx_buf = txbuf;
transfer.rx_buf = rxbuf;
transfer.len = len;
- transfer.speed_hz = 150000;
+ transfer.speed_hz = g_spi_speed_hz;
transfer.delay.value = 10;
transfer.delay.unit = SPI_DELAY_UNIT_USECS;
memset(g_fw_version, 0, sizeof(g_fw_version));
memset(g_hw_version, 0, sizeof(g_hw_version));
+ g_spi_speed_hz = 150000;
+ if (dev->of_node) {
+ struct device_node *spi_node;
+
+ spi_node = of_parse_phandle(
+ dev->of_node,
+ "spi-controller",
+ 0
+ );
+
+ if (spi_node) {
+ ret = of_property_read_u32(spi_node, "spi-speed-hz", &g_spi_speed_hz);
+ if (ret != 0)
+ printe("Failed reading spi-speed-hz! (%d)\n", ret);
+
+ of_node_put(spi_node);
+ }
+ }
+ printi("Using SPI speed: %u\n", g_spi_speed_hz);
+
spi = pisnd_spi_find_device();
if (spi != NULL) {
return 0;
}
-static struct snd_soc_ops pisnd_ops = {
+static const struct snd_soc_ops pisnd_ops = {
.startup = pisnd_startup,
.hw_params = pisnd_hw_params,
};