simtec-audio.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2009 Simtec Electronics
  4. // http://armlinux.simtec.co.uk/
  5. // Ben Dooks <[email protected]>
  6. //
  7. // Audio setup for various Simtec S3C24XX implementations
  8. #include <linux/kernel.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/init.h>
  11. #include <linux/device.h>
  12. #include <linux/io.h>
  13. #include "regs-gpio.h"
  14. #include "gpio-samsung.h"
  15. #include "gpio-cfg.h"
  16. #include <linux/platform_data/asoc-s3c24xx_simtec.h>
  17. #include "devs.h"
  18. #include "bast.h"
  19. #include "simtec.h"
  20. /* platform ops for audio */
  21. static void simtec_audio_startup_lrroute(void)
  22. {
  23. unsigned int tmp;
  24. unsigned long flags;
  25. local_irq_save(flags);
  26. tmp = __raw_readb(BAST_VA_CTRL1);
  27. tmp &= ~BAST_CPLD_CTRL1_LRMASK;
  28. tmp |= BAST_CPLD_CTRL1_LRCDAC;
  29. __raw_writeb(tmp, BAST_VA_CTRL1);
  30. local_irq_restore(flags);
  31. }
  32. static struct s3c24xx_audio_simtec_pdata simtec_audio_platdata;
  33. static char our_name[32];
  34. static struct platform_device simtec_audio_dev = {
  35. .name = our_name,
  36. .id = -1,
  37. .dev = {
  38. .parent = &s3c_device_iis.dev,
  39. .platform_data = &simtec_audio_platdata,
  40. },
  41. };
  42. int __init simtec_audio_add(const char *name, bool has_lr_routing,
  43. struct s3c24xx_audio_simtec_pdata *spd)
  44. {
  45. if (!name)
  46. name = "tlv320aic23";
  47. snprintf(our_name, sizeof(our_name)-1, "s3c24xx-simtec-%s", name);
  48. /* copy platform data so the source can be __initdata */
  49. if (spd)
  50. simtec_audio_platdata = *spd;
  51. if (has_lr_routing)
  52. simtec_audio_platdata.startup = simtec_audio_startup_lrroute;
  53. /* Configure the I2S pins (GPE0...GPE4) in correct mode */
  54. s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
  55. S3C_GPIO_PULL_NONE);
  56. platform_device_register(&s3c_device_iis);
  57. platform_device_register(&simtec_audio_dev);
  58. return 0;
  59. }