Krzysztof Kozlowski | 84b2170 | 2017-12-25 20:54:32 +0100 | [diff] [blame] | 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 |
Ben Dooks | 4d3a346 | 2009-11-13 22:34:20 +0000 | [diff] [blame] | 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 | |
Ben Dooks | 4d3a346 | 2009-11-13 22:34:20 +0000 | [diff] [blame] | 15 | #include <mach/hardware.h> |
| 16 | #include <mach/regs-gpio.h> |
| 17 | |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 18 | #include <linux/platform_data/asoc-s3c24xx_simtec.h> |
Ben Dooks | 4d3a346 | 2009-11-13 22:34:20 +0000 | [diff] [blame] | 19 | #include <plat/devs.h> |
| 20 | |
Kukjin Kim | bbd7e5e | 2013-01-01 19:56:20 -0800 | [diff] [blame] | 21 | #include "bast.h" |
Heiko Stuebner | ec2cc75 | 2012-03-07 01:47:11 -0800 | [diff] [blame] | 22 | #include "simtec.h" |
| 23 | |
Ben Dooks | 4d3a346 | 2009-11-13 22:34:20 +0000 | [diff] [blame] | 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 | } |