diff --git a/arch/arm/src/cxd56xx/cxd56_charger.c b/arch/arm/src/cxd56xx/cxd56_charger.c index 6163411cf5..d819b58f52 100644 --- a/arch/arm/src/cxd56xx/cxd56_charger.c +++ b/arch/arm/src/cxd56xx/cxd56_charger.c @@ -140,6 +140,7 @@ static struct charger_dev_s g_chargerdev; /**************************************************************************** * Private Functions ****************************************************************************/ + /**************************************************************************** * Name: charger_therm2temp * @@ -167,11 +168,39 @@ static int charger_therm2temp(int val) return (int)f6; #else - static short T[29] = /* -40,-35,..-20,-15,..,95,100 */ - { 4020, 3986, 3939, 3877, 3759, 3691, 3562, 3405, 3222, 3015, /* -40,.. */ - 2787, 2545, 2296, 2048, 1808, 1582, 1374, 1186, 1020, 874, /* 10,.. */ - 747, 639 , 546, 467, 400, 343, 295, 254, 220 + static short T[29] = + { + 4020, /* -40,-35,..-20,-15,..,95,100 */ + 3986, + 3939, + 3877, + 3759, + 3691, + 3562, + 3405, + 3222, + 3015, /* -40,.. */ + 2787, + 2545, + 2296, + 2048, + 1808, + 1582, + 1374, + 1186, + 1020, + 874, /* 10,.. */ + 747, + 639, + 546, + 467, + 400, + 343, + 295, + 254, + 220 }; /* 60,..,100 */ + int i; int t0 = -45; int t1 = -40; @@ -183,6 +212,7 @@ static int charger_therm2temp(int val) { break; } + t0 += 5; t1 += 5; } @@ -316,6 +346,7 @@ static int charger_online(FAR bool *online) { return -EINVAL; } + *online = true; return OK; } @@ -629,6 +660,7 @@ static int charger_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /**************************************************************************** * Public Functions ****************************************************************************/ + /**************************************************************************** * Name: cxd56_charger_initialize * diff --git a/arch/arm/src/cxd56xx/cxd56_emmc.h b/arch/arm/src/cxd56xx/cxd56_emmc.h index 078ad961dc..cb279b0b7f 100644 --- a/arch/arm/src/cxd56xx/cxd56_emmc.h +++ b/arch/arm/src/cxd56xx/cxd56_emmc.h @@ -36,6 +36,10 @@ #ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_EMMC_H #define __ARCH_ARM_SRC_CXD56XX_CXD56_EMMC_H +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include #ifndef __ASSEMBLY__ @@ -49,6 +53,10 @@ extern "C" #define EXTERN extern #endif +/**************************************************************************** + * Public Function Protoypes + ****************************************************************************/ + int cxd56_emmcinitialize(void); void cxd56_emmcuninitialize(void); diff --git a/arch/arm/src/cxd56xx/cxd56_farapi.c b/arch/arm/src/cxd56xx/cxd56_farapi.c index f9b2d344fd..c5f793a9e1 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapi.c +++ b/arch/arm/src/cxd56xx/cxd56_farapi.c @@ -128,7 +128,8 @@ extern char Image$$MODLIST$$Base[]; static sem_t g_farwait; static sem_t g_farlock; -static struct pm_cpu_wakelock_s g_wlock = { +static struct pm_cpu_wakelock_s g_wlock = +{ .count = 0, .info = PM_CPUWAKELOCK_TAG('R', 'M', 0), }; @@ -269,6 +270,7 @@ void cxd56_farapiinitialize(void) PANIC(); # endif } + #endif nxsem_init(&g_farlock, 0, 1); nxsem_init(&g_farwait, 0, 0); diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.c b/arch/arm/src/cxd56xx/cxd56_gauge.c index 91ba738917..34dac3de9a 100644 --- a/arch/arm/src/cxd56xx/cxd56_gauge.c +++ b/arch/arm/src/cxd56xx/cxd56_gauge.c @@ -33,8 +33,7 @@ * ****************************************************************************/ -/* CXD5247GF is Li-Ion Battery Charger with Power-Path Management. - */ +/* CXD5247GF is Li-Ion Battery Charger with Power-Path Management. */ /**************************************************************************** * Included Files @@ -108,13 +107,13 @@ static const struct file_operations g_gaugeops = gauge_close, /* close */ gauge_read, /* read */ gauge_write, /* write */ - 0, /* seek */ + 0, /* seek */ gauge_ioctl /* ioctl */ #ifndef CONFIG_DISABLE_POLL - , NULL /* poll */ + , NULL /* poll */ #endif #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; @@ -123,6 +122,7 @@ static struct bat_gauge_dev_s g_gaugedev; /**************************************************************************** * Private Functions ****************************************************************************/ + /**************************************************************************** * Name: gauge_get_status ****************************************************************************/ @@ -231,6 +231,7 @@ static int gauge_get_capacity(FAR b16_t *capacity) { return -EIO; } + ret = cxd56_pmic_getlowervol(&lower); if (ret < 0) { diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.h b/arch/arm/src/cxd56xx/cxd56_gauge.h index 94e5e32903..358bff0392 100644 --- a/arch/arm/src/cxd56xx/cxd56_gauge.h +++ b/arch/arm/src/cxd56xx/cxd56_gauge.h @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ****************************************************************************/ + ***************************************************************************/ #ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_GAUGE_H #define __ARCH_ARM_SRC_CXD56XX_CXD56_GAUGE_H diff --git a/arch/arm/src/cxd56xx/cxd56_ge2d.c b/arch/arm/src/cxd56xx/cxd56_ge2d.c index 19460b4a1a..512a56fdde 100644 --- a/arch/arm/src/cxd56xx/cxd56_ge2d.c +++ b/arch/arm/src/cxd56xx/cxd56_ge2d.c @@ -133,7 +133,9 @@ static int ge2d_close(FAR struct file *filep) * Name: ge2d_read ****************************************************************************/ -static ssize_t ge2d_read(FAR struct file *filep, FAR char *buffer, size_t len) +static ssize_t ge2d_read(FAR struct file *filep, + FAR char *buffer, + size_t len) { return 0; } @@ -170,8 +172,12 @@ static ssize_t ge2d_write(FAR struct file *filep, /* Enable error and completion interrupts. */ - bits = GE2D_INTR_WR_ERR | GE2D_INTR_RD_ERR | GE2D_INTR_NDE | GE2D_INTR_DSD | - GE2D_INTR_NDF; + bits = GE2D_INTR_WR_ERR | + GE2D_INTR_RD_ERR | + GE2D_INTR_NDE | + GE2D_INTR_DSD | + GE2D_INTR_NDF; + putreg32(bits, GE2D_INTR_ENABLE); /* Wait for interrupts for processing done. */ diff --git a/arch/arm/src/cxd56xx/cxd56_geofence.c b/arch/arm/src/cxd56xx/cxd56_geofence.c index f41a107c5b..109ac5a8d4 100644 --- a/arch/arm/src/cxd56xx/cxd56_geofence.c +++ b/arch/arm/src/cxd56xx/cxd56_geofence.c @@ -85,12 +85,15 @@ struct cxd56_geofence_dev_s static int cxd56_geofence_open(FAR struct file *filep); static int cxd56_geofence_close(FAR struct file *filep); -static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer, +static ssize_t cxd56_geofence_read(FAR struct file *filep, + FAR char *buffer, size_t len); -static int cxd56_geofence_ioctl(FAR struct file *filep, int cmd, +static int cxd56_geofence_ioctl(FAR struct file *filep, + int cmd, unsigned long arg); #ifndef CONFIG_DISABLE_POLL -static int cxd56_geofence_poll(FAR struct file *filep, FAR struct pollfd *fds, +static int cxd56_geofence_poll(FAR struct file *filep, + FAR struct pollfd *fds, bool setup); #endif @@ -213,9 +216,12 @@ static int cxd56_geofence_add_region(unsigned long arg) { return -EINVAL; } + reg_data = (FAR struct cxd56_geofence_region_s *)arg; - ret = GD_GeoAddRegion(reg_data->id, reg_data->latitude, reg_data->longitude, + ret = GD_GeoAddRegion(reg_data->id, + reg_data->latitude, + reg_data->longitude, reg_data->radius); return ret; @@ -245,6 +251,7 @@ static int cxd56_geofence_modify_region(unsigned long arg) { return -EINVAL; } + reg_data = (FAR struct cxd56_geofence_region_s *)arg; ret = GD_GeoModifyRegion(reg_data->id, reg_data->latitude, @@ -332,6 +339,7 @@ static int cxd56_geofence_get_region_data(unsigned long arg) { return -EINVAL; } + reg_data = (FAR struct cxd56_geofence_region_s *)arg; ret = GD_GeoGetRegionData(reg_data->id, ®_data->latitude, @@ -415,6 +423,7 @@ static int cxd56_geofence_set_mode(unsigned long arg) { return -EINVAL; } + mode = (FAR struct cxd56_geofence_mode_s *)arg; ret = GD_GeoSetOpMode(mode->deadzone, mode->dwell_detecttime); @@ -478,7 +487,7 @@ static void cxd56_geofence_sighandler(uint32_t data, FAR void *userdata) * ****************************************************************************/ -static int cxd56_geofence_initialize(FAR struct cxd56_geofence_dev_s* dev) +static int cxd56_geofence_initialize(FAR struct cxd56_geofence_dev_s *dev) { int32_t ret = 0; @@ -555,6 +564,7 @@ static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer, ret = -EINVAL; goto _err; } + if (len == 0) { ret = 0; @@ -565,7 +575,7 @@ static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer, ret = GD_ReadBuffer(CXD56_CPU1_DEV_GEOFENCE, 0, buffer, len); -_err: + _err: return ret; } @@ -613,7 +623,8 @@ static int cxd56_geofence_ioctl(FAR struct file *filep, int cmd, ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -static int cxd56_geofence_poll(FAR struct file *filep, FAR struct pollfd *fds, +static int cxd56_geofence_poll(FAR struct file *filep, + FAR struct pollfd *fds, bool setup) { FAR struct inode * inode; @@ -738,9 +749,9 @@ static int cxd56_geofence_register(FAR const char *devpath) return ret; -_err2: + _err2: unregister_driver(devpath); -_err0: + _err0: kmm_free(priv); return ret; } diff --git a/arch/arm/src/cxd56xx/cxd56_geofence.h b/arch/arm/src/cxd56xx/cxd56_geofence.h index cb6c764a09..4f3f2938e4 100644 --- a/arch/arm/src/cxd56xx/cxd56_geofence.h +++ b/arch/arm/src/cxd56xx/cxd56_geofence.h @@ -58,7 +58,7 @@ extern "C" #endif /**************************************************************************** - * Public Functions + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c index 6f0e5054f5..b984c38c05 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.c +++ b/arch/arm/src/cxd56xx/cxd56_gnss.c @@ -66,7 +66,7 @@ * External Defined Functions ****************************************************************************/ -extern int PM_LoadImage(int cpuid, const char* filename); +extern int PM_LoadImage(int cpuid, const char *filename); extern int PM_StartCpu(int cpuid, int wait); extern int PM_SleepCpu(int cpuid, int mode); @@ -194,17 +194,23 @@ static int cxd56_gnss_get_satellite_system(FAR struct file *filep, static int cxd56_gnss_set_receiver_position_ellipsoidal(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_receiver_position_orthogonal(FAR struct file *filep, - unsigned long arg); -static int cxd56_gnss_set_ope_mode(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_get_ope_mode(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_set_receiver_position_orthogonal( + FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_set_ope_mode(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_get_ope_mode(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_set_tcxo_offset(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_get_tcxo_offset(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_time(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_get_almanac(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_almanac(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_set_time(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_get_almanac(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_set_almanac(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_get_ephemeris(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_set_ephemeris(FAR struct file *filep, @@ -219,15 +225,18 @@ static int cxd56_gnss_close_cep_data(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_check_cep_data(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_get_cep_age(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_get_cep_age(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_reset_cep_flag(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_set_acquist_data(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_set_frametime(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_tau_gps(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_time_gps(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_set_tau_gps(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_set_time_gps(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_clear_receiver_info(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_set_tow_assist(FAR struct file *filep, @@ -236,13 +245,18 @@ static int cxd56_gnss_set_utc_model(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_control_spectrum(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_start_test(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_stop_test(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_start_test(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_stop_test(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_get_test_result(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_start_pvtlog(FAR struct file *filep, unsigned long arg); -static int cxd56_gnss_stop_pvtlog(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_set_signal(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_start_pvtlog(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_stop_pvtlog(FAR struct file *filep, + unsigned long arg); static int cxd56_gnss_delete_pvtlog(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_get_pvtlog_status(FAR struct file *filep, @@ -286,7 +300,8 @@ static int cxd56_gnss_poll(FAR struct file *filep, FAR struct pollfd *fds, #endif static int8_t cxd56_gnss_select_notifytype(off_t fpos, uint32_t *offset); -static int cxd56_gnss_cpufifo_api(FAR struct file *filep, unsigned int api, +static int cxd56_gnss_cpufifo_api(FAR struct file *filep, + unsigned int api, unsigned int data); /**************************************************************************** @@ -535,7 +550,8 @@ cxd56_gnss_set_receiver_position_ellipsoidal(FAR struct file *filep, pos = (FAR struct cxd56_gnss_ellipsoidal_position_s *)arg; - return GD_SetReceiverPositionEllipsoidal(&pos->latitude, &pos->longitude, + return GD_SetReceiverPositionEllipsoidal(&pos->latitude, + &pos->longitude, &pos->altitude); } @@ -556,8 +572,9 @@ cxd56_gnss_set_receiver_position_ellipsoidal(FAR struct file *filep, * ****************************************************************************/ -static int cxd56_gnss_set_receiver_position_orthogonal(FAR struct file *filep, - unsigned long arg) +static int cxd56_gnss_set_receiver_position_orthogonal( + FAR struct file *filep, + unsigned long arg) { FAR struct cxd56_gnss_orthogonal_position_s *pos; @@ -793,7 +810,8 @@ static int cxd56_gnss_set_almanac(FAR struct file *filep, unsigned long arg) * ****************************************************************************/ -static int cxd56_gnss_get_ephemeris(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_get_ephemeris(FAR struct file *filep, + unsigned long arg) { FAR struct cxd56_gnss_orbital_param_s *param; uint32_t ephemeris_size; @@ -824,7 +842,8 @@ static int cxd56_gnss_get_ephemeris(FAR struct file *filep, unsigned long arg) * ****************************************************************************/ -static int cxd56_gnss_set_ephemeris(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_set_ephemeris(FAR struct file *filep, + unsigned long arg) { FAR struct cxd56_gnss_orbital_param_s *param; @@ -883,6 +902,7 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep, { break; } + n = fwrite(buf, 1, n, fp); offset += n; } @@ -932,7 +952,8 @@ static int cxd56_gnss_erase_backup_data(FAR struct file *filep, * ****************************************************************************/ -static int cxd56_gnss_open_cep_data(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_open_cep_data(FAR struct file *filep, + unsigned long arg) { return cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEPFILE, TRUE); } @@ -1081,7 +1102,8 @@ static int cxd56_gnss_set_acquist_data(FAR struct file *filep, * ****************************************************************************/ -static int cxd56_gnss_set_frametime(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_set_frametime(FAR struct file *filep, + unsigned long arg) { FAR struct cxd56_gnss_agps_frametime_s *frametime; @@ -1226,7 +1248,8 @@ static int cxd56_gnss_set_tow_assist(FAR struct file *filep, * ****************************************************************************/ -static int cxd56_gnss_set_utc_model(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_set_utc_model(FAR struct file *filep, + unsigned long arg) { FAR struct cxd56_gnss_agps_utc_model_s *model; @@ -1354,7 +1377,7 @@ static int cxd56_gnss_stop_test(FAR struct file *filep, unsigned long arg) /* term test */ ret = GD_StopGpsTest(); - if(ret == OK) + if (ret == OK) { /* stop test */ @@ -1474,6 +1497,7 @@ static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg) goto _success; } } + if (sig == NULL) { ret = -ENOENT; @@ -1489,11 +1513,14 @@ static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg) sig->info.signo = setting->signo; sig->info.data = setting->data; -_success: -_err: + _success: + _err: nxsem_post(&priv->devsem); -#endif /* if !defined(CONFIG_DISABLE_SIGNAL) && \ - (CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0) */ +#endif +/* if !defined(CONFIG_DISABLE_SIGNAL) && + * (CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0) + */ + return ret; } @@ -1564,7 +1591,8 @@ static int cxd56_gnss_stop_pvtlog(FAR struct file *filep, unsigned long arg) * ****************************************************************************/ -static int cxd56_gnss_delete_pvtlog(FAR struct file *filep, unsigned long arg) +static int cxd56_gnss_delete_pvtlog(FAR struct file *filep, + unsigned long arg) { return GD_PvtlogDeleteLog(); } @@ -1881,6 +1909,7 @@ static int cxd56_gnss_set_var_ephemeris(FAR struct file *filep, { return -EINVAL; } + param = (FAR struct cxd56_gnss_set_var_ephemeris_s *)arg; return GD_SetVarEphemeris(param->data, param->size); @@ -2010,9 +2039,9 @@ static FAR char *cxd56_gnss_read_cep_file(FAR FILE *fp, int32_t offset, /* send signal to CPU1 in error for just notify completion of read sequence */ -_err1: + _err1: free(buf); -_err0: + _err0: *retval = ret; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_CEP, 0); @@ -2064,11 +2093,13 @@ static void cxd56_gnss_read_backup_file(FAR int *retval) ret = n < 0 ? n : ferror(fp) ? -ENFILE : 0; break; } + ret = GD_WriteBuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, n); if (ret < 0) { break; } + offset += n; } while (n > 0); @@ -2078,7 +2109,7 @@ static void cxd56_gnss_read_backup_file(FAR int *retval) /* Notify the termination of backup sequence by write zero length data */ -_err: + _err: *retval = ret; cxd56_cpu1sigsend(CXD56_CPU1_DATA_TYPE_BKUPFILE, 0); } @@ -2102,9 +2133,11 @@ _err: * ****************************************************************************/ -static void cxd56_gnss_common_signalhandler(uint32_t data, FAR void *userdata) +static void cxd56_gnss_common_signalhandler(uint32_t data, + FAR void *userdata) { - FAR struct cxd56_gnss_dev_s *priv = (FAR struct cxd56_gnss_dev_s *)userdata; + FAR struct cxd56_gnss_dev_s *priv = + (FAR struct cxd56_gnss_dev_s *)userdata; uint8_t sigtype = CXD56_CPU1_GET_DEV(data); int issetmask = 0; int i; @@ -2140,8 +2173,10 @@ static void cxd56_gnss_common_signalhandler(uint32_t data, FAR void *userdata) nxsem_post(&priv->devsem); } -#endif /* if !defined(CONFIG_DISABLE_SIGNAL) && \ - (CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0) */ +#endif +/* if !defined(CONFIG_DISABLE_SIGNAL) && + * (CONFIG_CXD56_GNSS_NSIGNALRECEIVERS != 0) + */ /**************************************************************************** * Name: cxd56_gnss_default_sighandler @@ -2161,7 +2196,8 @@ static void cxd56_gnss_common_signalhandler(uint32_t data, FAR void *userdata) static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) { - FAR struct cxd56_gnss_dev_s *priv = (FAR struct cxd56_gnss_dev_s *)userdata; + FAR struct cxd56_gnss_dev_s *priv = + (FAR struct cxd56_gnss_dev_s *)userdata; int i; int ret; int dtype = CXD56_CPU1_GET_DATA(data); @@ -2182,6 +2218,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) { free(priv->cepbuf); } + return; case CXD56_GNSS_NOTIFY_TYPE_BOOTCOMP: @@ -2194,6 +2231,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) priv->notify_data = dtype; nxsem_post(&priv->syncsem); } + return; case CXD56_GNSS_NOTIFY_TYPE_REQBKUPDAT: @@ -2205,6 +2243,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) { fclose(priv->cepfp); } + priv->cepfp = fopen(CONFIG_CXD56_GNSS_CEP_FILENAME, "rb"); return; @@ -2214,6 +2253,7 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) fclose(priv->cepfp); priv->cepfp = NULL; } + return; default: @@ -2264,7 +2304,8 @@ static void cxd56_gnss_default_sighandler(uint32_t data, FAR void *userdata) static void cxd56_gnss_cpufifoapi_signalhandler(uint32_t data, FAR void *userdata) { - FAR struct cxd56_gnss_dev_s *priv = (FAR struct cxd56_gnss_dev_s *)userdata; + FAR struct cxd56_gnss_dev_s *priv = + (FAR struct cxd56_gnss_dev_s *)userdata; priv->apiret = CXD56_CPU1_GET_DATA((int)data); nxsem_post(&priv->apiwait); @@ -2316,7 +2357,7 @@ static int cxd56_gnss_cpufifo_api(FAR struct file *filep, unsigned int api, ret = priv->apiret; -_err: + _err: return ret; } @@ -2407,7 +2448,7 @@ static int8_t cxd56_gnss_select_notifytype(off_t fpos, FAR uint32_t *offset) * ****************************************************************************/ - static int cxd56_gnss_initialize(FAR struct cxd56_gnss_dev_s* dev) +static int cxd56_gnss_initialize(FAR struct cxd56_gnss_dev_s *dev) { int32_t ret = 0; @@ -2456,6 +2497,7 @@ static int cxd56_gnss_open(FAR struct file *filep) { goto _err1; } + ret = PM_StartCpu(CXD56_GNSS_GPS_CPUID, 1); if (ret < 0) { @@ -2467,9 +2509,9 @@ static int cxd56_gnss_open(FAR struct file *filep) #endif /* Wait the request from GNSS core to restore backup data, - * or for completion of initialization of GNSS core here. - * It is post the semaphore syncsem from cxd56_gnss_default_sighandler. - */ + * or for completion of initialization of GNSS core here. + * It is post the semaphore syncsem from cxd56_gnss_default_sighandler. + */ ret = cxd56_gnss_wait_notify(&priv->syncsem, 5); if (ret < 0) @@ -2490,15 +2532,15 @@ static int cxd56_gnss_open(FAR struct file *filep) priv->num_open++; goto _success; -_err2: + _err2: #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); #endif PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); -_err1: + _err1: nxsem_destroy(&priv->syncsem); -_err0: -_success: + _err0: + _success: nxsem_post(&priv->devsem); return ret; } @@ -2546,7 +2588,7 @@ static int cxd56_gnss_close(FAR struct file *filep) } } -errout: + errout: nxsem_post(&priv->devsem); return ret; } @@ -2579,6 +2621,7 @@ static ssize_t cxd56_gnss_read(FAR struct file *filep, FAR char *buffer, ret = -EINVAL; goto _err; } + if (len == 0) { goto _success; @@ -2614,8 +2657,8 @@ static ssize_t cxd56_gnss_read(FAR struct file *filep, FAR char *buffer, ret = GD_ReadBuffer(type, offset, buffer, len); -_err: -_success: + _err: + _success: filep->f_pos = 0; return ret; } @@ -2634,7 +2677,7 @@ _success: * Returned Value: * Always returns -ENOENT error. * - *****************************************************************************/ + ****************************************************************************/ static ssize_t cxd56_gnss_write(FAR struct file *filep, FAR const char *buffer, size_t buflen) @@ -2799,38 +2842,47 @@ static int cxd56_gnss_register(FAR const char *devpath) CXD56_CPU1_DATA_TYPE_GNSS, cxd56_gnss_default_sighandler }, + { CXD56_CPU1_DATA_TYPE_AGPS, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_RTK, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_GPSEPHEMERIS, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_GLNEPHEMERIS, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_SPECTRUM, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_PVTLOG, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_CPUFIFOAPI, cxd56_gnss_cpufifoapi_signalhandler }, + { CXD56_CPU1_DATA_TYPE_SBAS, cxd56_gnss_common_signalhandler }, + { CXD56_CPU1_DATA_TYPE_DCREPORT, cxd56_gnss_common_signalhandler @@ -2891,6 +2943,7 @@ static int cxd56_gnss_register(FAR const char *devpath) devsig_table[i].sigtype); goto _err2; } + cxd56_cpu1sigregisterhandler(devsig_table[i].sigtype, devsig_table[i].handler); } @@ -2899,10 +2952,10 @@ static int cxd56_gnss_register(FAR const char *devpath) return ret; -_err2: + _err2: unregister_driver(devpath); -_err0: + _err0: kmm_free(priv); return ret; } diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.h b/arch/arm/src/cxd56xx/cxd56_gnss.h index 761e1af2b8..df80cdae99 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.h +++ b/arch/arm/src/cxd56xx/cxd56_gnss.h @@ -80,7 +80,7 @@ extern "C" #endif /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_gnss_api.h b/arch/arm/src/cxd56xx/cxd56_gnss_api.h index 9a545c152f..dc05a9979f 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss_api.h +++ b/arch/arm/src/cxd56xx/cxd56_gnss_api.h @@ -36,9 +36,17 @@ #ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H #define __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include #include +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + /* GD Start mode */ #define CXD56_GNSS_STMOD_COLD 0 @@ -60,6 +68,10 @@ #define CXD56_GNSS_OPMOD_BALANCE 4 #define CXD56_GNSS_OPMOD_1PSS 5 +/**************************************************************************** + * Public Function Protoypes + ****************************************************************************/ + /* Start a positioning * beginning to search the satellites and measure the receiver position */ @@ -132,7 +144,7 @@ int GD_SetFrameTime(uint16_t sec, uint32_t fracSec); /* Get the almanac data */ -int GD_GetAlmanac(uint32_t satellite, FAR uint32_t* almanac, +int GD_GetAlmanac(uint32_t satellite, FAR uint32_t *almanac, FAR uint32_t *almanacSize); /* Set the almanac data */ @@ -141,7 +153,7 @@ int GD_SetAlmanac(uint32_t satellite, FAR uint32_t *almanac); /* Get the Ephemeris data */ -int GD_GetEphemeris(uint32_t satellite, FAR uint32_t* ephemeris, +int GD_GetEphemeris(uint32_t satellite, FAR uint32_t *ephemeris, FAR uint32_t *ephemerisSize); /* Set the Ephemeris data */ @@ -187,7 +199,7 @@ int GD_StopGpsTest(void); /* Get GPS test result */ -int GD_GetGpsTestResult(FAR float* cn, FAR float* doppler); +int GD_GetGpsTestResult(FAR float *cn, FAR float *doppler); /* Control Spectrum output */ @@ -326,7 +338,7 @@ int GD_RtkSetOutputInterval(int interval); /* Get output interval of carrier phase info. [ms] */ -int GD_RtkGetOutputInterval(FAR int* interval); +int GD_RtkGetOutputInterval(FAR int *interval); /* Set GNSS of outputting carrier phase info. */ @@ -334,7 +346,7 @@ int GD_RtkSetGnss(uint32_t gnss); /* Get GNSS of outputting carrier phase info. */ -int GD_RtkGetGnss(FAR uint32_t* pGnss); +int GD_RtkGetGnss(FAR uint32_t *pGnss); /* Set enable/disable GD to notify updating ephemeris */ @@ -342,7 +354,7 @@ int GD_RtkSetEphNotify(int enable); /* Get enable/disable GD to notify updating ephemeris */ -int GD_RtkGetEphNotify(FAR int* enable); +int GD_RtkGetEphNotify(FAR int *enable); /* Set the Ephemeris data Ephemeris data size is variable. */ @@ -350,7 +362,7 @@ int GD_SetVarEphemeris(uint32_t *ephemeris, uint32_t ephemerisSize); /* Get the Ephemeris data Ephemeris data size is variable. */ -int GD_GetVarEphemeris(uint32_t satellite, uint32_t* ephemeris, +int GD_GetVarEphemeris(uint32_t satellite, uint32_t *ephemeris, uint32_t ephemerisSize); #endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H */ diff --git a/arch/arm/src/cxd56xx/cxd56_gpio.c b/arch/arm/src/cxd56xx/cxd56_gpio.c index eb51075bb1..74d35c68e5 100644 --- a/arch/arm/src/cxd56xx/cxd56_gpio.c +++ b/arch/arm/src/cxd56xx/cxd56_gpio.c @@ -259,7 +259,7 @@ bool cxd56_gpio_read(uint32_t pin) return ((regval & (1 << shift)) != 0); } -/************************************************************ +/**************************************************************************** * Name: cxd56_gpio_status * * Description: @@ -268,7 +268,7 @@ bool cxd56_gpio_read(uint32_t pin) * Returned Value: * OK on success; A negated errno value on failure. * - *************************************************************/ + ****************************************************************************/ int cxd56_gpio_status(uint32_t pin, cxd56_gpio_status_t *stat) { diff --git a/arch/arm/src/cxd56xx/cxd56_gpio.h b/arch/arm/src/cxd56xx/cxd56_gpio.h index d9cd5db837..891da8b5c1 100644 --- a/arch/arm/src/cxd56xx/cxd56_gpio.h +++ b/arch/arm/src/cxd56xx/cxd56_gpio.h @@ -80,7 +80,7 @@ extern "C" #endif /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ /**************************************************************************** diff --git a/arch/arm/src/cxd56xx/cxd56_gpioint.c b/arch/arm/src/cxd56xx/cxd56_gpioint.c index 83804abc31..669a1316ff 100644 --- a/arch/arm/src/cxd56xx/cxd56_gpioint.c +++ b/arch/arm/src/cxd56xx/cxd56_gpioint.c @@ -139,8 +139,10 @@ static int alloc_slot(int pin, bool isalloc) { putreg8(INTSEL_DEFAULT_VAL, base + slot); } + break; /* already used */ } + if ((-1 == alloc) && (INTSEL_DEFAULT_VAL == val)) { alloc = slot; @@ -254,6 +256,7 @@ static int set_gpioint_config(int slot, uint32_t gpiocfg) { val &= ~(1 << (slot + 16)); } + putreg32(val, CXD56_TOPREG_PMU_WAKE_TRIG_NOISECUTEN0); /* Configure the polarity */ @@ -307,6 +310,7 @@ static int set_gpioint_config(int slot, uint32_t gpiocfg) DEBUGASSERT(0); break; } + putreg32(val, selreg); return 0; @@ -410,7 +414,8 @@ static int gpioint_handler(int irq, FAR void *context, FAR void *arg) * IRQ number on success; a negated errno value on failure. * * Assumptions: - * The interrupt are disabled so that read-modify-write operations are safe. + * The interrupt are disabled so that read-modify-write operations + * are safe. * ****************************************************************************/ @@ -453,24 +458,24 @@ int cxd56_gpioint_config(uint32_t pin, uint32_t gpiocfg, xcpt_t isr, /* set GPIO interrupt configuration */ if (gpiocfg & GPIOINT_TOGGLE_BOTH_MASK) - { - /* set GPIO pseudo both edge interrupt */ - - flags = enter_critical_section(); - g_bothedge |= (1 << slot); - leave_critical_section(flags); - - /* detect the change from the current signal */ - - if (true == cxd56_gpio_read(pin)) { - gpiocfg |= GPIOINT_SET_POLARITY(GPIOINT_LEVEL_LOW); + /* set GPIO pseudo both edge interrupt */ + + flags = enter_critical_section(); + g_bothedge |= (1 << slot); + leave_critical_section(flags); + + /* detect the change from the current signal */ + + if (true == cxd56_gpio_read(pin)) + { + gpiocfg |= GPIOINT_SET_POLARITY(GPIOINT_LEVEL_LOW); + } + else + { + gpiocfg |= GPIOINT_SET_POLARITY(GPIOINT_LEVEL_HIGH); + } } - else - { - gpiocfg |= GPIOINT_SET_POLARITY(GPIOINT_LEVEL_HIGH); - } - } set_gpioint_config(slot, gpiocfg); @@ -523,6 +528,7 @@ int cxd56_gpioint_pin(int irq) { return -1; } + slot = GET_IRQ2SLOT(irq); return get_slot2pin(slot); } @@ -638,10 +644,12 @@ int cxd56_gpioint_status(uint32_t pin, cxd56_gpioint_status_t *stat) { stat->polarity = GPIOINT_EDGE_RISE; } + if ((g_isr[slot]) && (stat->polarity == GPIOINT_LEVEL_LOW)) { stat->polarity = GPIOINT_EDGE_FALL; } + if ((g_isr[slot]) && (g_bothedge & (1 << slot))) { stat->polarity = GPIOINT_EDGE_BOTH; diff --git a/arch/arm/src/cxd56xx/cxd56_gpioint.h b/arch/arm/src/cxd56xx/cxd56_gpioint.h index c307088b04..0bb114573a 100644 --- a/arch/arm/src/cxd56xx/cxd56_gpioint.h +++ b/arch/arm/src/cxd56xx/cxd56_gpioint.h @@ -64,7 +64,9 @@ /* GPIO Interrupt Polarity Definitions */ /* #define GPIOINT_INSTANT_HIGH (0) */ /* Not supported */ + /* #define GPIOINT_INSTANT_LOW (1) */ /* Not supported */ + #define GPIOINT_LEVEL_HIGH (2) /* High Level */ #define GPIOINT_LEVEL_LOW (3) /* Low Level */ #define GPIOINT_EDGE_RISE (4) /* Rising Edge */ @@ -120,7 +122,7 @@ extern "C" #endif /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ /**************************************************************************** @@ -139,7 +141,8 @@ extern "C" * IRQ number on success; a negated errno value on failure. * * Assumptions: - * The interrupt are disabled so that read-modify-write operations are safe. + * The interrupt are disabled so that read-modify-write operations + * are safe. * ****************************************************************************/ diff --git a/arch/arm/src/cxd56xx/cxd56_i2c.c b/arch/arm/src/cxd56xx/cxd56_i2c.c index fe0f7ab06f..1428ee75d3 100644 --- a/arch/arm/src/cxd56xx/cxd56_i2c.c +++ b/arch/arm/src/cxd56xx/cxd56_i2c.c @@ -94,7 +94,7 @@ struct cxd56_i2cdev_s unsigned int base; /* Base address of registers */ uint16_t irqid; /* IRQ for this device */ int8_t port; /* Port number */ - uint32_t base_freq; /* branch frequency */ + uint32_t base_freq; /* branch frequency */ sem_t mutex; /* Only one thread can access at a time */ sem_t wait; /* Place to wait for transfer completion */ @@ -148,9 +148,11 @@ static struct cxd56_i2cdev_s g_i2c2dev = static inline uint32_t i2c_reg_read(struct cxd56_i2cdev_s *priv, uint32_t offset); -static inline void i2c_reg_write(struct cxd56_i2cdev_s *priv, uint32_t offset, +static inline void i2c_reg_write(struct cxd56_i2cdev_s *priv, + uint32_t offset, uint32_t val); -static inline void i2c_reg_rmw(struct cxd56_i2cdev_s *dev, uint32_t offset, +static inline void i2c_reg_rmw(struct cxd56_i2cdev_s *dev, + uint32_t offset, uint32_t val, uint32_t mask); static int cxd56_i2c_disable(struct cxd56_i2cdev_s *priv); @@ -724,7 +726,8 @@ static int cxd56_i2c_reset(FAR struct i2c_master_s *dev) #if defined(CONFIG_CXD56_I2C0_SCUSEQ) || defined(CONFIG_CXD56_I2C1_SCUSEQ) -static int cxd56_i2c_scurecv(int port, int addr, uint8_t *buf, ssize_t buflen) +static int cxd56_i2c_scurecv(int port, int addr, + uint8_t *buf, ssize_t buflen) { uint16_t inst[2]; int instn; @@ -774,7 +777,8 @@ static int cxd56_i2c_scurecv(int port, int addr, uint8_t *buf, ssize_t buflen) return ret; } -static int cxd56_i2c_scusend(int port, int addr, uint8_t *buf, ssize_t buflen) +static int cxd56_i2c_scusend(int port, int addr, + uint8_t *buf, ssize_t buflen) { uint16_t inst[12]; ssize_t rem; @@ -874,8 +878,8 @@ static inline uint32_t i2c_reg_read(struct cxd56_i2cdev_s *priv, return getreg32(priv->base + offset); } -static inline void i2c_reg_write(struct cxd56_i2cdev_s *priv, uint32_t offset, - uint32_t val) +static inline void i2c_reg_write(struct cxd56_i2cdev_s *priv, + uint32_t offset, uint32_t val) { putreg32(val, priv->base + offset); }