Commit 4235c80b authored by Mark Brown's avatar Mark Brown

Add audio support for LPC32XX CPUs

Merge series from Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>:

This pach set is to bring back audio to machines with a LPC32XX CPU.
The legacy LPC32XX SoC used to have audio spport in linux 2.6.27.
The support was dropped due to lack of interest from mainaeners.
parents 730674b2 0959de65
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/nxp,lpc3220-i2s.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: NXP LPC32XX I2S Controller
description:
The I2S controller in LPC32XX SoCs, ASoC DAI.
maintainers:
- J.M.B. Downing <jonathan.downing@nautel.com>
- Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>
allOf:
- $ref: dai-common.yaml#
properties:
compatible:
enum:
- nxp,lpc3220-i2s
reg:
maxItems: 1
interrupts:
maxItems: 1
clocks:
items:
- description: input clock of the peripheral.
dmas:
items:
- description: RX DMA Channel
- description: TX DMA Channel
dma-names:
items:
- const: rx
- const: tx
"#sound-dai-cells":
const: 0
required:
- compatible
- reg
- interrupts
- clocks
- dmas
- dma-names
- '#sound-dai-cells'
additionalProperties: false
examples:
- |
#include <dt-bindings/clock/lpc32xx-clock.h>
#include <dt-bindings/interrupt-controller/irq.h>
i2s@20094000 {
compatible = "nxp,lpc3220-i2s";
reg = <0x20094000 0x1000>;
interrupts = <22 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk LPC32XX_CLK_I2S0>;
dmas = <&dma 0 1>, <&dma 13 1>;
dma-names = "rx", "tx";
#sound-dai-cells = <0>;
};
...
......@@ -8909,6 +8909,16 @@ S: Maintained
F: sound/soc/fsl/fsl*
F: sound/soc/fsl/imx*
FREESCALE SOC LPC32XX SOUND DRIVERS
M: J.M.B. Downing <jonathan.downing@nautel.com>
M: Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>
R: Vladimir Zapolskiy <vz@mleia.com>
L: alsa-devel@alsa-project.org (moderated for non-subscribers)
L: linuxppc-dev@lists.ozlabs.org
S: Maintained
F: Documentation/devicetree/bindings/sound/nxp,lpc3220-i2s.yaml
F: sound/soc/fsl/lpc3xxx-*
FREESCALE SOC SOUND QMC DRIVER
M: Herve Codina <herve.codina@bootlin.com>
L: alsa-devel@alsa-project.org (moderated for non-subscribers)
......
......@@ -131,6 +131,13 @@ config SND_SOC_FSL_RPMSG
This option is only useful for out-of-tree drivers since
in-tree drivers select it automatically.
config SND_SOC_FSL_LPC3XXX
tristate "SoC Audio for NXP LPC32XX CPUs"
depends on ARCH_LPC32XX || COMPILE_TEST
select SND_SOC_GENERIC_DMAENGINE_PCM
help
Say Y or M if you want to add support for the LPC3XXX I2S interface.
config SND_SOC_IMX_PCM_DMA
tristate
select SND_SOC_GENERIC_DMAENGINE_PCM
......
......@@ -11,6 +11,7 @@ obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o
snd-soc-fsl-audmix-y := fsl_audmix.o
snd-soc-fsl-asoc-card-y := fsl-asoc-card.o
snd-soc-fsl-asrc-y := fsl_asrc.o fsl_asrc_dma.o
snd-soc-fsl-lpc3xxx-y := lpc3xxx-pcm.o lpc3xxx-i2s.o
snd-soc-fsl-sai-y := fsl_sai.o
snd-soc-fsl-ssi-y := fsl_ssi.o
snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o
......@@ -29,6 +30,7 @@ snd-soc-fsl-qmc-audio-y := fsl_qmc_audio.o
obj-$(CONFIG_SND_SOC_FSL_AUDMIX) += snd-soc-fsl-audmix.o
obj-$(CONFIG_SND_SOC_FSL_ASOC_CARD) += snd-soc-fsl-asoc-card.o
obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o
obj-$(CONFIG_SND_SOC_FSL_LPC3XXX) += snd-soc-fsl-lpc3xxx.o
obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o
obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o
obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Author: Kevin Wells <kevin.wells@nxp.com>
*
* Copyright (C) 2008 NXP Semiconductors
* Copyright 2023 Timesys Corporation <piotr.wojtaszczyk@timesys.com>
*/
#ifndef __SOUND_SOC_LPC3XXX_I2S_H
#define __SOUND_SOC_LPC3XXX_I2S_H
#include <linux/types.h>
#include <linux/regmap.h>
struct lpc3xxx_i2s_info {
struct device *dev;
struct clk *clk;
struct mutex lock; /* To serialize user-space access */
struct regmap *regs;
u32 streams_in_use;
u32 clkrate;
int freq;
struct snd_dmaengine_dai_dma_data playback_dma_config;
struct snd_dmaengine_dai_dma_data capture_dma_config;
};
int lpc3xxx_pcm_register(struct platform_device *pdev);
/* I2S controller register offsets */
#define LPC3XXX_REG_I2S_DAO 0x00
#define LPC3XXX_REG_I2S_DAI 0x04
#define LPC3XXX_REG_I2S_TX_FIFO 0x08
#define LPC3XXX_REG_I2S_RX_FIFO 0x0C
#define LPC3XXX_REG_I2S_STAT 0x10
#define LPC3XXX_REG_I2S_DMA0 0x14
#define LPC3XXX_REG_I2S_DMA1 0x18
#define LPC3XXX_REG_I2S_IRQ 0x1C
#define LPC3XXX_REG_I2S_TX_RATE 0x20
#define LPC3XXX_REG_I2S_RX_RATE 0x24
/* i2s_daO i2s_dai register definitions */
#define LPC3XXX_I2S_WW8 FIELD_PREP(0x3, 0) /* Word width is 8bit */
#define LPC3XXX_I2S_WW16 FIELD_PREP(0x3, 1) /* Word width is 16bit */
#define LPC3XXX_I2S_WW32 FIELD_PREP(0x3, 3) /* Word width is 32bit */
#define LPC3XXX_I2S_MONO BIT(2) /* Mono */
#define LPC3XXX_I2S_STOP BIT(3) /* Stop, diables the access to FIFO, mutes the channel */
#define LPC3XXX_I2S_RESET BIT(4) /* Reset the channel */
#define LPC3XXX_I2S_WS_SEL BIT(5) /* Channel Master(0) or slave(1) mode select */
#define LPC3XXX_I2S_WS_HP(s) FIELD_PREP(0x7FC0, s) /* Word select half period - 1 */
#define LPC3XXX_I2S_MUTE BIT(15) /* Mute the channel, Transmit channel only */
#define LPC3XXX_I2S_WW32_HP 0x1f /* Word select half period for 32bit word width */
#define LPC3XXX_I2S_WW16_HP 0x0f /* Word select half period for 16bit word width */
#define LPC3XXX_I2S_WW8_HP 0x7 /* Word select half period for 8bit word width */
/* i2s_stat register definitions */
#define LPC3XXX_I2S_IRQ_STAT BIT(0)
#define LPC3XXX_I2S_DMA0_REQ BIT(1)
#define LPC3XXX_I2S_DMA1_REQ BIT(2)
/* i2s_dma0 Configuration register definitions */
#define LPC3XXX_I2S_DMA0_RX_EN BIT(0) /* Enable RX DMA1 */
#define LPC3XXX_I2S_DMA0_TX_EN BIT(1) /* Enable TX DMA1 */
#define LPC3XXX_I2S_DMA0_RX_DEPTH(s) FIELD_PREP(0xF00, s) /* Set the DMA1 RX Request level */
#define LPC3XXX_I2S_DMA0_TX_DEPTH(s) FIELD_PREP(0xF0000, s) /* Set the DMA1 TX Request level */
/* i2s_dma1 Configuration register definitions */
#define LPC3XXX_I2S_DMA1_RX_EN BIT(0) /* Enable RX DMA1 */
#define LPC3XXX_I2S_DMA1_TX_EN BIT(1) /* Enable TX DMA1 */
#define LPC3XXX_I2S_DMA1_RX_DEPTH(s) FIELD_PREP(0x700, s) /* Set the DMA1 RX Request level */
#define LPC3XXX_I2S_DMA1_TX_DEPTH(s) FIELD_PREP(0x70000, s) /* Set the DMA1 TX Request level */
/* i2s_irq register definitions */
#define LPC3XXX_I2S_RX_IRQ_EN BIT(0) /* Enable RX IRQ */
#define LPC3XXX_I2S_TX_IRQ_EN BIT(1) /* Enable TX IRQ */
#define LPC3XXX_I2S_IRQ_RX_DEPTH(s) FIELD_PREP(0xFF00, s) /* valid values ar 0 to 7 */
#define LPC3XXX_I2S_IRQ_TX_DEPTH(s) FIELD_PREP(0xFF0000, s) /* valid values ar 0 to 7 */
#endif
// SPDX-License-Identifier: GPL-2.0-or-later
//
// Author: Kevin Wells <kevin.wells@nxp.com>
//
// Copyright (C) 2008 NXP Semiconductors
// Copyright 2023 Timesys Corporation <piotr.wojtaszczyk@timesys.com>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/amba/pl08x.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/dmaengine_pcm.h>
#include <sound/soc.h>
#include "lpc3xxx-i2s.h"
#define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
SNDRV_PCM_FMTBIT_U8 | \
SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_U16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \
SNDRV_PCM_FMTBIT_U24_LE | \
SNDRV_PCM_FMTBIT_S32_LE | \
SNDRV_PCM_FMTBIT_U32_LE | \
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
static const struct snd_pcm_hardware lpc3xxx_pcm_hardware = {
.info = (SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_PAUSE |
SNDRV_PCM_INFO_RESUME),
.formats = STUB_FORMATS,
.period_bytes_min = 128,
.period_bytes_max = 2048,
.periods_min = 2,
.periods_max = 1024,
.buffer_bytes_max = 128 * 1024
};
static const struct snd_dmaengine_pcm_config lpc3xxx_dmaengine_pcm_config = {
.pcm_hardware = &lpc3xxx_pcm_hardware,
.prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
.compat_filter_fn = pl08x_filter_id,
.prealloc_buffer_size = 128 * 1024,
};
const struct snd_soc_component_driver lpc3xxx_soc_platform_driver = {
.name = "lpc32xx-pcm",
};
int lpc3xxx_pcm_register(struct platform_device *pdev)
{
int ret;
ret = devm_snd_dmaengine_pcm_register(&pdev->dev, &lpc3xxx_dmaengine_pcm_config, 0);
if (ret) {
dev_err(&pdev->dev, "failed to register dmaengine: %d\n", ret);
return ret;
}
return devm_snd_soc_register_component(&pdev->dev, &lpc3xxx_soc_platform_driver,
NULL, 0);
}
EXPORT_SYMBOL(lpc3xxx_pcm_register);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment