blob: 12e17f82dae3e32ce567d4e6fba56f33e69c9aac [file] [log] [blame]
Krzysztof Kozlowski84b21702017-12-25 20:54:32 +01001// 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
Ben Dooks4d3a3462009-11-13 22:34:20 +00008
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
Ben Dooks4d3a3462009-11-13 22:34:20 +000015#include <mach/hardware.h>
16#include <mach/regs-gpio.h>
17
Arnd Bergmann436d42c2012-08-24 15:22:12 +020018#include <linux/platform_data/asoc-s3c24xx_simtec.h>
Ben Dooks4d3a3462009-11-13 22:34:20 +000019#include <plat/devs.h>
20
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080021#include "bast.h"
Heiko Stuebnerec2cc752012-03-07 01:47:11 -080022#include "simtec.h"
23
Ben Dooks4d3a3462009-11-13 22:34:20 +000024/* platform ops for audio */
25
26static 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
41static struct s3c24xx_audio_simtec_pdata simtec_audio_platdata;
42static char our_name[32];
43
44static 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
53int __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}