Skip to content

Commit

Permalink
Merge remote-tracking branches 'asoc/topic/rcar', 'asoc/topic/rl6347a…
Browse files Browse the repository at this point in the history
…', 'asoc/topic/rockchip' and 'asoc/topic/rt286' into asoc-next
  • Loading branch information
Mark Brown committed Oct 26, 2015
5 parents 3db5de5 + b415b4d + 0f7e177 + b3f2dcd + dc6d84c commit 512def8
Show file tree
Hide file tree
Showing 23 changed files with 655 additions and 116 deletions.
6 changes: 2 additions & 4 deletions Documentation/devicetree/bindings/sound/rockchip-i2s.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,24 @@ Required properties:
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: should contain the I2S interrupt.
- #address-cells: should be 1.
- #size-cells: should be 0.
- dmas: DMA specifiers for tx and rx dma. See the DMA client binding,
Documentation/devicetree/bindings/dma/dma.txt
- dma-names: should include "tx" and "rx".
- clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names.
- clock-names: should contain followings:
- "i2s_hclk": clock for I2S BUS
- "i2s_clk" : clock for I2S controller
- rockchip,capture-channels: max capture channels, if not set, 2 channels default.

Example for rk3288 I2S controller:

i2s@ff890000 {
compatible = "rockchip,rk3288-i2s", "rockchip,rk3066-i2s";
reg = <0xff890000 0x10000>;
interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
dmas = <&pdma1 0>, <&pdma1 1>;
dma-names = "tx", "rx";
clock-names = "i2s_hclk", "i2s_clk";
clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>;
rockchip,capture-channels = <2>;
};
40 changes: 40 additions & 0 deletions Documentation/devicetree/bindings/sound/rockchip-spdif.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
* Rockchip SPDIF transceiver

The S/PDIF audio block is a stereo transceiver that allows the
processor to receive and transmit digital audio via an coaxial cable or
a fibre cable.

Required properties:

- compatible: should be one of the following:
- "rockchip,rk3288-spdif", "rockchip,rk3188-spdif" or
"rockchip,rk3066-spdif"
- reg: physical base address of the controller and length of memory mapped
region.
- interrupts: should contain the SPDIF interrupt.
- dmas: DMA specifiers for tx dma. See the DMA client binding,
Documentation/devicetree/bindings/dma/dma.txt
- dma-names: should be "tx"
- clocks: a list of phandle + clock-specifier pairs, one for each entry
in clock-names.
- clock-names: should contain following:
- "hclk": clock for SPDIF controller
- "mclk" : clock for SPDIF bus

Required properties on RK3288:
- rockchip,grf: the phandle of the syscon node for the general register
file (GRF)

Example for the rk3188 SPDIF controller:

spdif: spdif@0x1011e000 {
compatible = "rockchip,rk3188-spdif", "rockchip,rk3066-spdif";
reg = <0x1011e000 0x2000>;
interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
dmas = <&dmac1_s 8>;
dma-names = "tx";
clock-names = "hclk", "mclk";
clocks = <&cru HCLK_SPDIF>, <&cru SCLK_SPDIF>;
status = "disabled";
#sound-dai-cells = <0>;
};
19 changes: 1 addition & 18 deletions sound/soc/codecs/rl6347a.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,8 @@
*/

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/dmi.h>
#include <linux/acpi.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <sound/jack.h>
#include <linux/workqueue.h>
#include <sound/hda_verbs.h>
#include <linux/regmap.h>

#include "rl6347a.h"

Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/rl6347a.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#ifndef __RL6347A_H__
#define __RL6347A_H__

#include <sound/hda_verbs.h>

#define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D)

#define RL6347A_VENDOR_REGISTERS 0x20
Expand Down
9 changes: 6 additions & 3 deletions sound/soc/codecs/rt286.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <sound/jack.h>
#include <linux/workqueue.h>
#include <sound/rt286.h>
#include <sound/hda_verbs.h>

#include "rl6347a.h"
#include "rt286.h"
Expand All @@ -38,7 +37,7 @@
#define RT288_VENDOR_ID 0x10ec0288

struct rt286_priv {
const struct reg_default *index_cache;
struct reg_default *index_cache;
int index_cache_size;
struct regmap *regmap;
struct snd_soc_codec *codec;
Expand Down Expand Up @@ -1161,7 +1160,11 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
return -ENODEV;
}

rt286->index_cache = rt286_index_def;
rt286->index_cache = devm_kmemdup(&i2c->dev, rt286_index_def,
sizeof(rt286_index_def), GFP_KERNEL);
if (!rt286->index_cache)
return -ENOMEM;

rt286->index_cache_size = INDEX_CACHE_SIZE;
rt286->i2c = i2c;
i2c_set_clientdata(i2c, rt286);
Expand Down
1 change: 0 additions & 1 deletion sound/soc/codecs/rt298.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <sound/jack.h>
#include <linux/workqueue.h>
#include <sound/rt298.h>
#include <sound/hda_verbs.h>

#include "rl6347a.h"
#include "rt298.h"
Expand Down
8 changes: 8 additions & 0 deletions sound/soc/rockchip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ config SND_SOC_ROCKCHIP_I2S
Rockchip I2S device. The device supports upto maximum of
8 channels each for play and record.

config SND_SOC_ROCKCHIP_SPDIF
tristate "Rockchip SPDIF Device Driver"
depends on CLKDEV_LOOKUP && SND_SOC_ROCKCHIP
select SND_SOC_GENERIC_DMAENGINE_PCM
help
Say Y or M if you want to add support for SPDIF driver for
Rockchip SPDIF transceiver device.

