18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// ALSA SoC Audio Layer - S3C PCM-Controller driver
48c2ecf20Sopenharmony_ci//
58c2ecf20Sopenharmony_ci// Copyright (c) 2009 Samsung Electronics Co. Ltd
68c2ecf20Sopenharmony_ci// Author: Jaswinder Singh <jassisinghbrar@gmail.com>
78c2ecf20Sopenharmony_ci// based upon I2S drivers by Ben Dooks.
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/clk.h>
108c2ecf20Sopenharmony_ci#include <linux/io.h>
118c2ecf20Sopenharmony_ci#include <linux/module.h>
128c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include <sound/soc.h>
158c2ecf20Sopenharmony_ci#include <sound/pcm_params.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#include <linux/platform_data/asoc-s3c.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include "dma.h"
208c2ecf20Sopenharmony_ci#include "pcm.h"
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/*Register Offsets */
238c2ecf20Sopenharmony_ci#define S3C_PCM_CTL		0x00
248c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL		0x04
258c2ecf20Sopenharmony_ci#define S3C_PCM_TXFIFO		0x08
268c2ecf20Sopenharmony_ci#define S3C_PCM_RXFIFO		0x0C
278c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL		0x10
288c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT		0x14
298c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT	0x18
308c2ecf20Sopenharmony_ci#define S3C_PCM_CLRINT		0x20
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* PCM_CTL Bit-Fields */
338c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_TXDIPSTICK_MASK	0x3f
348c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_TXDIPSTICK_SHIFT	13
358c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_RXDIPSTICK_MASK	0x3f
368c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_RXDIPSTICK_SHIFT	7
378c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_TXDMA_EN		(0x1 << 6)
388c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_RXDMA_EN		(0x1 << 5)
398c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_TXMSB_AFTER_FSYNC	(0x1 << 4)
408c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_RXMSB_AFTER_FSYNC	(0x1 << 3)
418c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_TXFIFO_EN		(0x1 << 2)
428c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_RXFIFO_EN		(0x1 << 1)
438c2ecf20Sopenharmony_ci#define S3C_PCM_CTL_ENABLE		(0x1 << 0)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* PCM_CLKCTL Bit-Fields */
468c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SERCLK_EN	(0x1 << 19)
478c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SERCLKSEL_PCLK	(0x1 << 18)
488c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SCLKDIV_MASK	0x1ff
498c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SYNCDIV_MASK	0x1ff
508c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SCLKDIV_SHIFT	9
518c2ecf20Sopenharmony_ci#define S3C_PCM_CLKCTL_SYNCDIV_SHIFT	0
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/* PCM_TXFIFO Bit-Fields */
548c2ecf20Sopenharmony_ci#define S3C_PCM_TXFIFO_DVALID	(0x1 << 16)
558c2ecf20Sopenharmony_ci#define S3C_PCM_TXFIFO_DATA_MSK	(0xffff << 0)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* PCM_RXFIFO Bit-Fields */
588c2ecf20Sopenharmony_ci#define S3C_PCM_RXFIFO_DVALID	(0x1 << 16)
598c2ecf20Sopenharmony_ci#define S3C_PCM_RXFIFO_DATA_MSK	(0xffff << 0)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* PCM_IRQCTL Bit-Fields */
628c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_IRQEN		(0x1 << 14)
638c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_WRDEN		(0x1 << 12)
648c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXEMPTYEN	(0x1 << 11)
658c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXALMSTEMPTYEN	(0x1 << 10)
668c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXFULLEN		(0x1 << 9)
678c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXALMSTFULLEN	(0x1 << 8)
688c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXSTARVEN	(0x1 << 7)
698c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_TXERROVRFLEN	(0x1 << 6)
708c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXEMPTEN		(0x1 << 5)
718c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXALMSTEMPTEN	(0x1 << 4)
728c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXFULLEN		(0x1 << 3)
738c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXALMSTFULLEN	(0x1 << 2)
748c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXSTARVEN	(0x1 << 1)
758c2ecf20Sopenharmony_ci#define S3C_PCM_IRQCTL_RXERROVRFLEN	(0x1 << 0)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* PCM_IRQSTAT Bit-Fields */
788c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_IRQPND		(0x1 << 13)
798c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_WRD_XFER	(0x1 << 12)
808c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXEMPTY		(0x1 << 11)
818c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXALMSTEMPTY	(0x1 << 10)
828c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXFULL		(0x1 << 9)
838c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXALMSTFULL	(0x1 << 8)
848c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXSTARV		(0x1 << 7)
858c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_TXERROVRFL	(0x1 << 6)
868c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXEMPT		(0x1 << 5)
878c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXALMSTEMPT	(0x1 << 4)
888c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXFULL		(0x1 << 3)
898c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXALMSTFULL	(0x1 << 2)
908c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXSTARV		(0x1 << 1)
918c2ecf20Sopenharmony_ci#define S3C_PCM_IRQSTAT_RXERROVRFL	(0x1 << 0)
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* PCM_FIFOSTAT Bit-Fields */
948c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_TXCNT_MSK		(0x3f << 14)
958c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_TXFIFOEMPTY		(0x1 << 13)
968c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_TXFIFOALMSTEMPTY	(0x1 << 12)
978c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_TXFIFOFULL		(0x1 << 11)
988c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_TXFIFOALMSTFULL	(0x1 << 10)
998c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_RXCNT_MSK		(0x3f << 4)
1008c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_RXFIFOEMPTY		(0x1 << 3)
1018c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_RXFIFOALMSTEMPTY	(0x1 << 2)
1028c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_RXFIFOFULL		(0x1 << 1)
1038c2ecf20Sopenharmony_ci#define S3C_PCM_FIFOSTAT_RXFIFOALMSTFULL	(0x1 << 0)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/**
1068c2ecf20Sopenharmony_ci * struct s3c_pcm_info - S3C PCM Controller information
1078c2ecf20Sopenharmony_ci * @lock: Spin lock
1088c2ecf20Sopenharmony_ci * @dev: The parent device passed to use from the probe.
1098c2ecf20Sopenharmony_ci * @regs: The pointer to the device register block.
1108c2ecf20Sopenharmony_ci * @sclk_per_fs: number of sclk per frame sync
1118c2ecf20Sopenharmony_ci * @idleclk: Whether to keep PCMSCLK enabled even when idle (no active xfer)
1128c2ecf20Sopenharmony_ci * @pclk: the PCLK_PCM (pcm) clock pointer
1138c2ecf20Sopenharmony_ci * @cclk: the SCLK_AUDIO (audio-bus) clock pointer
1148c2ecf20Sopenharmony_ci * @dma_playback: DMA information for playback channel.
1158c2ecf20Sopenharmony_ci * @dma_capture: DMA information for capture channel.
1168c2ecf20Sopenharmony_ci */
1178c2ecf20Sopenharmony_cistruct s3c_pcm_info {
1188c2ecf20Sopenharmony_ci	spinlock_t lock;
1198c2ecf20Sopenharmony_ci	struct device	*dev;
1208c2ecf20Sopenharmony_ci	void __iomem	*regs;
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ci	unsigned int sclk_per_fs;
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	/* Whether to keep PCMSCLK enabled even when idle(no active xfer) */
1258c2ecf20Sopenharmony_ci	unsigned int idleclk;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	struct clk	*pclk;
1288c2ecf20Sopenharmony_ci	struct clk	*cclk;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data *dma_playback;
1318c2ecf20Sopenharmony_ci	struct snd_dmaengine_dai_dma_data *dma_capture;
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cistatic struct snd_dmaengine_dai_dma_data s3c_pcm_stereo_out[] = {
1358c2ecf20Sopenharmony_ci	[0] = {
1368c2ecf20Sopenharmony_ci		.addr_width	= 4,
1378c2ecf20Sopenharmony_ci	},
1388c2ecf20Sopenharmony_ci	[1] = {
1398c2ecf20Sopenharmony_ci		.addr_width	= 4,
1408c2ecf20Sopenharmony_ci	},
1418c2ecf20Sopenharmony_ci};
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_cistatic struct snd_dmaengine_dai_dma_data s3c_pcm_stereo_in[] = {
1448c2ecf20Sopenharmony_ci	[0] = {
1458c2ecf20Sopenharmony_ci		.addr_width	= 4,
1468c2ecf20Sopenharmony_ci	},
1478c2ecf20Sopenharmony_ci	[1] = {
1488c2ecf20Sopenharmony_ci		.addr_width	= 4,
1498c2ecf20Sopenharmony_ci	},
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistatic struct s3c_pcm_info s3c_pcm[2];
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_cistatic void s3c_pcm_snd_txctrl(struct s3c_pcm_info *pcm, int on)
1558c2ecf20Sopenharmony_ci{
1568c2ecf20Sopenharmony_ci	void __iomem *regs = pcm->regs;
1578c2ecf20Sopenharmony_ci	u32 ctl, clkctl;
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci	clkctl = readl(regs + S3C_PCM_CLKCTL);
1608c2ecf20Sopenharmony_ci	ctl = readl(regs + S3C_PCM_CTL);
1618c2ecf20Sopenharmony_ci	ctl &= ~(S3C_PCM_CTL_TXDIPSTICK_MASK
1628c2ecf20Sopenharmony_ci			 << S3C_PCM_CTL_TXDIPSTICK_SHIFT);
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	if (on) {
1658c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_TXDMA_EN;
1668c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_TXFIFO_EN;
1678c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_ENABLE;
1688c2ecf20Sopenharmony_ci		ctl |= (0x4<<S3C_PCM_CTL_TXDIPSTICK_SHIFT);
1698c2ecf20Sopenharmony_ci		clkctl |= S3C_PCM_CLKCTL_SERCLK_EN;
1708c2ecf20Sopenharmony_ci	} else {
1718c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_TXDMA_EN;
1728c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_TXFIFO_EN;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci		if (!(ctl & S3C_PCM_CTL_RXFIFO_EN)) {
1758c2ecf20Sopenharmony_ci			ctl &= ~S3C_PCM_CTL_ENABLE;
1768c2ecf20Sopenharmony_ci			if (!pcm->idleclk)
1778c2ecf20Sopenharmony_ci				clkctl |= S3C_PCM_CLKCTL_SERCLK_EN;
1788c2ecf20Sopenharmony_ci		}
1798c2ecf20Sopenharmony_ci	}
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	writel(clkctl, regs + S3C_PCM_CLKCTL);
1828c2ecf20Sopenharmony_ci	writel(ctl, regs + S3C_PCM_CTL);
1838c2ecf20Sopenharmony_ci}
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_cistatic void s3c_pcm_snd_rxctrl(struct s3c_pcm_info *pcm, int on)
1868c2ecf20Sopenharmony_ci{
1878c2ecf20Sopenharmony_ci	void __iomem *regs = pcm->regs;
1888c2ecf20Sopenharmony_ci	u32 ctl, clkctl;
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci	ctl = readl(regs + S3C_PCM_CTL);
1918c2ecf20Sopenharmony_ci	clkctl = readl(regs + S3C_PCM_CLKCTL);
1928c2ecf20Sopenharmony_ci	ctl &= ~(S3C_PCM_CTL_RXDIPSTICK_MASK
1938c2ecf20Sopenharmony_ci			 << S3C_PCM_CTL_RXDIPSTICK_SHIFT);
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci	if (on) {
1968c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_RXDMA_EN;
1978c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_RXFIFO_EN;
1988c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_ENABLE;
1998c2ecf20Sopenharmony_ci		ctl |= (0x20<<S3C_PCM_CTL_RXDIPSTICK_SHIFT);
2008c2ecf20Sopenharmony_ci		clkctl |= S3C_PCM_CLKCTL_SERCLK_EN;
2018c2ecf20Sopenharmony_ci	} else {
2028c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_RXDMA_EN;
2038c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_RXFIFO_EN;
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci		if (!(ctl & S3C_PCM_CTL_TXFIFO_EN)) {
2068c2ecf20Sopenharmony_ci			ctl &= ~S3C_PCM_CTL_ENABLE;
2078c2ecf20Sopenharmony_ci			if (!pcm->idleclk)
2088c2ecf20Sopenharmony_ci				clkctl |= S3C_PCM_CLKCTL_SERCLK_EN;
2098c2ecf20Sopenharmony_ci		}
2108c2ecf20Sopenharmony_ci	}
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci	writel(clkctl, regs + S3C_PCM_CLKCTL);
2138c2ecf20Sopenharmony_ci	writel(ctl, regs + S3C_PCM_CTL);
2148c2ecf20Sopenharmony_ci}
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_cistatic int s3c_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
2178c2ecf20Sopenharmony_ci			       struct snd_soc_dai *dai)
2188c2ecf20Sopenharmony_ci{
2198c2ecf20Sopenharmony_ci	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
2208c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
2218c2ecf20Sopenharmony_ci	unsigned long flags;
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci	dev_dbg(pcm->dev, "Entered %s\n", __func__);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci	switch (cmd) {
2268c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_START:
2278c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_RESUME:
2288c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
2298c2ecf20Sopenharmony_ci		spin_lock_irqsave(&pcm->lock, flags);
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
2328c2ecf20Sopenharmony_ci			s3c_pcm_snd_rxctrl(pcm, 1);
2338c2ecf20Sopenharmony_ci		else
2348c2ecf20Sopenharmony_ci			s3c_pcm_snd_txctrl(pcm, 1);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci		spin_unlock_irqrestore(&pcm->lock, flags);
2378c2ecf20Sopenharmony_ci		break;
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_STOP:
2408c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_SUSPEND:
2418c2ecf20Sopenharmony_ci	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2428c2ecf20Sopenharmony_ci		spin_lock_irqsave(&pcm->lock, flags);
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci		if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
2458c2ecf20Sopenharmony_ci			s3c_pcm_snd_rxctrl(pcm, 0);
2468c2ecf20Sopenharmony_ci		else
2478c2ecf20Sopenharmony_ci			s3c_pcm_snd_txctrl(pcm, 0);
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci		spin_unlock_irqrestore(&pcm->lock, flags);
2508c2ecf20Sopenharmony_ci		break;
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	default:
2538c2ecf20Sopenharmony_ci		return -EINVAL;
2548c2ecf20Sopenharmony_ci	}
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	return 0;
2578c2ecf20Sopenharmony_ci}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_cistatic int s3c_pcm_hw_params(struct snd_pcm_substream *substream,
2608c2ecf20Sopenharmony_ci				 struct snd_pcm_hw_params *params,
2618c2ecf20Sopenharmony_ci				 struct snd_soc_dai *socdai)
2628c2ecf20Sopenharmony_ci{
2638c2ecf20Sopenharmony_ci	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
2648c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0));
2658c2ecf20Sopenharmony_ci	void __iomem *regs = pcm->regs;
2668c2ecf20Sopenharmony_ci	struct clk *clk;
2678c2ecf20Sopenharmony_ci	int sclk_div, sync_div;
2688c2ecf20Sopenharmony_ci	unsigned long flags;
2698c2ecf20Sopenharmony_ci	u32 clkctl;
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci	dev_dbg(pcm->dev, "Entered %s\n", __func__);
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	/* Strictly check for sample size */
2748c2ecf20Sopenharmony_ci	switch (params_width(params)) {
2758c2ecf20Sopenharmony_ci	case 16:
2768c2ecf20Sopenharmony_ci		break;
2778c2ecf20Sopenharmony_ci	default:
2788c2ecf20Sopenharmony_ci		return -EINVAL;
2798c2ecf20Sopenharmony_ci	}
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci	spin_lock_irqsave(&pcm->lock, flags);
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	/* Get hold of the PCMSOURCE_CLK */
2848c2ecf20Sopenharmony_ci	clkctl = readl(regs + S3C_PCM_CLKCTL);
2858c2ecf20Sopenharmony_ci	if (clkctl & S3C_PCM_CLKCTL_SERCLKSEL_PCLK)
2868c2ecf20Sopenharmony_ci		clk = pcm->pclk;
2878c2ecf20Sopenharmony_ci	else
2888c2ecf20Sopenharmony_ci		clk = pcm->cclk;
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci	/* Set the SCLK divider */
2918c2ecf20Sopenharmony_ci	sclk_div = clk_get_rate(clk) / pcm->sclk_per_fs /
2928c2ecf20Sopenharmony_ci					params_rate(params) / 2 - 1;
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	clkctl &= ~(S3C_PCM_CLKCTL_SCLKDIV_MASK
2958c2ecf20Sopenharmony_ci			<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
2968c2ecf20Sopenharmony_ci	clkctl |= ((sclk_div & S3C_PCM_CLKCTL_SCLKDIV_MASK)
2978c2ecf20Sopenharmony_ci			<< S3C_PCM_CLKCTL_SCLKDIV_SHIFT);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	/* Set the SYNC divider */
3008c2ecf20Sopenharmony_ci	sync_div = pcm->sclk_per_fs - 1;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	clkctl &= ~(S3C_PCM_CLKCTL_SYNCDIV_MASK
3038c2ecf20Sopenharmony_ci				<< S3C_PCM_CLKCTL_SYNCDIV_SHIFT);
3048c2ecf20Sopenharmony_ci	clkctl |= ((sync_div & S3C_PCM_CLKCTL_SYNCDIV_MASK)
3058c2ecf20Sopenharmony_ci				<< S3C_PCM_CLKCTL_SYNCDIV_SHIFT);
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	writel(clkctl, regs + S3C_PCM_CLKCTL);
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&pcm->lock, flags);
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	dev_dbg(pcm->dev, "PCMSOURCE_CLK-%lu SCLK=%ufs SCLK_DIV=%d SYNC_DIV=%d\n",
3128c2ecf20Sopenharmony_ci				clk_get_rate(clk), pcm->sclk_per_fs,
3138c2ecf20Sopenharmony_ci				sclk_div, sync_div);
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	return 0;
3168c2ecf20Sopenharmony_ci}
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_cistatic int s3c_pcm_set_fmt(struct snd_soc_dai *cpu_dai,
3198c2ecf20Sopenharmony_ci			       unsigned int fmt)
3208c2ecf20Sopenharmony_ci{
3218c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(cpu_dai);
3228c2ecf20Sopenharmony_ci	void __iomem *regs = pcm->regs;
3238c2ecf20Sopenharmony_ci	unsigned long flags;
3248c2ecf20Sopenharmony_ci	int ret = 0;
3258c2ecf20Sopenharmony_ci	u32 ctl;
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci	dev_dbg(pcm->dev, "Entered %s\n", __func__);
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci	spin_lock_irqsave(&pcm->lock, flags);
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	ctl = readl(regs + S3C_PCM_CTL);
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
3348c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_IB_NF:
3358c2ecf20Sopenharmony_ci		/* Nothing to do, IB_NF by default */
3368c2ecf20Sopenharmony_ci		break;
3378c2ecf20Sopenharmony_ci	default:
3388c2ecf20Sopenharmony_ci		dev_err(pcm->dev, "Unsupported clock inversion!\n");
3398c2ecf20Sopenharmony_ci		ret = -EINVAL;
3408c2ecf20Sopenharmony_ci		goto exit;
3418c2ecf20Sopenharmony_ci	}
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
3448c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_CBS_CFS:
3458c2ecf20Sopenharmony_ci		/* Nothing to do, Master by default */
3468c2ecf20Sopenharmony_ci		break;
3478c2ecf20Sopenharmony_ci	default:
3488c2ecf20Sopenharmony_ci		dev_err(pcm->dev, "Unsupported master/slave format!\n");
3498c2ecf20Sopenharmony_ci		ret = -EINVAL;
3508c2ecf20Sopenharmony_ci		goto exit;
3518c2ecf20Sopenharmony_ci	}
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) {
3548c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_CONT:
3558c2ecf20Sopenharmony_ci		pcm->idleclk = 1;
3568c2ecf20Sopenharmony_ci		break;
3578c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_GATED:
3588c2ecf20Sopenharmony_ci		pcm->idleclk = 0;
3598c2ecf20Sopenharmony_ci		break;
3608c2ecf20Sopenharmony_ci	default:
3618c2ecf20Sopenharmony_ci		dev_err(pcm->dev, "Invalid Clock gating request!\n");
3628c2ecf20Sopenharmony_ci		ret = -EINVAL;
3638c2ecf20Sopenharmony_ci		goto exit;
3648c2ecf20Sopenharmony_ci	}
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
3678c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_DSP_A:
3688c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_TXMSB_AFTER_FSYNC;
3698c2ecf20Sopenharmony_ci		ctl |= S3C_PCM_CTL_RXMSB_AFTER_FSYNC;
3708c2ecf20Sopenharmony_ci		break;
3718c2ecf20Sopenharmony_ci	case SND_SOC_DAIFMT_DSP_B:
3728c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_TXMSB_AFTER_FSYNC;
3738c2ecf20Sopenharmony_ci		ctl &= ~S3C_PCM_CTL_RXMSB_AFTER_FSYNC;
3748c2ecf20Sopenharmony_ci		break;
3758c2ecf20Sopenharmony_ci	default:
3768c2ecf20Sopenharmony_ci		dev_err(pcm->dev, "Unsupported data format!\n");
3778c2ecf20Sopenharmony_ci		ret = -EINVAL;
3788c2ecf20Sopenharmony_ci		goto exit;
3798c2ecf20Sopenharmony_ci	}
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci	writel(ctl, regs + S3C_PCM_CTL);
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ciexit:
3848c2ecf20Sopenharmony_ci	spin_unlock_irqrestore(&pcm->lock, flags);
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	return ret;
3878c2ecf20Sopenharmony_ci}
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_cistatic int s3c_pcm_set_clkdiv(struct snd_soc_dai *cpu_dai,
3908c2ecf20Sopenharmony_ci						int div_id, int div)
3918c2ecf20Sopenharmony_ci{
3928c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(cpu_dai);
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_ci	switch (div_id) {
3958c2ecf20Sopenharmony_ci	case S3C_PCM_SCLK_PER_FS:
3968c2ecf20Sopenharmony_ci		pcm->sclk_per_fs = div;
3978c2ecf20Sopenharmony_ci		break;
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci	default:
4008c2ecf20Sopenharmony_ci		return -EINVAL;
4018c2ecf20Sopenharmony_ci	}
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	return 0;
4048c2ecf20Sopenharmony_ci}
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_cistatic int s3c_pcm_set_sysclk(struct snd_soc_dai *cpu_dai,
4078c2ecf20Sopenharmony_ci				  int clk_id, unsigned int freq, int dir)
4088c2ecf20Sopenharmony_ci{
4098c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(cpu_dai);
4108c2ecf20Sopenharmony_ci	void __iomem *regs = pcm->regs;
4118c2ecf20Sopenharmony_ci	u32 clkctl = readl(regs + S3C_PCM_CLKCTL);
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci	switch (clk_id) {
4148c2ecf20Sopenharmony_ci	case S3C_PCM_CLKSRC_PCLK:
4158c2ecf20Sopenharmony_ci		clkctl |= S3C_PCM_CLKCTL_SERCLKSEL_PCLK;
4168c2ecf20Sopenharmony_ci		break;
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci	case S3C_PCM_CLKSRC_MUX:
4198c2ecf20Sopenharmony_ci		clkctl &= ~S3C_PCM_CLKCTL_SERCLKSEL_PCLK;
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci		if (clk_get_rate(pcm->cclk) != freq)
4228c2ecf20Sopenharmony_ci			clk_set_rate(pcm->cclk, freq);
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci		break;
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci	default:
4278c2ecf20Sopenharmony_ci		return -EINVAL;
4288c2ecf20Sopenharmony_ci	}
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	writel(clkctl, regs + S3C_PCM_CLKCTL);
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	return 0;
4338c2ecf20Sopenharmony_ci}
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops s3c_pcm_dai_ops = {
4368c2ecf20Sopenharmony_ci	.set_sysclk	= s3c_pcm_set_sysclk,
4378c2ecf20Sopenharmony_ci	.set_clkdiv	= s3c_pcm_set_clkdiv,
4388c2ecf20Sopenharmony_ci	.trigger	= s3c_pcm_trigger,
4398c2ecf20Sopenharmony_ci	.hw_params	= s3c_pcm_hw_params,
4408c2ecf20Sopenharmony_ci	.set_fmt	= s3c_pcm_set_fmt,
4418c2ecf20Sopenharmony_ci};
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_cistatic int s3c_pcm_dai_probe(struct snd_soc_dai *dai)
4448c2ecf20Sopenharmony_ci{
4458c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = snd_soc_dai_get_drvdata(dai);
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci	snd_soc_dai_init_dma_data(dai, pcm->dma_playback, pcm->dma_capture);
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	return 0;
4508c2ecf20Sopenharmony_ci}
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ci#define S3C_PCM_RATES  SNDRV_PCM_RATE_8000_96000
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci#define S3C_PCM_DAI_DECLARE			\
4558c2ecf20Sopenharmony_ci	.symmetric_rates = 1,					\
4568c2ecf20Sopenharmony_ci	.probe = s3c_pcm_dai_probe,				\
4578c2ecf20Sopenharmony_ci	.ops = &s3c_pcm_dai_ops,				\
4588c2ecf20Sopenharmony_ci	.playback = {						\
4598c2ecf20Sopenharmony_ci		.channels_min	= 2,				\
4608c2ecf20Sopenharmony_ci		.channels_max	= 2,				\
4618c2ecf20Sopenharmony_ci		.rates		= S3C_PCM_RATES,		\
4628c2ecf20Sopenharmony_ci		.formats	= SNDRV_PCM_FMTBIT_S16_LE,	\
4638c2ecf20Sopenharmony_ci	},							\
4648c2ecf20Sopenharmony_ci	.capture = {						\
4658c2ecf20Sopenharmony_ci		.channels_min	= 2,				\
4668c2ecf20Sopenharmony_ci		.channels_max	= 2,				\
4678c2ecf20Sopenharmony_ci		.rates		= S3C_PCM_RATES,		\
4688c2ecf20Sopenharmony_ci		.formats	= SNDRV_PCM_FMTBIT_S16_LE,	\
4698c2ecf20Sopenharmony_ci	}
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver s3c_pcm_dai[] = {
4728c2ecf20Sopenharmony_ci	[0] = {
4738c2ecf20Sopenharmony_ci		.name	= "samsung-pcm.0",
4748c2ecf20Sopenharmony_ci		S3C_PCM_DAI_DECLARE,
4758c2ecf20Sopenharmony_ci	},
4768c2ecf20Sopenharmony_ci	[1] = {
4778c2ecf20Sopenharmony_ci		.name	= "samsung-pcm.1",
4788c2ecf20Sopenharmony_ci		S3C_PCM_DAI_DECLARE,
4798c2ecf20Sopenharmony_ci	},
4808c2ecf20Sopenharmony_ci};
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver s3c_pcm_component = {
4838c2ecf20Sopenharmony_ci	.name		= "s3c-pcm",
4848c2ecf20Sopenharmony_ci};
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_cistatic int s3c_pcm_dev_probe(struct platform_device *pdev)
4878c2ecf20Sopenharmony_ci{
4888c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm;
4898c2ecf20Sopenharmony_ci	struct resource *mem_res;
4908c2ecf20Sopenharmony_ci	struct s3c_audio_pdata *pcm_pdata;
4918c2ecf20Sopenharmony_ci	dma_filter_fn filter;
4928c2ecf20Sopenharmony_ci	int ret;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci	/* Check for valid device index */
4958c2ecf20Sopenharmony_ci	if ((pdev->id < 0) || pdev->id >= ARRAY_SIZE(s3c_pcm)) {
4968c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "id %d out of range\n", pdev->id);
4978c2ecf20Sopenharmony_ci		return -EINVAL;
4988c2ecf20Sopenharmony_ci	}
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci	pcm_pdata = pdev->dev.platform_data;
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci	if (pcm_pdata && pcm_pdata->cfg_gpio && pcm_pdata->cfg_gpio(pdev)) {
5038c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "Unable to configure gpio\n");
5048c2ecf20Sopenharmony_ci		return -EINVAL;
5058c2ecf20Sopenharmony_ci	}
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci	pcm = &s3c_pcm[pdev->id];
5088c2ecf20Sopenharmony_ci	pcm->dev = &pdev->dev;
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci	spin_lock_init(&pcm->lock);
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	/* Default is 128fs */
5138c2ecf20Sopenharmony_ci	pcm->sclk_per_fs = 128;
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
5168c2ecf20Sopenharmony_ci	pcm->regs = devm_ioremap_resource(&pdev->dev, mem_res);
5178c2ecf20Sopenharmony_ci	if (IS_ERR(pcm->regs))
5188c2ecf20Sopenharmony_ci		return PTR_ERR(pcm->regs);
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci	pcm->cclk = devm_clk_get(&pdev->dev, "audio-bus");
5218c2ecf20Sopenharmony_ci	if (IS_ERR(pcm->cclk)) {
5228c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "failed to get audio-bus clock\n");
5238c2ecf20Sopenharmony_ci		return PTR_ERR(pcm->cclk);
5248c2ecf20Sopenharmony_ci	}
5258c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(pcm->cclk);
5268c2ecf20Sopenharmony_ci	if (ret)
5278c2ecf20Sopenharmony_ci		return ret;
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci	/* record our pcm structure for later use in the callbacks */
5308c2ecf20Sopenharmony_ci	dev_set_drvdata(&pdev->dev, pcm);
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci	pcm->pclk = devm_clk_get(&pdev->dev, "pcm");
5338c2ecf20Sopenharmony_ci	if (IS_ERR(pcm->pclk)) {
5348c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "failed to get pcm clock\n");
5358c2ecf20Sopenharmony_ci		ret = PTR_ERR(pcm->pclk);
5368c2ecf20Sopenharmony_ci		goto err_dis_cclk;
5378c2ecf20Sopenharmony_ci	}
5388c2ecf20Sopenharmony_ci	ret = clk_prepare_enable(pcm->pclk);
5398c2ecf20Sopenharmony_ci	if (ret)
5408c2ecf20Sopenharmony_ci		goto err_dis_cclk;
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	s3c_pcm_stereo_in[pdev->id].addr = mem_res->start + S3C_PCM_RXFIFO;
5438c2ecf20Sopenharmony_ci	s3c_pcm_stereo_out[pdev->id].addr = mem_res->start + S3C_PCM_TXFIFO;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	filter = NULL;
5468c2ecf20Sopenharmony_ci	if (pcm_pdata) {
5478c2ecf20Sopenharmony_ci		s3c_pcm_stereo_in[pdev->id].filter_data = pcm_pdata->dma_capture;
5488c2ecf20Sopenharmony_ci		s3c_pcm_stereo_out[pdev->id].filter_data = pcm_pdata->dma_playback;
5498c2ecf20Sopenharmony_ci		filter = pcm_pdata->dma_filter;
5508c2ecf20Sopenharmony_ci	}
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_ci	pcm->dma_capture = &s3c_pcm_stereo_in[pdev->id];
5538c2ecf20Sopenharmony_ci	pcm->dma_playback = &s3c_pcm_stereo_out[pdev->id];
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci	ret = samsung_asoc_dma_platform_register(&pdev->dev, filter,
5568c2ecf20Sopenharmony_ci						 NULL, NULL, NULL);
5578c2ecf20Sopenharmony_ci	if (ret) {
5588c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret);
5598c2ecf20Sopenharmony_ci		goto err_dis_pclk;
5608c2ecf20Sopenharmony_ci	}
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci	pm_runtime_enable(&pdev->dev);
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci	ret = devm_snd_soc_register_component(&pdev->dev, &s3c_pcm_component,
5658c2ecf20Sopenharmony_ci					 &s3c_pcm_dai[pdev->id], 1);
5668c2ecf20Sopenharmony_ci	if (ret != 0) {
5678c2ecf20Sopenharmony_ci		dev_err(&pdev->dev, "failed to get register DAI: %d\n", ret);
5688c2ecf20Sopenharmony_ci		goto err_dis_pm;
5698c2ecf20Sopenharmony_ci	}
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci	return 0;
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_cierr_dis_pm:
5748c2ecf20Sopenharmony_ci	pm_runtime_disable(&pdev->dev);
5758c2ecf20Sopenharmony_cierr_dis_pclk:
5768c2ecf20Sopenharmony_ci	clk_disable_unprepare(pcm->pclk);
5778c2ecf20Sopenharmony_cierr_dis_cclk:
5788c2ecf20Sopenharmony_ci	clk_disable_unprepare(pcm->cclk);
5798c2ecf20Sopenharmony_ci	return ret;
5808c2ecf20Sopenharmony_ci}
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_cistatic int s3c_pcm_dev_remove(struct platform_device *pdev)
5838c2ecf20Sopenharmony_ci{
5848c2ecf20Sopenharmony_ci	struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id];
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	pm_runtime_disable(&pdev->dev);
5878c2ecf20Sopenharmony_ci	clk_disable_unprepare(pcm->cclk);
5888c2ecf20Sopenharmony_ci	clk_disable_unprepare(pcm->pclk);
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	return 0;
5918c2ecf20Sopenharmony_ci}
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_cistatic struct platform_driver s3c_pcm_driver = {
5948c2ecf20Sopenharmony_ci	.probe  = s3c_pcm_dev_probe,
5958c2ecf20Sopenharmony_ci	.remove = s3c_pcm_dev_remove,
5968c2ecf20Sopenharmony_ci	.driver = {
5978c2ecf20Sopenharmony_ci		.name = "samsung-pcm",
5988c2ecf20Sopenharmony_ci	},
5998c2ecf20Sopenharmony_ci};
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cimodule_platform_driver(s3c_pcm_driver);
6028c2ecf20Sopenharmony_ci
6038c2ecf20Sopenharmony_ci/* Module information */
6048c2ecf20Sopenharmony_ciMODULE_AUTHOR("Jaswinder Singh, <jassisinghbrar@gmail.com>");
6058c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("S3C PCM Controller Driver");
6068c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
6078c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:samsung-pcm");
608