From 7c3355ac013045db684e109d2e36c6ca52bbcbf8 Mon Sep 17 00:00:00 2001 From: Inha Song Date: Wed, 14 Jan 2015 11:48:48 +0900 Subject: LOCAL / ASoC: samsung: Add Samsung Low Power Audio Subsystem driver This patch adds LPASS driver. The LPASS (Low Power Audio Subsystem) is a special subsystem that supports audio playback with low power consumption. Signed-off-by: Inha Song --- sound/soc/samsung/Kconfig | 4 ++ sound/soc/samsung/Makefile | 2 + sound/soc/samsung/lpass.c | 109 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/samsung/lpass.h | 35 +++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 sound/soc/samsung/lpass.c create mode 100644 sound/soc/samsung/lpass.h (limited to 'sound') diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index e0244fe4c531..6fd4c9f1940a 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig @@ -33,6 +33,9 @@ config SND_SAMSUNG_SPDIF config SND_SAMSUNG_I2S tristate +config SND_SAMSUNG_AUDSS + tristate + config SND_SOC_SAMSUNG_NEO1973_WM8753 tristate "Audio support for Openmoko Neo1973 Smartphones (GTA02)" depends on SND_SOC_SAMSUNG && MACH_NEO1973_GTA02 @@ -241,5 +244,6 @@ config SND_SOC_SAMSUNG_TM2_WM5110 select SND_SOC_MAX98504A select SND_SOC_WM5110 select SND_SAMSUNG_I2S + select SND_SAMSUNG_AUDSS help Say Y if you want to add support for SoC audio on the TM2 board. diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index c15a7596f782..16ab0d05bfa7 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -8,6 +8,7 @@ snd-soc-s3c-i2s-v2-objs := s3c-i2s-v2.o snd-soc-samsung-spdif-objs := spdif.o snd-soc-pcm-objs := pcm.o snd-soc-i2s-objs := i2s.o +snd-soc-lpass-objs := lpass.o obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c-dma.o obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o @@ -18,6 +19,7 @@ obj-$(CONFIG_SND_SAMSUNG_SPDIF) += snd-soc-samsung-spdif.o obj-$(CONFIG_SND_SAMSUNG_PCM) += snd-soc-pcm.o obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-i2s.o obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-idma.o +obj-$(CONFIG_SND_SAMSUNG_AUDSS) += snd-soc-lpass.o # S3C24XX Machine Support snd-soc-jive-wm8750-objs := jive_wm8750.o diff --git a/sound/soc/samsung/lpass.c b/sound/soc/samsung/lpass.c new file mode 100644 index 000000000000..e93e65a107d3 --- /dev/null +++ b/sound/soc/samsung/lpass.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2015 Samsung Electronics Co., Ltd. + * Inha Song + * + * Low Power Audio SubSystem driver for Samsung Exynos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include + +#include "lpass.h" + +#define EXYNOS5433_PAD_RETENTION_AUD_OPTION_OFFSET 0x3028 +#define EXYNOS5433_INITIATE_WAKEUP_FROM_LOWPWR_MASK BIT(28) + +static struct lpass_info { + struct platform_device *pdev; + void __iomem *reg_sfr; + struct regmap *reg_pmu; +}; + +static void lpass_enable(struct lpass_info *lpass) +{ + if (!lpass->reg_pmu) + return; + + /* Unmasks SFR, DMA, I2S Interrupt */ + writel(LPASS_INTR_SFR | LPASS_INTR_DMA | LPASS_INTR_I2S, + lpass->reg_sfr + SFR_LPASS_INTR_CA5_MASK); + + writel(LPASS_INTR_DMA | LPASS_INTR_I2S | LPASS_INTR_SFR, + lpass->reg_sfr + SFR_LPASS_INTR_CPU_MASK); + + /* Active related PADs from retention state */ + regmap_write(lpass->reg_pmu, + EXYNOS5433_PAD_RETENTION_AUD_OPTION_OFFSET, + EXYNOS5433_INITIATE_WAKEUP_FROM_LOWPWR_MASK); +} + +static int lpass_probe(struct platform_device *pdev) +{ + struct lpass_info *lpass; + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct resource *res; + + if (!np) { + dev_err(dev, "Failed to get DT node\n"); + return -ENODEV; + } + + lpass = devm_kzalloc(dev, sizeof(*lpass), GFP_KERNEL); + if (!lpass) + return -ENOMEM; + + lpass->pdev = pdev; + platform_set_drvdata(pdev, lpass); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "Failed to get SFR address\n"); + return -ENXIO; + } + + lpass->reg_sfr = devm_ioremap_resource(dev, res); + if (IS_ERR(lpass->reg_sfr)) + return PTR_ERR(lpass->reg_sfr); + + lpass->reg_pmu = syscon_regmap_lookup_by_phandle(np, + "samsung,pmu-syscon"); + if (IS_ERR(lpass->reg_pmu)) { + dev_err(dev, "Failed to lookup PMU regmap\n"); + return PTR_ERR(lpass->reg_pmu); + } + + lpass_enable(lpass); + + return 0; +} + +static const struct of_device_id lpass_of_match[] = { + { .compatible = "samsung,exynos5433-lpass", }, + { }, +}; +MODULE_DEVICE_TABLE(of, lpass_of_match); + +static struct platform_driver lpass_driver = { + .driver = { + .name = "samsung-lpass", + .owner = THIS_MODULE, + .of_match_table = lpass_of_match, + }, + .probe = lpass_probe, +}; + +module_platform_driver(lpass_driver); + +MODULE_AUTHOR("Inha Song "); +MODULE_DESCRIPTION("Samsung Low Power Audio Subsystem Interface"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/samsung/lpass.h b/sound/soc/samsung/lpass.h new file mode 100644 index 000000000000..137705bb189f --- /dev/null +++ b/sound/soc/samsung/lpass.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2015 Samsung Electronics Co., Ltd. + * Inha Song + * + * Low Power Audio SubSystem driver for Samsung Exynos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#ifndef __SND_SOC_SAMSUNG_LPASS_H +#define __SND_SOC_SAMSUNG_LPASS_H + +/* SFR */ +#define SFR_LPASS_INTR_CA5_MASK (0x48) +#define SFR_LPASS_INTR_CPU_MASK (0x58) + +/* SW_RESET */ +#define LPASS_SW_RESET_CA5 (1 << 0) +#define LPASS_SW_RESET_SB (1 << 11) + +/* Interrupt mask */ +#define LPASS_INTR_APM (1 << 9) +#define LPASS_INTR_MIF (1 << 8) +#define LPASS_INTR_TIMER (1 << 7) +#define LPASS_INTR_DMA (1 << 6) +#define LPASS_INTR_GPIO (1 << 5) +#define LPASS_INTR_I2S (1 << 4) +#define LPASS_INTR_PCM (1 << 3) +#define LPASS_INTR_SB (1 << 2) +#define LPASS_INTR_UART (1 << 1) +#define LPASS_INTR_SFR (1 << 0) + +#endif /* __SND_SOC_SAMSUNG_LPASS_H */ -- cgit v1.2.3