Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 //
0003 // Copyright (c) 2009 Simtec Electronics
0004 //  http://armlinux.simtec.co.uk/
0005 //  Ben Dooks <ben@simtec.co.uk>
0006 //
0007 // Audio setup for various Simtec S3C24XX implementations
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/interrupt.h>
0011 #include <linux/init.h>
0012 #include <linux/device.h>
0013 #include <linux/io.h>
0014 
0015 #include "regs-gpio.h"
0016 #include "gpio-samsung.h"
0017 #include "gpio-cfg.h"
0018 
0019 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
0020 #include "devs.h"
0021 
0022 #include "bast.h"
0023 #include "simtec.h"
0024 
0025 /* platform ops for audio */
0026 
0027 static void simtec_audio_startup_lrroute(void)
0028 {
0029     unsigned int tmp;
0030     unsigned long flags;
0031 
0032     local_irq_save(flags);
0033 
0034     tmp = __raw_readb(BAST_VA_CTRL1);
0035     tmp &= ~BAST_CPLD_CTRL1_LRMASK;
0036     tmp |= BAST_CPLD_CTRL1_LRCDAC;
0037     __raw_writeb(tmp, BAST_VA_CTRL1);
0038 
0039     local_irq_restore(flags);
0040 }
0041 
0042 static struct s3c24xx_audio_simtec_pdata simtec_audio_platdata;
0043 static char our_name[32];
0044 
0045 static struct platform_device simtec_audio_dev = {
0046     .name   = our_name,
0047     .id = -1,
0048     .dev    = {
0049         .parent     = &s3c_device_iis.dev,
0050         .platform_data  = &simtec_audio_platdata,
0051     },
0052 };
0053 
0054 int __init simtec_audio_add(const char *name, bool has_lr_routing,
0055                 struct s3c24xx_audio_simtec_pdata *spd)
0056 {
0057     if (!name)
0058         name = "tlv320aic23";
0059 
0060     snprintf(our_name, sizeof(our_name)-1, "s3c24xx-simtec-%s", name);
0061 
0062     /* copy platform data so the source can be __initdata */
0063     if (spd)
0064         simtec_audio_platdata = *spd;
0065 
0066     if (has_lr_routing)
0067         simtec_audio_platdata.startup = simtec_audio_startup_lrroute;
0068 
0069     /* Configure the I2S pins (GPE0...GPE4) in correct mode */
0070     s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
0071                   S3C_GPIO_PULL_NONE);
0072 
0073     platform_device_register(&s3c_device_iis);
0074     platform_device_register(&simtec_audio_dev);
0075     return 0;
0076 }