All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: Dragos Tarcatu <dragos_tarcatu@mentor.com>,
	Daniel Baluta <daniel.baluta@gmail.com>,
	Alan Cox <alan@linux.intel.com>,
	tiwai@suse.de, Keyon Jie <yang.jie@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	liam.r.girdwood@linux.intel.com, vkoul@kernel.org,
	broonie@kernel.org, andriy.shevchenko@linux.intel.com,
	sound-open-firmware@alsa-project.org
Subject: [PATCH v6 14/14] ASoC: SOF: Add utils
Date: Fri, 12 Apr 2019 11:05:19 -0500	[thread overview]
Message-ID: <20190412160519.30207-15-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20190412160519.30207-1-pierre-louis.bossart@linux.intel.com>

Helpers to set-up back-ends, create platform devices and common
IO/block read/write operations

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/utils.c | 112 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)
 create mode 100644 sound/soc/sof/utils.c

diff --git a/sound/soc/sof/utils.c b/sound/soc/sof/utils.c
new file mode 100644
index 000000000000..2ac4c3da0320
--- /dev/null
+++ b/sound/soc/sof/utils.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+//
+// This file is provided under a dual BSD/GPLv2 license.  When using or
+// redistributing this file, you may do so under either license.
+//
+// Copyright(c) 2018 Intel Corporation. All rights reserved.
+//
+// Author: Keyon Jie <yang.jie@linux.intel.com>
+//
+
+#include <linux/io-64-nonatomic-lo-hi.h>
+#include <linux/platform_device.h>
+#include <sound/soc.h>
+#include <sound/sof.h>
+#include "sof-priv.h"
+
+/*
+ * Register IO
+ *
+ * The sof_io_xyz() wrappers are typically referenced in snd_sof_dsp_ops
+ * structures and cannot be inlined.
+ */
+
+void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value)
+{
+	writel(value, addr);
+}
+EXPORT_SYMBOL(sof_io_write);
+
+u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr)
+{
+	return readl(addr);
+}
+EXPORT_SYMBOL(sof_io_read);
+
+void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value)
+{
+	writeq(value, addr);
+}
+EXPORT_SYMBOL(sof_io_write64);
+
+u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr)
+{
+	return readq(addr);
+}
+EXPORT_SYMBOL(sof_io_read64);
+
+/*
+ * IPC Mailbox IO
+ */
+
+void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
+		       void *message, size_t bytes)
+{
+	void __iomem *dest = sdev->bar[sdev->mailbox_bar] + offset;
+
+	memcpy_toio(dest, message, bytes);
+}
+EXPORT_SYMBOL(sof_mailbox_write);
+
+void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
+		      void *message, size_t bytes)
+{
+	void __iomem *src = sdev->bar[sdev->mailbox_bar] + offset;
+
+	memcpy_fromio(message, src, bytes);
+}
+EXPORT_SYMBOL(sof_mailbox_read);
+
+/*
+ * Memory copy.
+ */
+
+void sof_block_write(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *src,
+		     size_t size)
+{
+	void __iomem *dest = sdev->bar[bar] + offset;
+	const u8 *src_byte = src;
+	u32 affected_mask;
+	u32 tmp;
+	int m, n;
+
+	m = size / 4;
+	n = size % 4;
+
+	/* __iowrite32_copy use 32bit size values so divide by 4 */
+	__iowrite32_copy(dest, src, m);
+
+	if (n) {
+		affected_mask = (1 << (8 * n)) - 1;
+
+		/* first read the 32bit data of dest, then change affected
+		 * bytes, and write back to dest. For unaffected bytes, it
+		 * should not be changed
+		 */
+		tmp = ioread32(dest + m * 4);
+		tmp &= ~affected_mask;
+
+		tmp |= *(u32 *)(src_byte + m * 4) & affected_mask;
+		iowrite32(tmp, dest + m * 4);
+	}
+}
+EXPORT_SYMBOL(sof_block_write);
+
+void sof_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *dest,
+		    size_t size)
+{
+	void __iomem *src = sdev->bar[bar] + offset;
+
+	memcpy_fromio(dest, src, size);
+}
+EXPORT_SYMBOL(sof_block_read);
-- 
2.17.1

  parent reply	other threads:[~2019-04-12 16:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 16:05 [PATCH v6 00/14] ASoC: Sound Open Firmware (SOF) core Pierre-Louis Bossart
2019-04-12 16:05 ` [PATCH v6 01/14] ASoC: SOF: Add Sound Open Firmware driver core Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add Sound Open Firmware driver core" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 02/14] ASoC: SOF: Add Sound Open Firmware KControl support Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add Sound Open Firmware KControl support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 03/14] ASoC: SOF: Add driver debug support Pierre-Louis Bossart
2019-04-19 15:54   ` Mark Brown
2019-04-19 16:09     ` Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add driver debug support." to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 04/14] ASoC: SOF: Add support for IPC IO between DSP and Host Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add support for IPC IO between DSP and Host" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 05/14] ASoC: SOF: Add PCM operations support Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add PCM operations support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 06/14] ASoC: SOF: Add support for loading topologies Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add support for loading topologies" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 07/14] ASoC: SOF: Add DSP firmware logger support Pierre-Louis Bossart
2019-04-27 17:53   ` Applied "ASoC: SOF: Add DSP firmware logger support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 08/14] ASoC: SOF: Add DSP HW abstraction operations Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add DSP HW abstraction operations" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 09/14] ASoC: SOF: Add firmware loader support Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add firmware loader support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 10/14] ASoC: SOF: Add userspace ABI support Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add userspace ABI support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 11/14] ASoC: SOF: Add PM support Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add PM support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 12/14] ASoC: SOF: Add Nocodec machine driver support Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add Nocodec machine driver support" to the asoc tree Mark Brown
2019-04-12 16:05 ` [PATCH v6 13/14] ASoC: SOF: Add xtensa support Pierre-Louis Bossart
2019-04-27 17:52   ` Applied "ASoC: SOF: Add xtensa support" to the asoc tree Mark Brown
2019-04-12 16:05 ` Pierre-Louis Bossart [this message]
2019-04-27 17:52   ` Applied "ASoC: SOF: Add utils" " Mark Brown
2019-04-23 15:40 ` [PATCH v6 00/14] ASoC: Sound Open Firmware (SOF) core Takashi Iwai
2019-04-23 19:25   ` Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190412160519.30207-15-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alan@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@gmail.com \
    --cc=dragos_tarcatu@mentor.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.de \
    --cc=vkoul@kernel.org \
    --cc=yang.jie@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.