Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68f9abd8 authored by Bhalchandra Gajare's avatar Bhalchandra Gajare Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: wcd-spi: SPI driver for WCD audio codecs



WCD audio codecs contain SPI slave hardware module to provide access
to codec memory and SPI register space. Change adds driver for this
slave hardware. This driver uses regmap for SPI internal register
accesses and plugs in to standard SPI framework as child device to
master controller driver.

CRs-Fixed: 1049012
Change-Id: I0640ac1ed60a2ec3633636760593211ecd2f9c2d
Signed-off-by: default avatarBhalchandra Gajare <gajare@codeaurora.org>
parent 64317399
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
WCD audio codec SPI driver support

* wcd_spi

The wcd_spi device is child device node to the master contoller's device node
and will have properties that the SPI framework or the master controller driver
expects. The properties listed here are specific to wcd-spi driver.

Required properties:

- compatible : "qcom,wcd-spi-v2"

- qcom,mem-base-addr : Defines the memory base address from the SPI
		       memory map. This will be used as an offset to read
		       and write memory.

Example:

&spi_10 {
	status = "ok";
	wcd_spi_0: wcd_spi@0 {
		compatible = "qcom,wcd-spi-v2";
		reg = <0>;
		spi-max-frequency = <24000000>;
		qcom,mem-base-addr = <0x100000>;
	};
};
+57 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __WCD_SPI_H__
#define __WCD_SPI_H__

struct wcd_spi_msg {
	/*
	 * Caller's buffer pointer that holds data to
	 * be transmitted in case of data_write and
	 * data to be copied to in case of data_read.
	 */
	void *data;

	/* Length of data to write/read */
	size_t len;

	/*
	 * Address in remote memory to write to
	 * or read from.
	 */
	u32 remote_addr;

	/* Bitmask of flags, currently unused */
	u32 flags;
};

#ifdef CONFIG_SND_SOC_WCD_SPI

int wcd_spi_data_write(struct spi_device *spi, struct wcd_spi_msg *msg);
int wcd_spi_data_read(struct spi_device *spi, struct wcd_spi_msg *msg);

#else

int wcd_spi_data_write(struct spi_device *spi, struct wcd_spi_msg *msg)
{
	return -ENODEV;
}

int wcd_spi_data_read(struct spi_device *spi, struct wcd_spi_msg *msg)
{
	return -ENODEV;
}

#endif /* End of CONFIG_SND_SOC_WCD_SPI */

#endif /* End of __WCD_SPI_H__ */
+4 −0
Original line number Diff line number Diff line
@@ -765,6 +765,10 @@ config SND_SOC_WCD_MBHC
config SND_SOC_WCD_DSP_MGR
	tristate

config SND_SOC_WCD_SPI
	depends on CONFIG_SPI
	tristate

config SND_SOC_WL1273
	tristate

+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ snd-soc-wsa881x-analog-objs := wsa881x-analog.o wsa881x-tables-analog.o
snd-soc-wsa881x-analog-objs += wsa881x-regmap-analog.o wsa881x-irq.o
snd-soc-wcd-dsp-utils-objs := wcd-dsp-utils.o
snd-soc-wcd-dsp-mgr-objs := wcd-dsp-mgr.o
snd-soc-wcd-spi-objs := wcd-spi.o
snd-soc-wl1273-objs := wl1273.o
snd-soc-wm-adsp-objs := wm_adsp.o
snd-soc-wm0010-objs := wm0010.o
@@ -354,6 +355,7 @@ obj-$(CONFIG_SND_SOC_WSA881X) += snd-soc-wsa881x.o
obj-$(CONFIG_SND_SOC_WSA881X_ANALOG)	+= snd-soc-wsa881x-analog.o
obj-$(CONFIG_SND_SOC_WL1273)	+= snd-soc-wl1273.o
obj-$(CONFIG_SND_SOC_WCD_DSP_MGR)	+= snd-soc-wcd-dsp-mgr.o snd-soc-wcd-dsp-utils.o
obj-$(CONFIG_SND_SOC_WCD_SPI)  += snd-soc-wcd-spi.o
obj-$(CONFIG_SND_SOC_WM0010)	+= snd-soc-wm0010.o
obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o
obj-$(CONFIG_SND_SOC_WM2000)	+= snd-soc-wm2000.o
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

#ifndef __WCD_SPI_REGISTERS_H__
#define __WCD_SPI_REGISTERS_H__

#include <linux/regmap.h>

#define WCD_SPI_SLAVE_SANITY         (0x00)
#define WCD_SPI_SLAVE_DEVICE_ID      (0x04)
#define WCD_SPI_SLAVE_STATUS         (0x08)
#define WCD_SPI_SLAVE_CONFIG         (0x0c)
#define WCD_SPI_SLAVE_SW_RESET       (0x10)
#define WCD_SPI_SLAVE_IRQ_STATUS     (0x14)
#define WCD_SPI_SLAVE_IRQ_EN         (0x18)
#define WCD_SPI_SLAVE_IRQ_CLR        (0x1c)
#define WCD_SPI_SLAVE_IRQ_FORCE      (0x20)
#define WCD_SPI_SLAVE_TX             (0x24)
#define WCD_SPI_SLAVE_TEST_BUS_DATA  (0x2c)
#define WCD_SPI_SLAVE_TEST_BUS_CTRL  (0x30)
#define WCD_SPI_SLAVE_SW_RST_IRQ     (0x34)
#define WCD_SPI_SLAVE_CHAR_CFG       (0x38)
#define WCD_SPI_SLAVE_CHAR_DATA_MOSI (0x3c)
#define WCD_SPI_SLAVE_CHAR_DATA_CS_N (0x40)
#define WCD_SPI_SLAVE_CHAR_DATA_MISO (0x44)
#define WCD_SPI_SLAVE_TRNS_BYTE_CNT  (0x4c)
#define WCD_SPI_SLAVE_TRNS_LEN       (0x50)
#define WCD_SPI_SLAVE_FIFO_LEVEL     (0x54)
#define WCD_SPI_SLAVE_GENERICS       (0x58)
#define WCD_SPI_SLAVE_EXT_BASE_ADDR  (0x5c)
#define WCD_SPI_MAX_REGISTER         (0x5F)

#endif /* End __WCD_SPI_REGISTERS_H__ */
Loading