mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
Merged in alinjerpelea/nuttx (pull request #902)
arch: arm: cxd56xx: PM and PWM
* configs: spresense: add SPI configuration
add SPI configuration for spresense board
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* arch: arm: cxd56xx: add support for PWM
add support for PWM for cxd56xx
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* configs: spresense: enable PWM support
enable PWM support on spresense board
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* arch: arm: cxd56xx: add Power Management PROCFS support
the powermanager procfs support will export
/proc/pm:
clock
power
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* configs: spresense: enable powermanager procfs support
The powermanager procfs is disabled by default and need to be enabled
by the CONFIG_CXD56_PM_PROCFS option
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* arch: arm: cxd56xx: add timer driver
Add timer driver for cxd56xx.
NOTE
The timer allows a divider of 1, 16 and 256 options
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* arch: arm: cxd56xx: add Watch Dog Timer
Add Watch Dog Timer on cxd56xx
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* configs: spresense: enable timer
the platform support has been added and now we can use the timers
on spresense board.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* configs: spresense: enable WatchDog timer
The platform support has been added and now we can use the WatchDog
Timer on spresense board.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
committed by
Gregory Nutt
parent
ae2506619f
commit
92892a8dd7
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/include/cxd56xx/timer.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file timer.h
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_TIMER_H
|
||||
#define __ARCH_ARM_INCLUDE_CXD56XX_TIMER_H
|
||||
|
||||
#include <nuttx/timers/timer.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* Set callback handler
|
||||
*
|
||||
* @param A pointer to struct timer_sethandler_s
|
||||
* @return ioctl return value provides success/failure indication
|
||||
*/
|
||||
|
||||
#define TCIOC_SETHANDLER _TCIOC(0x0020)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This is the type of the argument passed to the TCIOC_SETHANDLER ioctl */
|
||||
|
||||
struct timer_sethandler_s
|
||||
{
|
||||
FAR void *arg; /* An argument */
|
||||
CODE tccb_t handler; /* The timer interrupt handler */
|
||||
};
|
||||
|
||||
#endif /* __ARCH_ARM_INCLUDE_CXD56XX_TIMER_H */
|
||||
@@ -61,7 +61,6 @@ config CXD56_FARAPI_VERSION_CHECK
|
||||
|
||||
if CXD56_FARAPI_VERSION_CHECK
|
||||
|
||||
|
||||
config CXD56_FARAPI_VERSION_FAILED_PANIC
|
||||
bool "Far API Version Check Failed to PANIC"
|
||||
default n
|
||||
@@ -76,6 +75,8 @@ endmenu # Far API Configuration
|
||||
|
||||
comment "Timer Options"
|
||||
|
||||
menu "Timer Options"
|
||||
|
||||
menuconfig CXD56_RTC
|
||||
bool "Real Time Clock (RTC)"
|
||||
default y
|
||||
@@ -94,6 +95,74 @@ config CXD56_RTC_LATEINIT
|
||||
|
||||
endif # CXD56_RTC
|
||||
|
||||
menuconfig CXD56_TIMER
|
||||
bool "Timer"
|
||||
default y
|
||||
select TIMER
|
||||
|
||||
if CXD56_TIMER
|
||||
|
||||
choice
|
||||
prompt "Timer divider selection"
|
||||
default CXD56_TIMER_DIVIDER_1
|
||||
---help---
|
||||
Timer divider selects 1, 16 or 256. The smaller the divider, the higher
|
||||
time resolution, but the shorter the maximum time until wrap-around.
|
||||
|
||||
config CXD56_TIMER_DIVIDER_1
|
||||
bool "Divider 1"
|
||||
|
||||
config CXD56_TIMER_DIVIDER_16
|
||||
bool "Divider 16"
|
||||
|
||||
config CXD56_TIMER_DIVIDER_256
|
||||
bool "Divider 256"
|
||||
|
||||
endchoice
|
||||
endif # CXD56_TIMER
|
||||
|
||||
menuconfig CXD56_WDT
|
||||
bool "Watchdog Timer (WDT)"
|
||||
default y
|
||||
select WATCHDOG
|
||||
|
||||
if CXD56_WDT
|
||||
|
||||
config CXD56_WDT_INTERRUPT
|
||||
bool "Interrupt on timeout"
|
||||
default y
|
||||
---help---
|
||||
This watchdog timer run 2 laps as long as the counter is not reloaded.
|
||||
In the first lap, the watchdog interrupt occurs. Without interrupt
|
||||
clear, The reset signal is asserted in the second timeout. This setting
|
||||
enables the first interrupt.
|
||||
|
||||
config CXD56_WDT_REGDEBUG
|
||||
bool "Register level debug"
|
||||
default n
|
||||
---help---
|
||||
Enable low-level register debug output
|
||||
|
||||
endif # CXD56_WDT
|
||||
|
||||
endmenu
|
||||
|
||||
comment "Power Management Options"
|
||||
|
||||
menuconfig CXD56_PM
|
||||
bool "Power Management"
|
||||
default y
|
||||
|
||||
if CXD56_PM
|
||||
|
||||
config CXD56_PM_PROCFS
|
||||
bool "Power Management PROCFS support"
|
||||
default n
|
||||
---help---
|
||||
Enable the power domain status or the clock frequency monitor.
|
||||
|
||||
endif # CXD56_PM
|
||||
|
||||
comment "Peripheral Support"
|
||||
|
||||
menu "Peripheral Support"
|
||||
@@ -297,6 +366,37 @@ config CXD56_USBDEV
|
||||
default n
|
||||
---help---
|
||||
Enables USB
|
||||
|
||||
config CXD56_PWM
|
||||
bool "PWM"
|
||||
|
||||
if CXD56_PWM
|
||||
|
||||
config CXD56_PWM0
|
||||
bool "PWM0"
|
||||
default n
|
||||
---help---
|
||||
Enable PWM channel 0
|
||||
|
||||
config CXD56_PWM1
|
||||
bool "PWM1"
|
||||
default n
|
||||
---help---
|
||||
Enable PWM channel 1
|
||||
|
||||
config CXD56_PWM2
|
||||
bool "PWM2"
|
||||
default n
|
||||
---help---
|
||||
Enable PWM channel 2
|
||||
|
||||
config CXD56_PWM3
|
||||
bool "PWM3"
|
||||
default n
|
||||
---help---
|
||||
Enable PWM channel 3
|
||||
|
||||
endif # CXD56_PWM
|
||||
endmenu
|
||||
|
||||
comment "Storage Options"
|
||||
|
||||
@@ -99,6 +99,10 @@ CHIP_CSRCS += cxd56_powermgr.c
|
||||
CHIP_CSRCS += cxd56_farapi.c
|
||||
CHIP_CSRCS += cxd56_sysctl.c
|
||||
|
||||
ifeq ($(CONFIG_CXD56_PM_PROCFS),y)
|
||||
CHIP_CSRCS += cxd56_powermgr_procfs.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_RTC),y)
|
||||
CHIP_CSRCS += cxd56_rtc.c
|
||||
ifeq ($(CONFIG_RTC_DRIVER),y)
|
||||
@@ -129,3 +133,15 @@ endif
|
||||
ifeq ($(CONFIG_CXD56_DMAC),y)
|
||||
CHIP_CSRCS += cxd56_dmac.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_PWM),y)
|
||||
CHIP_CSRCS += cxd56_pwm.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_TIMER),y)
|
||||
CHIP_CSRCS += cxd56_timer.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_WDT),y)
|
||||
CHIP_CSRCS += cxd56_wdt.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_timerisr.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Copyright (C) 2012 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_CXD56XX_CXD56_POWERMGR_PROCFS_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_POWERMGR_PROCFS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_pm_initialize_procfs
|
||||
*
|
||||
* Description:
|
||||
* Initialize power manager procfs
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cxd56_pm_initialize_procfs(void);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_POWERMGR_PROCFS_H */
|
||||
@@ -0,0 +1,495 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_pwm.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 <nuttx/drivers/pwm.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "cxd56_pinconfig.h"
|
||||
#include "cxd56_clock.h"
|
||||
#include "cxd56_pwm.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define PWM_REG_BASE (0x04195600)
|
||||
#define PWM_PHASE_REG_BASE (0x04195630)
|
||||
|
||||
#define PWM_REG(ch) \
|
||||
( \
|
||||
(PWM_REG_t*)(PWM_REG_BASE + (sizeof(PWM_REG_t) * (ch))) \
|
||||
)
|
||||
|
||||
#define PWM_PHASE_REG(ch) \
|
||||
( \
|
||||
(PWM_PHASE_REG_t*) \
|
||||
(PWM_PHASE_REG_BASE + (sizeof(PWM_PHASE_REG_t) * (ch))) \
|
||||
)
|
||||
|
||||
#define PWM_PARAM_OFFPERIOD_SHIFT (16)
|
||||
|
||||
#ifndef itemsof
|
||||
# define itemsof(array) (sizeof(array)/sizeof(array[0]))
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure represents the state of one PWM channel */
|
||||
|
||||
struct cxd56_pwm_chan_s
|
||||
{
|
||||
const struct pwm_ops_s *ops; /* PWM operations */
|
||||
uint8_t ch; /* PWM channel: {0..3} */
|
||||
uint8_t prescale; /* prescale (reserved) */
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
volatile uint32_t PARAM;
|
||||
volatile uint32_t EN;
|
||||
volatile uint32_t UPDATE;
|
||||
} PWM_REG_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
volatile uint32_t PHASE;
|
||||
} PWM_PHASE_REG_t;
|
||||
|
||||
/****************************************************************************
|
||||
* Static Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* PWM driver methods */
|
||||
|
||||
static int pwm_setup(FAR struct pwm_lowerhalf_s *dev);
|
||||
static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev);
|
||||
static int pwm_start(FAR struct pwm_lowerhalf_s *dev,
|
||||
FAR const struct pwm_info_s *info);
|
||||
static int pwm_stop(FAR struct pwm_lowerhalf_s *dev);
|
||||
static int pwm_ioctl(FAR struct pwm_lowerhalf_s *dev,
|
||||
int cmd, unsigned long arg);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* This is the list of lower half PWM driver methods used by the upper half
|
||||
* driver
|
||||
*/
|
||||
|
||||
static const struct pwm_ops_s g_pwmops =
|
||||
{
|
||||
.setup = pwm_setup,
|
||||
.shutdown = pwm_shutdown,
|
||||
.start = pwm_start,
|
||||
.stop = pwm_stop,
|
||||
.ioctl = pwm_ioctl,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM0
|
||||
static struct cxd56_pwm_chan_s g_pwm_ch0 =
|
||||
{
|
||||
.ops = &g_pwmops,
|
||||
.ch = CXD56_PWM_CH0,
|
||||
.prescale = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM1
|
||||
static struct cxd56_pwm_chan_s g_pwm_ch1 =
|
||||
{
|
||||
.ops = &g_pwmops,
|
||||
.ch = CXD56_PWM_CH1,
|
||||
.prescale = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM2
|
||||
static struct cxd56_pwm_chan_s g_pwm_ch2 =
|
||||
{
|
||||
.ops = &g_pwmops,
|
||||
.ch = CXD56_PWM_CH2,
|
||||
.prescale = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM3
|
||||
static struct cxd56_pwm_chan_s g_pwm_ch3 =
|
||||
{
|
||||
.ops = &g_pwmops,
|
||||
.ch = CXD56_PWM_CH3,
|
||||
.prescale = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_pin_config
|
||||
*
|
||||
* Description:
|
||||
* Configure PWM pin
|
||||
*
|
||||
* Input Parameters:
|
||||
* channel - pwm channel number.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_pin_config(uint32_t channel)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t pingroupa[] = PINCONFS_PWMA;
|
||||
uint32_t pingroupb[] = PINCONFS_PWMB;
|
||||
|
||||
if ((channel == CXD56_PWM_CH0) || (channel == CXD56_PWM_CH1))
|
||||
{
|
||||
ret = cxd56_pin_configs(pingroupa, itemsof(pingroupa));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = cxd56_pin_configs(pingroupb, itemsof(pingroupb));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: convert_freq2period
|
||||
*
|
||||
* Description:
|
||||
* Convert frequency and duty to period and offperiod of param register.
|
||||
*
|
||||
* Input Parameters:
|
||||
* freq - pwm frequency [Hz]
|
||||
* duty - duty
|
||||
*
|
||||
* Output Parameters:
|
||||
* param - set value of PWM_PARAM register
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int convert_freq2period(uint32_t freq, ub16_t duty, uint32_t *param)
|
||||
{
|
||||
DEBUGASSERT(param);
|
||||
|
||||
uint32_t pwmfreq = 0;
|
||||
uint32_t period = 0;
|
||||
uint32_t offperiod = 0;
|
||||
|
||||
/* Get frequency of pwm base clock */
|
||||
|
||||
pwmfreq = cxd56_get_pwm_baseclock();
|
||||
if (pwmfreq == 0)
|
||||
{
|
||||
pwmerr("Unknown pwm frequency\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check frequency range */
|
||||
|
||||
if ((freq > ((pwmfreq + 1) >> 1)) || (freq < (pwmfreq >> 16)))
|
||||
{
|
||||
pwmerr("Frequency out of range. %d [Effective range:%d - %d]\n",
|
||||
freq, pwmfreq >> 16, (pwmfreq + 1) >> 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check duty range */
|
||||
|
||||
if ((duty < 0x00000001) || (duty > 0x0000ffff))
|
||||
{
|
||||
pwmerr("Duty out of range. %d\n", duty);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* calcurate period and offperiod */
|
||||
|
||||
period = (pwmfreq * 10 / freq - 5) / 10;
|
||||
if (period > 0xffff)
|
||||
{
|
||||
period = 0xffff;
|
||||
}
|
||||
offperiod = ((0x10000 - duty) * (period + 1) + 0x8000) >> 16;
|
||||
if (offperiod == 0)
|
||||
{
|
||||
offperiod = 0;
|
||||
}
|
||||
else if (period < offperiod)
|
||||
{
|
||||
offperiod = period;
|
||||
}
|
||||
*param = (period & 0xffff) |
|
||||
((offperiod & 0xffff) << PWM_PARAM_OFFPERIOD_SHIFT);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* This method is called when the driver is opened. The lower half driver
|
||||
* should configure and initialize the device so that it is ready for use.
|
||||
* It should not, however, output pulses until the start method is called.
|
||||
*
|
||||
* Input parameters:
|
||||
* dev - A reference to the lower half PWM driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_setup(FAR struct pwm_lowerhalf_s *dev)
|
||||
{
|
||||
FAR struct cxd56_pwm_chan_s *priv = (FAR struct cxd56_pwm_chan_s *)dev;
|
||||
int ret;
|
||||
|
||||
ret = pwm_pin_config(priv->ch);
|
||||
if (ret < 0)
|
||||
{
|
||||
pwmerr("Failed to pinconf():%d\n", channel);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_shutdown
|
||||
*
|
||||
* Description:
|
||||
* This method is called when the driver is closed. The lower half driver
|
||||
* stop pulsed output, free any resources, disable the timer hardware, and
|
||||
* put the system into the lowest possible power usage state
|
||||
*
|
||||
* Input parameters:
|
||||
* dev - A reference to the lower half PWM driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_shutdown(FAR struct pwm_lowerhalf_s *dev)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_start
|
||||
*
|
||||
* Description:
|
||||
* (Re-)initialize the timer resources and start the pulsed output
|
||||
*
|
||||
* Input parameters:
|
||||
* dev - A reference to the lower half PWM driver state structure
|
||||
* info - A reference to the characteristics of the pulsed output
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_start(FAR struct pwm_lowerhalf_s *dev,
|
||||
FAR const struct pwm_info_s *info)
|
||||
{
|
||||
FAR struct cxd56_pwm_chan_s *priv = (FAR struct cxd56_pwm_chan_s *)dev;
|
||||
uint32_t param;
|
||||
int ret;
|
||||
|
||||
if (info->duty <= 0)
|
||||
{
|
||||
/* Output low level if duty cycle is almost 0% */
|
||||
|
||||
PWM_REG(priv->ch)->EN = 0x0;
|
||||
}
|
||||
else if (info->duty >= 65536)
|
||||
{
|
||||
/* Output high level if duty cycle is almost 100% */
|
||||
|
||||
PWM_REG(priv->ch)->PARAM = 1;
|
||||
PWM_REG(priv->ch)->EN = 0x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = convert_freq2period(info->frequency, info->duty, ¶m);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (PWM_REG(priv->ch)->EN & 1)
|
||||
{
|
||||
/* Change duty cycle dynamically if already running */
|
||||
|
||||
PWM_REG(priv->ch)->PARAM = param;
|
||||
return OK;
|
||||
}
|
||||
|
||||
PWM_REG(priv->ch)->EN = 0x0;
|
||||
PWM_REG(priv->ch)->PARAM = param;
|
||||
|
||||
/* Since prescale is not supported, always set to a fixed value '0' */
|
||||
|
||||
PWM_PHASE_REG(priv->ch)->PHASE = 0x0;
|
||||
|
||||
PWM_REG(priv->ch)->EN = 0x1;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_stop
|
||||
*
|
||||
* Description:
|
||||
* Stop the pulsed output and reset the timer resources
|
||||
*
|
||||
* Input parameters:
|
||||
* dev - A reference to the lower half PWM driver state structure
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_stop(FAR struct pwm_lowerhalf_s *dev)
|
||||
{
|
||||
FAR struct cxd56_pwm_chan_s *priv = (FAR struct cxd56_pwm_chan_s *)dev;
|
||||
|
||||
PWM_REG(priv->ch)->EN = 0x0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pwm_ioctl
|
||||
*
|
||||
* Description:
|
||||
* Lower-half logic may support platform-specific ioctl commands
|
||||
*
|
||||
* Input parameters:
|
||||
* dev - A reference to the lower half PWM driver state structure
|
||||
* cmd - The ioctl command
|
||||
* arg - The argument accompanying the ioctl command
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; A negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int pwm_ioctl(FAR struct pwm_lowerhalf_s *dev, int cmd,
|
||||
unsigned long arg)
|
||||
{
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_pwminitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM channel for use with the upper_level PWM driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* channel - pwm channel number.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a pointer to the CXD56 lower half PWM driver is returned.
|
||||
* NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct pwm_lowerhalf_s *cxd56_pwminitialize(uint32_t channel)
|
||||
{
|
||||
FAR struct cxd56_pwm_chan_s *pwmch;
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
#ifdef CONFIG_CXD56_PWM0
|
||||
case CXD56_PWM_CH0:
|
||||
pwmch = &g_pwm_ch0;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_CXD56_PWM1
|
||||
case CXD56_PWM_CH1:
|
||||
pwmch = &g_pwm_ch1;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_CXD56_PWM2
|
||||
case CXD56_PWM_CH2:
|
||||
pwmch = &g_pwm_ch2;
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_CXD56_PWM3
|
||||
case CXD56_PWM_CH3:
|
||||
pwmch = &g_pwm_ch3;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
pwmerr("Illeagal channel number:%d\n", channel);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (FAR struct pwm_lowerhalf_s *)pwmch;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_pwm.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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_CXD56XX_CXD56_PWM_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_PWM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* PWM channel definitions **************************************************/
|
||||
|
||||
#define CXD56_PWM_CH0 0
|
||||
#define CXD56_PWM_CH1 1
|
||||
#define CXD56_PWM_CH2 2
|
||||
#define CXD56_PWM_CH3 3
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_pwminitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM channel for use with the upper_level PWM driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* channel - pwm channel number.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a pointer to the CXD56 lower half PWM driver is returned.
|
||||
* NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct pwm_lowerhalf_s *cxd56_pwminitialize(uint32_t channel);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_PWM_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_timer.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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_CXD56XX_CXD56_TIMER_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_TIMER_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Channel ******************************************************************/
|
||||
|
||||
#define CXD56_TIMER0 (0)
|
||||
#define CXD56_TIMER1 (1)
|
||||
#define CXD56_TIMER_NUM (2)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_timer_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the timer. The timer is initialized and
|
||||
* registers as 'devpath. The initial state of the timer is
|
||||
* disabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the timer. This should be of the form
|
||||
* /dev/timer0
|
||||
* timer - the timer's number.
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_timer_initialize(FAR const char *devpath, int timer);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_TIMER */
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_TIMER_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,94 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_wdt.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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_CXD56XX_CXD56_WDT_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_WDT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "hardware/cxd56_wdt.h"
|
||||
|
||||
#ifdef CONFIG_CXD56_WDT
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_wdt_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the WDT watchdog time. The watchdog timer is initialized and
|
||||
* registered as 'devpath. The initial state of the watchdog time is
|
||||
* disabled.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Values:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cxd56_wdt_initialize(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_CXD56_WDT */
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_WDT_H */
|
||||
@@ -0,0 +1,117 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/hardware/cxd56_timer.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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_CXD56XX_CHIP_CXD56_TIMER_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CHIP_CXD56_TIMER_H
|
||||
|
||||
/****************************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/cxd56xx/chip.h>
|
||||
|
||||
#include "hardware/cxd5602_memorymap.h"
|
||||
|
||||
/****************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************************/
|
||||
|
||||
/* Register addresses *******************************************************************/
|
||||
|
||||
#define CXD56_TIMER0_BASE (CXD56_TIMER_BASE)
|
||||
#define CXD56_TIMER1_BASE (CXD56_TIMER_BASE + 0x0020)
|
||||
#define CXD56_TIMER_LOAD (0x0000) /* Load register */
|
||||
#define CXD56_TIMER_VALUE (0x0004) /* Value register [RO] */
|
||||
#define CXD56_TIMER_CONTROL (0x0008) /* Control register */
|
||||
#define CXD56_TIMER_INTCLR (0x000C) /* Clear Interrupt register [WO] */
|
||||
#define CXD56_TIMER_RIS (0x0010) /* Raw Interrupt Status register [RO] */
|
||||
#define CXD56_TIMER_MIS (0x0014) /* Interrupt Status register [RO] */
|
||||
#define CXD56_TIMER_BGLOAD (0x0018) /* Backround Load register [RO] */
|
||||
#define CXD56_TIMER_ITCR (0x0F00) /* Integration Test Control register */
|
||||
#define CXD56_TIMER_ITOP (0x0F04) /* Integration Test Output register [WO] */
|
||||
#define CXD56_TIMER_PERIPHID0 (0x0FE0) /* Peripheral ID0 register [RO] */
|
||||
#define CXD56_TIMER_PERIPHID1 (0x0FE4) /* Peripheral ID1 register [RO] */
|
||||
#define CXD56_TIMER_PERIPHID2 (0x0FE8) /* Peripheral ID2 register [RO] */
|
||||
#define CXD56_TIMER_PERIPHID3 (0x0FFC) /* Peripheral ID3 register [RO] */
|
||||
#define CXD56_TIMER_PCELLID0 (0x0FF0) /* PrimeCell ID0 register [RO] */
|
||||
#define CXD56_TIMER_PCELLID1 (0x0FF4) /* PrimeCell ID1 register [RO] */
|
||||
#define CXD56_TIMER_PCELLID2 (0x0FF8) /* PrimeCell ID2 register [RO] */
|
||||
#define CXD56_TIMER_PCELLID3 (0x0FFC) /* PrimeCell ID3 register [RO] */
|
||||
|
||||
/* Register bit definitions *************************************************************/
|
||||
|
||||
/* Control Register */
|
||||
|
||||
#define TIMERCTRL_ENABLE (0x1u << 7)
|
||||
#define TIMERCTRL_DISABLE (0x0u << 7)
|
||||
#define TIMERCTRL_PERIODIC (0x1u << 6)
|
||||
#define TIMERCTRL_FREERUN (0x0u << 6)
|
||||
#define TIMERCTRL_INTENABLE (0x1u << 5)
|
||||
#define TIMERCTRL_INTDISABLE (0x0u << 5)
|
||||
#define TIMERCTRL_DIV_256 (0x2u << 2)
|
||||
#define TIMERCTRL_DIV_16 (0x1u << 2)
|
||||
#define TIMERCTRL_DIV_1 (0x0u << 2)
|
||||
#define TIMERCTRL_SIZE_32BIT (0x1u << 1)
|
||||
#define TIMERCTRL_SIZE_16BIT (0x0u << 1)
|
||||
#define TIMERCTRL_MODE_ONESHOT (0x1u << 0)
|
||||
#define TIMERCTRL_MODE_WRAP (0x0u << 0)
|
||||
|
||||
/* Interrupt Register */
|
||||
|
||||
#define TIMER_INTERRUPT (0x1u << 0)
|
||||
|
||||
/* Integration Test Control register */
|
||||
|
||||
#define TIMERITCR_ENABLE (0x1u << 0)
|
||||
|
||||
/* Integration Test Output register */
|
||||
|
||||
#define TIMERITOP_TIMINT1 (0x1u << 0)
|
||||
#define TIMERITOP_TIMINT2 (0x1u << 1)
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CHIP_CXD56_TIMER_H */
|
||||
@@ -0,0 +1,108 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/hardware/cxd56_wdt.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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_CXD56XX_CHIP_CXD56_WDT_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CHIP_CXD56_WDT_H
|
||||
|
||||
/****************************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************************/
|
||||
|
||||
#include <arch/cxd56xx/chip.h>
|
||||
|
||||
#include "hardware/cxd5602_memorymap.h"
|
||||
|
||||
/****************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************************/
|
||||
|
||||
/* WDT register addresses ***************************************************************/
|
||||
|
||||
#define CXD56_WDT_WDOGLOAD (CXD56_WDOG_BASE + 0x0000) /* Load register */
|
||||
#define CXD56_WDT_WDOGVALUE (CXD56_WDOG_BASE + 0x0004) /* Value register [RO] */
|
||||
#define CXD56_WDT_WDOGCONTROL (CXD56_WDOG_BASE + 0x0008) /* Control register */
|
||||
#define CXD56_WDT_WDOGINTCLR (CXD56_WDOG_BASE + 0x000C) /* Clear Interrupt register [WO] */
|
||||
#define CXD56_WDT_WDOGRIS (CXD56_WDOG_BASE + 0x0010) /* Raw Interrupt Status register [RO] */
|
||||
#define CXD56_WDT_WDOGMIS (CXD56_WDOG_BASE + 0x0014) /* Interrupt Status register [RO] */
|
||||
#define CXD56_WDT_WDOGLOCK (CXD56_WDOG_BASE + 0x0C00) /* Lock register */
|
||||
#define CXD56_WDT_WDOGITCR (CXD56_WDOG_BASE + 0x0F00) /* Integration Test Control register */
|
||||
#define CXD56_WDT_WDOGITOP (CXD56_WDOG_BASE + 0x0F04) /* Integration Test Output register [WO] */
|
||||
#define CXD56_WDT_WDOGPERIPHID0 (CXD56_WDOG_BASE + 0x0FE0) /* Peripheral ID0 register [RO] */
|
||||
#define CXD56_WDT_WDOGPERIPHID1 (CXD56_WDOG_BASE + 0x0FE4) /* Peripheral ID1 register [RO] */
|
||||
#define CXD56_WDT_WDOGPERIPHID2 (CXD56_WDOG_BASE + 0x0FE8) /* Peripheral ID2 register [RO] */
|
||||
#define CXD56_WDT_WDOGPERIPHID3 (CXD56_WDOG_BASE + 0x0FFC) /* Peripheral ID3 register [RO] */
|
||||
#define CXD56_WDT_WDOGPCELLID0 (CXD56_WDOG_BASE + 0x0FF0) /* PrimeCell ID0 register [RO] */
|
||||
#define CXD56_WDT_WDOGPCELLID1 (CXD56_WDOG_BASE + 0x0FF4) /* PrimeCell ID1 register [RO] */
|
||||
#define CXD56_WDT_WDOGPCELLID2 (CXD56_WDOG_BASE + 0x0FF8) /* PrimeCell ID2 register [RO] */
|
||||
#define CXD56_WDT_WDOGPCELLID3 (CXD56_WDOG_BASE + 0x0FFC) /* PrimeCell ID3 register [RO] */
|
||||
|
||||
/* WDT register bit definitions *********************************************************/
|
||||
|
||||
/* Control Register */
|
||||
|
||||
#define WDOGCONTROL_RESEN (0x1 << 1) /* enable reset output */
|
||||
#define WDOGCONTROL_INTEN (0x1 << 0) /* enable interrupt output */
|
||||
#define WDOGCONTROL_STOP (0x0) /* stop */
|
||||
|
||||
/* Interrupt Register */
|
||||
|
||||
#define WDOGRIS_RAWINT (0x1 << 0) /* raw interrupt status */
|
||||
#define WDOGRIS_INT (0x1 << 0) /* interrupt status */
|
||||
|
||||
/* Lock Register */
|
||||
|
||||
#define WDOGLOCK_UNLOCK_KEY (0x1ACCE551) /* unlock key */
|
||||
#define WDOGLOCK_ACCESS_ENABLE (0x0 << 0) /* enable write access */
|
||||
#define WDOGLOCK_ACCESS_DISABLE (0x1 << 0) /* disable write access */
|
||||
|
||||
/* Test Register */
|
||||
|
||||
#define WDOGITCR_ENABLE (0x1 << 0) /* enable test mode */
|
||||
#define WDOGITOP_WDOGINT (0x1 << 1) /* output interrupt */
|
||||
#define WDOGITOP_WDOGRES (0x1 << 0) /* output reset */
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************************/
|
||||
|
||||
/****************************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************************/
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CHIP_CXD56_WDT_H */
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "cxd56_power.h"
|
||||
#include "cxd56_flash.h"
|
||||
#include "cxd56_sdcard.h"
|
||||
#include "cxd56_wdt.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* configs/spresense/include/cxd56_pwm.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 __BOARD_COMMON_INCLUDE_CXD56_PWM_H
|
||||
#define __BOARD_COMMON_INCLUDE_CXD56_PWM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* Initialize PWM on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_pwm_setup(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARD_COMMON_INCLUDE_CXD56_PWM_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/****************************************************************************
|
||||
* configs/spresense/include/cxd56_wdt.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 __BOARD_COMMON_INCLUDE_CXD56_WDT_H
|
||||
#define __BOARD_COMMON_INCLUDE_CXD56_WDT_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_wdt_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize WDT on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cxd56_wdt_initialize(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARD_COMMON_INCLUDE_CXD56_WDT_H */
|
||||
@@ -60,10 +60,18 @@ ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += cxd56_leds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_PWM),y)
|
||||
CSRCS += cxd56_pwm.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_SFC),y)
|
||||
CSRCS += cxd56_flash.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SPI),y)
|
||||
CSRCS += cxd56_spi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CXD56_SDIO),y)
|
||||
CSRCS += cxd56_sdcard.c
|
||||
endif
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
@@ -62,6 +63,18 @@
|
||||
#include "cxd56_gpio.h"
|
||||
#include "cxd56_pinconfig.h"
|
||||
|
||||
#ifdef CONFIG_CXD56_PM_PROCFS
|
||||
#include "cxd56_powermgr_procfs.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
#include "cxd56_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WDT
|
||||
#include "cxd56_wdt.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_RTC
|
||||
#include <nuttx/timers/rtc.h>
|
||||
#include "cxd56_rtc.h"
|
||||
@@ -83,6 +96,10 @@
|
||||
#include "cxd56_usbdev.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
#include "cxd56_pwm.h"
|
||||
#endif
|
||||
|
||||
#include "spresense.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -127,6 +144,21 @@ static int nsh_cpucom_initialize(void)
|
||||
# define nsh_cpucom_initialize() (OK)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
static void timer_initialize(void)
|
||||
{
|
||||
int i;
|
||||
char devname[16];
|
||||
|
||||
for (i = 0; i < CXD56_TIMER_NUM; i++)
|
||||
{
|
||||
snprintf(devname, sizeof(devname), "/dev/timer%d", i);
|
||||
cxd56_timer_initialize(devname, i);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -162,6 +194,14 @@ int cxd56_bringup(void)
|
||||
_err("ERROR: Failed to initialize powermgr.\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CXD56_PM_PROCFS
|
||||
ret = cxd56_pm_initialize_procfs();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: Failed to initialize powermgr.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
wlock.info = PM_CPUWAKELOCK_TAG('C', 'A', 0);
|
||||
wlock.count = 0;
|
||||
up_pm_acquire_wakelock(&wlock);
|
||||
@@ -170,6 +210,18 @@ int cxd56_bringup(void)
|
||||
rtc_initialize(0, cxd56_rtc_lowerhalf());
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
timer_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_WDT
|
||||
ret = cxd56_wdt_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: Failed to initialize WDT.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
cxd56_uart_initialize();
|
||||
cxd56_timerisr_initialize();
|
||||
|
||||
@@ -208,6 +260,14 @@ int cxd56_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
ret = board_pwm_setup();
|
||||
if (ret < 0)
|
||||
{
|
||||
_err("ERROR: Failed to initialze pwm. \n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_SFC
|
||||
ret = board_flash_initialize();
|
||||
if (ret < 0)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/****************************************************************************
|
||||
* configs/spresense/src/cxd56_pwm.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/drivers/pwm.h>
|
||||
|
||||
#include "cxd56_pwm.h"
|
||||
|
||||
#ifdef CONFIG_PWM
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_CXD56_PWM0) || defined(CONFIG_CXD56_PWM1) || \
|
||||
defined(CONFIG_CXD56_PWM2) || defined(CONFIG_CXD56_PWM3)
|
||||
static int pwm_initialize(uint32_t channel)
|
||||
{
|
||||
char devname[16];
|
||||
struct pwm_lowerhalf_s *pwm = NULL;
|
||||
int ret;
|
||||
|
||||
/* Call cxd56_pwminitialize() to get an instance of the PWM interface */
|
||||
|
||||
pwm = cxd56_pwminitialize(channel);
|
||||
if (!pwm)
|
||||
{
|
||||
pwmerr("Failed to get the CXD56 PWM%d lower half\n", channel);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* Register the PWM driver at "/dev/pwmX" */
|
||||
|
||||
snprintf(devname, sizeof(devname), "/dev/pwm%d", channel);
|
||||
ret = pwm_register(devname, pwm);
|
||||
if (ret < 0)
|
||||
{
|
||||
pwmerr("pwm_register(%s) failed: %d\n", devname, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_pwm_setup
|
||||
*
|
||||
* Description:
|
||||
* All CXD56 architectures must provide the following interface to work
|
||||
* with examples/pwm.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_pwm_setup(void)
|
||||
{
|
||||
static bool initialized = false;
|
||||
|
||||
/* Have we already initialized? */
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
#ifdef CONFIG_CXD56_PWM0
|
||||
pwm_initialize(CXD56_PWM_CH0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM1
|
||||
pwm_initialize(CXD56_PWM_CH1);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM2
|
||||
pwm_initialize(CXD56_PWM_CH2);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_PWM3
|
||||
pwm_initialize(CXD56_PWM_CH3);
|
||||
#endif
|
||||
|
||||
/* Now we are initialized */
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PWM */
|
||||
@@ -0,0 +1,174 @@
|
||||
/****************************************************************************
|
||||
* configs/spresense/src/cxd56_spi.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* 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 of Sony Semiconductor Solutions Corporation 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
#include "chip.h"
|
||||
#include "hardware/cxd56_spi.h"
|
||||
#include "cxd56_clock.h"
|
||||
#include "cxd56_gpio.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MMCSD_DETECT PIN_AP_CLK
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cxd56_spi0/3/4/5select and cxd56_spi0/3/4/5status
|
||||
*
|
||||
* Description:
|
||||
* The external functions, cxd56_spi1/2/3select and cxd56_spi1/2/3status must be
|
||||
* provided by board-specific logic. They are implementations of the select
|
||||
* and status methods of the SPI interface defined by struct spi_ops_s (see
|
||||
* include/nuttx/spi/spi.h). All other methods (including cxd56_spibus_initialize())
|
||||
* are provided by common CXD56 logic. To use this common SPI logic on your
|
||||
* board:
|
||||
*
|
||||
* 1. Provide logic in cxd56_boardinitialize() to configure SPI chip select
|
||||
* pins.
|
||||
* 2. Provide cxd56_spi0/3/4/5select() and cxd56_spi0/3/4/5status() functions in your
|
||||
* board-specific logic. These functions will perform chip selection and
|
||||
* status operations using GPIOs in the way your board is configured.
|
||||
* 3. Add a calls to cxd56_spibus_initialize() in your low level application
|
||||
* initialization logic
|
||||
* 4. The handle returned by cxd56_spibus_initialize() may then be used to bind the
|
||||
* SPI driver to higher level logic (e.g., calling
|
||||
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to
|
||||
* the SPI MMC/SD driver).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CXD56_SPI0
|
||||
void cxd56_spi0select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t cxd56_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_SPI3
|
||||
void cxd56_spi3select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
|
||||
/* Disable clock gating (clock enable) */
|
||||
|
||||
cxd56_spi_clock_gate_disable(3);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
putreg32(0, CXD56_SPI3_CS);
|
||||
}
|
||||
else
|
||||
{
|
||||
putreg32(1, CXD56_SPI3_CS);
|
||||
}
|
||||
|
||||
/* Enable clock gating (clock disable) */
|
||||
|
||||
cxd56_spi_clock_gate_enable(3);
|
||||
}
|
||||
|
||||
uint8_t cxd56_spi3status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_SPI4
|
||||
void cxd56_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t cxd56_spi4status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
# ifdef CONFIG_CXD56_SPISD
|
||||
if (devid == SPIDEV_MMCSD(0))
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (initialized == false)
|
||||
{
|
||||
/* Input enable */
|
||||
|
||||
cxd56_gpio_config(MMCSD_DETECT, true);
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/* MMCSD_DETECT is mapping to SD Card detect pin
|
||||
* MMCSD_DETECT = 0: Inserted
|
||||
* MMCSD_DETECT = 1: Removed
|
||||
*/
|
||||
return cxd56_gpio_read(MMCSD_DETECT) ? 0 : SPI_STATUS_PRESENT;
|
||||
}
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_SPI5
|
||||
void cxd56_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
|
||||
{
|
||||
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
|
||||
}
|
||||
|
||||
uint8_t cxd56_spi5status(FAR struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user