summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-14 11:17:00 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-14 11:17:00 -0600
commit695c703edb33db35c664c3a395a8c1c0e60d5c20 (patch)
treea65fa4a96cbcfe2b14d0da59aa5a43a279d3dd09 /nuttx
parent386a6f595e9be0409ebf4c6e0a73c12188cb4a8c (diff)
downloadpx4-nuttx-695c703edb33db35c664c3a395a8c1c0e60d5c20.tar.gz
px4-nuttx-695c703edb33db35c664c3a395a8c1c0e60d5c20.tar.bz2
px4-nuttx-695c703edb33db35c664c3a395a8c1c0e60d5c20.zip
SAMA5 ISI: Framework for ISI drivers. Not much there on initial check-in
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/arch/arm/src/sama5/sam_isi.c177
-rw-r--r--nuttx/arch/arm/src/sama5/sam_isi.h92
2 files changed, 269 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_isi.c b/nuttx/arch/arm/src/sama5/sam_isi.c
new file mode 100644
index 000000000..979517fc7
--- /dev/null
+++ b/nuttx/arch/arm/src/sama5/sam_isi.c
@@ -0,0 +1,177 @@
+/****************************************************************************
+ * arch/arm/src/sama5/sam_isi.c
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <debug.h>
+
+#include "sam_pio.h"
+#include "sam_pck.h"
+#include "sam_isi.h"
+
+#ifdef CONFIG_SAMA5_ISI
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The sensor master clock (ISI_MCK) is generated by the Advanced Power
+ * Management Controller (APMC) through a Programmable Clock output.
+ */
+
+#ifndef CONFIG_ISI_MCKFREQ
+# error "CONFIG_ISI_MCKFREQ must be defined"
+#endif
+
+#if defined(CONFIG_ISI_PCK0)
+# define ISI_PCKID PCK0
+#elif defined(CONFIG_ISI_PCK1)
+# define ISI_PCKID PCK1
+#elif defined(CONFIG_ISI_PCK2)
+# define ISI_PCKID PCK2
+#else
+# error "No valid PCK selection"
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+/* This structure defines the overall state of the ISI interface */
+
+struct sam_isi_s
+{
+ uint32_t actual; /* Acutal ISI_MCK frequency */
+};
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* ISI interface state */
+
+static struct sam_isi_s g_isi;
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: sam_isi_initialize
+ *
+ * Description:
+ * Initialize the ISI driver.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ * Assumptions:
+ * Called very early in the initialization sequence.
+ *
+ ****************************************************************************/
+
+int sam_isi_initialize(void)
+{
+ int ret;
+
+ /* Configure PIO pins for the ISI (outputs) */
+ /* Data pins */
+
+ (void)sam_configpio(PIO_ISI_D0);
+ (void)sam_configpio(PIO_ISI_D1);
+ (void)sam_configpio(PIO_ISI_D2);
+ (void)sam_configpio(PIO_ISI_D3);
+ (void)sam_configpio(PIO_ISI_D4);
+ (void)sam_configpio(PIO_ISI_D5);
+ (void)sam_configpio(PIO_ISI_D6);
+ (void)sam_configpio(PIO_ISI_D7);
+ (void)sam_configpio(PIO_ISI_D8);
+ (void)sam_configpio(PIO_ISI_D9);
+ (void)sam_configpio(PIO_ISI_D10);
+ (void)sam_configpio(PIO_ISI_D11);
+
+ /* Horizontal and vertical sync pins (inputs) */
+
+ (void)sam_configpio(PIO_ISI_HSYNC);
+ (void)sam_configpio(PIO_ISI_VSYNC);
+
+ /* Pixel clock input (ISI_PCK, not to be confused with the processor clock
+ * (PCK) or the programmable clock (PCK).
+ *
+ * NOTE: "Several parts of the ISI controller use the pixel clock provided
+ * by the image sensor (ISI_PCK). Thus the user must first program the
+ * image sensor to provide this clock (ISI_PCK) before programming the
+ * Image Sensor Controller."
+ */
+
+ (void)sam_configpio(PIO_ISI_PCK);
+
+ /* Configure ISI_MCK programmable clock output.
+ *
+ * REVISIT: Might this not be needed before the image sensor is
+ * initialized?
+ */
+
+ g_isi.actual = sam_pck_configure(ISI_PCKID, CONFIG_ISI_MCKFREQ);
+ gvdbg("PCK%d frequency=%d actual=%d\n",
+ ISI_PCKID, CONFIG_ISI_MCKFREQ, g_isi.actual);
+
+ /* Enable the MCK (output) */
+
+ sam_pck_enable(ISI_PCKID, true);
+
+ /* Configure the pixel clock */
+#warning Missing logic
+
+ /* Configure color */
+#warning Missing logic
+
+}
+
+#endif /* CONFIG_SAMA5_ISI && CONFIG_SAMA5_EMAC */
diff --git a/nuttx/arch/arm/src/sama5/sam_isi.h b/nuttx/arch/arm/src/sama5/sam_isi.h
new file mode 100644
index 000000000..24bbb01b9
--- /dev/null
+++ b/nuttx/arch/arm/src/sama5/sam_isi.h
@@ -0,0 +1,92 @@
+/************************************************************************************
+ * arch/arm/src/sama5/sam_isi.h
+ *
+ * Copyright (C) 2013 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_SAMA5_SAM_ISI_H
+#define __ARCH_ARM_SRC_SAMA5_SAM_ISI_H
+
+/************************************************************************************
+ * Included Files
+ ************************************************************************************/
+
+#include <nuttx/config.h>
+
+#include "chip.h"
+#include "chip/sam_isi.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Function: sam_isi_initialize
+ *
+ * Description:
+ * Initialize the ISI driver.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * OK on success; Negated errno on failure.
+ *
+ * Assumptions:
+ * Called very early in the initialization sequence.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SAMA5_ISI
+int sam_isi_initialize(void);
+#endif
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_SAMA5_SAM_ISI_H */