config SND_SOC_ROCKCHIP_MAX98090
tristate "ASoC support for Rockchip boards using a MAX98090 codec"
depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP
Expand Down
6 changes: 4 additions & 2 deletions sound/soc/rockchip/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# ROCKCHIP Platform Support
snd-soc-i2s-objs := rockchip_i2s.o
snd-soc-rockchip-i2s-objs := rockchip_i2s.o
snd-soc-rockchip-spdif-objs := rockchip_spdif.o

obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-i2s.o
obj-$(CONFIG_SND_SOC_ROCKCHIP_I2S) += snd-soc-rockchip-i2s.o
obj-$(CONFIG_SND_SOC_ROCKCHIP_SPDIF) += snd-soc-rockchip-spdif.o

snd-soc-rockchip-max98090-objs := rockchip_max98090.o
snd-soc-rockchip-rt5645-objs := rockchip_rt5645.o
Expand Down
48 changes: 46 additions & 2 deletions sound/soc/rockchip/rockchip_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct rk_i2s_dev *i2s = to_info(dai);
struct snd_soc_pcm_runtime *rtd = substream->private_data;
unsigned int val = 0;

switch (params_format(params)) {
Expand All @@ -245,13 +246,46 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}

regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val);
regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val);
switch (params_channels(params)) {
case 8:
val |= I2S_CHN_8;
break;
case 6:
val |= I2S_CHN_6;
break;
case 4:
val |= I2S_CHN_4;
break;
case 2:
val |= I2S_CHN_2;
break;
default:
dev_err(i2s->dev, "invalid channel: %d\n",
params_channels(params));
return -EINVAL;
}

if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
regmap_update_bits(i2s->regmap, I2S_RXCR,
I2S_RXCR_VDW_MASK | I2S_RXCR_CSR_MASK,
val);
else
regmap_update_bits(i2s->regmap, I2S_TXCR,
I2S_TXCR_VDW_MASK | I2S_TXCR_CSR_MASK,
val);

regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK,
I2S_DMACR_TDL(16));
regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK,
I2S_DMACR_RDL(16));

val = I2S_CKR_TRCM_TXRX;
if (dai->driver->symmetric_rates || rtd->dai_link->symmetric_rates)
val = I2S_CKR_TRCM_TXSHARE;

regmap_update_bits(i2s->regmap, I2S_CKR,
I2S_CKR_TRCM_MASK,
val);
return 0;
}

Expand Down Expand Up @@ -415,10 +449,12 @@ static const struct regmap_config rockchip_i2s_regmap_config = {

static int rockchip_i2s_probe(struct platform_device *pdev)
{
struct device_node *node = pdev->dev.of_node;
struct rk_i2s_dev *i2s;
struct resource *res;
void __iomem *regs;
int ret;
int val;

i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
if (!i2s) {
Expand Down Expand Up @@ -475,6 +511,14 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
goto err_pm_disable;
}

/* refine capture channels */
if (!of_property_read_u32(node, "rockchip,capture-channels", &val)) {
if (val >= 2 && val <= 8)
rockchip_i2s_dai.capture.channels_max = val;
else
rockchip_i2s_dai.capture.channels_max = 2;
}

ret = devm_snd_soc_register_component(&pdev->dev,
&rockchip_i2s_component,
&rockchip_i2s_dai, 1);
Expand Down
16 changes: 16 additions & 0 deletions sound/soc/rockchip/rockchip_i2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
* RXCR
* receive operation control register
*/
#define I2S_RXCR_CSR_SHIFT 15
#define I2S_RXCR_CSR(x) (x << I2S_RXCR_CSR_SHIFT)
#define I2S_RXCR_CSR_MASK (3 << I2S_RXCR_CSR_SHIFT)
#define I2S_RXCR_HWT BIT(14)
#define I2S_RXCR_SJM_SHIFT 12
#define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT)
Expand All @@ -75,6 +78,12 @@
* CKR
* clock generation register
*/
#define I2S_CKR_TRCM_SHIFT 28
#define I2S_CKR_TRCM(x) (x << I2S_CKR_TRCM_SHIFT)
#define I2S_CKR_TRCM_TXRX (0 << I2S_CKR_TRCM_SHIFT)
#define I2S_CKR_TRCM_TXSHARE (1 << I2S_CKR_TRCM_SHIFT)
#define I2S_CKR_TRCM_RXSHARE (2 << I2S_CKR_TRCM_SHIFT)
#define I2S_CKR_TRCM_MASK (3 << I2S_CKR_TRCM_SHIFT)
#define I2S_CKR_MSS_SHIFT 27
#define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT)
#define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT)
Expand Down Expand Up @@ -207,6 +216,13 @@ enum {
ROCKCHIP_DIV_BCLK,
};

/* channel select */
#define I2S_CSR_SHIFT 15
#define I2S_CHN_2 (0 << I2S_CSR_SHIFT)
#define I2S_CHN_4 (1 << I2S_CSR_SHIFT)
#define I2S_CHN_6 (2 << I2S_CSR_SHIFT)
#define I2S_CHN_8 (3 << I2S_CSR_SHIFT)

/* I2S REGS */
#define I2S_TXCR (0x0000)
#define I2S_RXCR (0x0004)
Expand Down
Loading

0 comments on commit 512def8

Please sign in to comment.