summaryrefslogtreecommitdiff
path: root/nuttx/configs/sama5d3x-ek/src
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-31 11:14:57 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-31 11:14:57 -0600
commitfb5abc7406ccf2a60916ef9e27dbda17340c63a5 (patch)
treefd2c8e1bad9303217fc1fd7aa8ced85a644aaef6 /nuttx/configs/sama5d3x-ek/src
parent49ce5fbe3b51dfab403915d36b12d2c8c5adf206 (diff)
downloadpx4-nuttx-fb5abc7406ccf2a60916ef9e27dbda17340c63a5.tar.gz
px4-nuttx-fb5abc7406ccf2a60916ef9e27dbda17340c63a5.tar.bz2
px4-nuttx-fb5abc7406ccf2a60916ef9e27dbda17340c63a5.zip
SAMA5D3X-EK: Add support for the WM8904 audio CODEC
Diffstat (limited to 'nuttx/configs/sama5d3x-ek/src')
-rw-r--r--nuttx/configs/sama5d3x-ek/src/Makefile10
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_nsh.c17
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h90
3 files changed, 113 insertions, 4 deletions
diff --git a/nuttx/configs/sama5d3x-ek/src/Makefile b/nuttx/configs/sama5d3x-ek/src/Makefile
index d49463996..e0e57b279 100644
--- a/nuttx/configs/sama5d3x-ek/src/Makefile
+++ b/nuttx/configs/sama5d3x-ek/src/Makefile
@@ -1,7 +1,7 @@
############################################################################
# configs/sama5d3x-ek/src/Makefile
#
-# Copyright (C) 2013 Gregory Nutt. All rights reserved.
+# Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@@ -106,6 +106,14 @@ CSRCS += sam_ethernet.c
endif
endif
+ifeq ($(CONFIG_AUDIO_WM8904),y)
+ifeq ($(CONFIG_SAMA5_TWI0),y)
+ifeq ($(CONFIG_SAMA5_SSC0),y)
+CSRCS += sam_wm8904.c
+endif
+endif
+endif
+
ifeq ($(CONFIG_NSH_ARCHINIT),y)
CSRCS += sam_nsh.c
endif
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
index dc62c193e..e057c5144 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_nsh.c
@@ -1,7 +1,7 @@
/****************************************************************************
* config/sama5d3x-ek/src/sam_nsh.c
*
- * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -86,8 +86,9 @@
int nsh_archinitialize(void)
{
-#if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_AT24) || \
- defined(HAVE_HSMCI) || defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR)
+#if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_AT24) || \
+ defined(HAVE_HSMCI) || defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) ||\
+ defined(HAVE_WM8904)
int ret;
#endif
@@ -173,5 +174,15 @@ int nsh_archinitialize(void)
}
#endif
+#ifdef HAVE_WM8904
+ /* Configure WM8904 audio */
+
+ ret = sam_wm8904_initialize(0);
+ if (ret != OK)
+ {
+ message("ERROR: Failed to initialize WM8904 audio: %d\n", ret);
+ }
+#endif
+
return OK;
}
diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
index feebec328..8bf647d36 100644
--- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
+++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
@@ -64,6 +64,7 @@
#define HAVE_USBMONITOR 1
#define HAVE_NETWORK 1
#define HAVE_CAMERA 1
+#define HAVE_WM8904 1
/* HSMCI */
/* Can't support MMC/SD if the card interface(s) are not enable */
@@ -318,6 +319,41 @@
# undef HAVE_NETWORK
#endif
+/* Audio */
+/* PCM/WM8904 driver */
+
+#ifndef CONFIG_AUDIO_WM8904
+# undef HAVE_WM8904
+#endif
+
+#ifdef HAVE_WM8904
+# ifndef CONFIG_SAMA5_TWI0
+# warning CONFIG_SAMA5_TWI0 is required for audio support
+# undef HAVE_WM8904
+# endif
+
+# ifndef CONFIG_SAMA5_SSC0
+# warning CONFIG_SAMA5_SSC0 is required for audio support
+# undef HAVE_WM8904
+# endif
+
+# ifndef CONFIG_AUDIO_FORMAT_PCM
+# warning CONFIG_AUDIO_FORMAT_PCM is required for audio support
+# undef HAVE_WM8904
+# endif
+
+# ifndef CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY
+# warning Defaulting to maximum WM8904 I2C frequency
+# define CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY 400000
+# endif
+
+# if CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY > 400000
+# warning WM8904 I2C frequency cannot exceed 400KHz
+# undef CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY
+# define CONFIG_SAMA5D3xEK_WM8904_I2CFREQUENCY 400000
+# endif
+#endif
+
/* Camera */
#define OV2640_BUS 1
@@ -549,6 +585,39 @@
#endif
+/* WM8904 Audio Codec ***************************************************************/
+/* SAMA5D3-EK Interface
+ * ------------- ---------------- -----------------
+ * WM8904 SAMA5D3 NuttX Pin Name
+ * ------------- ---------------- -----------------
+ * 3 SDA PA30 TWD0 PIO_TWI0_D
+ * 2 SCLK PA31 TWCK0 PIO_TWI0_CK
+ * 28 MCLK PD30 PCK0 PIO_PMC_PCK0
+ * 29 BCLK/GPIO4 PC16 TK PIO_SSC0_TK
+ * "" " " PC19 RK PIO_SSC0_RK
+ * 30 LRCLK PC17 TF PIO_SSC0_TF
+ * "" " " PC20 RF PIO_SSC0_RF
+ * 31 ADCDAT PC21 RD PIO_SSC0_RD
+ * 32 DACDAT PC18 TD PIO_SSC0_TD
+ * 1 IRQ/GPIO1 PD16 INT_AUDIO N/A
+ * ------------- ---------------- -----------------
+ */
+
+/* Audio Interrupt */
+
+#define PIO_INT_WM8904 (PIO_INPUT | PIO_CFG_PULLUP | PIO_CFG_DEGLITCH | \
+ PIO_INT_BOTHEDGES | PIO_PORT_PIOD | PIO_PIN16)
+#define IRQ_INT_WM8904 SAM_IRQ_PD16
+
+/* The MW8904 communicates on TWI0, I2C address 0x1a for control operations */
+
+#define WM8904_TWI_BUS 0
+#define WM8904_I2C_ADDRESS 0x1a
+
+/* The MW8904 transfers data on SSC0 */
+
+#define WM8904_SSC_BUS 0
+
/* SPI Chip Selects *****************************************************************/
/* Both the Ronetix and Embest versions of the SAMAD3x CPU modules include an
* Atmel AT25DF321A, 32-megabit, 2.7-volt SPI serial flash. The SPI
@@ -743,6 +812,27 @@ int sam_usbhost_initialize(void);
void weak_function sam_netinitialize(void);
#endif
+/****************************************************************************
+ * Name: sam_wm8904_initialize
+ *
+ * Description:
+ * This function is called by platform-specific, setup logic to configure
+ * and register the WM8904 device. This function will register the driver
+ * as /dev/wm8904[x] where x is determined by the minor device number.
+ *
+ * Input Parameters:
+ * minor - The input device minor number
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+#ifdef HAVE_WM8904
+int sam_wm8904_initialize(int minor);
+#endif /* HAVE_WM8904 */
+
/************************************************************************************
* Name: board_led_initialize
************************************************************************************/