ALSA: sh: add SuperH DAC audio driver for ALSA V4
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / sh / boards / mach-hp6xx / setup.c
index 8f305b3..e6dd5e9 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/irq.h>
+#include <sound/sh_dac_audio.h>
 #include <asm/hd64461.h>
 #include <asm/io.h>
 #include <mach/hp6xx.h>
@@ -51,9 +52,63 @@ static struct platform_device jornadakbd_device = {
        .id             = -1,
 };
 
+static void dac_audio_start(struct dac_audio_pdata *pdata)
+{
+       u16 v;
+       u8 v8;
+
+       /* HP Jornada 680/690 speaker on */
+       v = inw(HD64461_GPADR);
+       v &= ~HD64461_GPADR_SPEAKER;
+       outw(v, HD64461_GPADR);
+
+       /* HP Palmtop 620lx/660lx speaker on */
+       v8 = inb(PKDR);
+       v8 &= ~PKDR_SPEAKER;
+       outb(v8, PKDR);
+
+       sh_dac_enable(pdata->channel);
+}
+
+static void dac_audio_stop(struct dac_audio_pdata *pdata)
+{
+       u16 v;
+       u8 v8;
+
+       /* HP Jornada 680/690 speaker off */
+       v = inw(HD64461_GPADR);
+       v |= HD64461_GPADR_SPEAKER;
+       outw(v, HD64461_GPADR);
+
+       /* HP Palmtop 620lx/660lx speaker off */
+       v8 = inb(PKDR);
+       v8 |= PKDR_SPEAKER;
+       outb(v8, PKDR);
+
+       sh_dac_output(0, pdata->channel);
+       sh_dac_disable(pdata->channel);
+}
+
+static struct dac_audio_pdata dac_audio_platform_data = {
+       .buffer_size            = 64000,
+       .channel                = 1,
+       .start                  = dac_audio_start,
+       .stop                   = dac_audio_stop,
+};
+
+static struct platform_device dac_audio_device = {
+       .name           = "dac_audio",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &dac_audio_platform_data,
+       }
+
+};
+
 static struct platform_device *hp6xx_devices[] __initdata = {
        &cf_ide_device,
        &jornadakbd_device,
+       &dac_audio_device,
 };
 
 static void __init hp6xx_init_irq(void)