diff options
Diffstat (limited to 'sound/soc/sh')
-rw-r--r-- | sound/soc/sh/Kconfig | 6 | ||||
-rw-r--r-- | sound/soc/sh/fsi-ak4642.c | 4 | ||||
-rw-r--r-- | sound/soc/sh/fsi-da7210.c | 2 | ||||
-rw-r--r-- | sound/soc/sh/fsi-hdmi.c | 3 | ||||
-rw-r--r-- | sound/soc/sh/fsi.c | 177 | ||||
-rw-r--r-- | sound/soc/sh/migor.c | 15 | ||||
-rw-r--r-- | sound/soc/sh/siu.h | 3 | ||||
-rw-r--r-- | sound/soc/sh/siu_dai.c | 41 | ||||
-rw-r--r-- | sound/soc/sh/siu_pcm.c | 2 |
9 files changed, 145 insertions, 108 deletions
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index 6b224d21e51..7f0a496e07c 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig @@ -47,7 +47,7 @@ config SND_SH7760_AC97 AC97 unit of the SH7760. config SND_FSI_AK4642 - bool "FSI-AK4642 sound support" + tristate "FSI-AK4642 sound support" depends on SND_SOC_SH4_FSI && I2C_SH_MOBILE select SND_SOC_AK4642 help @@ -55,7 +55,7 @@ config SND_FSI_AK4642 FSI - AK4642 unit config SND_FSI_DA7210 - bool "FSI-DA7210 sound support" + tristate "FSI-DA7210 sound support" depends on SND_SOC_SH4_FSI && I2C_SH_MOBILE select SND_SOC_DA7210 help @@ -63,7 +63,7 @@ config SND_FSI_DA7210 FSI - DA7210 unit config SND_FSI_HDMI - bool "FSI-HDMI sound support" + tristate "FSI-HDMI sound support" depends on SND_SOC_SH4_FSI && FB_SH_MOBILE_HDMI help This option enables generic sound support for the diff --git a/sound/soc/sh/fsi-ak4642.c b/sound/soc/sh/fsi-ak4642.c index 53836ca11d3..d96602de71d 100644 --- a/sound/soc/sh/fsi-ak4642.c +++ b/sound/soc/sh/fsi-ak4642.c @@ -32,7 +32,7 @@ static struct snd_soc_dai_link fsi_dai_link = { .cpu_dai_name = "fsia-dai", /* fsi A */ .codec_dai_name = "ak4642-hifi", #ifdef CONFIG_MACH_AP4EVB - .platform_name = "sh_fsi2.0", + .platform_name = "sh_fsi2", .codec_name = "ak4642-codec.0-0013", #else .platform_name = "sh_fsi.0", @@ -43,7 +43,7 @@ static struct snd_soc_dai_link fsi_dai_link = { }; static struct snd_soc_card fsi_soc_card = { - .name = "FSI", + .name = "FSI (AK4642)", .dai_link = &fsi_dai_link, .num_links = 1, }; diff --git a/sound/soc/sh/fsi-da7210.c b/sound/soc/sh/fsi-da7210.c index b5270156c81..a6adb6e4325 100644 --- a/sound/soc/sh/fsi-da7210.c +++ b/sound/soc/sh/fsi-da7210.c @@ -33,7 +33,7 @@ static struct snd_soc_dai_link fsi_da7210_dai = { }; static struct snd_soc_card fsi_soc_card = { - .name = "FSI", + .name = "FSI (DA7210)", .dai_link = &fsi_da7210_dai, .num_links = 1, }; diff --git a/sound/soc/sh/fsi-hdmi.c b/sound/soc/sh/fsi-hdmi.c index 950e3e0c971..a52dd8ec71d 100644 --- a/sound/soc/sh/fsi-hdmi.c +++ b/sound/soc/sh/fsi-hdmi.c @@ -11,7 +11,6 @@ #include <linux/platform_device.h> #include <sound/sh_fsi.h> -#include <video/sh_mobile_hdmi.h> static struct snd_soc_dai_link fsi_dai_link = { .name = "HDMI", @@ -23,7 +22,7 @@ static struct snd_soc_dai_link fsi_dai_link = { }; static struct snd_soc_card fsi_soc_card = { - .name = "FSI", + .name = "FSI (SH MOBILE HDMI)", .dai_link = &fsi_dai_link, .num_links = 1, }; diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index abc6d830960..363b37a603c 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -101,13 +101,10 @@ #define FSI_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE) -/************************************************************************ - - - struct - +/* + * struct + */ -************************************************************************/ struct fsi_priv { void __iomem *base; struct snd_pcm_substream *substream; @@ -142,13 +139,10 @@ struct fsi_master { spinlock_t lock; }; -/************************************************************************ - - - basic read write function - +/* + * basic read write function + */ -************************************************************************/ static void __fsi_reg_write(u32 reg, u32 data) { /* valid data area is 24bit */ @@ -251,13 +245,10 @@ static void fsi_master_mask_set(struct fsi_master *master, spin_unlock_irqrestore(&master->lock, flags); } -/************************************************************************ - - - basic function - +/* + * basic function + */ -************************************************************************/ static struct fsi_master *fsi_get_master(struct fsi_priv *fsi) { return fsi->master; @@ -357,13 +348,63 @@ static int fsi_get_fifo_residue(struct fsi_priv *fsi, int is_play) return residue; } -/************************************************************************ +/* + * dma function + */ + +static u8 *fsi_dma_get_area(struct fsi_priv *fsi) +{ + return fsi->substream->runtime->dma_area + fsi->byte_offset; +} + +static void fsi_dma_soft_push16(struct fsi_priv *fsi, int size) +{ + u16 *start; + int i; + + start = (u16 *)fsi_dma_get_area(fsi); + + for (i = 0; i < size; i++) + fsi_reg_write(fsi, DODT, ((u32)*(start + i) << 8)); +} + +static void fsi_dma_soft_pop16(struct fsi_priv *fsi, int size) +{ + u16 *start; + int i; + + start = (u16 *)fsi_dma_get_area(fsi); + + for (i = 0; i < size; i++) + *(start + i) = (u16)(fsi_reg_read(fsi, DIDT) >> 8); +} + +static void fsi_dma_soft_push32(struct fsi_priv *fsi, int size) +{ + u32 *start; + int i; + + start = (u32 *)fsi_dma_get_area(fsi); + + for (i = 0; i < size; i++) + fsi_reg_write(fsi, DODT, *(start + i)); +} + +static void fsi_dma_soft_pop32(struct fsi_priv *fsi, int size) +{ + u32 *start; + int i; + start = (u32 *)fsi_dma_get_area(fsi); - irq function + for (i = 0; i < size; i++) + *(start + i) = fsi_reg_read(fsi, DIDT); +} +/* + * irq function + */ -************************************************************************/ static void fsi_irq_enable(struct fsi_priv *fsi, int is_play) { u32 data = fsi_port_ab_io_bit(fsi, is_play); @@ -404,13 +445,11 @@ static void fsi_irq_clear_status(struct fsi_priv *fsi) fsi_master_mask_set(master, master->core->int_st, data, 0); } -/************************************************************************ - - - SPDIF master clock function - -These functions are used later FSI2 -************************************************************************/ +/* + * SPDIF master clock function + * + * These functions are used later FSI2 + */ static void fsi_spdif_clk_ctrl(struct fsi_priv *fsi, int enable) { struct fsi_master *master = fsi_get_master(fsi); @@ -427,13 +466,10 @@ static void fsi_spdif_clk_ctrl(struct fsi_priv *fsi, int enable) fsi_master_mask_set(master, fsi->mst_ctrl, val, 0); } -/************************************************************************ - - - ctrl function - +/* + * ctrl function + */ -************************************************************************/ static void fsi_clk_ctrl(struct fsi_priv *fsi, int enable) { u32 val = fsi_is_port_a(fsi) ? (1 << 0) : (1 << 4); @@ -512,8 +548,7 @@ static int fsi_data_push(struct fsi_priv *fsi, int startup) int send; int fifo_free; int width; - u8 *start; - int i, over_period; + int over_period; if (!fsi || !fsi->substream || @@ -550,18 +585,12 @@ static int fsi_data_push(struct fsi_priv *fsi, int startup) if (fifo_free < send) send = fifo_free; - start = runtime->dma_area; - start += fsi->byte_offset; - switch (width) { case 2: - for (i = 0; i < send; i++) - fsi_reg_write(fsi, DODT, - ((u32)*((u16 *)start + i) << 8)); + fsi_dma_soft_push16(fsi, send); break; case 4: - for (i = 0; i < send; i++) - fsi_reg_write(fsi, DODT, *((u32 *)start + i)); + fsi_dma_soft_push32(fsi, send); break; default: return -EINVAL; @@ -596,8 +625,7 @@ static int fsi_data_pop(struct fsi_priv *fsi, int startup) int free; int fifo_fill; int width; - u8 *start; - int i, over_period; + int over_period; if (!fsi || !fsi->substream || @@ -633,18 +661,12 @@ static int fsi_data_pop(struct fsi_priv *fsi, int startup) if (free < fifo_fill) fifo_fill = free; - start = runtime->dma_area; - start += fsi->byte_offset; - switch (width) { case 2: - for (i = 0; i < fifo_fill; i++) - *((u16 *)start + i) = - (u16)(fsi_reg_read(fsi, DIDT) >> 8); + fsi_dma_soft_pop16(fsi, fifo_fill); break; case 4: - for (i = 0; i < fifo_fill; i++) - *((u32 *)start + i) = fsi_reg_read(fsi, DIDT); + fsi_dma_soft_pop32(fsi, fifo_fill); break; default: return -EINVAL; @@ -694,13 +716,10 @@ static irqreturn_t fsi_interrupt(int irq, void *data) return IRQ_HANDLED; } -/************************************************************************ - - - dai ops - +/* + * dai ops + */ -************************************************************************/ static int fsi_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -919,13 +938,10 @@ static struct snd_soc_dai_ops fsi_dai_ops = { .hw_params = fsi_dai_hw_params, }; -/************************************************************************ - - - pcm ops - +/* + * pcm ops + */ -************************************************************************/ static struct snd_pcm_hardware fsi_pcm_hardware = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | @@ -991,13 +1007,10 @@ static struct snd_pcm_ops fsi_pcm_ops = { .pointer = fsi_pointer, }; -/************************************************************************ - - - snd_soc_platform - +/* + * snd_soc_platform + */ -************************************************************************/ #define PREALLOC_BUFFER (32 * 1024) #define PREALLOC_BUFFER_MAX (32 * 1024) @@ -1021,13 +1034,10 @@ static int fsi_pcm_new(struct snd_card *card, PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -/************************************************************************ - - - alsa struct - +/* + * alsa struct + */ -************************************************************************/ static struct snd_soc_dai_driver fsi_soc_dai[] = { { .name = "fsia-dai", @@ -1069,13 +1079,10 @@ static struct snd_soc_platform_driver fsi_soc_platform = { .pcm_free = fsi_pcm_free, }; -/************************************************************************ - - - platform function - +/* + * platform function + */ -************************************************************************/ static int fsi_probe(struct platform_device *pdev) { struct fsi_master *master; @@ -1219,6 +1226,7 @@ static struct platform_device_id fsi_id_table[] = { { "sh_fsi", (kernel_ulong_t)&fsi1_core }, { "sh_fsi2", (kernel_ulong_t)&fsi2_core }, }; +MODULE_DEVICE_TABLE(platform, fsi_id_table); static struct platform_driver fsi_driver = { .driver = { @@ -1239,6 +1247,7 @@ static void __exit fsi_mobile_exit(void) { platform_driver_unregister(&fsi_driver); } + module_init(fsi_mobile_init); module_exit(fsi_mobile_exit); diff --git a/sound/soc/sh/migor.c b/sound/soc/sh/migor.c index 866d78fb839..f4620176a3f 100644 --- a/sound/soc/sh/migor.c +++ b/sound/soc/sh/migor.c @@ -12,6 +12,7 @@ #include <linux/firmware.h> #include <linux/module.h> +#include <asm/clkdev.h> #include <asm/clock.h> #include <cpu/sh7722.h> @@ -40,12 +41,12 @@ static struct clk_ops siumckb_clk_ops = { }; static struct clk siumckb_clk = { - .name = "siumckb_clk", - .id = -1, .ops = &siumckb_clk_ops, .rate = 0, /* initialised at run-time */ }; +static struct clk_lookup *siumckb_lookup; + static int migor_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -177,6 +178,13 @@ static int __init migor_init(void) if (ret < 0) return ret; + siumckb_lookup = clkdev_alloc(&siumckb_clk, "siumckb_clk", NULL); + if (!siumckb_lookup) { + ret = -ENOMEM; + goto eclkdevalloc; + } + clkdev_add(siumckb_lookup); + /* Port number used on this machine: port B */ migor_snd_device = platform_device_alloc("soc-audio", 1); if (!migor_snd_device) { @@ -195,12 +203,15 @@ static int __init migor_init(void) epdevadd: platform_device_put(migor_snd_device); epdevalloc: + clkdev_drop(siumckb_lookup); +eclkdevalloc: clk_unregister(&siumckb_clk); return ret; } static void __exit migor_exit(void) { + clkdev_drop(siumckb_lookup); clk_unregister(&siumckb_clk); platform_device_unregister(migor_snd_device); } diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h index aa239ff7310..9f4dcb921ff 100644 --- a/sound/soc/sh/siu.h +++ b/sound/soc/sh/siu.h @@ -98,7 +98,9 @@ enum { SIU_CLKB_EXT }; +struct device; struct siu_info { + struct device *dev; int port_id; u32 __iomem *pram; u32 __iomem *xram; @@ -182,7 +184,6 @@ static inline u32 siu_read32(u32 __iomem *addr) #define SIU_BRRB (0x10c / sizeof(u32)) extern struct snd_soc_platform_driver siu_platform; -extern struct snd_soc_dai_driver siu_i2s_dai; extern struct siu_info *siu_i2s_data; int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card); diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 827940a8e24..af53b64d8af 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -71,8 +71,7 @@ struct port_flag { struct format_flag capture; }; -struct siu_info *siu_i2s_data = NULL; -EXPORT_SYMBOL_GPL(siu_i2s_data); +struct siu_info *siu_i2s_data; static struct port_flag siu_flags[SIU_PORT_NUM] = { [SIU_PORT_A] = { @@ -113,7 +112,7 @@ static void siu_dai_start(struct siu_port *port_info) dev_dbg(port_info->pcm->card->dev, "%s\n", __func__); /* Turn on SIU clock */ - pm_runtime_get_sync(port_info->pcm->card->dev); + pm_runtime_get_sync(info->dev); /* Issue software reset to siu */ siu_write32(base + SIU_SRCTL, 0); @@ -160,7 +159,7 @@ static void siu_dai_stop(struct siu_port *port_info) siu_write32(base + SIU_SRCTL, 0); /* Turn off SIU clock */ - pm_runtime_put_sync(port_info->pcm->card->dev); + pm_runtime_put_sync(info->dev); } static void siu_dai_spbAselect(struct siu_port *port_info) @@ -675,20 +674,36 @@ static int siu_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, } siu_clk = clk_get(dai->dev, siu_name); - if (IS_ERR(siu_clk)) + if (IS_ERR(siu_clk)) { + dev_err(dai->dev, "%s: cannot get a SIU clock: %ld\n", __func__, + PTR_ERR(siu_clk)); return PTR_ERR(siu_clk); + } parent_clk = clk_get(dai->dev, parent_name); - if (!IS_ERR(parent_clk)) { - ret = clk_set_parent(siu_clk, parent_clk); - if (!ret) - clk_set_rate(siu_clk, freq); - clk_put(parent_clk); + if (IS_ERR(parent_clk)) { + ret = PTR_ERR(parent_clk); + dev_err(dai->dev, "cannot get a SIU clock parent: %d\n", ret); + goto epclkget; + } + + ret = clk_set_parent(siu_clk, parent_clk); + if (ret < 0) { + dev_err(dai->dev, "cannot reparent the SIU clock: %d\n", ret); + goto eclksetp; } + ret = clk_set_rate(siu_clk, freq); + if (ret < 0) + dev_err(dai->dev, "cannot set SIU clock rate: %d\n", ret); + + /* TODO: when clkdev gets reference counting we'll move these to siu_dai_shutdown() */ +eclksetp: + clk_put(parent_clk); +epclkget: clk_put(siu_clk); - return 0; + return ret; } static struct snd_soc_dai_ops siu_dai_ops = { @@ -700,7 +715,7 @@ static struct snd_soc_dai_ops siu_dai_ops = { }; static struct snd_soc_dai_driver siu_i2s_dai = { - .name = "sui-i2s-dai", + .name = "siu-i2s-dai", .playback = { .channels_min = 2, .channels_max = 2, @@ -727,6 +742,7 @@ static int __devinit siu_probe(struct platform_device *pdev) if (!info) return -ENOMEM; siu_i2s_data = info; + info->dev = &pdev->dev; ret = request_firmware(&fw_entry, "siu_spb.bin", &pdev->dev); if (ret) @@ -828,6 +844,7 @@ static int __devexit siu_remove(struct platform_device *pdev) static struct platform_driver siu_driver = { .driver = { + .owner = THIS_MODULE, .name = "siu-pcm-audio", }, .probe = siu_probe, diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 44047699332..d6c79fa56d1 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -341,7 +341,7 @@ static int siu_pcm_open(struct snd_pcm_substream *ss) { /* Playback / Capture */ struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct siu_platform *pdata = snd_soc_platform_get_drvdata(rtd->platform); + struct siu_platform *pdata = rtd->platform->dev->platform_data; struct siu_info *info = siu_i2s_data; struct siu_port *port_info = siu_port_info(ss); struct siu_stream *siu_stream; |