Merge tag 'iommu-updates-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / arch / arm / mach-s3c24xx / simtec-audio.c
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Copyright (c) 2009 Simtec Electronics
4 //      http://armlinux.simtec.co.uk/
5 //      Ben Dooks <ben@simtec.co.uk>
6 //
7 // Audio setup for various Simtec S3C24XX implementations
8
9 #include <linux/kernel.h>
10 #include <linux/interrupt.h>
11 #include <linux/init.h>
12 #include <linux/device.h>
13 #include <linux/io.h>
14
15 #include <mach/hardware.h>
16 #include <mach/regs-gpio.h>
17
18 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
19 #include <plat/devs.h>
20
21 #include "bast.h"
22 #include "simtec.h"
23
24 /* platform ops for audio */
25
26 static void simtec_audio_startup_lrroute(void)
27 {
28         unsigned int tmp;
29         unsigned long flags;
30
31         local_irq_save(flags);
32
33         tmp = __raw_readb(BAST_VA_CTRL1);
34         tmp &= ~BAST_CPLD_CTRL1_LRMASK;
35         tmp |= BAST_CPLD_CTRL1_LRCDAC;
36         __raw_writeb(tmp, BAST_VA_CTRL1);
37
38         local_irq_restore(flags);
39 }
40
41 static struct s3c24xx_audio_simtec_pdata simtec_audio_platdata;
42 static char our_name[32];
43
44 static struct platform_device simtec_audio_dev = {
45         .name   = our_name,
46         .id     = -1,
47         .dev    = {
48                 .parent         = &s3c_device_iis.dev,
49                 .platform_data  = &simtec_audio_platdata,
50         },
51 };
52
53 int __init simtec_audio_add(const char *name, bool has_lr_routing,
54                             struct s3c24xx_audio_simtec_pdata *spd)
55 {
56         if (!name)
57                 name = "tlv320aic23";
58
59         snprintf(our_name, sizeof(our_name)-1, "s3c24xx-simtec-%s", name);
60
61         /* copy platform data so the source can be __initdata */
62         if (spd)
63                 simtec_audio_platdata = *spd;
64
65         if (has_lr_routing)
66                 simtec_audio_platdata.startup = simtec_audio_startup_lrroute;
67
68         platform_device_register(&s3c_device_iis);
69         platform_device_register(&simtec_audio_dev);
70         return 0;
71 }