diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b7a5e284385..b55e225e955 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -429,6 +429,7 @@ config ARCH_CHIP_CXD56XX select ARCH_HAVE_MULTICPU select ARCH_GLOBAL_IRQDISABLE select ARCH_HAVE_SDIO if MMCSD + select ARCH_HAVE_MATH_H ---help--- Sony CXD56XX (ARM Cortex-M4) architectures diff --git a/arch/arm/include/cxd56xx/gnss.h b/arch/arm/include/cxd56xx/gnss.h index 77f1a895966..82ef27e5d10 100644 --- a/arch/arm/include/cxd56xx/gnss.h +++ b/arch/arm/include/cxd56xx/gnss.h @@ -527,12 +527,47 @@ extern "C" #define CXD56_GNSS_IOCTL_GET_VAR_EPHEMERIS 49 +/* Set usecase mode + * This command must be issued in idle mode. + * + * param[in] arg + * The usecase definitions + */ + +#define CXD56_GNSS_IOCTL_SET_USECASE 50 + +/* Get usecase mode + * + * param[out] arg + * The usecase definitions + */ + +#define CXD56_GNSS_IOCTL_GET_USECASE 51 + +/* Set enable or disable of 1PPS output + * This command must be issued in idle mode. + * + * param[in] arg + * enable(1) or disable(0) + */ + +#define CXD56_GNSS_IOCTL_SET_1PPS_OUTPUT 52 + +/** + * Get the current 1PPS output setting + * + * @param[out] arg + * enable(1) or disable(0) + */ + +#define CXD56_GNSS_IOCTL_GET_1PPS_OUTPUT 53 + /* check macros for GNSS commands */ #define CXD56_GNSS_IOCTL_INVAL 0 -#define CXD56_GNSS_IOCTL_MAX 50 +#define CXD56_GNSS_IOCTL_MAX 54 -/* Same value to GD Start mode CXD56_GNSS_STMOD_XXXX for GD_Start */ +/* Same value to GD Start mode CXD56_GNSS_STMOD_XXXX for fw_gd_start */ #define CXD56_GNSS_STMOD_COLD 0 /* Cold Start */ #define CXD56_GNSS_STMOD_WARM 1 /* Warm Start */ @@ -593,6 +628,10 @@ extern "C" #define CXD56_GNSS_READ_OFFSET_DCREPORT 0x9800 +/* Offset for SAR/RLM */ + +#define CXD56_GNSS_READ_OFFSET_SARRLM 0x9900 + /* Offset for Spectrum data */ #define CXD56_GNSS_READ_OFFSET_SPECTRUM 0xa000 @@ -643,6 +682,10 @@ extern "C" #define CXD56_GNSS_SIG_DCREPORT 15 +/* Signal type is GAL SAR/RLM */ + +#define CXD56_GNSS_SIG_SARRLM 16 + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/arch/arm/include/cxd56xx/gnss_type.h b/arch/arm/include/cxd56xx/gnss_type.h index 5fdf57965d3..6f84e9b27cb 100644 --- a/arch/arm/include/cxd56xx/gnss_type.h +++ b/arch/arm/include/cxd56xx/gnss_type.h @@ -98,9 +98,13 @@ extern "C" /* GNSS oribital information data type, almanac & ephemeris */ -#define CXD56_GNSS_DATA_GPS 0 /* GPS data type */ -#define CXD56_GNSS_DATA_GLONASS 1 /* Glonass data type */ -#define CXD56_GNSS_DATA_QZSSL1CA 2 /* QZSS/L1CA data type */ +#define CXD56_GNSS_DATA_GPS 0 /* GPS data type */ +#define CXD56_GNSS_DATA_GLONASS 1 /* Glonass data type */ +#define CXD56_GNSS_DATA_QZSSL1CA 2 /* QZSS/L1CA data type */ +#define CXD56_GNSS_DATA_GALILEO 3 /* GALILEO data type */ +#define CXD56_GNSS_DATA_BEIDOU_D1 4 /* BEIDOU D1 data type */ +#define CXD56_GNSS_DATA_BEIDOU_D2 5 /* BEIDOU D2 data type */ +#define CXD56_GNSS_DATA_BEIDOU_ALM 6 /* BEIDOU Almanac data type */ /* GNSS satellite status */ @@ -111,6 +115,37 @@ extern "C" #define CXD56_GNSS_SV_STAT_VISIBLE (1 << 3) /* Visible */ #define CXD56_GNSS_SV_STAT_SUB_CH (1 << 4) /* Sub Ch */ +/* GNSS carrier phase status */ + +#define CXD56_GNSS_SV_PHASESTAT_NONE (0) /* None */ +#define CXD56_GNSS_SV_PHASESTAT_UNKNOWN (1 << 0) /* Unknown */ +#define CXD56_GNSS_SV_PHASESTAT_VALID (1 << 1) /* Valid */ +#define CXD56_GNSS_SV_PHASESTAT_RESET (1 << 2) /* Reset detected */ +#define CXD56_GNSS_SV_PHASESTAT_CYCLE_SLIP (1 << 3) /* Cycle Slip detected */ +#define CXD56_GNSS_SV_PHASESTAT_HALF_CYCLE_RESOLVED (1 << 4) + /* Half cycle ambiguity resolved */ + +/* GNSS Validity of raw measurement */ + +#define CXD56_GNSS_SV_RAWSTAT_NONE (0) /* None */ +#define CXD56_GNSS_SV_RAWSTAT_DOPPLER (1 << 0) /* doppler */ +#define CXD56_GNSS_SV_RAWSTAT_PSEUDORANGE (1 << 1) /* pseudorange */ +#define CXD56_GNSS_SV_RAWSTAT_CARRIERPHASE (1 << 2) /* carrier phase */ +#define CXD56_GNSS_SV_RAWSTAT_SVTIME (1 << 3) /* received sv time */ +#define CXD56_GNSS_SV_RAWSTAT_SVCLOCKPARAM (1 << 4) /* correction parameter of sv clock*/ +#define CXD56_GNSS_SV_RAWSTAT_SVPOSVEL (1 << 5) /* sv position and velocity */ + +/* GNSS Cause of measurement invalidity */ + +#define CXD56_GNSS_SV_INVCAUS_NOT_TRACKED (1 << 0) /* not tracked */ +#define CXD56_GNSS_SV_INVCAUS_NO_SIGNAL (1 << 1) /* no signal */ +#define CXD56_GNSS_SV_INVCAUS_NO_EPHEMERIS (1 << 2) /* no ephemeris */ +#define CXD56_GNSS_SV_INVCAUS_CLK_NOT_ADJUSTED (1 << 3) /* clock not adjusted */ +#define CXD56_GNSS_SV_INVCAUS_BEFORE_TOW_LOCKED (1 << 4) /* before TOW locked */ +#define CXD56_GNSS_SV_INVCAUS_SPEED_LIMIT (1 << 5) /* speed limit */ +#define CXD56_GNSS_SV_INVCAUS_NOT_SUPPORTED (1 << 6) /* not supported */ +#define CXD56_GNSS_SV_INVCAUS_OTHER (1 << 7) /* other */ + /* GNSS 1PPS synchronization status (internal use) */ #define CXD56_GNSS_PPS_NOT_ADJUSTED 0 /* not adjusted */ @@ -153,12 +188,18 @@ extern "C" /* AGPS Measurement tracking data */ -#define CXD56_GNSS_SUPL_TRK_DATA_SIZE (16) +#define CXD56_GNSS_SUPL_TRK_DATA_SIZE (24) /* PVTLOG Max stored log number */ #define CXD56_GNSS_PVTLOG_MAXNUM 170 +/* PVTLOG notify threshold of the stored data */ + +#define CXD56_GNSS_PVTLOG_THRESHOLD_FULL 0 /* Limit of the storage size */ +#define CXD56_GNSS_PVTLOG_THRESHOLD_HALF 1 /* 1/2 of the Storage size */ +#define CXD56_GNSS_PVTLOG_THRESHOLD_ONE_DATA 2 /* Each log stored */ + /* assist bit fields */ #define CXD56_GNSS_PVT_RECEIVER_ASSIST_NONE (0x00) @@ -225,7 +266,7 @@ struct cxd56_gnss_var_s /* Extra data for debugging */ -#define CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA_SIZE (520) +#define CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA_SIZE (568) #define CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA \ uint8_t extra[CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA_SIZE] #define CXD56_GNSS_PVT_SV_EXTRA_DATA_SIZE 40 @@ -246,88 +287,304 @@ struct cxd56_gnss_var_s struct cxd56_gnss_receiver_s { - uint8_t type; /* [out] Position type; 0:Invalid, 1:GNSS, - * 2:IMES, 3:user set, 4:previous - */ - uint8_t dgps; /* [out] FALSE:SGPS, TRUE:DGPS */ - uint8_t pos_fixmode; /* [out] 1:Invalid, 2:2D, 3:3D */ - uint8_t vel_fixmode; /* [out] 1:Invalid, 2:2D VZ, 3:2D Offset, - * 4:3D, 5:1D, 6:PRED - */ - uint8_t numsv; /* [out] Nr of visible satellites */ - uint8_t numsv_tracking; /* [out] Nr of tracking satellites */ - uint8_t numsv_calcpos; /* [out] Nr of satellites to calculate position */ - uint8_t numsv_calcvel; /* [out] Nr of satellites to calculate velocity */ - uint8_t assist; /* [out] bit field - * [7..5]Reserved - * [4]AEP Velocity - * [3]AEP Position - * [2]CEP Velocity - * [1]CEP Position, - * [0]user set - */ - uint8_t pos_dataexist; /* [out] 0:none, 1:exist */ - uint16_t svtype; /* [out] Using sv system, bit field; - * bit0:GPS, bit1:GLONASS, bit2:SBAS, - * bit3:QZSS_L1CA, bit4:IMES, - * bit5:QZSS_L1SAIF, bit6:Beidu, - * bit7:Galileo - */ - uint16_t pos_svtype; /* [out] using sv system, bit field; - * bit0:GPS, bit1:GLONASS, bit2:SBAS, - * bit3:QZSS_L1CA, bit4:IMES, - * bit5:QZSS_L1SAIF, bit6:Beidu, - * bit7:Galileo - * */ - uint16_t vel_svtype; /* [out] using sv system, bit field; bit0:GPS, - * bit0:GPS, bit1:GLONASS, bit2:SBAS, - * bit3:QZSS_L1CA, bit4:IMES, - * bit5:QZSS_L1SAIF, bit6:Beidu, - * bit7:Galileo - */ - uint32_t possource; /* [out] position source; 0:Invalid, 1:GNSS, - * 2:IMES, 3:user set, 4:previous - */ + /* [out] Position type; 0:Invalid, 1:GNSS, + * 2:IMES, 3:user set, 4:previous + */ - int32_t tcxo_offset; /* [out] TCXO offset[Hz] */ - struct cxd56_gnss_dop_s pos_dop; /* [out] DOPs of Position */ - struct cxd56_gnss_dop_s vel_idx; /* [out] Weighted DOPs of Velocity */ - struct cxd56_gnss_var_s pos_accuracy; /* [out] Accuracy of Position */ - double latitude; /* [out] Latitude [degree] */ - double longitude; /* [out] Longitude [degree] */ - double altitude; /* [out] Altitude [m] */ - double geoid; /* [out] Geoid height [m] */ - float velocity; /* [out] Velocity [m/s] */ - float direction; /* [out] Direction [degree] */ - struct cxd56_gnss_date_s date; /* [out] Current day (UTC) */ - struct cxd56_gnss_time_s time; /* [out] Current time (UTC) */ - struct cxd56_gnss_date_s gpsdate; /* [out] Current day (GPS) */ - struct cxd56_gnss_time_s gpstime; /* [out] Current time (GPS) */ - struct cxd56_gnss_time_s receivetime; /* [out] Receive time (UTC) */ - uint32_t priv; /* [out] For internal use */ - CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA; /* [out] Receiver extra data */ + uint8_t type; + + /* [out] FALSE:SGPS, TRUE:DGPS */ + + uint8_t dgps; + + /* [out] 1:Invalid, 2:2D, 3:3D */ + + uint8_t pos_fixmode; + + /* [out] 1:Invalid, 2:2D VZ, 3:2D Offset, + * 4:3D, 5:1D, 6:PRED + */ + + uint8_t vel_fixmode; + + /* [out] Nr of visible satellites */ + + uint8_t numsv; + + /* [out] Nr of tracking satellites */ + + uint8_t numsv_tracking; + + /* [out] Nr of satellites to calculate position */ + + uint8_t numsv_calcpos; + + /* [out] Nr of satellites to calculate velocity */ + + uint8_t numsv_calcvel; + + /* [out] bit field + * [7..5]Reserved + * [4]AEP Velocity + * [3]AEP Position + * [2]CEP Velocity + * [1]CEP Position, + * [0]user set + */ + + uint8_t assist; + + /* [out] 0:none, 1:exist */ + + uint8_t pos_dataexist; + + /* [out] Using sv system, bit field; + * bit0:GPS, bit1:GLONASS, bit2:SBAS, + * bit3:QZSS_L1CA, bit4:IMES, + * bit5:QZSS_L1SAIF, bit6:BeiDou, + * bit7:Galileo + */ + + uint16_t svtype; + + /* [out] using sv system, bit field; + * bit0:GPS, bit1:GLONASS, bit2:SBAS, + * bit3:QZSS_L1CA, bit4:IMES, + * bit5:QZSS_L1SAIF, bit6:BeiDou, + * bit7:Galileo + */ + + uint16_t pos_svtype; + + /* [out] using sv system, bit field; bit0:GPS, + * bit0:GPS, bit1:GLONASS, bit2:SBAS, + * bit3:QZSS_L1CA, bit4:IMES, + * bit5:QZSS_L1SAIF, bit6:BeiDou, + * bit7:Galileo + */ + + uint16_t vel_svtype; + + /* [out] position source; 0:Invalid, 1:GNSS, + * 2:IMES, 3:user set, 4:previous + */ + + uint32_t possource; + + /* [out] TCXO offset[Hz] */ + + float tcxo_offset; + + /* [out] DOPs of Position */ + + struct cxd56_gnss_dop_s pos_dop; + + /* [out] Weighted DOPs of Velocity */ + + struct cxd56_gnss_dop_s vel_idx; + + /* [out] Accuracy of Position */ + + struct cxd56_gnss_var_s pos_accuracy; + + /* [out] Latitude [degree] */ + + double latitude; + + /* [out] Longitude [degree] */ + + double longitude; + + /* [out] Altitude [m] */ + + double altitude; + + /* [out] Geoid height [m] */ + + double geoid; + + /* [out] Velocity [m/s] */ + + float velocity; + + /* [out] Direction [degree] */ + + float direction; + + /* [out] Current day (UTC) */ + + struct cxd56_gnss_date_s date; + + /* [out] Current time (UTC) */ + + struct cxd56_gnss_time_s time; + + /* [out] Current day (GPS) */ + + struct cxd56_gnss_date_s gpsdate; + + /* [out] Current time (GPS) */ + + struct cxd56_gnss_time_s gpstime; + + /* [out] Receive time (UTC) */ + + struct cxd56_gnss_time_s receivetime; + + /* [out] For internal use */ + + uint32_t priv; + + /* [out] Leap Second[sec] */ + + int8_t leap_sec; + + /* [out] elapsed time + * from reset in ns + */ + + uint64_t time_ns; + + /* [out] elapsed time + * from GPS epoch in ns + */ + + int64_t full_bias_ns; + + /* [out] Receiver extra data */ + + CXD56_GNSS_PVT_RECEIVER_EXTRA_DATA; +}; + +/* satellite position (ECEF) */ + +struct cxd56_gnss_pvt_sv_pos_s +{ + double dx; /* X [m] */ + double dy; /* Y [m] */ + double dz; /* Z [m] */ +}; + +/* satellite velocity (ECEF) */ + +struct cxd56_gnss_pvt_sv_vel_s +{ + float fvx; /* Vx [m/s] */ + float fvy; /* Vy [m/s] */ + float fvz; /* Vz [m/s] */ }; /* GNSS satellite data */ struct cxd56_gnss_sv_s { - uint16_t type; /* [out] Using sv system, bit field; bit0:GPS, - * bit1:GLONASS, bit2:SBAS, bit3:QZSS_L1CA, - * bit4:IMES, bit5:QZSS_L1SAIF, bit6:Beidu, - * bit7:Galileo - * same as struct cxd56_gnss_receiver_s::svtype - */ - uint8_t svid; /* [out] Satellite id */ - uint8_t stat; /* Using sv info, bit field; bit0:tracking, - * bit1:positioning, bit2:calculating velocity, - * bit3:visible satellite - */ - uint8_t elevation; /* [out] Elevation [degree] */ - int16_t azimuth; /* [out] Azimuth [degree] */ - float siglevel; /* [out] CN */ + /* [out] Using sv system, bit field; bit0:GPS, + * bit1:GLONASS, bit2:SBAS, bit3:QZSS_L1CA, + * bit4:IMES, bit5:QZSS_L1SAIF, bit6:BeiDou, + * bit7:Galileo + * same as struct cxd56_gnss_receiver_s::svtype + */ - CXD56_GNSS_PVT_SV_EXTRA_DATA; /* [out] Sv extra data */ + uint16_t type; + + /* [out] Satellite id */ + + uint8_t svid; + + /* Using sv info, bit field; bit0:tracking, + * bit1:positioning, bit2:calculating velocity, + * bit3:visible satellite + */ + + uint8_t stat; + + /* [out] Azimuth [degree] */ + + int16_t azimuth; + + /* [out] carrier phase status, bit field; + * bit0: unknown, bit1: valid, bit2: reset, + * bit3: cycle slip (Loss of Lock Indicator) + */ + + uint8_t phase_stat; + + /* [out] navigation message of the satellite vehicle + * bit0: 1 = almanac OK, 0 = almanac NG + */ + + uint8_t nav_message_info; + + /* [out] Validity of raw measurement, bit field; + * bit0: doppler, bit1: pseudorange, + * bit2: carrierphase, bit3: svtime, + * bit4: svClockOffset & svClockDrift + * bit5: svpos & svvel + */ + + uint8_t raw_stat; + + /* [out] Cause of measurement invalidity, bit field; + * bit0: not tracked, bit1: no signal, + * bit2: no ephemeris + * bit3: clock not adjusted, + * bit4: before TOW locked + * bit5: not supported, bit6: speed limit + */ + + uint8_t invalid_cause; + + /* [out] Elevation [degree] */ + + uint8_t elevation; + + /* [out] Frequency Channel (Glonass) */ + + int8_t freqchannel; + + /* [out] CN */ + + float siglevel; + + /* [out] Doppler frequency [Hz] */ + + float doppler; + + /* [out] Pseudo range [m] */ + + double pseudo_range; + + /* [out] Carrier phase [cycle] */ + + double carrier_phase; + + /* [out] received sv time in [sec] */ + + double sv_time; + + /* [out] Time tracked[sec] */ + + float timetracked; + + /* [out] Satellite clock offset [m] (Af0 * C) */ + + float svclockoffset; + + /* [out] Satellite clock drift [m/s] (Af1 * C) */ + + float svclockdrift; + + /* [out] satellite position (ECEF) */ + + struct cxd56_gnss_pvt_sv_pos_s svpos; + + /* [out] satellite velocity (ECEF) */ + + struct cxd56_gnss_pvt_sv_vel_s svvel; + + /* [out] Sv extra data */ + + CXD56_GNSS_PVT_SV_EXTRA_DATA; }; /* Positioning data with SV data */ @@ -353,6 +610,26 @@ struct cxd56_gnss_dcreport_data_s uint8_t svid; /* [out] Satellite id */ }; +/* Galileo SAR/RLM data */ + +struct cxd56_gnss_sarrlm_data_s +{ + uint8_t svid; /* SVID */ + uint8_t rlmtype; /* 0x0:Short, 0x1:Long */ + uint8_t datacmplt; /* 0xf:Short, 0xff:Long */ + uint8_t msgcode; /* Massage code(4bit) */ + uint32_t beacon_id1; /* Beacon ID (bit[31:0]) */ + uint32_t beacon_id2; /* Beacon ID (bit[59:32]) */ + uint32_t param1; /* Short:16bit, Long:96bit(bit[31:0]) */ + uint32_t param2; /* Long:96bit(bit[63:31]) */ + uint32_t param3; /* Long:96bit(bit[95:63]) */ +}; + +struct cxd56_gnss_gal_sarrlm_s +{ + struct cxd56_gnss_sarrlm_data_s data; +}; + /* SF_EVENT_GNSS_MEASUREMENT_VALUE */ /* SUPL tracking data */ @@ -461,16 +738,22 @@ struct cxd56_rtk_sv_s uint32_t gnss; /* [out] GNSS type (CXD56_GNSS_GNSS_XXX) */ int8_t svid; /* [out] Satellite id */ int8_t fdmch; /* [out] Frequency slot for GLONASS (-7 ... 6) */ - int16_t cn; /* [out] [0.01dBHz] CN */ int8_t polarity; /* [out] Carrier polarity * (0: not inverted, 1: inverted) */ + int16_t cn; /* [out] [0.01dBHz] CN */ int8_t lastpreamble; /* [out] Parity of last premable (0: ok, 1: ng) */ int8_t lli; /* [out] Lock loss indicator * (0: no lock loss, 1: lock loss) */ int8_t ch; /* [out] TRK channel number */ float c2p; /* [out] C2P (0 ... 1.0) */ + uint8_t phase_stat; /* [out] carrier phase status, bit field; + * bit0: unknown, bit1: valid, bit2: reset, + * bit3: cycle slip (Loss of Lock Indicator) + */ + float timetracked; /* [out] Tracked time[sec] */ + double sv_time; /* [out] received transmit time of the SV[sec] */ float doppler; /* [out] [Hz] Doppler shift */ }; @@ -604,6 +887,16 @@ struct cxd56_gnss_sbasdata_s uint8_t sbasmsg[CXD56_GNSS_SBAS_MESSAGE_DATA_LEN]; /* sbas message data */ }; +/* RTK Setting Parameter */ + +struct cxd56_gnss_rtk_setting_s +{ + int interval; /* Interval */ + uint32_t gnss; /* Satellite system */ + int eph_out; /* Ephemeris out enable */ + uint64_t sbas_out; /* sbas out enable */ +}; + /* PVTLog Parameter */ /* Latitude of PVT data */ diff --git a/arch/arm/src/cxd56xx/Kconfig b/arch/arm/src/cxd56xx/Kconfig index 84a58ede598..49839eba95c 100644 --- a/arch/arm/src/cxd56xx/Kconfig +++ b/arch/arm/src/cxd56xx/Kconfig @@ -26,6 +26,18 @@ config CXD56_WLCSP endchoice +choice + prompt "CXD56xx core selection" + default CXD56_MAINCORE + +config CXD56_MAINCORE + bool "Main Core" + +config CXD56_SUBCORE + bool "Sub Core" + +endchoice + config CXD56_CUSTOM_PINCONFIG bool "Board-specific pin configuration" default n @@ -60,10 +72,12 @@ config CXD56_SPH config CXD56_PMIC bool - default y + default y if CXD56_MAINCORE + default n if CXD56_SUBCORE config CXD56_CPUFIFO bool + default y config CXD56_ICC bool @@ -81,8 +95,8 @@ config CXD56_CPUFIFO_NBUFFERS config CXD56_FARAPI bool - default y - select CXD56_CPUFIFO + default y if CXD56_MAINCORE + default n if CXD56_SUBCORE menu "Far API Configuration" depends on CXD56_FARAPI @@ -192,12 +206,25 @@ menuconfig CXD56_PM if CXD56_PM +config CPUFREQ_RELEASE_LOCK + bool "Dynamic clock control" + default n + ---help--- + CPU frequency lock allows the system clock to be changed dynamically. + Acquiring the higher frequency lock will improve the performance, but + will increase the power consumption. If this is enabled, the system + clock is the lower frequency unless the frequency lock is acquired. + If disabled, the system clock will not change and will remain at the + maximum system clock. + 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 + config CXD56_GAUGE bool "CXD5247 battery gauge" default n @@ -241,7 +268,6 @@ config CXD56_CHARGER_DEBUG Enable battery charger driver debug messages. endif -endif # CXD56_PM comment "Peripheral Support" @@ -321,6 +347,15 @@ config CXD56_SPI if CXD56_SPI +config CXD56_SPI_DRIVER + bool "SPI character driver" + default y + select SPI_DRIVER + ---help--- + Build in support for a character driver at /dev/spi[N] that may be + used to perform SPI bus transfers from applications. The intent of + this driver is to support SPI testing. + config CXD56_SPI0 bool "SPI0" @@ -482,6 +517,7 @@ endif config CXD56_I2C bool "I2C" + select I2C if CXD56_I2C @@ -598,6 +634,27 @@ config CXD56_HPADC0_FREQ RCOSC : 0 to 7 (0 ~ 6 : over-sampling mode) XOSC : 0 to 7 (0 ~ 6 : over-sampling mode) +choice + prompt "Input Gain" + default CXD56_HPADC0_INPUT_GAIN_0DB + +config CXD56_HPADC0_INPUT_GAIN_M6DB + bool "-6 dB" + +config CXD56_HPADC0_INPUT_GAIN_0DB + bool "0 dB" + +config CXD56_HPADC0_INPUT_GAIN_6DB + bool "+6 dB" + +config CXD56_HPADC0_INPUT_GAIN_12DB + bool "+12 dB" + +config CXD56_HPADC0_INPUT_GAIN_14DB + bool "+14 dB" + +endchoice + config CXD56_HPADC0_OFFSET int "Offset" default 0 @@ -615,6 +672,17 @@ config CXD56_HPADC0_FSIZE ---help--- SCU FIFO size +config CXD56_HPADC0_HIGHSPEED + bool "High speed support" + default n + depends on !CXD56_LPADC && !CXD56_HPADC1 && !CXD56_I2C0_SCUSEQ && !CXD56_I2C1_SCUSEQ && !CXD56_SPI3_SCUSEQ + ---help--- + Enable high-speed ADC. It supports a sampling rate of up to 512kHz + only for HPADC0. In other to use the 512kHz sampling rate, SCU clock + mode should be selected CXD56_SCU_XOSC, and Coefficient of sampling + frequency CXD56_HPADC0_FREQ should be set 2. When this is enabled, + other ADC channels and SCU sequencers cannot be used at the same time. + endif # CXD56_HPADC0 menuconfig CXD56_HPADC1 @@ -642,6 +710,27 @@ config CXD56_HPADC1_FREQ RCOSC : 0 to 7 (0 ~ 6 : over-sampling mode) XOSC : 0 to 7 (0 ~ 6 : over-sampling mode) +choice + prompt "Input Gain" + default CXD56_HPADC1_INPUT_GAIN_0DB + +config CXD56_HPADC1_INPUT_GAIN_M6DB + bool "-6 dB" + +config CXD56_HPADC1_INPUT_GAIN_0DB + bool "0 dB" + +config CXD56_HPADC1_INPUT_GAIN_6DB + bool "+6 dB" + +config CXD56_HPADC1_INPUT_GAIN_12DB + bool "+12 dB" + +config CXD56_HPADC1_INPUT_GAIN_14DB + bool "+14 dB" + +endchoice + config CXD56_HPADC1_OFFSET int "Offset" default 0 @@ -669,7 +758,7 @@ if CXD56_LPADC choice prompt "Select LPADC channel" - default CXD56_LPADC0 + default CXD56_LPADC_ALL config CXD56_LPADC0 bool "LPADC channel 0" @@ -713,7 +802,8 @@ menu "LPADC0" config CXD56_LPADC0_FREQ int "Coefficient of sampling frequency" - default 12 + default 12 if CXD56_SCU_32K + default 7 if CXD56_SCU_RCOSC || CXD56_SCU_XOSC range 11 15 if CXD56_SCU_32K && CXD56_LPADC0 range 3 15 if CXD56_SCU_RCOSC && CXD56_LPADC0 range 2 15 if CXD56_SCU_XOSC && CXD56_LPADC0 @@ -767,7 +857,8 @@ menu "LPADC1" config CXD56_LPADC1_FREQ int "Coefficient of sampling frequency" - default 12 + default 12 if CXD56_SCU_32K + default 7 if CXD56_SCU_RCOSC || CXD56_SCU_XOSC range 11 15 if CXD56_SCU_32K && CXD56_LPADC1 range 3 15 if CXD56_SCU_RCOSC && CXD56_LPADC1 range 2 15 if CXD56_SCU_XOSC && CXD56_LPADC1 @@ -821,7 +912,8 @@ menu "LPADC2" config CXD56_LPADC2_FREQ int "Coefficient of sampling frequency" - default 12 + default 12 if CXD56_SCU_32K + default 7 if CXD56_SCU_RCOSC || CXD56_SCU_XOSC range 11 15 if CXD56_SCU_32K && CXD56_LPADC2 range 3 15 if CXD56_SCU_RCOSC && CXD56_LPADC2 range 2 15 if CXD56_SCU_XOSC && CXD56_LPADC2 @@ -867,7 +959,8 @@ menu "LPADC3" config CXD56_LPADC3_FREQ int "Coefficient of sampling frequency" - default 12 + default 12 if CXD56_SCU_32K + default 7 if CXD56_SCU_RCOSC || CXD56_SCU_XOSC range 11 15 if CXD56_SCU_32K && CXD56_LPADC3 range 3 15 if CXD56_SCU_RCOSC && CXD56_LPADC3 range 2 15 if CXD56_SCU_XOSC && CXD56_LPADC3 @@ -1035,7 +1128,7 @@ menuconfig CXD56_SDIO default n select ARCH_HAVE_SDIO select SDIO_BLOCKSETUP - select SCHED_HPWORK + depends on SCHED_HPWORK if CXD56_SDIO @@ -1062,12 +1155,6 @@ config CXD56_SDIO_DISABLE_CD_WP Disable the CD and WP pin for Embedded SDIO.If the CD pin is not disable, the SDIO initialization will be failed. -config CXD56_SDIO_ENABLE_MULTIFUNCTION - bool "Enable SDIO multi-function" - default n - ---help--- - Support multi-function with SDIO interfaced peripheral other than SD Card. - endif # SDIO Configuration menuconfig CXD56_SPISD @@ -1083,6 +1170,13 @@ config CXD56_SPISD_SLOT_NO ---help--- Select spi sd card slot number. +config CXD56_SPISD_SPI_CH + int "SPI channel number" + default 5 + range 4 5 + ---help--- + Select spi channel number to use spi sd card. + endif # SPISD Configuration config CXD56_EMMC @@ -1141,6 +1235,22 @@ config CXD56_GNSS_FW_RTK ---help--- This is experimental function. +choice + prompt "GNSS 1PPS output" + default CXD56_GNSS_1PPS_PIN_HIF_IRQ_OUT + +config CXD56_GNSS_1PPS_PIN_GNSS_1PPS_OUT + bool "Use PIN_GNSS_1PPS_OUT" + depends on CXD56_FCBGA + ---help--- + GNSS 1PPS output from PIN_GNSS_1PPS_OUT pin. + +config CXD56_GNSS_1PPS_PIN_HIF_IRQ_OUT + bool "Use PIN_HIF_IRQ_OUT" + ---help--- + GNSS 1PPS output from PIN_HIF_IRQ_OUT pin. +endchoice + config CXD56_GNSS_DEBUG_FEATURE bool "GNSS debug feature" diff --git a/arch/arm/src/cxd56xx/Make.defs b/arch/arm/src/cxd56xx/Make.defs index 54feefedd46..8c3d1420c1d 100644 --- a/arch/arm/src/cxd56xx/Make.defs +++ b/arch/arm/src/cxd56xx/Make.defs @@ -45,7 +45,7 @@ endif endif CMN_CSRCS = arm_assert.c arm_blocktask.c arm_copyfullstate.c -CMN_CSRCS += arm_createstack.c arm_mdelay.c arm_udelay.c arm_exit.c +CMN_CSRCS += arm_createstack.c arm_exit.c CMN_CSRCS += arm_initialize.c arm_initialstate.c arm_interruptcontext.c CMN_CSRCS += arm_memfault.c arm_modifyreg8.c arm_modifyreg16.c arm_modifyreg32.c CMN_CSRCS += arm_releasepending.c arm_releasestack.c arm_reprioritizertr.c diff --git a/arch/arm/src/cxd56xx/chip.h b/arch/arm/src/cxd56xx/chip.h index 0ccfe5ffda2..33240c5b08a 100644 --- a/arch/arm/src/cxd56xx/chip.h +++ b/arch/arm/src/cxd56xx/chip.h @@ -50,20 +50,4 @@ #include "hardware/cxd5602_memorymap.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - #endif /* __ARCH_ARM_SRC_CXD56XX_CHIP_H */ diff --git a/arch/arm/src/cxd56xx/cxd56_adc.c b/arch/arm/src/cxd56xx/cxd56_adc.c index ee49b5eebcd..fffcae2fe01 100644 --- a/arch/arm/src/cxd56xx/cxd56_adc.c +++ b/arch/arm/src/cxd56xx/cxd56_adc.c @@ -124,6 +124,40 @@ #define ADC_BYTESPERSAMPLE 2 #define ADC_ELEMENTSIZE 0 +/* Input Gain setting */ + +#define INPUT_GAIN(a, g1, g2) (((a) << 24) | ((g2) << 16) | ((g1) << 12)) +#define INPUT_GAIN_MASK INPUT_GAIN(3, 15, 15) +#define INPUT_GAIN_MINUS_6DB INPUT_GAIN(2, 0, 0) +#define INPUT_GAIN_THROUGH INPUT_GAIN(0, 0, 0) +#define INPUT_GAIN_PLUS_6DB INPUT_GAIN(0, 4, 0) +#define INPUT_GAIN_PLUS_12DB INPUT_GAIN(0, 12, 0) +#define INPUT_GAIN_PLUS_14DB INPUT_GAIN(0, 4, 8) + +#if defined(CONFIG_CXD56_HPADC0_INPUT_GAIN_M6DB) +#define HPADC0_INPUT_GAIN INPUT_GAIN_MINUS_6DB +#elif defined(CONFIG_CXD56_HPADC0_INPUT_GAIN_6DB) +#define HPADC0_INPUT_GAIN INPUT_GAIN_PLUS_6DB +#elif defined(CONFIG_CXD56_HPADC0_INPUT_GAIN_12DB) +#define HPADC0_INPUT_GAIN INPUT_GAIN_PLUS_12DB +#elif defined(CONFIG_CXD56_HPADC0_INPUT_GAIN_14DB) +#define HPADC0_INPUT_GAIN INPUT_GAIN_PLUS_14DB +#else +#define HPADC0_INPUT_GAIN INPUT_GAIN_THROUGH +#endif + +#if defined(CONFIG_CXD56_HPADC1_INPUT_GAIN_M6DB) +#define HPADC1_INPUT_GAIN INPUT_GAIN_MINUS_6DB +#elif defined(CONFIG_CXD56_HPADC1_INPUT_GAIN_6DB) +#define HPADC1_INPUT_GAIN INPUT_GAIN_PLUS_6DB +#elif defined(CONFIG_CXD56_HPADC1_INPUT_GAIN_12DB) +#define HPADC1_INPUT_GAIN INPUT_GAIN_PLUS_12DB +#elif defined(CONFIG_CXD56_HPADC1_INPUT_GAIN_14DB) +#define HPADC1_INPUT_GAIN INPUT_GAIN_PLUS_14DB +#else +#define HPADC1_INPUT_GAIN INPUT_GAIN_THROUGH +#endif + typedef enum adc_ch { CH0 = 0, /* LPADC0 */ @@ -523,6 +557,15 @@ static int adc_start(adc_ch_t ch, uint8_t freq, FAR struct seq_s *seq, (uint32_t *)SCUADCIF_HPADC1_A2; putreg32(1, addr); + /* HPADC.A3 */ + + addr = (ch == CH4) ? (uint32_t *)SCUADCIF_HPADC0_A3 : + (uint32_t *)SCUADCIF_HPADC1_A3; + + val = getreg32(addr) & ~INPUT_GAIN_MASK; + val |= (ch == CH4) ? HPADC0_INPUT_GAIN : HPADC1_INPUT_GAIN; + putreg32(val, addr); + /* HPADC.D0 */ addr = (ch == CH4) ? (uint32_t *)SCUADCIF_HPADC0_D0 : diff --git a/arch/arm/src/cxd56xx/cxd56_allocateheap.c b/arch/arm/src/cxd56xx/cxd56_allocateheap.c index 16d87896247..fa24c29f21d 100644 --- a/arch/arm/src/cxd56xx/cxd56_allocateheap.c +++ b/arch/arm/src/cxd56xx/cxd56_allocateheap.c @@ -83,7 +83,9 @@ const uint32_t g_idle_topstack = (uint32_t)&_ebss + # error Invalid memory configuration #endif -#define MM_RAM_END CONFIG_RAM_END +/* __stack is the end of RAM address, it would be set by linker. */ + +extern char __stack[]; /**************************************************************************** * Private Functions @@ -131,7 +133,7 @@ void up_allocate_heap(FAR void **heap_start, size_t *heap_size) board_autoled_on(LED_HEAPALLOCATE); *heap_start = (FAR void *)g_idle_topstack; - *heap_size = MM_RAM_END - g_idle_topstack; + *heap_size = (uint32_t)&__stack - g_idle_topstack; /* Colorize the heap for debug */ diff --git a/arch/arm/src/cxd56xx/cxd56_charger.c b/arch/arm/src/cxd56xx/cxd56_charger.c index d819b58f52b..7da837ee8d9 100644 --- a/arch/arm/src/cxd56xx/cxd56_charger.c +++ b/arch/arm/src/cxd56xx/cxd56_charger.c @@ -69,11 +69,9 @@ /* Debug ********************************************************************/ #ifdef CONFIG_CXD56_CHARGER_DEBUG -#define baterr(fmt, ...) logerr(fmt, ## __VA_ARGS__) -#define batdbg(fmt, ...) logdebug(fmt, ## __VA_ARGS__) +#define baterr(fmt, ...) _err(fmt, ## __VA_ARGS__) #else #define baterr(fmt, ...) -#define batdbg(fmt, ...) #endif /* Configuration */ @@ -81,7 +79,7 @@ #undef USE_FLOAT_CONVERSION #ifdef CONFIG_CXD56_CHARGER_TEMP_PRECISE -#if !defined(CONFIG_LIBM) && !defined(CONFIG_LIBM_NEWLIB) +#if !defined(CONFIG_LIBM) && !defined(CONFIG_ARCH_MATH_H) # error Temperature conversion in float requires math library. #endif #define USE_FLOAT_CONVERSION 1 @@ -370,7 +368,9 @@ static int charger_get_current(FAR int *current) return -EIO; } - /* (Register value - 800h) / Current detection resistor (0.1 ohm) * 0.02929 */ + /* (Register value - 800h) / Current detection resistor (0.1 ohm) + * x 0.02929 + */ #ifdef USE_FLOAT_CONVERSION *current = (gauge.current - 0x800) / 0.1f * 0.02929f; @@ -508,7 +508,7 @@ static int charger_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct charger_dev_s *priv = inode->i_private; int ret = -ENOTTY; - nxsem_wait(&priv->batsem); + nxsem_wait_uninterruptible(&priv->batsem); switch (cmd) { diff --git a/arch/arm/src/cxd56xx/cxd56_clock.c b/arch/arm/src/cxd56xx/cxd56_clock.c index c4edcadf851..58665a22d00 100644 --- a/arch/arm/src/cxd56xx/cxd56_clock.c +++ b/arch/arm/src/cxd56xx/cxd56_clock.c @@ -140,14 +140,13 @@ struct power_domain static void cxd56_img_clock_enable(void); static void cxd56_img_clock_disable(void); -static void cxd56_scu_clock_ctrl(\ - uint32_t block, uint32_t intr, int on); -static void cxd56_scu_peri_clock_enable(\ - FAR const struct scu_peripheral *p) __unused; -static void cxd56_scu_peri_clock_disable(\ - FAR const struct scu_peripheral *p) __unused; -static void cxd56_scu_peri_clock_gating(\ - FAR const struct scu_peripheral *p, int enable) __unused; +static void cxd56_scu_clock_ctrl(uint32_t block, uint32_t intr, int on); +static void cxd56_scu_peri_clock_enable(FAR const struct scu_peripheral *p) + __unused; +static void cxd56_scu_peri_clock_disable(FAR const struct scu_peripheral *p) + __unused; +static void cxd56_scu_peri_clock_gating(FAR const struct scu_peripheral *p, + int enable) __unused; /**************************************************************************** * Public Data @@ -238,7 +237,7 @@ static void clock_semtake(sem_t *id) { if (!up_interrupt_context()) { - nxsem_wait(id); + nxsem_wait_uninterruptible(id); } } @@ -2033,7 +2032,7 @@ static void cxd56_scu_peri_clock_disable(FAR const struct scu_peripheral *p) disable_pwd(PDID_SCU); } -static void cxd56_scu_peri_clock_gating(\ +static void cxd56_scu_peri_clock_gating( FAR const struct scu_peripheral *p, int enable) { uint32_t cken = 1u << p->cken; diff --git a/arch/arm/src/cxd56xx/cxd56_cpu1signal.c b/arch/arm/src/cxd56xx/cxd56_cpu1signal.c index 7dac15dd2f2..2e5104ab4bf 100644 --- a/arch/arm/src/cxd56xx/cxd56_cpu1signal.c +++ b/arch/arm/src/cxd56xx/cxd56_cpu1signal.c @@ -83,7 +83,10 @@ struct cxd56cpu1_info_s * Private Data ****************************************************************************/ -static struct cxd56cpu1_info_s g_cpu1_info = {0}; +static struct cxd56cpu1_info_s g_cpu1_info = + { + 0 + }; /**************************************************************************** * Private Functions @@ -105,6 +108,7 @@ static FAR void *cxd56cpu1_worker(FAR void *arg) { continue; } + sigtype = (uint8_t)CXD56_CPU1_GET_DEV(msg.data); if (sigtype >= CXD56_CPU1_DATA_TYPE_MAX) { @@ -180,7 +184,7 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data) if (priv->sigtype[sigtype].use) { ret = -EBUSY; - goto _err1; + goto err1; } priv->sigtype[sigtype].use = true; @@ -189,7 +193,7 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data) if (priv->ndev > 0) { ret = OK; - goto _err1; + goto err1; } priv->ndev++; @@ -202,7 +206,7 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data) if (ret < 0) { _err("Failed to initialize ICC for GPS CPU: %d\n", ret); - goto _err0; + goto err0; } pthread_attr_init(&tattr); @@ -216,18 +220,19 @@ int cxd56_cpu1siginit(uint8_t sigtype, FAR void *data) { cxd56_iccuninitmsg(CXD56CPU1_CPUID); ret = -ret; /* pthread_create does not modify errno. */ - goto _err0; + goto err0; } + priv->workertid = tid; return ret; -_err0: +err0: priv->sigtype[sigtype].use = false; priv->sigtype[sigtype].data = NULL; return ret; -_err1: +err1: sched_unlock(); return ret; } @@ -248,7 +253,8 @@ int cxd56_cpu1siguninit(uint8_t sigtype) if (!priv->sigtype[sigtype].use) { ret = -EBUSY; - goto _err1; + sched_unlock(); + return ret; } priv->ndev--; @@ -258,7 +264,7 @@ int cxd56_cpu1siguninit(uint8_t sigtype) if (priv->ndev > 0) { ret = OK; - goto _err0; + return ret; } tid = priv->workertid; @@ -272,10 +278,4 @@ int cxd56_cpu1siguninit(uint8_t sigtype) cxd56_iccuninit(CXD56CPU1_CPUID); return 0; - -_err1: - sched_unlock(); - -_err0: - return ret; } diff --git a/arch/arm/src/cxd56xx/cxd56_cpu1signal.h b/arch/arm/src/cxd56xx/cxd56_cpu1signal.h index 5898da67f9e..3b530d6f856 100644 --- a/arch/arm/src/cxd56xx/cxd56_cpu1signal.h +++ b/arch/arm/src/cxd56xx/cxd56_cpu1signal.h @@ -54,7 +54,8 @@ #define CXD56_CPU1_DATA_TYPE_CPUFIFOAPI 13 #define CXD56_CPU1_DATA_TYPE_SBAS 14 #define CXD56_CPU1_DATA_TYPE_DCREPORT 15 -#define CXD56_CPU1_DATA_TYPE_MAX 16 +#define CXD56_CPU1_DATA_TYPE_SARRLM 16 +#define CXD56_CPU1_DATA_TYPE_MAX 17 /* CPU1 devices */ diff --git a/arch/arm/src/cxd56xx/cxd56_dmac.c b/arch/arm/src/cxd56xx/cxd56_dmac.c index 003535166c2..557c9132022 100644 --- a/arch/arm/src/cxd56xx/cxd56_dmac.c +++ b/arch/arm/src/cxd56xx/cxd56_dmac.c @@ -775,7 +775,7 @@ DMA_HANDLE cxd56_dmachannel(int ch, ssize_t maxsize) /* Get exclusive access to allocate channel */ - nxsem_wait(&g_dmaexc); + nxsem_wait_uninterruptible(&g_dmaexc); if (ch < 0 || ch >= NCHANNELS) { @@ -858,7 +858,7 @@ void cxd56_dmafree(DMA_HANDLE handle) return; } - nxsem_wait(&g_dmaexc); + nxsem_wait_uninterruptible(&g_dmaexc); if (!dmach->inuse) { diff --git a/arch/arm/src/cxd56xx/cxd56_emmc.c b/arch/arm/src/cxd56xx/cxd56_emmc.c index 4c4406e9d84..9b2b6933c10 100644 --- a/arch/arm/src/cxd56xx/cxd56_emmc.c +++ b/arch/arm/src/cxd56xx/cxd56_emmc.c @@ -962,6 +962,7 @@ int cxd56_emmcinitialize(void) memset(priv, 0, sizeof(struct cxd56_emmc_state_s)); nxsem_init(&priv->excsem, 0, 1); nxsem_init(&g_waitsem, 0, 0); + nxsem_set_protocol(&g_waitsem, SEM_PRIO_NONE); ret = emmc_hwinitialize(); if (ret != OK) diff --git a/arch/arm/src/cxd56xx/cxd56_farapi.c b/arch/arm/src/cxd56xx/cxd56_farapi.c index 980dbfe835e..3068e3caec7 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapi.c +++ b/arch/arm/src/cxd56xx/cxd56_farapi.c @@ -55,7 +55,7 @@ #include "cxd56_farapistub.h" #include "hardware/cxd5602_backupmem.h" -int PM_WakeUpCpu(int cpuid); +int fw_pm_wakeupcpu(int cpuid); /**************************************************************************** * Pre-processor Definitions @@ -120,7 +120,7 @@ struct farmsg_s * Public Data ****************************************************************************/ -extern char Image$$MODLIST$$Base[]; +extern char _image_modlist_base[]; /**************************************************************************** * Private Data @@ -210,7 +210,7 @@ void farapi_main(int id, void *arg, struct modulelist_s *mlist) if (((gnscken & GNSDSP_CKEN_P1) != GNSDSP_CKEN_P1) && ((gnscken & GNSDSP_CKEN_COP) != GNSDSP_CKEN_COP)) { - PM_WakeUpCpu(GPS_CPU_ID); + fw_pm_wakeupcpu(GPS_CPU_ID); } } #endif @@ -220,7 +220,7 @@ void farapi_main(int id, void *arg, struct modulelist_s *mlist) api = &msg.u.api; msg.cpuid = getreg32(CPU_ID); - msg.modid = mlist - (struct modulelist_s *)&Image$$MODLIST$$Base; + msg.modid = mlist - (struct modulelist_s *)&_image_modlist_base; api->id = id; api->arg = arg; @@ -274,6 +274,7 @@ void cxd56_farapiinitialize(void) #endif nxsem_init(&g_farlock, 0, 1); nxsem_init(&g_farwait, 0, 0); + nxsem_set_protocol(&g_farwait, SEM_PRIO_NONE); cxd56_iccinit(CXD56_PROTO_MBX); cxd56_iccinit(CXD56_PROTO_FLG); diff --git a/arch/arm/src/cxd56xx/cxd56_farapistub.S b/arch/arm/src/cxd56xx/cxd56_farapistub.S index 60993ce1f15..94bb44bff9f 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapistub.S +++ b/arch/arm/src/cxd56xx/cxd56_farapistub.S @@ -57,141 +57,141 @@ .align 2 3: - /* PM_GpsPllClockSetSource */ + /* fw_pm_gpspllclocksetsource */ nop nop - /* PM_PmicGetChargingPortType */ + /* fw_pm_pmicgetchargingporttype */ nop nop - /* PM_PmicSetChargingCurrentValue */ + /* fw_pm_pmicsetchargingcurrentvalue */ nop nop - /* PM_PmicStartCharging */ + /* fw_pm_pmicstartcharging */ nop nop - /* PM_PmicStopCharging */ + /* fw_pm_pmicstopcharging */ nop nop - /* PM_PeriPowerOn */ + /* fw_pm_peripoweron */ nop nop - /* PM_PeriPowerOff */ + /* fw_pm_peripoweroff */ nop nop - /* _PM_PeriClockEnable */ + /* fw__pm_periclockenable */ nop nop - /* _PM_PeriClockDisable */ + /* fw__pm_periclockdisable */ nop nop - /* _PM_UpdateCpuFreqInfo */ + /* fw__pm_updatecpufreqinfo */ nop nop - /* PM_PmicPowerOn */ + /* fw_pm_pmicpoweron */ nop nop - /* PM_PmicPowerOff */ + /* fw_pm_pmicpoweroff */ nop nop - /* PM_SetWakeupTrigger */ + /* fw_pm_setwakeuptrigger */ nop nop - /* PM_HostifClockEnable */ + /* fw_pm_hostifclockenable */ nop nop - /* PM_HostifClockDisable */ + /* fw_pm_hostifclockdisable */ nop nop - .global PM_StartCpu + .global fw_pm_startcpu .thumb_func -PM_StartCpu: +fw_pm_startcpu: mov r12, pc b 1b - .global PM_StopCpu + .global fw_pm_stopcpu .thumb_func -PM_StopCpu: +fw_pm_stopcpu: mov r12, pc b 1b - .global PM_SleepCpu + .global fw_pm_sleepcpu .thumb_func -PM_SleepCpu: +fw_pm_sleepcpu: mov r12, pc b 1b - .global PM_WakeUpCpu + .global fw_pm_wakeupcpu .thumb_func -PM_WakeUpCpu: +fw_pm_wakeupcpu: mov r12, pc b 1b - .global PM_ColdSleep + .global fw_pm_coldsleep .thumb_func -PM_ColdSleep: +fw_pm_coldsleep: mov r12, pc b 1b - .global PM_DeepSleep + .global fw_pm_deepsleep .thumb_func -PM_DeepSleep: +fw_pm_deepsleep: mov r12, pc b 1b - .global PM_Reboot + .global fw_pm_reboot .thumb_func -PM_Reboot: +fw_pm_reboot: mov r12, pc b 1b - .global PM_LoadImage + .global fw_pm_loadimage .thumb_func -PM_LoadImage: +fw_pm_loadimage: mov r12, pc b 1b - /* PM_LoadImageToAddress */ + /* fw_pm_loadimagetoaddress */ nop nop - /* PM_RamControlByAddress */ + /* fw_pm_ramcontrolbyaddress */ nop nop - /* PM_ChangeClock */ + /* fw_pm_changeclock */ nop nop - .global pm_pmic_control + .global fw_pm_pmiccontrol .thumb_func -pm_pmic_control: +fw_pm_pmiccontrol: mov r12, pc b 1b - /* PM_BootCpu */ + /* fw_pm_bootcpu */ nop nop - /* PM_BootCpuWithWaitMode */ + /* fw_pm_bootcpuwithwaitmode */ nop nop - /* PM_GetClock */ + /* fw_pm_getclock */ nop nop @@ -229,95 +229,95 @@ _modulelist_power_mgr: .align 2 3: - /* FM_GetRegistryValue */ + /* fw_fm_getregistryvalue */ nop nop - /* FM_SetRegistryValue */ + /* fw_fm_setregistryvalue */ nop nop - /* FM_SetRegistryValueList */ + /* fw_fm_setregistryvaluelist */ nop nop - /* FM_DeleteRegistryKey */ + /* fw_fm_deleteregistrykey */ nop nop - /* FM_GenerateRegistryKey */ + /* fw_fm_generateregistrykey */ nop nop - /* FM_Sync */ + /* fw_fm_sync */ nop nop - /* FM_FileOpen */ + /* fw_fm_fileopen */ nop nop - /* FM_FileClose */ + /* fw_fm_fileclose */ nop nop - /* FM_FileRead */ + /* fw_fm_fileread */ nop nop - /* FM_FileWrite */ + /* fw_fm_filewrite */ nop nop - /* FM_FileSeek */ + /* fw_fm_fileseek */ nop nop - /* FM_FileFlush */ + /* fw_fm_fileflush */ nop nop - /* FM_FileDelete */ + /* fw_fm_filedelete */ nop nop - .global FM_RawWrite + .global fw_fm_rawwrite .thumb_func -FM_RawWrite: +fw_fm_rawwrite: mov r12, pc b 1b - .global FM_RawRead + .global fw_fm_rawread .thumb_func -FM_RawRead: +fw_fm_rawread: mov r12, pc b 1b - .global FM_RawEraseSector + .global fw_fm_rawerasesector .thumb_func -FM_RawEraseSector: +fw_fm_rawerasesector: mov r12, pc b 1b - /* FM_FileRename */ + /* fw_fm_filerename */ nop nop - /* FM_FileGetAttr */ + /* fw_fm_filegetattr */ nop nop - /* FM_FileSetAttr */ + /* fw_fm_filesetattr */ nop nop - /* FM_FileClearAttr */ + /* fw_fm_fileclearattr */ nop nop - .global FM_RawVerifyWrite + .global fw_fm_rawverifywrite .thumb_func -FM_RawVerifyWrite: +fw_fm_rawverifywrite: mov r12, pc b 1b @@ -355,39 +355,39 @@ _modulelist_flash_mgr: .align 2 3: - /* SYS_RtcMgrSetTime */ + /* fw_sys_rtcmgrsettime */ nop nop - /* SYS_RtcMgrGetTime */ + /* fw_sys_rtcmgrgettime */ nop nop - /* SYS_RtcMgrConvTime */ + /* fw_sys_rtcmgrconvtime */ nop nop - /* SYS_RtcMgrConvCalendarTime */ + /* fw_sys_rtcmgrconvcalendartime */ nop nop - /* SYS_RtcMgrSetCalendarTime */ + /* fw_sys_rtcmgrsetcalendartime */ nop nop - /* SYS_RtcMgrGetCalendarTime */ + /* fw_sys_rtcmgrgetcalendartime */ nop nop - /* SYS_RtcMgrAdjustTime */ + /* fw_sys_rtcmgradjusttime */ nop nop - /* SYS_RtcMgrRequestAlarm */ + /* fw_sys_rtcmgrrequestalarm */ nop nop - /* SYS_RtcMgrCancelAlarm */ + /* fw_sys_rtcmgrcancelalarm */ nop nop @@ -425,107 +425,131 @@ _modulelist_rtc_mgr: .align 2 3: - /* GNSP_ChangeClockBoot */ + /* fw_gnsp_changeclockboot */ nop nop - /* GNSP_ChangeClockNormal */ + /* fw_gnsp_changeclocknormal */ nop nop - /* GNSP_SetAttribute */ + /* fw_gnsp_setattribute */ nop nop - /* GNSP_GetPowerStatus */ + /* fw_gnsp_getpowerstatus */ nop nop - /* GNSP_PonGnss */ + /* fw_gnsp_pongnss */ nop nop - /* GNSP_PoffGnss */ + /* fw_gnsp_poffgnss */ nop nop - /* GNSP_Sleep */ + /* fw_gnsp_pofflna */ nop nop - /* GNSP_Wakeup */ + /* fw_gnsp_sleep */ nop nop - /* GNSP_SetWakeupTime */ + /* fw_gnsp_wakeup */ nop nop - /* GNSP_GetAttribute */ + /* fw_gnsp_setwakeuptime */ nop nop - /* GNSP_ClockOn */ + /* fw_gnsp_getattribute */ nop nop - /* GNSP_ClockOff */ + /* fw_gnsp_clockon */ nop nop - /* GNSP_ChangeMode */ + /* fw_gnsp_clockoff */ nop nop - /* GNSP_EnableIo */ + /* fw_gnsp_changemode */ nop nop - /* GNSP_ControlGpioOut */ + /* fw_gnsp_enableio */ nop nop - /* GNSP_Debug */ + /* fw_gnsp_controlgpioout */ nop nop - /* GNSP_ChangeClockRtc */ + /* fw_gnsp_debug */ nop nop - /* GNSP_ChangeClockSFCClkup */ + /* fw_gnsp_changeclockrtc */ nop nop - /* GNSP_ChangeClockSFCClkdwn */ + /* fw_gnsp_changeclocksfcclkup */ nop nop - /* GNSP_GetBootCause */ + /* fw_gnsp_changeclocksfcclkdwn */ nop nop - /* GNSP_GetWakeupTrigger */ + /* fw_gnsp_changeclockgpscpuclkup */ nop nop - /* GNSP_SelfReboot */ + /* fw_gnsp_changeclockgpscpuclkdwn */ nop nop - /* GNSP_Start_KeepPPSOut */ + /* fw_gnsp_getbootcause */ nop nop - /* GNSP_Stop_KeepPPSOut */ + /* fw_gnsp_getwakeuptrigger */ nop nop - /* GNSP_SetSleepState */ + /* fw_gnsp_selfreboot */ nop nop - /* GNSP_FreeSysMemory */ + /* fw_gnsp_start_keepppsout */ + nop + nop + + /* fw_gnsp_stop_keepppsout */ + nop + nop + + /* fw_gnsp_start_keepitpout */ + nop + nop + + /* fw_gnsp_stop_keepitpout */ + nop + nop + + /* fw_gnsp_setsleepstate */ + nop + nop + + /* fw_gnsp_freesysmemory */ + nop + nop + + /* fw_gnsp_readalmanacfile */ nop nop @@ -563,9 +587,9 @@ _modulelist_gnss_pwr: .align 2 3: - .global as_aca_control + .global fw_as_acacontrol .thumb_func -as_aca_control: +fw_as_acacontrol: mov r12, pc b 1b @@ -603,9 +627,9 @@ _modulelist_aca: .align 2 3: - .global PD_PinConfigs + .global fw_pd_pinconfigs .thumb_func -PD_PinConfigs: +fw_pd_pinconfigs: mov r12, pc b 1b @@ -643,45 +667,45 @@ _modulelist_pinconfig: .align 2 3: - .global PD_UartInit + .global fw_pd_uartinit .thumb_func -PD_UartInit: +fw_pd_uartinit: mov r12, pc b 1b - .global PD_UartUninit + .global fw_pd_uartuninit .thumb_func -PD_UartUninit: +fw_pd_uartuninit: mov r12, pc b 1b - .global PD_UartConfiguration + .global fw_pd_uartconfiguration .thumb_func -PD_UartConfiguration: +fw_pd_uartconfiguration: mov r12, pc b 1b - .global PD_UartEnable + .global fw_pd_uartenable .thumb_func -PD_UartEnable: +fw_pd_uartenable: mov r12, pc b 1b - .global PD_UartDisable + .global fw_pd_uartdisable .thumb_func -PD_UartDisable: +fw_pd_uartdisable: mov r12, pc b 1b - .global PD_UartReceive + .global fw_pd_uartreceive .thumb_func -PD_UartReceive: +fw_pd_uartreceive: mov r12, pc b 1b - .global PD_UartSend + .global fw_pd_uartsend .thumb_func -PD_UartSend: +fw_pd_uartsend: mov r12, pc b 1b @@ -719,45 +743,45 @@ _modulelist_uart: .align 2 3: - .global UM_Init + .global fw_um_init .thumb_func -UM_Init: +fw_um_init: mov r12, pc b 1b - .global UM_Open + .global fw_um_open .thumb_func -UM_Open: +fw_um_open: mov r12, pc b 1b - .global UM_Commit + .global fw_um_commit .thumb_func -UM_Commit: +fw_um_commit: mov r12, pc b 1b - .global UM_Close + .global fw_um_close .thumb_func -UM_Close: +fw_um_close: mov r12, pc b 1b - .global UM_CheckPoint + .global fw_um_checkpoint .thumb_func -UM_CheckPoint: +fw_um_checkpoint: mov r12, pc b 1b - .global UM_DoUpdateSequence + .global fw_um_doupdatesequence .thumb_func -UM_DoUpdateSequence: +fw_um_doupdatesequence: mov r12, pc b 1b - .global UM_Abort + .global fw_um_abort .thumb_func -UM_Abort: +fw_um_abort: mov r12, pc b 1b @@ -795,363 +819,387 @@ _modulelist_update_mgr: .align 2 3: - .global GD_Start + .global fw_gd_start .thumb_func -GD_Start: +fw_gd_start: mov r12, pc b 1b - .global GD_Stop + .global fw_gd_stop .thumb_func -GD_Stop: +fw_gd_stop: mov r12, pc b 1b - .global GD_SelectSatelliteSystem + .global fw_gd_selectsatellitesystem .thumb_func -GD_SelectSatelliteSystem: +fw_gd_selectsatellitesystem: mov r12, pc b 1b - .global GD_GetSatelliteSystem + .global fw_gd_getsatellitesystem .thumb_func -GD_GetSatelliteSystem: +fw_gd_getsatellitesystem: mov r12, pc b 1b - .global GD_SetReceiverPositionEllipsoidal + .global fw_gd_setreceiverpositionellipsoidal .thumb_func -GD_SetReceiverPositionEllipsoidal: +fw_gd_setreceiverpositionellipsoidal: mov r12, pc b 1b - .global GD_SetReceiverPositionOrthogonal + .global fw_gd_setreceiverpositionorthogonal .thumb_func -GD_SetReceiverPositionOrthogonal: +fw_gd_setreceiverpositionorthogonal: mov r12, pc b 1b - .global GD_SetOperationMode + .global fw_gd_setoperationmode .thumb_func -GD_SetOperationMode: +fw_gd_setoperationmode: mov r12, pc b 1b - .global GD_GetOperationMode + .global fw_gd_getoperationmode .thumb_func -GD_GetOperationMode: +fw_gd_getoperationmode: mov r12, pc b 1b - .global GD_SetTcxoOffset + .global fw_gd_settcxooffset .thumb_func -GD_SetTcxoOffset: +fw_gd_settcxooffset: mov r12, pc b 1b - .global GD_GetTcxoOffset + .global fw_gd_gettcxooffset .thumb_func -GD_GetTcxoOffset: +fw_gd_gettcxooffset: mov r12, pc b 1b - .global GD_SetTime + .global fw_gd_settime .thumb_func -GD_SetTime: +fw_gd_settime: mov r12, pc b 1b - .global GD_GetAlmanac + .global fw_gd_getalmanac .thumb_func -GD_GetAlmanac: +fw_gd_getalmanac: mov r12, pc b 1b - .global GD_SetAlmanac + .global fw_gd_setalmanac .thumb_func -GD_SetAlmanac: +fw_gd_setalmanac: mov r12, pc b 1b - .global GD_GetEphemeris + .global fw_gd_getephemeris .thumb_func -GD_GetEphemeris: +fw_gd_getephemeris: mov r12, pc b 1b - .global GD_SetEphemeris + .global fw_gd_setephemeris .thumb_func -GD_SetEphemeris: +fw_gd_setephemeris: mov r12, pc b 1b - .global GD_GetVarEphemeris + .global fw_gd_getvarephemeris .thumb_func -GD_GetVarEphemeris: +fw_gd_getvarephemeris: mov r12, pc b 1b - .global GD_SetVarEphemeris + .global fw_gd_setvarephemeris .thumb_func -GD_SetVarEphemeris: +fw_gd_setvarephemeris: mov r12, pc b 1b - .global GD_StartGpsTest + .global fw_gd_startgpstest .thumb_func -GD_StartGpsTest: +fw_gd_startgpstest: mov r12, pc b 1b - .global GD_StopGpsTest + .global fw_gd_stopgpstest .thumb_func -GD_StopGpsTest: +fw_gd_stopgpstest: mov r12, pc b 1b - .global GD_GetGpsTestResult + .global fw_gd_getgpstestresult .thumb_func -GD_GetGpsTestResult: +fw_gd_getgpstestresult: mov r12, pc b 1b - .global GD_SaveBackupdata + .global fw_gd_savebackupdata .thumb_func -GD_SaveBackupdata: +fw_gd_savebackupdata: mov r12, pc b 1b - .global GD_EraseBackup + .global fw_gd_erasebackup .thumb_func -GD_EraseBackup: +fw_gd_erasebackup: mov r12, pc b 1b - .global GD_CepSetAssistData + .global fw_gd_cepsetassistdata .thumb_func -GD_CepSetAssistData: +fw_gd_cepsetassistdata: mov r12, pc b 1b - .global GD_CepEraseAssistData + .global fw_gd_ceperaseassistdata .thumb_func -GD_CepEraseAssistData: +fw_gd_ceperaseassistdata: mov r12, pc b 1b - .global GD_CepCheckAssistData + .global fw_gd_cepcheckassistdata .thumb_func -GD_CepCheckAssistData: +fw_gd_cepcheckassistdata: mov r12, pc b 1b - .global GD_CepGetAgeData + .global fw_gd_cepgetagedata .thumb_func -GD_CepGetAgeData: +fw_gd_cepgetagedata: mov r12, pc b 1b - .global GD_CepInitAssistData + .global fw_gd_cepinitassistdata .thumb_func -GD_CepInitAssistData: +fw_gd_cepinitassistdata: mov r12, pc b 1b - .global GD_SetAcquist + .global fw_gd_setacquist .thumb_func -GD_SetAcquist: +fw_gd_setacquist: mov r12, pc b 1b - .global GD_SetFrameTime + .global fw_gd_setframetime .thumb_func -GD_SetFrameTime: +fw_gd_setframetime: mov r12, pc b 1b - .global GD_SetTauGps + .global fw_gd_settaugps .thumb_func -GD_SetTauGps: +fw_gd_settaugps: mov r12, pc b 1b - .global GD_SetTimeGps + .global fw_gd_settimegps .thumb_func -GD_SetTimeGps: +fw_gd_settimegps: mov r12, pc b 1b - .global GD_ClearReceiverInfo + .global fw_gd_clearreceiverinfo .thumb_func -GD_ClearReceiverInfo: +fw_gd_clearreceiverinfo: mov r12, pc b 1b - .global GD_SetTowAssist + .global fw_gd_settowassist .thumb_func -GD_SetTowAssist: +fw_gd_settowassist: mov r12, pc b 1b - .global GD_SetUtcModel + .global fw_gd_setutcmodel .thumb_func -GD_SetUtcModel: +fw_gd_setutcmodel: mov r12, pc b 1b - .global GD_SpectrumControl + .global fw_gd_spectrumcontrol .thumb_func -GD_SpectrumControl: +fw_gd_spectrumcontrol: mov r12, pc b 1b - .global GD_ReadBuffer + .global fw_gd_readbuffer .thumb_func -GD_ReadBuffer: +fw_gd_readbuffer: mov r12, pc b 1b - .global GD_WriteBuffer + .global fw_gd_writebuffer .thumb_func -GD_WriteBuffer: +fw_gd_writebuffer: mov r12, pc b 1b - .global GD_SetNotifyMask + .global fw_gd_setnotifymask .thumb_func -GD_SetNotifyMask: +fw_gd_setnotifymask: mov r12, pc b 1b - .global GD_GeoAddRegion + .global fw_gd_geoaddregion .thumb_func -GD_GeoAddRegion: +fw_gd_geoaddregion: mov r12, pc b 1b - .global GD_GeoModifyRegion + .global fw_gd_geomodifyregion .thumb_func -GD_GeoModifyRegion: +fw_gd_geomodifyregion: mov r12, pc b 1b - .global GD_GeoDeleteRegione + .global fw_gd_geodeleteregione .thumb_func -GD_GeoDeleteRegione: +fw_gd_geodeleteregione: mov r12, pc b 1b - .global GD_GeoDeleteAllRegion + .global fw_gd_geodeleteallregion .thumb_func -GD_GeoDeleteAllRegion: +fw_gd_geodeleteallregion: mov r12, pc b 1b - .global GD_GeoGetRegionData + .global fw_gd_geogetregiondata .thumb_func -GD_GeoGetRegionData: +fw_gd_geogetregiondata: mov r12, pc b 1b - .global GD_GeoGetUsedRegionId + .global fw_gd_geogetusedregionid .thumb_func -GD_GeoGetUsedRegionId: +fw_gd_geogetusedregionid: mov r12, pc b 1b - .global GD_GeoSetOpMode + .global fw_gd_geosetopmode .thumb_func -GD_GeoSetOpMode: +fw_gd_geosetopmode: mov r12, pc b 1b - .global GD_GeoSetAllRgionNotifyRequest + .global fw_gd_geosetallrgionnotifyrequest .thumb_func -GD_GeoSetAllRgionNotifyRequest: +fw_gd_geosetallrgionnotifyrequest: mov r12, pc b 1b - .global GD_RegisterGeofence + .global fw_gd_registergeofence .thumb_func -GD_RegisterGeofence: +fw_gd_registergeofence: mov r12, pc b 1b - .global GD_ReleaseGeofence + .global fw_gd_releasegeofence .thumb_func -GD_ReleaseGeofence: +fw_gd_releasegeofence: mov r12, pc b 1b - .global GD_RegisterPvtlog + .global fw_gd_registerpvtlog .thumb_func -GD_RegisterPvtlog: +fw_gd_registerpvtlog: mov r12, pc b 1b - .global GD_ReleasePvtlog + .global fw_gd_releasepvtlog .thumb_func -GD_ReleasePvtlog: +fw_gd_releasepvtlog: mov r12, pc b 1b - .global GD_PvtlogDeleteLog + .global fw_gd_pvtlogdeletelog .thumb_func -GD_PvtlogDeleteLog: +fw_gd_pvtlogdeletelog: mov r12, pc b 1b - .global GD_PvtlogGetLogStatus + .global fw_gd_pvtloggetlogstatus .thumb_func -GD_PvtlogGetLogStatus: +fw_gd_pvtloggetlogstatus: mov r12, pc b 1b - .global GD_RtkStart + .global fw_gd_rtkstart .thumb_func -GD_RtkStart: +fw_gd_rtkstart: mov r12, pc b 1b - .global GD_RtkStop + .global fw_gd_rtkstop .thumb_func -GD_RtkStop: +fw_gd_rtkstop: mov r12, pc b 1b - .global GD_RtkSetOutputInterval + .global fw_gd_rtksetoutputinterval .thumb_func -GD_RtkSetOutputInterval: +fw_gd_rtksetoutputinterval: mov r12, pc b 1b - .global GD_RtkGetOutputInterval + .global fw_gd_rtkgetoutputinterval .thumb_func -GD_RtkGetOutputInterval: +fw_gd_rtkgetoutputinterval: mov r12, pc b 1b - .global GD_RtkSetGnss + .global fw_gd_rtksetgnss .thumb_func -GD_RtkSetGnss: +fw_gd_rtksetgnss: mov r12, pc b 1b - .global GD_RtkGetGnss + .global fw_gd_rtkgetgnss .thumb_func -GD_RtkGetGnss: +fw_gd_rtkgetgnss: mov r12, pc b 1b - .global GD_RtkSetEphNotify + .global fw_gd_rtksetephnotify .thumb_func -GD_RtkSetEphNotify: +fw_gd_rtksetephnotify: mov r12, pc b 1b - .global GD_RtkGetEphNotify + .global fw_gd_rtkgetephnotify .thumb_func -GD_RtkGetEphNotify: +fw_gd_rtkgetephnotify: + mov r12, pc + b 1b + + .global fw_gd_setusecase + .thumb_func +fw_gd_setusecase: + mov r12, pc + b 1b + + .global fw_gd_getusecase + .thumb_func +fw_gd_getusecase: + mov r12, pc + b 1b + + .global fw_gd_set1ppsoutput + .thumb_func +fw_gd_set1ppsoutput: + mov r12, pc + b 1b + + .global fw_gd_get1ppsoutput + .thumb_func +fw_gd_get1ppsoutput: mov r12, pc b 1b diff --git a/arch/arm/src/cxd56xx/cxd56_farapistub.h b/arch/arm/src/cxd56xx/cxd56_farapistub.h index c3790d0cd90..1c3bdfbb478 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapistub.h +++ b/arch/arm/src/cxd56xx/cxd56_farapistub.h @@ -36,6 +36,6 @@ #ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H #define __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H -#define FARAPISTUB_VERSION 17660 +#define FARAPISTUB_VERSION 20129 #endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_FARAPISTUB_H */ diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.c b/arch/arm/src/cxd56xx/cxd56_gauge.c index 34dac3de9a0..4776f20efcd 100644 --- a/arch/arm/src/cxd56xx/cxd56_gauge.c +++ b/arch/arm/src/cxd56xx/cxd56_gauge.c @@ -335,7 +335,7 @@ static int gauge_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR struct bat_gauge_dev_s *priv = inode->i_private; int ret = -ENOTTY; - nxsem_wait(&priv->batsem); + nxsem_wait_uninterruptible(&priv->batsem); switch (cmd) { diff --git a/arch/arm/src/cxd56xx/cxd56_geofence.c b/arch/arm/src/cxd56xx/cxd56_geofence.c index 109ac5a8d4c..adfd688ea59 100644 --- a/arch/arm/src/cxd56xx/cxd56_geofence.c +++ b/arch/arm/src/cxd56xx/cxd56_geofence.c @@ -169,7 +169,7 @@ FAR static int (*g_cmdlist[CXD56_GEOFENCE_IOCTL_MAX])(unsigned long) = static int cxd56_geofence_start(unsigned long arg) { - return GD_RegisterGeofence(); + return fw_gd_registergeofence(); } /**************************************************************************** @@ -189,7 +189,7 @@ static int cxd56_geofence_start(unsigned long arg) static int cxd56_geofence_stop(unsigned long arg) { - return GD_ReleaseGeofence(); + return fw_gd_releasegeofence(); } /**************************************************************************** @@ -219,7 +219,7 @@ static int cxd56_geofence_add_region(unsigned long arg) reg_data = (FAR struct cxd56_geofence_region_s *)arg; - ret = GD_GeoAddRegion(reg_data->id, + ret = fw_gd_geoaddregion(reg_data->id, reg_data->latitude, reg_data->longitude, reg_data->radius); @@ -254,7 +254,7 @@ static int cxd56_geofence_modify_region(unsigned long arg) reg_data = (FAR struct cxd56_geofence_region_s *)arg; - ret = GD_GeoModifyRegion(reg_data->id, reg_data->latitude, + ret = fw_gd_geomodifyregion(reg_data->id, reg_data->latitude, reg_data->longitude, reg_data->radius); return ret; @@ -286,7 +286,7 @@ static int cxd56_geofence_delete_region(unsigned long arg) } id = (uint8_t)arg; - ret = GD_GeoDeleteRegione(id); + ret = fw_gd_geodeleteregione(id); return ret; } @@ -310,7 +310,7 @@ static int cxd56_geofence_delete_all_region(unsigned long arg) { int ret; - ret = GD_GeoDeleteAllRegion(); + ret = fw_gd_geodeleteallregion(); return ret; } @@ -342,7 +342,7 @@ static int cxd56_geofence_get_region_data(unsigned long arg) reg_data = (FAR struct cxd56_geofence_region_s *)arg; - ret = GD_GeoGetRegionData(reg_data->id, ®_data->latitude, + ret = fw_gd_geogetregiondata(reg_data->id, ®_data->latitude, ®_data->longitude, ®_data->radius); return ret; @@ -370,7 +370,7 @@ static int cxd56_geofence_get_used_id(unsigned long arg) return -EINVAL; } - *(uint32_t *)arg = GD_GeoGetUsedRegionId(); + *(uint32_t *)arg = fw_gd_geogetusedregionid(); return 0; } @@ -394,7 +394,7 @@ static int cxd56_geofence_get_all_status(unsigned long arg) { int ret; - ret = GD_GeoSetAllRgionNotifyRequest(); + ret = fw_gd_geosetallrgionnotifyrequest(); return ret; } @@ -426,7 +426,7 @@ static int cxd56_geofence_set_mode(unsigned long arg) mode = (FAR struct cxd56_geofence_mode_s *)arg; - ret = GD_GeoSetOpMode(mode->deadzone, mode->dwell_detecttime); + ret = fw_gd_geosetopmode(mode->deadzone, mode->dwell_detecttime); return ret; } @@ -571,9 +571,9 @@ static ssize_t cxd56_geofence_read(FAR struct file *filep, FAR char *buffer, goto _err; } - /* GD_ReadBuffer returns copied data size or negative error code */ + /* fw_gd_readbuffer returns copied data size or negative error code */ - ret = GD_ReadBuffer(CXD56_CPU1_DEV_GEOFENCE, 0, buffer, len); + ret = fw_gd_readbuffer(CXD56_CPU1_DEV_GEOFENCE, 0, buffer, len); _err: return ret; @@ -659,7 +659,7 @@ static int cxd56_geofence_poll(FAR struct file *filep, priv->fds[i] = fds; fds->priv = &priv->fds[i]; - GD_SetNotifyMask(CXD56_CPU1_DEV_GEOFENCE, FALSE); + fw_gd_setnotifymask(CXD56_CPU1_DEV_GEOFENCE, FALSE); break; } } diff --git a/arch/arm/src/cxd56xx/cxd56_gnss.c b/arch/arm/src/cxd56xx/cxd56_gnss.c index 0e5e61c9caf..ebc2630cd1f 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss.c +++ b/arch/arm/src/cxd56xx/cxd56_gnss.c @@ -54,11 +54,13 @@ #include #include +#include #include #include "cxd56_gnss_api.h" #include "cxd56_cpu1signal.h" #include "cxd56_gnss.h" +#include "cxd56_pinconfig.h" #if defined(CONFIG_CXD56_GNSS) @@ -66,9 +68,9 @@ * External Defined Functions ****************************************************************************/ -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); +extern int fw_pm_loadimage(int cpuid, const char *filename); +extern int fw_pm_startcpu(int cpuid, int wait); +extern int fw_pm_sleepcpu(int cpuid, int mode); /**************************************************************************** * Pre-processor Definitions @@ -289,6 +291,14 @@ static int cxd56_gnss_get_var_ephemeris(FAR struct file *filep, unsigned long arg); static int cxd56_gnss_set_var_ephemeris(FAR struct file *filep, unsigned long arg); +static int cxd56_gnss_set_usecase(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_get_usecase(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_set_1pps_output(FAR struct file *filep, + unsigned long arg); +static int cxd56_gnss_get_1pps_output(FAR struct file *filep, + unsigned long arg); /* file operation functions */ @@ -384,10 +394,18 @@ static int (*g_cmdlist[CXD56_GNSS_IOCTL_MAX])(FAR struct file *filep, cxd56_gnss_start_navmsg_output, cxd56_gnss_set_var_ephemeris, cxd56_gnss_get_var_ephemeris, + cxd56_gnss_set_usecase, + cxd56_gnss_get_usecase, + cxd56_gnss_set_1pps_output, + cxd56_gnss_get_1pps_output, - /* max CXD56_GNSS_IOCTL_MAX */ + /* max CXD56_GNSS_IOCTL_MAX */ }; +static struct pm_cpu_freqlock_s g_lv_lock = + PM_CPUFREQLOCK_INIT(PM_CPUFREQLOCK_TAG('G', 'T', 0), + PM_CPUFREQLOCK_FLAG_LV); + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -488,7 +506,7 @@ static int cxd56_gnss_select_satellite_system(FAR struct file *filep, { uint32_t system = (uint32_t)arg; - return GD_SelectSatelliteSystem(system); + return fw_gd_selectsatellitesystem(system); } /**************************************************************************** @@ -520,7 +538,7 @@ static int cxd56_gnss_get_satellite_system(FAR struct file *filep, return -EINVAL; } - ret = GD_GetSatelliteSystem(&system); + ret = fw_gd_getsatellitesystem(&system); *(uint32_t *)arg = system; return ret; @@ -556,7 +574,7 @@ cxd56_gnss_set_receiver_position_ellipsoidal(FAR struct file *filep, pos = (FAR struct cxd56_gnss_ellipsoidal_position_s *)arg; - return GD_SetReceiverPositionEllipsoidal(&pos->latitude, + return fw_gd_setreceiverpositionellipsoidal(&pos->latitude, &pos->longitude, &pos->altitude); } @@ -590,7 +608,7 @@ static int cxd56_gnss_set_receiver_position_orthogonal( } pos = (FAR struct cxd56_gnss_orthogonal_position_s *)arg; - return GD_SetReceiverPositionOrthogonal(pos->x, pos->y, pos->z); + return fw_gd_setreceiverpositionorthogonal(pos->x, pos->y, pos->z); } /**************************************************************************** @@ -619,7 +637,7 @@ static int cxd56_gnss_set_ope_mode(FAR struct file *filep, unsigned long arg) ope_mode = (FAR struct cxd56_gnss_ope_mode_param_s *)arg; - return GD_SetOperationMode(ope_mode->mode, ope_mode->cycle); + return fw_gd_setoperationmode(ope_mode->mode, ope_mode->cycle); } /**************************************************************************** @@ -648,7 +666,7 @@ static int cxd56_gnss_get_ope_mode(FAR struct file *filep, unsigned long arg) ope_mode = (FAR struct cxd56_gnss_ope_mode_param_s *)arg; - return GD_GetOperationMode(&ope_mode->mode, &ope_mode->cycle); + return fw_gd_getoperationmode(&ope_mode->mode, &ope_mode->cycle); } /**************************************************************************** @@ -672,7 +690,7 @@ static int cxd56_gnss_set_tcxo_offset(FAR struct file *filep, { int32_t offset = (int32_t)arg; - return GD_SetTcxoOffset(offset); + return fw_gd_settcxooffset(offset); } /**************************************************************************** @@ -702,7 +720,7 @@ static int cxd56_gnss_get_tcxo_offset(FAR struct file *filep, return -EINVAL; } - ret = GD_GetTcxoOffset(&offset); + ret = fw_gd_gettcxooffset(&offset); *(uint32_t *)arg = offset; return ret; @@ -728,6 +746,7 @@ static int cxd56_gnss_get_tcxo_offset(FAR struct file *filep, static int cxd56_gnss_set_time(FAR struct file *filep, unsigned long arg) { FAR struct cxd56_gnss_datetime_s *date_time; + int ret; if (!arg) { @@ -736,7 +755,11 @@ static int cxd56_gnss_set_time(FAR struct file *filep, unsigned long arg) date_time = (FAR struct cxd56_gnss_datetime_s *)arg; - return GD_SetTime(&date_time->date, &date_time->time); + up_pm_acquire_freqlock(&g_lv_lock); + ret = fw_gd_settime(&date_time->date, &date_time->time); + up_pm_release_freqlock(&g_lv_lock); + + return ret; } /**************************************************************************** @@ -767,7 +790,7 @@ static int cxd56_gnss_get_almanac(FAR struct file *filep, unsigned long arg) param = (FAR struct cxd56_gnss_orbital_param_s *)arg; - return GD_GetAlmanac(param->type, param->data, &almanac_size); + return fw_gd_getalmanac(param->type, param->data, &almanac_size); } /**************************************************************************** @@ -797,7 +820,7 @@ static int cxd56_gnss_set_almanac(FAR struct file *filep, unsigned long arg) param = (FAR struct cxd56_gnss_orbital_param_s *)arg; - return GD_SetAlmanac(param->type, param->data); + return fw_gd_setalmanac(param->type, param->data); } /**************************************************************************** @@ -829,7 +852,7 @@ static int cxd56_gnss_get_ephemeris(FAR struct file *filep, param = (FAR struct cxd56_gnss_orbital_param_s *)arg; - return GD_GetEphemeris(param->type, param->data, &ephemeris_size); + return fw_gd_getephemeris(param->type, param->data, &ephemeris_size); } /**************************************************************************** @@ -860,7 +883,7 @@ static int cxd56_gnss_set_ephemeris(FAR struct file *filep, param = (FAR struct cxd56_gnss_orbital_param_s *)arg; - return GD_SetEphemeris(param->type, param->data); + return fw_gd_setephemeris(param->type, param->data); } /**************************************************************************** @@ -902,7 +925,7 @@ static int cxd56_gnss_save_backup_data(FAR struct file *filep, do { - n = GD_ReadBuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, + n = fw_gd_readbuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, CONFIG_CXD56_GNSS_BACKUP_BUFFER_SIZE); if (n <= 0) { @@ -1005,7 +1028,7 @@ static int cxd56_gnss_close_cep_data(FAR struct file *filep, static int cxd56_gnss_check_cep_data(FAR struct file *filep, unsigned long arg) { - return GD_CepCheckAssistData(); + return fw_gd_cepcheckassistdata(); } /**************************************************************************** @@ -1035,7 +1058,7 @@ static int cxd56_gnss_get_cep_age(FAR struct file *filep, unsigned long arg) age = (FAR struct cxd56_gnss_cep_age_s *)arg; - return GD_CepGetAgeData(&age->age, &age->cepi); + return fw_gd_cepgetagedata(&age->age, &age->cepi); } /**************************************************************************** @@ -1089,7 +1112,7 @@ static int cxd56_gnss_set_acquist_data(FAR struct file *filep, acquist = (FAR struct cxd56_gnss_agps_acquist_s *)arg; - return GD_SetAcquist(acquist->data, acquist->size); + return fw_gd_setacquist(acquist->data, acquist->size); } /**************************************************************************** @@ -1120,7 +1143,7 @@ static int cxd56_gnss_set_frametime(FAR struct file *filep, frametime = (FAR struct cxd56_gnss_agps_frametime_s *)arg; - return GD_SetFrameTime(frametime->sec, frametime->frac); + return fw_gd_setframetime(frametime->sec, frametime->frac); } /**************************************************************************** @@ -1150,7 +1173,7 @@ static int cxd56_gnss_set_tau_gps(FAR struct file *filep, unsigned long arg) taugpstime = (FAR struct cxd56_gnss_agps_tau_gps_s *)arg; - return GD_SetTauGps(&taugpstime->taugps); + return fw_gd_settaugps(&taugpstime->taugps); } /**************************************************************************** @@ -1180,7 +1203,7 @@ static int cxd56_gnss_set_time_gps(FAR struct file *filep, unsigned long arg) time_gps = (FAR struct cxd56_gnss_agps_time_gps_s *)arg; - return GD_SetTimeGps(&time_gps->date, &time_gps->time); + return fw_gd_settimegps(&time_gps->date, &time_gps->time); } /**************************************************************************** @@ -1204,7 +1227,7 @@ static int cxd56_gnss_clear_receiver_info(FAR struct file *filep, { uint32_t clear_type = arg; - return GD_ClearReceiverInfo(clear_type); + return fw_gd_clearreceiverinfo(clear_type); } /**************************************************************************** @@ -1235,7 +1258,7 @@ static int cxd56_gnss_set_tow_assist(FAR struct file *filep, assist = (FAR struct cxd56_gnss_agps_tow_assist_s *)arg; - return GD_SetTowAssist(assist->data, assist->size); + return fw_gd_settowassist(assist->data, assist->size); } /**************************************************************************** @@ -1266,7 +1289,7 @@ static int cxd56_gnss_set_utc_model(FAR struct file *filep, model = (FAR struct cxd56_gnss_agps_utc_model_s *)arg; - return GD_SetUtcModel(model->data, model->size); + return fw_gd_setutcmodel(model->data, model->size); } /**************************************************************************** @@ -1297,8 +1320,9 @@ static int cxd56_gnss_control_spectrum(FAR struct file *filep, control = (FAR struct cxd56_gnss_spectrum_control_s *)arg; - return GD_SpectrumControl(control->time, control->enable, control->point1, - control->step1, control->point2, control->step2); + return fw_gd_spectrumcontrol(control->time, control->enable, + control->point1, control->step1, + control->point2, control->step2); } /**************************************************************************** @@ -1349,12 +1373,12 @@ static int cxd56_gnss_start_test(FAR struct file *filep, unsigned long arg) /* set parameter */ info = (FAR struct cxd56_gnss_test_info_s *)arg; - GD_StartGpsTest(info->satellite, info->reserve1, + fw_gd_startgpstest(info->satellite, info->reserve1, info->reserve2, info->reserve3); /* start test */ - ret = GD_Start(CXD56_GNSS_STMOD_COLD); + ret = fw_gd_start(CXD56_GNSS_STMOD_COLD); } return ret; @@ -1382,12 +1406,12 @@ static int cxd56_gnss_stop_test(FAR struct file *filep, unsigned long arg) /* term test */ - ret = GD_StopGpsTest(); + ret = fw_gd_stopgpstest(); if (ret == OK) { /* stop test */ - ret = GD_Stop(); + ret = fw_gd_stop(); } /* Power off the LNA device */ @@ -1425,7 +1449,7 @@ static int cxd56_gnss_get_test_result(FAR struct file *filep, result = (FAR struct cxd56_gnss_test_result_s *)arg; - return GD_GetGpsTestResult(&result->cn, &result->doppler); + return fw_gd_getgpstestresult(&result->cn, &result->doppler); } /**************************************************************************** @@ -1510,7 +1534,7 @@ static int cxd56_gnss_set_signal(FAR struct file *filep, unsigned long arg) goto _err; } - GD_SetNotifyMask(setting->gnsssig, FALSE); + fw_gd_setnotifymask(setting->gnsssig, FALSE); sig->enable = 1; sig->pid = pid; @@ -1557,7 +1581,7 @@ static int cxd56_gnss_start_pvtlog(FAR struct file *filep, unsigned long arg) setting = (FAR struct cxd56_pvtlog_setting_s *)arg; - return GD_RegisterPvtlog(setting->cycle, setting->threshold); + return fw_gd_registerpvtlog(setting->cycle, setting->threshold); } /**************************************************************************** @@ -1578,7 +1602,7 @@ 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) { - return GD_ReleasePvtlog(); + return fw_gd_releasepvtlog(); } /**************************************************************************** @@ -1600,7 +1624,7 @@ 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) { - return GD_PvtlogDeleteLog(); + return fw_gd_pvtlogdeletelog(); } /**************************************************************************** @@ -1631,7 +1655,7 @@ static int cxd56_gnss_get_pvtlog_status(FAR struct file *filep, status = (FAR struct cxd56_pvtlog_status_s *)arg; - return GD_PvtlogGetLogStatus(&status->status); + return fw_gd_pvtloggetlogstatus(&status->status); } /**************************************************************************** @@ -1663,7 +1687,7 @@ static int cxd56_gnss_start_rtk_output(FAR struct file *filep, setting = (FAR struct cxd56_rtk_setting_s *)arg; setting->sbasout = 0; - return GD_RtkStart(setting); + return fw_gd_rtkstart(setting); } /**************************************************************************** @@ -1685,7 +1709,7 @@ static int cxd56_gnss_start_rtk_output(FAR struct file *filep, static int cxd56_gnss_stop_rtk_output(FAR struct file *filep, unsigned long arg) { - return GD_RtkStop(); + return fw_gd_rtkstop(); } /**************************************************************************** @@ -1709,7 +1733,7 @@ static int cxd56_gnss_set_rtk_interval(FAR struct file *filep, { int interval = (int)arg; - return GD_RtkSetOutputInterval(interval); + return fw_gd_rtksetoutputinterval(interval); } /**************************************************************************** @@ -1739,7 +1763,7 @@ static int cxd56_gnss_get_rtk_interval(FAR struct file *filep, return -EINVAL; } - ret = GD_RtkGetOutputInterval(&interval); + ret = fw_gd_rtkgetoutputinterval(&interval); *(uint32_t *)arg = interval; return ret; @@ -1766,7 +1790,7 @@ static int cxd56_gnss_select_rtk_satellite(FAR struct file *filep, { uint32_t gnss = (uint32_t)arg; - return GD_RtkSetGnss(gnss); + return fw_gd_rtksetgnss(gnss); } /**************************************************************************** @@ -1796,7 +1820,7 @@ static int cxd56_gnss_get_rtk_satellite(FAR struct file *filep, return -EINVAL; } - ret = GD_RtkGetGnss(&gnss); + ret = fw_gd_rtkgetgnss(&gnss); *(uint32_t *)arg = gnss; return ret; @@ -1823,7 +1847,7 @@ static int cxd56_gnss_set_rtk_ephemeris_enable(FAR struct file *filep, { int enable = (int)arg; - return GD_RtkSetEphNotify(enable); + return fw_gd_rtksetephnotify(enable); } /**************************************************************************** @@ -1853,7 +1877,7 @@ static int cxd56_gnss_get_rtk_ephemeris_enable(FAR struct file *filep, return -EINVAL; } - ret = GD_RtkGetEphNotify(&enable); + ret = fw_gd_rtkgetephnotify(&enable); *(uint32_t *)arg = enable; return ret; @@ -1887,7 +1911,7 @@ static int cxd56_gnss_start_navmsg_output(FAR struct file *filep, setting = (FAR struct cxd56_rtk_setting_s *)arg; - return GD_RtkStart(setting); + return fw_gd_rtkstart(setting); } /**************************************************************************** @@ -1918,7 +1942,7 @@ static int cxd56_gnss_set_var_ephemeris(FAR struct file *filep, param = (FAR struct cxd56_gnss_set_var_ephemeris_s *)arg; - return GD_SetVarEphemeris(param->data, param->size); + return fw_gd_setvarephemeris(param->data, param->size); } /**************************************************************************** @@ -1949,7 +1973,134 @@ static int cxd56_gnss_get_var_ephemeris(FAR struct file *filep, param = (FAR struct cxd56_gnss_get_var_ephemeris_s *)arg; - return GD_GetVarEphemeris(param->type, param->data, param->size); + return fw_gd_getvarephemeris(param->type, param->data, param->size); +} + +/**************************************************************************** + * Name: cxd56_gnss_set_usecase + * + * Description: + * Set usecase mode + * + * Input Parameters: + * filep - File structure pointer + * arg - Data for command + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +static int cxd56_gnss_set_usecase(FAR struct file *filep, + unsigned long arg) +{ + return fw_gd_setusecase(arg); +} + +/**************************************************************************** + * Name: cxd56_gnss_get_usecase + * + * Description: + * Get usecase mode + * + * Input Parameters: + * filep - File structure pointer + * arg - Data for command + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +static int cxd56_gnss_get_usecase(FAR struct file *filep, + unsigned long arg) +{ + int ret; + uint32_t usecase = 0; + + if (!arg) + { + return -EINVAL; + } + + ret = fw_gd_getusecase(&usecase); + *(uint32_t *)arg = usecase; + + return ret; +} + +/**************************************************************************** + * Name: cxd56_gnss_set_1pps_output + * + * Description: + * Set enable or disable of 1PPS output + * + * Input Parameters: + * filep - File structure pointer + * arg - Data for command + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +static int cxd56_gnss_set_1pps_output(FAR struct file *filep, + unsigned long arg) +{ + if (arg) + { + /* Enable 1PPS output pin */ + +#ifdef CONFIG_CXD56_GNSS_1PPS_PIN_GNSS_1PPS_OUT + CXD56_PIN_CONFIGS(PINCONFS_GNSS_1PPS_OUT); +#else + CXD56_PIN_CONFIGS(PINCONFS_HIF_IRQ_OUT_GNSS_1PPS_OUT); +#endif + } + else + { + /* Disable 1PPS output pin */ + +#ifdef CONFIG_CXD56_GNSS_1PPS_PIN_GNSS_1PPS_OUT + CXD56_PIN_CONFIGS(PINCONFS_GNSS_1PPS_OUT_GPIO); +#else + CXD56_PIN_CONFIGS(PINCONFS_HIF_IRQ_OUT_GPIO); +#endif + } + + return fw_gd_set1ppsoutput(arg); +} + +/**************************************************************************** + * Name: cxd56_gnss_get_1pps_output + * + * Description: + * Get the current 1PPS output setting + * + * Input Parameters: + * filep - File structure pointer + * arg - Data for command + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +static int cxd56_gnss_get_1pps_output(FAR struct file *filep, + unsigned long arg) +{ + int ret; + uint32_t enable = 0; + + if (!arg) + { + return -EINVAL; + } + + ret = fw_gd_get1ppsoutput(&enable); + *(uint32_t *)arg = enable; + + return ret; } /* Synchronized with processes and CPUs @@ -2102,7 +2253,7 @@ static void cxd56_gnss_read_backup_file(FAR int *retval) break; } - ret = GD_WriteBuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, n); + ret = fw_gd_writebuffer(CXD56_CPU1_DATA_TYPE_BACKUP, offset, buf, n); if (ret < 0) { break; @@ -2172,7 +2323,7 @@ static void cxd56_gnss_common_signalhandler(uint32_t data, if (issetmask) { - GD_SetNotifyMask(sigtype, FALSE); + fw_gd_setnotifymask(sigtype, FALSE); } nxsem_post(&priv->devsem); @@ -2432,6 +2583,11 @@ static int8_t cxd56_gnss_select_notifytype(off_t fpos, FAR uint32_t *offset) type = CXD56_CPU1_DATA_TYPE_DCREPORT; *offset = 0; } + else if (fpos == CXD56_GNSS_READ_OFFSET_SARRLM) + { + type = CXD56_CPU1_DATA_TYPE_SARRLM; + *offset = 0; + } else { type = -1; @@ -2479,10 +2635,18 @@ static int cxd56_gnss_open(FAR struct file *filep) FAR struct inode * inode; FAR struct cxd56_gnss_dev_s *priv; int ret = OK; + int retry = 50; inode = filep->f_inode; priv = (FAR struct cxd56_gnss_dev_s *)inode->i_private; + while (!g_rtc_enabled && 0 < retry--) + { + /* GNSS requires stable RTC */ + + usleep(100 * 1000); + } + ret = nxsem_wait(&priv->devsem); if (ret < 0) { @@ -2497,20 +2661,22 @@ static int cxd56_gnss_open(FAR struct file *filep) goto _err0; } - ret = PM_LoadImage(CXD56_GNSS_GPS_CPUID, CXD56_GNSS_FWNAME); + nxsem_set_protocol(&priv->syncsem, SEM_PRIO_NONE); + + ret = fw_pm_loadimage(CXD56_GNSS_GPS_CPUID, CXD56_GNSS_FWNAME); if (ret < 0) { goto _err1; } - ret = PM_StartCpu(CXD56_GNSS_GPS_CPUID, 1); + ret = fw_pm_startcpu(CXD56_GNSS_GPS_CPUID, 1); if (ret < 0) { goto _err2; } #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP - PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_DISABLE); + fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_DISABLE); #endif /* Wait the request from GNSS core to restore backup data, @@ -2524,8 +2690,8 @@ static int cxd56_gnss_open(FAR struct file *filep) goto _err2; } - ret = GD_WriteBuffer(CXD56_CPU1_DATA_TYPE_INFO, 0, &priv->shared_info, - sizeof(priv->shared_info)); + ret = fw_gd_writebuffer(CXD56_CPU1_DATA_TYPE_INFO, 0, + &priv->shared_info, sizeof(priv->shared_info)); if (ret < 0) { goto _err2; @@ -2539,9 +2705,9 @@ static int cxd56_gnss_open(FAR struct file *filep) _err2: #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP - PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); + fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); #endif - PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); + fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); _err1: nxsem_destroy(&priv->syncsem); _err0: @@ -2583,10 +2749,10 @@ static int cxd56_gnss_close(FAR struct file *filep) if (priv->num_open == 0) { #ifndef CONFIG_CXD56_GNSS_HOT_SLEEP - PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); + fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_HOT_ENABLE); #endif - ret = PM_SleepCpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); + ret = fw_pm_sleepcpu(CXD56_GNSS_GPS_CPUID, PM_SLEEP_MODE_COLD); if (ret < 0) { goto errout; @@ -2658,9 +2824,9 @@ static ssize_t cxd56_gnss_read(FAR struct file *filep, FAR char *buffer, } } - /* GD_ReadBuffer returns copied data size or negative error code */ + /* fw_gd_readbuffer returns copied data size or negative error code */ - ret = GD_ReadBuffer(type, offset, buffer, len); + ret = fw_gd_readbuffer(type, offset, buffer, len); _err: _success: @@ -2786,7 +2952,7 @@ static int cxd56_gnss_poll(FAR struct file *filep, FAR struct pollfd *fds, priv->fds[i] = fds; fds->priv = &priv->fds[i]; - GD_SetNotifyMask(CXD56_CPU1_DEV_GNSS, FALSE); + fw_gd_setnotifymask(CXD56_CPU1_DEV_GNSS, FALSE); break; } } @@ -2879,6 +3045,10 @@ static int cxd56_gnss_register(FAR const char *devpath) { CXD56_CPU1_DATA_TYPE_DCREPORT, cxd56_gnss_common_signalhandler + }, + { + CXD56_CPU1_DATA_TYPE_SARRLM, + cxd56_gnss_common_signalhandler } }; @@ -2906,6 +3076,8 @@ static int cxd56_gnss_register(FAR const char *devpath) goto _err0; } + nxsem_set_protocol(&priv->apiwait, SEM_PRIO_NONE); + ret = nxsem_init(&priv->ioctllock, 0, 1); if (ret < 0) { diff --git a/arch/arm/src/cxd56xx/cxd56_gnss_api.h b/arch/arm/src/cxd56xx/cxd56_gnss_api.h index dc05a9979fd..23cbbef62bd 100644 --- a/arch/arm/src/cxd56xx/cxd56_gnss_api.h +++ b/arch/arm/src/cxd56xx/cxd56_gnss_api.h @@ -61,7 +61,7 @@ /* GD operation mode */ -/* GD_SetOperationMode, GD_GetOperationMode */ +/* fw_gd_setoperationmode, fw_gd_getoperationmode */ #define CXD56_GNSS_OPMOD_NORMAL 1 #define CXD56_GNSS_OPMOD_LOWPOWER 2 @@ -76,293 +76,309 @@ * beginning to search the satellites and measure the receiver position */ -int GD_Start(uint8_t startMode); +int fw_gd_start(uint8_t startmode); /* Stop a positioning */ -int GD_Stop(void); +int fw_gd_stop(void); /* Select GNSSs to positioning * These are able to specified by CXD56_GNSS_B_SAT_XXX defines. */ -int GD_SelectSatelliteSystem(uint32_t system); +int fw_gd_selectsatellitesystem(uint32_t system); /* Get current using GNSSs to positioning * A argument 'satellite' indicates current GNSSs by bit fields defined * by CXD56_GNSS_B_SAT_XXX. */ -int GD_GetSatelliteSystem(FAR uint32_t *system); +int fw_gd_getsatellitesystem(FAR uint32_t *system); /* Set the rough receiver position */ -int GD_SetReceiverPositionEllipsoidal(FAR double *dLat, FAR double *dLon, - FAR double *dHeight); +int fw_gd_setreceiverpositionellipsoidal(FAR double *dlat, FAR double *dlon, + FAR double *dheight); /* Set the rough receiver position as orgothonal */ -int GD_SetReceiverPositionOrthogonal(int32_t dX, int32_t dY, int32_t dZ); +int fw_gd_setreceiverpositionorthogonal(int32_t dx, int32_t dy, int32_t dz); /* Set enable or disable the 1PPS output. */ -int GD_Set1ppsOutput(uint32_t enable); +int fw_gd_set1ppsoutput(uint32_t enable); /* Get the current 1PPS output setting. */ -int GD_Get1ppsOutput(FAR uint32_t *enable); +int fw_gd_get1ppsoutput(FAR uint32_t *enable); /* Set the receiver operation mode * 1st argument 'mode' is a operation mode defined by CXD56_GNSS_OPMOD_XXX. * 2nd argument 'cycle' is a positioning period[ms], default is 1000[ms]. */ -int GD_SetOperationMode(uint32_t mode, uint32_t cycle); +int fw_gd_setoperationmode(uint32_t mode, uint32_t cycle); /* Get the receiver operation mode */ -int GD_GetOperationMode(FAR uint32_t *mode, FAR uint32_t *cycle); +int fw_gd_getoperationmode(FAR uint32_t *mode, FAR uint32_t *cycle); /* Set the TCXO offset */ -int GD_SetTcxoOffset(int32_t offset); +int fw_gd_settcxooffset(int32_t offset); /* Get the TCXO offset */ -int GD_GetTcxoOffset(FAR int32_t *offset); +int fw_gd_gettcxooffset(FAR int32_t *offset); /* Set the estimated current time of the receiver. * 1st argument date & time are in UTC. */ -int GD_SetTime(FAR struct cxd56_gnss_date_s *date, +int fw_gd_settime(FAR struct cxd56_gnss_date_s *date, FAR struct cxd56_gnss_time_s *time); /* Set the network time */ -int GD_SetFrameTime(uint16_t sec, uint32_t fracSec); +int fw_gd_setframetime(uint16_t sec, uint32_t fracsec); /* Get the almanac data */ -int GD_GetAlmanac(uint32_t satellite, FAR uint32_t *almanac, - FAR uint32_t *almanacSize); +int fw_gd_getalmanac(uint32_t satellite, FAR uint32_t *almanac, + FAR uint32_t *almanacsize); /* Set the almanac data */ -int GD_SetAlmanac(uint32_t satellite, FAR uint32_t *almanac); +int fw_gd_setalmanac(uint32_t satellite, FAR uint32_t *almanac); /* Get the Ephemeris data */ -int GD_GetEphemeris(uint32_t satellite, FAR uint32_t *ephemeris, - FAR uint32_t *ephemerisSize); +int fw_gd_getephemeris(uint32_t satellite, FAR uint32_t *ephemeris, + FAR uint32_t *ephemerissize); /* Set the Ephemeris data */ -int GD_SetEphemeris(uint32_t satellite, FAR uint32_t *ephemeris); +int fw_gd_setephemeris(uint32_t satellite, FAR uint32_t *ephemeris); /* Select to use or not use the initial position calculation supporting * information of the QZSS L1-SAIF. */ -int GD_SetQzssPosAssist(uint32_t enable); +int fw_gd_setqzssposassist(uint32_t enable); /* Get a setting of the initial position calculation supporting * information of the QZSS L1-SAIF. */ -int GD_GetQzssPosAssist(FAR uint32_t *enable); +int fw_gd_getqzssposassist(FAR uint32_t *enable); /* Set IMES bitrates. */ -int GD_SetImesBitrate(uint32_t bitrate); +int fw_gd_setimesbitrate(uint32_t bitrate); /* Get IMES bitrates. */ -int GD_GetImesBitrate(FAR uint32_t *bitrate); +int fw_gd_getimesbitrate(FAR uint32_t *bitrate); /* Set IMES center frequency offset. */ -int GD_SetImesCenterFreqOffset(uint32_t offset); +int fw_gd_setimescenterfreqoffset(uint32_t offset); /* Set IMES preamble. */ -int GD_SetImesPreamble(uint32_t preamble); +int fw_gd_setimespreamble(uint32_t preamble); /* Start GPS test */ -void GD_StartGpsTest(uint32_t satellite, uint32_t reserve1, +void fw_gd_startgpstest(uint32_t satellite, uint32_t reserve1, uint32_t reserve2, uint32_t reserve3); /* Stop GPS test */ -int GD_StopGpsTest(void); +int fw_gd_stopgpstest(void); /* Get GPS test result */ -int GD_GetGpsTestResult(FAR float *cn, FAR float *doppler); +int fw_gd_getgpstestresult(FAR float *cn, FAR float *doppler); /* Control Spectrum output */ -int GD_SpectrumControl(unsigned long time, unsigned int enable, - unsigned char moniPoint1, unsigned char step1, - unsigned char moniPoint2, unsigned char step2); +int fw_gd_spectrumcontrol(unsigned long time, unsigned int enable, + unsigned char monipoint1, unsigned char step1, + unsigned char monipoint2, unsigned char step2); /* Save the backup data to a Flash memory. */ -int GD_SaveBackupdata(void); +int fw_gd_savebackupdata(void); /* CEP Check Assist Data Valid */ -int GD_CepCheckAssistData(void); +int fw_gd_cepcheckassistdata(void); /* CEP Get Age Data */ -int GD_CepGetAgeData(FAR float *age, FAR float *cepi); +int fw_gd_cepgetagedata(FAR float *age, FAR float *cepi); /* CEP Reset Assist Data init flag & valid flag */ -int GD_CepInitAssistData(void); +int fw_gd_cepinitassistdata(void); /* AGPS Set tau */ -int GD_SetTauGps(FAR double *tau); +int fw_gd_settaugps(FAR double *tau); /* AGPS Set Acquist */ -int GD_SetAcquist(FAR uint8_t *pAcquistData, uint16_t acquistSize); +int fw_gd_setacquist(FAR uint8_t *pacquistdata, uint16_t acquistsize); /* Set the estimated current time of the receiver. * 1st argument date & time are in GPS time. */ -int GD_SetTimeGps(FAR struct cxd56_gnss_date_s *date, +int fw_gd_settimegps(FAR struct cxd56_gnss_date_s *date, FAR struct cxd56_gnss_time_s *time); /* Clear Receiver Information */ -int GD_ClearReceiverInfo(uint32_t type); +int fw_gd_clearreceiverinfo(uint32_t type); /* AGPS Set Tow Assist */ -int GD_SetTowAssist(FAR uint8_t *pAssistData, uint16_t dataSize); +int fw_gd_settowassist(FAR uint8_t *passistdata, uint16_t datasize); /* AGPS Set UTC Model */ -int GD_SetUtcModel(FAR uint8_t *pModelData, uint16_t dataSize); +int fw_gd_setutcmodel(FAR uint8_t *pmodeldata, uint16_t datasize); /* Read GNSS data to specified buffer */ -int GD_ReadBuffer(uint8_t type, int32_t offset, FAR void *buf, +int fw_gd_readbuffer(uint8_t type, int32_t offset, FAR void *buf, uint32_t length); /* Write GNSS data from specified buffer */ -int GD_WriteBuffer(uint8_t type, int32_t offset, FAR void *buf, +int fw_gd_writebuffer(uint8_t type, int32_t offset, FAR void *buf, uint32_t length); /* Set notify mask, this mask flag is cleared when notified(poll/signal) */ -int GD_SetNotifyMask(uint8_t type, uint8_t clear); +int fw_gd_setnotifymask(uint8_t type, uint8_t clear); /* Geofence Add Region */ -int GD_GeoAddRegion(uint8_t id, long lat, long lon, uint16_t rad); +int fw_gd_geoaddregion(uint8_t id, long lat, long lon, uint16_t rad); /* Geofence Modify Region */ -int GD_GeoModifyRegion(uint8_t id, long lat, long lon, uint16_t rad); +int fw_gd_geomodifyregion(uint8_t id, long lat, long lon, uint16_t rad); /* Geofence Delete Region */ -int GD_GeoDeleteRegione(uint8_t id); +int fw_gd_geodeleteregione(uint8_t id); /* Geofence All delete Region */ -int GD_GeoDeleteAllRegion(void); +int fw_gd_geodeleteallregion(void); /* Geofence Region check */ -int GD_GeoGetRegionData(uint8_t id, FAR long *lat, FAR long *lon, +int fw_gd_geogetregiondata(uint8_t id, FAR long *lat, FAR long *lon, FAR uint16_t *rad); /* Geofence Get Used Region ID */ -uint32_t GD_GeoGetUsedRegionId(void); +uint32_t fw_gd_geogetusedregionid(void); /* Geofence Set mode */ -int GD_GeoSetOpMode(uint16_t deadzone, uint16_t dwell_detecttime); +int fw_gd_geosetopmode(uint16_t deadzone, uint16_t dwell_detecttime); /* Geofence Request All region notify */ -int GD_GeoSetAllRgionNotifyRequest(void); +int fw_gd_geosetallrgionnotifyrequest(void); /* Geofence Register to gnss_provider */ -int GD_RegisterGeofence(void); +int fw_gd_registergeofence(void); /* Geofence Release from gnss_provider */ -int GD_ReleaseGeofence(void); +int fw_gd_releasegeofence(void); /* Pvtlog Register to gnss_provider */ -int GD_RegisterPvtlog(uint32_t cycle, uint32_t threshold); +int fw_gd_registerpvtlog(uint32_t cycle, uint32_t threshold); /* Pvtlog Release */ -int GD_ReleasePvtlog(void); +int fw_gd_releasepvtlog(void); /* Pvtlog Delete log data */ -int GD_PvtlogDeleteLog(void); +int fw_gd_pvtlogdeletelog(void); /* Pvtlog Get Log status */ -int GD_PvtlogGetLogStatus(FAR struct cxd56_gnss_status_s *pLogStatus); +int fw_gd_pvtloggetlogstatus(FAR struct cxd56_gnss_status_s *plogstatus); /* Start outputting carrier phase info. */ -int GD_RtkStart(FAR struct cxd56_rtk_setting_s *pParam); +int fw_gd_rtkstart(FAR struct cxd56_rtk_setting_s *pparam); /* Stop outputting carrier phase info. */ -int GD_RtkStop(void); +int fw_gd_rtkstop(void); /* Set output interval of carrier phase info. * * interval : CXD56_GNSS_RTK_INTERVAL_XXX (gd_type.h) */ -int GD_RtkSetOutputInterval(int interval); +int fw_gd_rtksetoutputinterval(int interval); /* Get output interval of carrier phase info. [ms] */ -int GD_RtkGetOutputInterval(FAR int *interval); +int fw_gd_rtkgetoutputinterval(FAR int *interval); /* Set GNSS of outputting carrier phase info. */ -int GD_RtkSetGnss(uint32_t gnss); +int fw_gd_rtksetgnss(uint32_t gnss); /* Get GNSS of outputting carrier phase info. */ -int GD_RtkGetGnss(FAR uint32_t *pGnss); +int fw_gd_rtkgetgnss(FAR uint32_t *pgnss); /* Set enable/disable GD to notify updating ephemeris */ -int GD_RtkSetEphNotify(int enable); +int fw_gd_rtksetephnotify(int enable); /* Get enable/disable GD to notify updating ephemeris */ -int GD_RtkGetEphNotify(FAR int *enable); +int fw_gd_rtkgetephnotify(FAR int *enable); /* Set the Ephemeris data Ephemeris data size is variable. */ -int GD_SetVarEphemeris(uint32_t *ephemeris, uint32_t ephemerisSize); +int fw_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, - uint32_t ephemerisSize); +int fw_gd_getvarephemeris(uint32_t satellite, uint32_t *ephemeris, + uint32_t ephemerissize); + +/* Set usecase mode */ + +int fw_gd_setusecase(uint32_t usecase); + +/* Get usecase mode */ + +int fw_gd_getusecase(uint32_t *usecase); + +/* Set enable or disable of 1PPS output */ + +int fw_gd_set1ppsoutput(uint32_t enable); + +/* Get the current 1PPS output setting */ + +int fw_gd_get1ppsoutput(uint32_t *enable); #endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_GNSS_API_H */ diff --git a/arch/arm/src/cxd56xx/cxd56_i2c.c b/arch/arm/src/cxd56xx/cxd56_i2c.c index 487f95f6bae..3a1610c998c 100644 --- a/arch/arm/src/cxd56xx/cxd56_i2c.c +++ b/arch/arm/src/cxd56xx/cxd56_i2c.c @@ -146,6 +146,9 @@ static struct cxd56_i2cdev_s g_i2c2dev = * Private Functions ****************************************************************************/ +static inline int i2c_takesem(FAR sem_t *sem); +static inline int i2c_givesem(FAR sem_t *sem); + 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, @@ -172,6 +175,24 @@ static int cxd56_i2c_transfer_scu(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, int count); #endif +/**************************************************************************** + * Name: i2c_takesem + ****************************************************************************/ + +static inline int i2c_takesem(FAR sem_t *sem) +{ + return nxsem_wait_uninterruptible(sem); +} + +/**************************************************************************** + * Name: i2c_givesem + ****************************************************************************/ + +static inline int i2c_givesem(FAR sem_t *sem) +{ + return nxsem_post(sem); +} + /**************************************************************************** * Name: cxd56_i2c_pincontrol * @@ -368,7 +389,7 @@ static void cxd56_i2c_timeout(int argc, uint32_t arg, ...) irqstate_t flags = enter_critical_section(); priv->error = -ENODEV; - nxsem_post(&priv->wait); + i2c_givesem(&priv->wait); leave_critical_section(flags); } @@ -475,7 +496,7 @@ static int cxd56_i2c_interrupt(int irq, FAR void *context, FAR void *arg) ret = wd_cancel(priv->timeout); if (ret == OK) { - nxsem_post(&priv->wait); + i2c_givesem(&priv->wait); } } @@ -538,7 +559,7 @@ static int cxd56_i2c_receive(struct cxd56_i2cdev_s *priv, int last) i2c_reg_rmw(priv, CXD56_IC_INTR_MASK, INTR_RX_FULL, INTR_RX_FULL); leave_critical_section(flags); - nxsem_wait(&priv->wait); + i2c_takesem(&priv->wait); if (priv->error != OK) { @@ -584,7 +605,7 @@ static int cxd56_i2c_send(struct cxd56_i2cdev_s *priv, int last) i2c_reg_rmw(priv, CXD56_IC_INTR_MASK, INTR_TX_EMPTY, INTR_TX_EMPTY); leave_critical_section(flags); - nxsem_wait(&priv->wait); + i2c_takesem(&priv->wait); return 0; } @@ -613,7 +634,7 @@ static int cxd56_i2c_transfer(FAR struct i2c_master_s *dev, /* Get exclusive access to the I2C bus */ - nxsem_wait(&priv->mutex); + i2c_takesem(&priv->mutex); /* Check wait semaphore value. If the value is not 0, the transfer can not * be performed normally. @@ -691,7 +712,8 @@ static int cxd56_i2c_transfer(FAR struct i2c_master_s *dev, cxd56_i2c_clock_gate_enable(priv->port); - nxsem_post(&priv->mutex); + i2c_givesem(&priv->mutex); + return ret; } @@ -829,7 +851,7 @@ static int cxd56_i2c_transfer_scu(FAR struct i2c_master_s *dev, /* Get exclusive access to the I2C bus */ - nxsem_wait(&priv->mutex); + i2c_takesem(&priv->mutex); /* Apply frequency for request msgs */ @@ -866,7 +888,7 @@ static int cxd56_i2c_transfer_scu(FAR struct i2c_master_s *dev, } } - nxsem_post(&priv->mutex); + i2c_givesem(&priv->mutex); return ret; } @@ -1031,6 +1053,7 @@ struct i2c_master_s *cxd56_i2cbus_initialize(int port) nxsem_init(&priv->mutex, 0, 1); nxsem_init(&priv->wait, 0, 0); + nxsem_set_protocol(&priv->wait, SEM_PRIO_NONE); priv->timeout = wd_create(); diff --git a/arch/arm/src/cxd56xx/cxd56_icc.c b/arch/arm/src/cxd56xx/cxd56_icc.c index d6d26fe37d1..92dcdc903a1 100644 --- a/arch/arm/src/cxd56xx/cxd56_icc.c +++ b/arch/arm/src/cxd56xx/cxd56_icc.c @@ -163,6 +163,11 @@ static int icc_semtake(sem_t *semid) return nxsem_wait_uninterruptible(semid); } +static int icc_semtrytake(sem_t *semid) +{ + return sem_trywait(semid); +} + static void icc_semgive(sem_t *semid) { nxsem_post(semid); @@ -314,20 +319,31 @@ static int icc_recv(FAR struct iccdev_s *priv, FAR iccmsg_t *msg, int32_t ms) irqstate_t flags; int ret = OK; - if (ms) + if (ms == -1) + { + /* Try to take the semaphore without waiging. */ + + ret = icc_semtrytake(&priv->rxwait); + if (ret < 0) + { + ret = -get_errno(); + return ret; + } + } + else if (ms == 0) + { + icc_semtake(&priv->rxwait); + } + else { int32_t timo; timo = ms * 1000 / CONFIG_USEC_PER_TICK; wd_start(priv->rxtimeout, timo, icc_rxtimeout, 1, (uint32_t)priv); - } - ret = icc_semtake(&priv->rxwait); - if (ret < 0) - { - return ret; - } + icc_semtake(&priv->rxwait); - wd_cancel(priv->rxtimeout); + wd_cancel(priv->rxtimeout); + } flags = enter_critical_section(); req = (FAR struct iccreq_s *)sq_remfirst(&priv->recvq); @@ -366,6 +382,7 @@ static FAR struct iccdev_s *icc_devnew(void) priv->rxtimeout = wd_create(); nxsem_init(&priv->rxwait, 0, 0); + nxsem_set_protocol(&priv->rxwait, SEM_PRIO_NONE); /* Initialize receive queue and free list */ diff --git a/arch/arm/src/cxd56xx/cxd56_pinconfig.c b/arch/arm/src/cxd56xx/cxd56_pinconfig.c index 1e483a622cf..0dc75de3dde 100644 --- a/arch/arm/src/cxd56xx/cxd56_pinconfig.c +++ b/arch/arm/src/cxd56xx/cxd56_pinconfig.c @@ -377,8 +377,7 @@ int cxd56_pin_configs(uint32_t pinconfs[], size_t n) /* Set HostIF latch off */ - if (((PIN_SPI2_CS_X <= pin) && (pin <= latch_endpin)) && - (PINCONF_MODE0 == mode)) + if ((PIN_SPI2_CS_X <= pin) && (pin <= latch_endpin)) { modifyreg32(CXD56_TOPREG_DBG_HOSTIF_SEL, LATCH_OFF_MASK, diff --git a/arch/arm/src/cxd56xx/cxd56_pmic.c b/arch/arm/src/cxd56xx/cxd56_pmic.c index f5869c7aeab..d61d785e8f6 100644 --- a/arch/arm/src/cxd56xx/cxd56_pmic.c +++ b/arch/arm/src/cxd56xx/cxd56_pmic.c @@ -163,7 +163,7 @@ struct pmic_temp_mode_s int high; }; -extern int pm_pmic_control(int cmd, void *arg); +extern int fw_pm_pmiccontrol(int cmd, void *arg); /**************************************************************************** * Private Data @@ -299,7 +299,7 @@ static int pmic_int_handler(int irq, void *context, void *arg) int cxd56_pmic_get_interrupt_status(uint8_t *status) { - return pm_pmic_control(PMIC_CMD_INTSTATUS, status); + return fw_pm_pmiccontrol(PMIC_CMD_INTSTATUS, status); } /**************************************************************************** @@ -347,7 +347,7 @@ int cxd56_pmic_set_gpo_reg(uint8_t *setbit0, uint8_t *clrbit0, .clrbit1 = clrbit1, }; - return pm_pmic_control(PMIC_CMD_GPO, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_GPO, &arg); } /**************************************************************************** @@ -485,6 +485,51 @@ bool cxd56_pmic_get_gpo(uint8_t chset) return false; } +/**************************************************************************** + * Name: cxd56_pmic_get_gpo_hiz + * + * Description: + * Get the tristate value from the specified GPO channel(s) + * + * Input Parameter: + * chset : GPO Channel number(s) + * + * Returned Value: + * Return 0(off), 1(on) or -1(HiZ) + * + ****************************************************************************/ + +int cxd56_pmic_get_gpo_hiz(uint8_t chset) +{ + uint8_t setbit0 = 0; + uint8_t clrbit0 = 0; + uint8_t setbit1 = 0; + uint8_t clrbit1 = 0; + uint8_t set; + uint8_t hiz; + + cxd56_pmic_set_gpo_reg(&setbit0, &clrbit0, &setbit1, &clrbit1); + + set = ((setbit1 & 0xf) << 4) | (setbit0 & 0xf); + hiz = ((setbit1) & 0xf0) | ((setbit0 & 0xf0) >> 4); + + /* If all of the specified chset is hiz, return -1 */ + + if ((hiz & chset) != chset) + { + return -1; + } + + /* If all of the specified chset is high, return 1 */ + + if ((set & chset) == chset) + { + return 1; + } + + return 0; +} + /**************************************************************************** * Name: cxd56_pmic_set_loadswitch_reg * @@ -522,7 +567,7 @@ int cxd56_pmic_set_loadswitch_reg(uint8_t *setbit, uint8_t *clrbit) .clrbit = clrbit, }; - return pm_pmic_control(PMIC_CMD_LOADSW, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_LOADSW, &arg); } /**************************************************************************** @@ -620,7 +665,7 @@ int cxd56_pmic_set_ddc_ldo_reg(uint8_t *setbit, uint8_t *clrbit) .clrbit = clrbit, }; - return pm_pmic_control(PMIC_CMD_DDCLDO, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_DDCLDO, &arg); } /**************************************************************************** @@ -740,7 +785,7 @@ error: int cxd56_pmic_get_gauge(FAR struct pmic_gauge_s *gauge) { - return pm_pmic_control(PMIC_CMD_AFE, gauge); + return fw_pm_pmiccontrol(PMIC_CMD_AFE, gauge); } /**************************************************************************** @@ -759,7 +804,7 @@ int cxd56_pmic_get_gauge(FAR struct pmic_gauge_s *gauge) int cxd56_pmic_getlowervol(FAR int *voltage) { - return pm_pmic_control(PMIC_CMD_GETVSYS, voltage); + return fw_pm_pmiccontrol(PMIC_CMD_GETVSYS, voltage); } /**************************************************************************** @@ -778,7 +823,7 @@ int cxd56_pmic_getlowervol(FAR int *voltage) int cxd56_pmic_setlowervol(int voltage) { - return pm_pmic_control(PMIC_CMD_SETVSYS, (void *)voltage); + return fw_pm_pmiccontrol(PMIC_CMD_SETVSYS, (void *)voltage); } /**************************************************************************** @@ -797,7 +842,7 @@ int cxd56_pmic_setlowervol(int voltage) int cxd56_pmic_getnotifyvol(FAR int *voltage) { - return pm_pmic_control(PMIC_CMD_GETPREVSYS, voltage); + return fw_pm_pmiccontrol(PMIC_CMD_GETPREVSYS, voltage); } /**************************************************************************** @@ -816,7 +861,7 @@ int cxd56_pmic_getnotifyvol(FAR int *voltage) int cxd56_pmic_setnotifyvol(int voltage) { - return pm_pmic_control(PMIC_CMD_SETPREVSYS, (void *)voltage); + return fw_pm_pmiccontrol(PMIC_CMD_SETPREVSYS, (void *)voltage); } /**************************************************************************** @@ -838,7 +883,7 @@ int cxd56_pmic_getchargevol(FAR int *voltage) int val; int ret; - ret = pm_pmic_control(PMIC_CMD_GET_CHG_VOLTAGE, &val); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_VOLTAGE, &val); if (ret) { return -EIO; @@ -894,7 +939,7 @@ int cxd56_pmic_setchargevol(int voltage) val = (voltage - 4000) / 50; - return pm_pmic_control(PMIC_CMD_SET_CHG_VOLTAGE, (void *)val); + return fw_pm_pmiccontrol(PMIC_CMD_SET_CHG_VOLTAGE, (void *)val); } /**************************************************************************** @@ -917,7 +962,7 @@ int cxd56_pmic_getchargecurrent(FAR int *current) int val; int ret; - ret = pm_pmic_control(PMIC_CMD_GET_CHG_CURRENT, &val); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_CURRENT, &val); if (ret) { return ret; @@ -985,7 +1030,7 @@ int cxd56_pmic_setchargecurrent(int current) return -EFAULT; } - return pm_pmic_control(PMIC_CMD_SET_CHG_CURRENT, (void *)val); + return fw_pm_pmiccontrol(PMIC_CMD_SET_CHG_CURRENT, (void *)val); } /**************************************************************************** @@ -1004,7 +1049,7 @@ int cxd56_pmic_setchargecurrent(int current) int cxd56_pmic_getporttype(FAR int *porttype) { - return pm_pmic_control(PMIC_CMD_GET_USB_PORT_TYPE, porttype); + return fw_pm_pmiccontrol(PMIC_CMD_GET_USB_PORT_TYPE, porttype); } /**************************************************************************** @@ -1029,7 +1074,7 @@ int cxd56_pmic_getchargestate(uint8_t *state) /* Update charge state */ - ret = pm_pmic_control(PMIC_CMD_AFE, &arg); + ret = fw_pm_pmiccontrol(PMIC_CMD_AFE, &arg); if (ret) { return ret; @@ -1037,7 +1082,7 @@ int cxd56_pmic_getchargestate(uint8_t *state) /* Get actual charging state (CNT_USB1) */ - ret = pm_pmic_control(PMIC_CMD_GET_CHG_STATE, &val); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_STATE, &val); *state = val & 0xff; return ret; @@ -1086,7 +1131,7 @@ int cxd56_pmic_setrechargevol(int mv) return -EINVAL; } - return pm_pmic_control(PMIC_CMD_SET_RECHG_VOLTAGE, (void *)val); + return fw_pm_pmiccontrol(PMIC_CMD_SET_RECHG_VOLTAGE, (void *)val); } /**************************************************************************** @@ -1109,7 +1154,7 @@ int cxd56_pmic_getrechargevol(FAR int *mv) int val; int ret; - ret = pm_pmic_control(PMIC_CMD_GET_RECHG_VOLTAGE, &val); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_RECHG_VOLTAGE, &val); if (ret) { return ret; @@ -1189,7 +1234,7 @@ int cxd56_pmic_setchargecompcurrent(int current) break; } - return pm_pmic_control(PMIC_CMD_SET_CHG_IFIN, (void *)val); + return fw_pm_pmiccontrol(PMIC_CMD_SET_CHG_IFIN, (void *)val); } /**************************************************************************** @@ -1211,7 +1256,7 @@ int cxd56_pmic_getchargecompcurrent(FAR int *current) int val; int ret; - ret = pm_pmic_control(PMIC_CMD_GET_CHG_IFIN, &val); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_IFIN, &val); if (ret) { return ret; @@ -1269,7 +1314,7 @@ int cxd56_pmic_gettemptable(FAR struct pmic_temp_table_s *table) { /* SET_T60 (70h) - SET_T0_2 (78h) */ - return pm_pmic_control(PMIC_CMD_GET_CHG_TEMPERATURE_TABLE, table); + return fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_TEMPERATURE_TABLE, table); } /**************************************************************************** @@ -1289,7 +1334,7 @@ int cxd56_pmic_gettemptable(FAR struct pmic_temp_table_s *table) int cxd56_pmic_settemptable(FAR struct pmic_temp_table_s *table) { - return pm_pmic_control(PMIC_CMD_SET_CHG_TEMPERATURE_TABLE, table); + return fw_pm_pmiccontrol(PMIC_CMD_SET_CHG_TEMPERATURE_TABLE, table); } /**************************************************************************** @@ -1342,7 +1387,7 @@ int cxd56_pmic_setchargemode(int low, int high) return -EINVAL; } - return pm_pmic_control(PMIC_CMD_SET_CHG_TEMPERATURE_MODE, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_SET_CHG_TEMPERATURE_MODE, &arg); } /**************************************************************************** @@ -1369,7 +1414,7 @@ int cxd56_pmic_getchargemode(FAR int *low, FAR int *high) struct pmic_temp_mode_s arg; int ret; - ret = pm_pmic_control(PMIC_CMD_GET_CHG_TEMPERATURE_MODE, &arg); + ret = fw_pm_pmiccontrol(PMIC_CMD_GET_CHG_TEMPERATURE_MODE, &arg); if (ret) { return ret; @@ -1388,22 +1433,22 @@ int cxd56_pmic_getchargemode(FAR int *low, FAR int *high) int cxd56_pmic_monitor_enable(FAR struct pmic_mon_s *ptr) { - return pm_pmic_control(PMIC_CMD_POWER_MONITOR_ENABLE, ptr); + return fw_pm_pmiccontrol(PMIC_CMD_POWER_MONITOR_ENABLE, ptr); } int cxd56_pmic_monitor_status(FAR struct pmic_mon_status_s *ptr) { - return pm_pmic_control(PMIC_CMD_POWER_MONITOR_STATUS, ptr); + return fw_pm_pmiccontrol(PMIC_CMD_POWER_MONITOR_STATUS, ptr); } int cxd56_pmic_monitor_set(FAR struct pmic_mon_set_s *ptr) { - return pm_pmic_control(PMIC_CMD_POWER_MONITOR_SET, ptr); + return fw_pm_pmiccontrol(PMIC_CMD_POWER_MONITOR_SET, ptr); } int cxd56_pmic_monitor_get(FAR struct pmic_mon_log_s *ptr) { - return pm_pmic_control(PMIC_CMD_POWER_MONITOR_GET, ptr); + return fw_pm_pmiccontrol(PMIC_CMD_POWER_MONITOR_GET, ptr); } #endif @@ -1505,7 +1550,7 @@ int cxd56_pmic_read(uint8_t addr, void *buf, uint32_t size) .size = size, }; - return pm_pmic_control(PMIC_CMD_READ, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_READ, &arg); } /**************************************************************************** @@ -1540,7 +1585,7 @@ int cxd56_pmic_write(uint8_t addr, void *buf, uint32_t size) .size = size, }; - return pm_pmic_control(PMIC_CMD_WRITE, &arg); + return fw_pm_pmiccontrol(PMIC_CMD_WRITE, &arg); } #endif /* CONFIG_CXD56_PMIC */ diff --git a/arch/arm/src/cxd56xx/cxd56_pmic.h b/arch/arm/src/cxd56xx/cxd56_pmic.h index 94191f0c12b..b1707dac8a5 100644 --- a/arch/arm/src/cxd56xx/cxd56_pmic.h +++ b/arch/arm/src/cxd56xx/cxd56_pmic.h @@ -309,6 +309,22 @@ int cxd56_pmic_set_gpo_hiz(uint8_t chset); bool cxd56_pmic_get_gpo(uint8_t chset); +/**************************************************************************** + * Name: cxd56_pmic_get_gpo_hiz + * + * Description: + * Get the tristate value from the specified GPO channel(s) + * + * Input Parameter: + * chset : GPO Channel number(s) + * + * Returned Value: + * Return 0(off), 1(on) or -1(HiZ) + * + ****************************************************************************/ + +int cxd56_pmic_get_gpo_hiz(uint8_t chset); + /**************************************************************************** * Name: cxd56_pmic_set_loadswitch_reg * diff --git a/arch/arm/src/cxd56xx/cxd56_powermgr.c b/arch/arm/src/cxd56xx/cxd56_powermgr.c index 2a57f04fb8a..3ec465519cc 100644 --- a/arch/arm/src/cxd56xx/cxd56_powermgr.c +++ b/arch/arm/src/cxd56xx/cxd56_powermgr.c @@ -164,6 +164,8 @@ static void cxd56_pm_do_hotsleep(uint32_t idletime); static void cxd56_pm_intc_suspend(void); static void cxd56_pm_intc_resume(void); #endif +static int cxd56_pmmsghandler(int cpuid, int protoid, uint32_t pdata, + uint32_t data, FAR void *userdata); /**************************************************************************** * Private Data @@ -171,6 +173,7 @@ static void cxd56_pm_intc_resume(void); static struct cxd56_pm_target_id_s g_target_id_table; static mqd_t g_queuedesc; +static sem_t g_bootsync; static sem_t g_regcblock; static sem_t g_freqlock; static sem_t g_freqlockwait; @@ -432,6 +435,29 @@ static int cxd56_pm_maintask(int argc, FAR char *argv[]) { int size; struct cxd56_pm_message_s message; + struct mq_attr attr; + + attr.mq_maxmsg = 8; + attr.mq_msgsize = sizeof(struct cxd56_pm_message_s); + attr.mq_curmsgs = 0; + attr.mq_flags = 0; + + g_queuedesc = mq_open("cxd56_pm_message", O_RDWR | O_CREAT, 0666, &attr); + DEBUGASSERT((int)g_queuedesc != ERROR); + if (g_queuedesc < 0) + { + pmerr("Failed to create message queue\n"); + } + + /* Register power manager messaging protocol handler. */ + + cxd56_iccinit(CXD56_PROTO_PM); + + cxd56_iccregisterhandler(CXD56_PROTO_PM, cxd56_pmmsghandler, NULL); + + /* Notify that cxd56_pm_maintask is ready */ + + nxsem_post(&g_bootsync); while (1) { @@ -787,16 +813,9 @@ int cxd56_pm_hotsleep(int idletime) int cxd56_pm_initialize(void) { - struct mq_attr attr; int taskid; int ret; - cxd56_iccinit(CXD56_PROTO_PM); - - /* Register power manager messaging protocol handler. */ - - cxd56_iccregisterhandler(CXD56_PROTO_PM, cxd56_pmmsghandler, NULL); - dq_init(&g_cbqueue); sq_init(&g_freqlockqueue); sq_init(&g_wakelockqueue); @@ -814,19 +833,17 @@ int cxd56_pm_initialize(void) } ret = nxsem_init(&g_freqlockwait, 0, 0); + nxsem_set_protocol(&g_freqlockwait, SEM_PRIO_NONE); if (ret < 0) { return ret; } - attr.mq_maxmsg = 8; - attr.mq_msgsize = sizeof(struct cxd56_pm_message_s); - attr.mq_curmsgs = 0; - attr.mq_flags = 0; - g_queuedesc = mq_open("cxd56_pm_message", O_RDWR | O_CREAT, 0666, &attr); - if (g_queuedesc < 0) + ret = nxsem_init(&g_bootsync, 0, 0); + nxsem_set_protocol(&g_bootsync, SEM_PRIO_NONE); + if (ret < 0) { - return -EPERM; + return ret; } taskid = task_create("cxd56_pm_task", CXD56_PM_TASK_PRIO, @@ -837,6 +854,10 @@ int cxd56_pm_initialize(void) return -EPERM; } + /* wait until cxd56_pm_maintask thread is ready */ + + cxd56_pm_semtake(&g_bootsync); + return OK; } @@ -985,16 +1006,16 @@ uint32_t up_pm_clr_bootmask(uint32_t mask) int up_pm_sleep(enum pm_sleepmode_e mode) { - int PM_DeepSleep(void *); - int PM_ColdSleep(void *); + int fw_pm_deepsleep(void *); + int fw_pm_coldsleep(void *); switch (mode) { case PM_SLEEP_DEEP: - PM_DeepSleep(NULL); + fw_pm_deepsleep(NULL); break; case PM_SLEEP_COLD: - PM_ColdSleep(NULL); + fw_pm_coldsleep(NULL); break; } @@ -1012,8 +1033,8 @@ int up_pm_sleep(enum pm_sleepmode_e mode) int up_pm_reboot(void) { - void PM_Reboot(void); - PM_Reboot(); + void fw_pm_reboot(void); + fw_pm_reboot(); __asm volatile ("dsb"); for (; ; ); } diff --git a/arch/arm/src/cxd56xx/cxd56_pwm.c b/arch/arm/src/cxd56xx/cxd56_pwm.c index 4eb1a409355..1238d284881 100644 --- a/arch/arm/src/cxd56xx/cxd56_pwm.c +++ b/arch/arm/src/cxd56xx/cxd56_pwm.c @@ -63,16 +63,17 @@ #define PWM_REG(ch) \ ( \ - (PWM_REG_t*)(PWM_REG_BASE + (sizeof(PWM_REG_t) * (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))) \ + (pwm_phase_reg_t*) \ + (PWM_PHASE_REG_BASE + (sizeof(pwm_phase_reg_t) * (ch))) \ ) #define PWM_PARAM_OFFPERIOD_SHIFT (16) +#define PWM_PHASE_PRESCALE_SHIFT (16) #ifndef itemsof # define itemsof(array) (sizeof(array)/sizeof(array[0])) @@ -96,12 +97,12 @@ typedef struct volatile uint32_t PARAM; volatile uint32_t EN; volatile uint32_t UPDATE; -} PWM_REG_t; +} pwm_reg_t; typedef struct { volatile uint32_t PHASE; -} PWM_PHASE_REG_t; +} pwm_phase_reg_t; /**************************************************************************** * Static Function Prototypes @@ -218,19 +219,23 @@ static int pwm_pin_config(uint32_t channel) * * Output Parameters: * param - set value of PWM_PARAM register + * phase - set value of PWM_PHASE 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) +static int convert_freq2period(uint32_t freq, ub16_t duty, uint32_t *param, + uint32_t *phase) { DEBUGASSERT(param); + DEBUGASSERT(phase); uint32_t pwmfreq = 0; uint32_t period = 0; uint32_t offperiod = 0; + uint32_t prescale = 0; /* Get frequency of pwm base clock */ @@ -243,10 +248,10 @@ static int convert_freq2period(uint32_t freq, ub16_t duty, uint32_t *param) /* check frequency range */ - if ((freq > ((pwmfreq + 1) >> 1)) || (freq < (pwmfreq >> 16))) + if ((freq > ((pwmfreq + 1) >> 1)) || (freq <= 0)) { pwmerr("Frequency out of range. %d [Effective range:%d - %d]\n", - freq, pwmfreq >> 16, (pwmfreq + 1) >> 1); + freq, 1, (pwmfreq + 1) >> 1); return -1; } @@ -258,26 +263,65 @@ static int convert_freq2period(uint32_t freq, ub16_t duty, uint32_t *param) return -1; } + /* calcurate prescale */ + + if ((freq << 8) < (pwmfreq >> 8)) + { + for (prescale = 1; prescale <= 8; prescale++) + { + if (freq > ((pwmfreq >> prescale) / 65535)) + { + break; + } + } + } + /* calculate period and offperiod */ - period = (pwmfreq * 10 / freq - 5) / 10; + if (prescale > 0) + { + period = (((pwmfreq * 10) >> prescale) / freq + 5) / 10; + } + else + { + period = (pwmfreq * 10 / freq - 5) / 10; + } + if (period > 0xffff) { period = 0xffff; } - offperiod = ((0x10000 - duty) * (period + 1) + 0x8000) >> 16; - if (offperiod == 0) + if (prescale > 0) { - offperiod = 0; + offperiod = ((0x10000 - duty) * period + (1 << (16 - prescale))) >> 16; + if (offperiod < 2) + { + pwmerr("Duty out of range. %d\n", duty); + return -1; + } } - else if (period < offperiod) + else + { + offperiod = ((0x10000 - duty) * (period + 1) + 0x8000) >> 16; + } + + if (period < offperiod) { offperiod = period; } + pwminfo("Cycle = %d, Low = %d, High = %d, Clock = %d Hz\n", + (prescale) ? (period << prescale) : period + 1, + (prescale) ? (offperiod << prescale) - 1 : offperiod, + (prescale) ? (period << prescale) - (offperiod << prescale) + 1 + : period + 1 - offperiod, pwmfreq); + pwminfo("period/off/on = 0x%04x/0x%04x/0x%04x, prescale = %d\n", + period, offperiod, period - offperiod, prescale); + *param = (period & 0xffff) | ((offperiod & 0xffff) << PWM_PARAM_OFFPERIOD_SHIFT); + *phase = prescale << PWM_PHASE_PRESCALE_SHIFT; return OK; } @@ -306,7 +350,7 @@ static int pwm_setup(FAR struct pwm_lowerhalf_s *dev) ret = pwm_pin_config(priv->ch); if (ret < 0) { - pwmerr("Failed to pinconf():%d\n", channel); + pwmerr("Failed to pinconf() channel: %d\n", priv->ch); return -EINVAL; } @@ -354,6 +398,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, { FAR struct cxd56_pwm_chan_s *priv = (FAR struct cxd56_pwm_chan_s *)dev; uint32_t param; + uint32_t phase; int ret; if (info->duty <= 0) @@ -371,7 +416,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, } else { - ret = convert_freq2period(info->frequency, info->duty, ¶m); + ret = convert_freq2period(info->frequency, info->duty, ¶m, &phase); if (ret < 0) { return -EINVAL; @@ -387,10 +432,7 @@ static int pwm_start(FAR struct pwm_lowerhalf_s *dev, 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_PHASE_REG(priv->ch)->PHASE = phase; PWM_REG(priv->ch)->EN = 0x1; } @@ -466,6 +508,8 @@ FAR struct pwm_lowerhalf_s *cxd56_pwminitialize(uint32_t channel) { FAR struct cxd56_pwm_chan_s *pwmch; + (void)g_pwmops; + switch (channel) { #ifdef CONFIG_CXD56_PWM0 diff --git a/arch/arm/src/cxd56xx/cxd56_rtc.c b/arch/arm/src/cxd56xx/cxd56_rtc.c index 308d1e46e8c..ab4414a68c5 100644 --- a/arch/arm/src/cxd56xx/cxd56_rtc.c +++ b/arch/arm/src/cxd56xx/cxd56_rtc.c @@ -208,16 +208,6 @@ static int cxd56_rtc_interrupt(int irq, FAR void *context, FAR void *arg) id = RTC_ALARM0; clear = source & RTCREG_ALM0_MASK; } - else if (source & RTCREG_ALM1_MASK) - { - id = RTC_ALARM1; - clear = source & RTCREG_ALM1_MASK; - } - else if (source & RTCREG_ALM2_MASK) - { - id = RTC_ALARM2; - clear = source & RTCREG_ALM2_MASK; - } else { rtcerr("ERROR: Invalid ALARM\n"); @@ -311,10 +301,8 @@ static void cxd56_rtc_initialize(int argc, uint32_t arg, ...) /* Configure RTC interrupt to catch overflow and alarm interrupts. */ irq_attach(CXD56_IRQ_RTC0_A0, cxd56_rtc_interrupt, NULL); - irq_attach(CXD56_IRQ_RTC0_A2, cxd56_rtc_interrupt, NULL); irq_attach(CXD56_IRQ_RTC_INT, cxd56_rtc_interrupt, NULL); up_enable_irq(CXD56_IRQ_RTC0_A0); - up_enable_irq(CXD56_IRQ_RTC0_A2); up_enable_irq(CXD56_IRQ_RTC_INT); #endif @@ -332,9 +320,11 @@ static void cxd56_rtc_initialize(int argc, uint32_t arg, ...) clock_systime_timespec(&ts); } - /* Synchronize the system time to the RTC time */ +#ifdef CONFIG_RTC_HIRES + /* Synchronize the base time to the RTC time */ - clock_synchronize(); + up_rtc_gettime(&g_basetime); +#endif if (g_rtc_save->offset == 0) { diff --git a/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c b/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c index 62ee7e2133d..99183641887 100644 --- a/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c +++ b/arch/arm/src/cxd56xx/cxd56_rtc_lowerhalf.c @@ -319,12 +319,11 @@ static int cxd56_setalarm(FAR struct rtc_lowerhalf_s *lower, int ret = -EINVAL; DEBUGASSERT(lower != NULL && alarminfo != NULL); - DEBUGASSERT((RTC_ALARM0 == alarminfo->id) || - (RTC_ALARM1 == alarminfo->id)); + DEBUGASSERT(RTC_ALARM0 == alarminfo->id); priv = (FAR struct cxd56_lowerhalf_s *)lower; - if ((RTC_ALARM0 == alarminfo->id) || (RTC_ALARM1 == alarminfo->id)) + if (RTC_ALARM0 == alarminfo->id) { /* Remember the callback information */ @@ -380,9 +379,6 @@ static int cxd56_setrelative(FAR struct rtc_lowerhalf_s *lower, { struct lower_setalarm_s setalarm; FAR struct timespec ts; - struct alm_setalarm_s lowerinfo; - FAR struct cxd56_lowerhalf_s *priv; - FAR struct cxd56_cbinfo_s *cbinfo; time_t seconds; int ret = -EINVAL; @@ -390,9 +386,7 @@ static int cxd56_setrelative(FAR struct rtc_lowerhalf_s *lower, DEBUGASSERT((RTC_ALARM0 <= alarminfo->id) && (alarminfo->id < RTC_ALARM_LAST)); - if (((alarminfo->id == RTC_ALARM0) || - (alarminfo->id == RTC_ALARM1)) && - (alarminfo->reltime > 0)) + if ((alarminfo->id == RTC_ALARM0) && (alarminfo->reltime > 0)) { /* Disable pre-emption while we do this so that we don't have to worry * about being suspended and working on an old time. @@ -434,36 +428,6 @@ static int cxd56_setrelative(FAR struct rtc_lowerhalf_s *lower, sched_unlock(); } - else if ((alarminfo->id == RTC_ALARM2) && (alarminfo->reltime > 0)) - { - sched_lock(); - - priv = (FAR struct cxd56_lowerhalf_s *)lower; - - /* Remember the callback information */ - - cbinfo = &priv->cbinfo[alarminfo->id]; - cbinfo->cb = alarminfo->cb; - cbinfo->priv = alarminfo->priv; - - /* Set the alarm */ - - lowerinfo.as_id = alarminfo->id; - lowerinfo.as_cb = cxd56_alarm_callback; - lowerinfo.as_arg = priv; - - lowerinfo.as_time.tv_sec = alarminfo->reltime; - lowerinfo.as_time.tv_nsec = 0; - - ret = cxd56_rtc_setalarm(&lowerinfo); - if (ret < 0) - { - cbinfo->cb = NULL; - cbinfo->priv = NULL; - } - - sched_unlock(); - } return ret; } diff --git a/arch/arm/src/cxd56xx/cxd56_scu.c b/arch/arm/src/cxd56xx/cxd56_scu.c index 6040d195ebc..5c76a99fd46 100644 --- a/arch/arm/src/cxd56xx/cxd56_scu.c +++ b/arch/arm/src/cxd56xx/cxd56_scu.c @@ -69,7 +69,11 @@ /* SCU firmware (iSoP) binary */ +#ifdef CONFIG_CXD56_HPADC0_HIGHSPEED +#include "hardware/cxd5602_isop_hadc0_highspeed.h" +#else #include "hardware/cxd5602_isop.h" +#endif /**************************************************************************** * Pre-processor Definitions @@ -2006,6 +2010,8 @@ static int seq_fifoinit(FAR struct seq_s *seq, int fifoid, uint16_t fsize) /* Initialize DMA done wait semaphore */ nxsem_init(&fifo->dmawait, 0, 0); + nxsem_set_protocol(&fifo->dmawait, SEM_PRIO_NONE); + fifo->dmaresult = -1; #endif @@ -2748,14 +2754,36 @@ FAR struct seq_s *seq_open(int type, int bustype) { FAR struct seq_s *seq; + /* Check bustype is valid */ + + switch (bustype) + { + case SCU_BUS_SPI: + case SCU_BUS_I2C0: + case SCU_BUS_I2C1: + case SCU_BUS_LPADC0: + case SCU_BUS_LPADC1: + case SCU_BUS_LPADC2: + case SCU_BUS_LPADC3: + case SCU_BUS_HPADC0: + case SCU_BUS_HPADC1: + break; + default: + return NULL; + } + if (type == SEQ_TYPE_DECI) { seq = deci_new(); } - else + else if (type == SEQ_TYPE_NORMAL) { seq = seq_new(); } + else + { + return NULL; + } if (!seq) { @@ -3446,12 +3474,14 @@ void scu_initialize(void) memset(priv, 0, sizeof(struct cxd56_scudev_s)); - nxsem_init(&priv->syncwait, 0, 0); nxsem_init(&priv->syncexc, 0, 1); + nxsem_init(&priv->syncwait, 0, 0); + nxsem_set_protocol(&priv->syncwait, SEM_PRIO_NONE); for (i = 0; i < 3; i++) { nxsem_init(&priv->oneshotwait[i], 0, 0); + nxsem_set_protocol(&priv->oneshotwait[i], SEM_PRIO_NONE); } scufifo_initialize(); diff --git a/arch/arm/src/cxd56xx/cxd56_sdhci.c b/arch/arm/src/cxd56xx/cxd56_sdhci.c index d594bbb78d2..8de702a6c0d 100644 --- a/arch/arm/src/cxd56xx/cxd56_sdhci.c +++ b/arch/arm/src/cxd56xx/cxd56_sdhci.c @@ -238,37 +238,6 @@ * Private Types ****************************************************************************/ -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION -/* Structure describing a single SDIO card slot. */ - -struct sdio_softc_s -{ - int func_num; /* number of I/O functions (SDIO) */ - - /* Selected card */ - - FAR struct sdio_function_s *fn[SDIO_FUNC_NUM_MAX + 1]; - - bool full_speed; /* high speed mode */ - uint8_t dma; /* true: hardware supports DMA */ - sem_t sem; /* Assures mutually exclusive access to the - * sdio */ -}; - -/* Structure describing either an SDIO device I/O function. */ - -struct sdio_function_s -{ - /* common members */ - - FAR struct sdio_softc_s *sc; /* Dard slot softc */ - sdio_irqhandler_t *irq_callback; /* function callback */ - int number; /* I/O function number or -1, 0 for - * func0,1 for func1... */ - struct sdio_cis_s cis; /* Decoded CIS */ -}; -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ - /* This structure defines the state of the CXD56xx SDIO interface */ struct cxd56_sdiodev_s @@ -318,10 +287,6 @@ struct cxd56_sdiodev_s /* Parameters */ uint16_t blocksize; -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION - struct sdio_softc_s sc; /* Structure describing a single SDIO - * card slot. */ -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ }; /* Register logging support */ @@ -390,8 +355,10 @@ static void cxd56_dataconfig(struct cxd56_sdiodev_s *priv, bool bwrite, unsigned int blocksize, unsigned int nblocks, unsigned int timeout); static void cxd56_datadisable(void); +#ifndef CONFIG_SDIO_DMA static void cxd56_transmit(struct cxd56_sdiodev_s *priv); static void cxd56_receive(struct cxd56_sdiodev_s *priv); +#endif static void cxd56_eventtimeout(int argc, uint32_t arg, ...); static void cxd56_endwait(struct cxd56_sdiodev_s *priv, sdio_eventset_t wkupevent); @@ -427,10 +394,12 @@ static int cxd56_sdio_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg); static void cxd56_blocksetup(FAR struct sdio_dev_s *dev, unsigned int blocklen, unsigned int nblocks); +#ifndef CONFIG_SDIO_DMA static int cxd56_sdio_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, size_t nbytes); static int cxd56_sdio_sendsetup(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, uint32_t nbytes); +#endif static int cxd56_sdio_cancel(FAR struct sdio_dev_s *dev); static int cxd56_sdio_waitresponse(FAR struct sdio_dev_s *dev, @@ -463,27 +432,6 @@ static int cxd56_sdio_dmasendsetup(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, size_t buflen); #endif -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION -static int cxd56_sdio_enable_cardint(void); -static int cxd56_sdio_register_irq(FAR struct sdio_dev_s *dev, int func_num, - FAR sdio_irqhandler_t * handler); -static int cxd56_sdio_function_disable(FAR struct sdio_dev_s *dev, - int func_num); -static int cxd56_sdio_function_enable(FAR struct sdio_dev_s *dev, - int func_num); -static int cxd56_sdio_readb(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * rdata); -static int cxd56_sdio_writeb(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, uint8_t data, FAR uint8_t * rdata); -static int cxd56_sdio_read(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * data, uint32_t size); -static int cxd56_sdio_write(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * data, uint32_t size); -static int cxd56_sdhci_irq_handler(FAR struct sdio_dev_s *dev); -static int cxd56_sdio_get_cis(FAR struct sdio_dev_s *dev, int func_num, - FAR struct sdio_cis_s * cis); -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ - /* Initialization/uninitialization/reset ************************************/ static void cxd56_sdio_callback(void *arg); @@ -507,8 +455,13 @@ struct cxd56_sdiodev_s g_sdhcdev = .attach = cxd56_sdio_attach, .sendcmd = cxd56_sdio_sendcmd, .blocksetup = cxd56_blocksetup, +#ifndef CONFIG_SDIO_DMA .recvsetup = cxd56_sdio_recvsetup, .sendsetup = cxd56_sdio_sendsetup, +#else + .recvsetup = cxd56_sdio_dmarecvsetup, + .sendsetup = cxd56_sdio_dmasendsetup, +#endif .cancel = cxd56_sdio_cancel, .waitresponse = cxd56_sdio_waitresponse, .recv_r1 = cxd56_sdio_recvshortcrc, @@ -525,17 +478,10 @@ struct cxd56_sdiodev_s g_sdhcdev = #ifdef CONFIG_SDIO_DMA .dmarecvsetup = cxd56_sdio_dmarecvsetup, .dmasendsetup = cxd56_sdio_dmasendsetup, +#else + .dmarecvsetup = cxd56_sdio_recvsetup, + .dmasendsetup = cxd56_sdio_sendsetup, #endif -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION - .register_irq = cxd56_sdio_register_irq, - .function_disable = cxd56_sdio_function_disable, - .function_enable = cxd56_sdio_function_enable, - .readb = cxd56_sdio_readb, - .writeb = cxd56_sdio_writeb, - .read = cxd56_sdio_read, - .write = cxd56_sdio_write, - .get_cis = cxd56_sdio_get_cis, -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ }, }; @@ -855,6 +801,7 @@ static void cxd56_datadisable(void) * ****************************************************************************/ +#ifndef CONFIG_SDIO_DMA static void cxd56_transmit(struct cxd56_sdiodev_s *priv) { union @@ -925,6 +872,7 @@ static void cxd56_transmit(struct cxd56_sdiodev_s *priv) mcinfo("Exit: remaining: %d IRQSTAT: %08x\n", priv->remaining, getreg32(CXD56_SDHCI_IRQSTAT)); } +#endif /**************************************************************************** * Name: cxd56_receive @@ -940,6 +888,7 @@ static void cxd56_transmit(struct cxd56_sdiodev_s *priv) * ****************************************************************************/ +#ifndef CONFIG_SDIO_DMA static void cxd56_receive(struct cxd56_sdiodev_s *priv) { union @@ -1001,6 +950,7 @@ static void cxd56_receive(struct cxd56_sdiodev_s *priv) } } } +#endif /**************************************************************************** * Name: cxd56_eventtimeout @@ -1195,16 +1145,19 @@ static int cxd56_interrupt(int irq, FAR void *context, FAR void *arg) * system. */ - regval &= ~(SDHCI_INT_CINT | enabled); + regval &= ~SDHCI_INT_CINT; putreg32(regval, CXD56_SDHCI_IRQSIGEN); /* Clear all pending interrupts */ + putreg32(enabled, CXD56_SDHCI_IRQSTAT); + /* Handle in progress, interrupt driven data transfers ********************/ pending = enabled & priv->xfrints; if (pending != 0) { +#ifndef CONFIG_SDIO_DMA /* Is the RX buffer read ready? Is so then we must be processing a * non-DMA receive transaction. */ @@ -1227,6 +1180,7 @@ static int cxd56_interrupt(int irq, FAR void *context, FAR void *arg) cxd56_transmit(priv); } +#endif /* Handle transfer complete events */ @@ -1259,21 +1213,6 @@ static int cxd56_interrupt(int irq, FAR void *context, FAR void *arg) } } -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION - if (enabled & SDHCI_INT_CINT) - { - /* Handle card interrupt events */ - - putreg32(getreg32(CXD56_SDHCI_IRQSIGEN) & (~SDHCI_INT_CINT), - CXD56_SDHCI_IRQSIGEN); - putreg32(getreg32(CXD56_SDHCI_IRQSTATEN) & (~SDHCI_INT_CINT), - CXD56_SDHCI_IRQSTATEN); - work_cancel(HPWORK, &priv->cbwork); - work_queue(HPWORK, &priv->cbwork, - (worker_t)cxd56_sdhci_irq_handler, &priv->dev, 0); - } -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ - /* Handle error interrupts ************************************************/ if ((getreg32(CXD56_SDHCI_IRQSTAT) & SDHCI_INT_EINT) != 0) @@ -1312,7 +1251,7 @@ static int cxd56_interrupt(int irq, FAR void *context, FAR void *arg) /* Re-enable card interrupts */ regval = getreg32(CXD56_SDHCI_IRQSIGEN); - regval |= SDHCI_INT_CINT | enabled; + regval |= SDHCI_INT_CINT; putreg32(regval, CXD56_SDHCI_IRQSIGEN); return OK; @@ -2004,6 +1943,7 @@ static void cxd56_blocksetup(FAR struct sdio_dev_s *dev, * ****************************************************************************/ +#ifndef CONFIG_SDIO_DMA static int cxd56_sdio_recvsetup(FAR struct sdio_dev_s *dev, FAR uint8_t *buffer, size_t nbytes) { @@ -2039,6 +1979,7 @@ static int cxd56_sdio_recvsetup(FAR struct sdio_dev_s *dev, cxd56_sample(priv, SAMPLENDX_AFTER_SETUP); return OK; } +#endif /**************************************************************************** * Name: cxd56_sdio_sendsetup @@ -2060,6 +2001,7 @@ static int cxd56_sdio_recvsetup(FAR struct sdio_dev_s *dev, * ****************************************************************************/ +#ifndef CONFIG_SDIO_DMA static int cxd56_sdio_sendsetup(FAR struct sdio_dev_s *dev, FAR const uint8_t *buffer, size_t nbytes) { @@ -2093,6 +2035,7 @@ static int cxd56_sdio_sendsetup(FAR struct sdio_dev_s *dev, cxd56_sample(priv, SAMPLENDX_AFTER_SETUP); return OK; } +#endif /**************************************************************************** * Name: cxd56_sdio_cancel @@ -3253,1297 +3196,6 @@ static void cxd56_sdio_callback(void *arg) } } -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION -static int cxd56_sdio_takesem(FAR struct cxd56_sdiodev_s *priv) -{ - return nxsem_wait_uninterruptible(&priv->sc.sem); -} - -/**************************************************************************** - * Name: cxd56_sdio_make_cmd52arg - * - * Description: - * Create argument parameters for CMD52 - * - ****************************************************************************/ - -static uint32_t cxd56_sdio_make_cmd52arg(uint32_t addr, uint8_t val_w, - FAR uint8_t * out, int32_t write, uint32_t func_num) -{ - uint32_t arg = 0; - - arg = write ? SDIO_CMD5253_WRITE : SDIO_CMD5253_READ; - arg |= func_num << SDIO_CMD5253_FUNC_SHIFT; - arg |= (write && out) ? 0x08000000 : 0x00000000; - arg |= addr << SDIO_CMD52_REG_SHIFT; - if (write) - { - arg |= (val_w & SDIO_CMD52_DATA_MASK) << 0; - } - - return arg; -} - -/**************************************************************************** - * Name: cxd56_sdio_make_cmd53arg - * - * Description: - * Create argument parameters for CMD53 - * - ****************************************************************************/ - -static uint32_t cxd56_sdio_make_cmd53arg(int32_t write, uint32_t func_num, - uint32_t addr, int32_t incr_addr, - uint32_t blocks, uint32_t bytesz) -{ - uint32_t arg = 0; - - arg = write ? SDIO_CMD5253_WRITE : SDIO_CMD5253_READ; - arg |= func_num << SDIO_CMD5253_FUNC_SHIFT; - arg |= incr_addr ? 0x04000000 : 0x00000000; - arg |= addr << SDIO_CMD52_REG_SHIFT; - if (blocks == 0) - { - arg |= (bytesz == 512) ? 0 : bytesz; /* byte mode */ - } - else - { - arg |= 0x08000000 | blocks; /* block mode */ - } - - return arg; -} - -/**************************************************************************** - * Name: cxd56_sdio_sendcmdpoll - * - * Description: - * Send a command and poll-wait for the response. - * - ****************************************************************************/ - -static int cxd56_sdio_sendcmdpoll(FAR struct cxd56_sdiodev_s *priv, - uint32_t cmd, uint32_t arg) -{ - int ret; - - /* Send the command */ - - ret = cxd56_sdio_sendcmd(&priv->dev, cmd, arg); - if (ret == OK) - { - /* Then poll-wait until the response is available */ - - ret = cxd56_sdio_waitresponse(&priv->dev, cmd); - if (ret != OK) - { - mcerr("ERROR: Wait for response to cmd: %08x failed: %d\n", - cmd, ret); - } - } - - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_readb_internal - * - * Description: - * Read a byte of data. - * - ****************************************************************************/ - -static uint32_t cxd56_sdio_readb_internal(FAR struct sdio_function_s * sf, - uint32_t addr, FAR uint8_t * rdata) -{ - uint32_t response; - uint32_t cmd52arg; - struct cxd56_sdiodev_s *priv = &g_sdhcdev; - int ret; - - DEBUGASSERT((NULL != rdata) && (NULL != sf)); - - cmd52arg = cxd56_sdio_make_cmd52arg(addr, 0, NULL, 0, sf->number); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, cmd52arg); - if (ret == OK) - { - cxd56_sdio_recvshort(&priv->dev, SDIO_ACMD52, &response); - if (ret != OK) - { - mcerr("ERROR: Addr:0x%x, recv R5 error\n", addr); - goto READB_ERR; - } - } - else - { - mcerr("ERROR: Send cmd52 addr:0x%x error\n", addr); - goto READB_ERR; - } - - if ((!CMD52_RESP_OK(response)) || (response == 0xffffffff)) - { - mcerr("ERROR: Fail resp %u\n", response); - goto READB_ERR; - } - - if (rdata) - { - *rdata = response & 0xff; - } - - return 0; - -READB_ERR: - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_writeb_internal - * - * Description: - * Write a byte of data. - * - ****************************************************************************/ - -static uint32_t cxd56_sdio_writeb_internal(FAR struct sdio_function_s * sf, - uint32_t addr, uint8_t data, FAR uint8_t * rdata) -{ - uint32_t response; - uint32_t cmd52arg; - struct cxd56_sdiodev_s *priv = &g_sdhcdev; - int ret; - - DEBUGASSERT(NULL != sf); - - cmd52arg = cxd56_sdio_make_cmd52arg(addr, data, rdata, 1, 0); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, cmd52arg); - if (ret == OK) - { - cxd56_sdio_recvshort(&priv->dev, SDIO_ACMD52, &response); - if (ret != OK) - { - mcerr("ERROR: Addr:0x%x, recv R5 error\n", addr); - goto WRITEB_ERR; - } - } - else - { - mcerr("ERROR: Send cmd52 addr:0x%x error\n", addr); - goto WRITEB_ERR; - } - - if ((!CMD52_RESP_OK(response)) || (response == 0xffffffff)) - { - mcerr("ERROR: Fail resp %u\n", response); - goto WRITEB_ERR; - } - - if (rdata) - { - *rdata = response & 0xff; - } - - return 0; -WRITEB_ERR: - return ret; -} - -/**************************************************************************** - * Name: mmcsd_io_changeclock - * - * Description: - * change the sdio clock. - * - ****************************************************************************/ - -static int cxd56_sdio_changeclock(FAR struct cxd56_sdiodev_s *priv) -{ - int ret; - uint32_t response = 0; - - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, 0x08 << 9); - if (ret == OK) - { - cxd56_sdio_recvshort(&priv->dev, SDIO_ACMD52, &response); - } - else - { - mcerr("ERROR: Send cmd52, getclock error\n"); - return ret; - } - - if ((response & 0x40) != 0) - { - mcinfo("Set clock to 400KHz\n"); - cxd56_sdio_clock(&priv->dev, CLOCK_IDMODE); - } - else - { - mcinfo("Set clock to 25MHz\n"); - cxd56_sdio_clock(&priv->dev, CLOCK_SD_TRANSFER_4BIT); - } - - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_function_alloc - * - * Description: - * Allocate space for each function. - * - ****************************************************************************/ - -static FAR struct sdio_function_s * - cxd56_sdio_function_alloc(FAR struct sdio_softc_s *sc) -{ - FAR struct sdio_function_s *sf; - - DEBUGASSERT(sc); - - sf = (FAR struct sdio_function_s *) - kmm_malloc(sizeof(struct sdio_function_s)); - if (!sf) - { - mcerr("ERROR: Failed\n"); - return NULL; - } - - memset(sf, 0, sizeof(struct sdio_function_s)); - sf->sc = sc; - sf->number = -1; - sf->cis.manufacturer = 0xffff; - sf->cis.product = 0xffff; - sf->cis.function = 0xff; - sf->irq_callback = NULL; - return sf; -} - -/**************************************************************************** - * Name: cxd56_sdio_read_cis - * - * Description: - * Read the card information structure. - * - ****************************************************************************/ - -static uint32_t cxd56_sdio_read_cis(FAR struct sdio_function_s * sf, - FAR struct sdio_cis_s * cis) -{ - int i; - FAR struct sdio_function_s *sf0; - uint8_t tplcode; - uint8_t tpllen; - uint32_t ret; - uint32_t cisptr = 0; - uint8_t response = 0; - uint32_t addr; - - mcinfo("I/O func's num:%d\n", sf->number); - - DEBUGASSERT(sf && cis); - sf0 = sf->sc->fn[0]; - addr = SDIO_CCCR_CCP + (sf->number * SDIO_CCCR_SIZE); - for (i = 0; i < 3; i++) - { - ret = cxd56_sdio_readb_internal(sf0, (addr + i), &response); - if (ret == 0) - { - cisptr |= (response << (8 * i)); - } - } - - if ((cisptr < SDIO_CIS_START) || (cisptr >= SDIO_CIS_END)) - { - mcerr("ERROR: Bad cis ptr %#x\n", cisptr); - return 1; - } - - for (; ; ) - { - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &tplcode); - if (ret != 0) - { - return ret; - } - - if (tplcode == SDIO_CISTPL_END) - { - break; - } - else if (tplcode == SDIO_CISTPL_NULL) - { - continue; - } - - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &tpllen); - if (ret != 0) - { - return ret; - } - - if (tpllen == 0) - { - mcerr("ERROR: Cis error reg %d tpl %#x len %d\n", - cisptr, tplcode, tpllen); - break; - } - - switch (tplcode) - { - case SDIO_CISTPL_FUNCID: - if (tpllen < 2) - { - mcerr("ERROR: Bad funcid length\n"); - cisptr += tpllen; - break; - } - - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &response); - if (ret != 0) - { - return ret; - } - - cis->function = response; - cisptr += tpllen; - mcinfo("get funcid 0x%x, len %d\n", cis->function, tpllen); - break; - case SDIO_CISTPL_MANFID: - if (tpllen < 4) - { - mcerr("ERROR: Bad manfid length\n"); - cisptr += tpllen; - break; - } - - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &response); - if (ret != 0) - { - return ret; - } - - cis->manufacturer = response; - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &response); - if (ret != 0) - { - return ret; - } - - cis->manufacturer |= response << 8; - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &response); - if (ret != 0) - { - return ret; - } - - cis->product = response; - ret = cxd56_sdio_readb_internal(sf0, cisptr++, &response); - if (ret != 0) - { - return ret; - } - - cis->product = response << 8; - mcinfo("manufacturer/product ID: %x:%x, len %d\n", - cis->manufacturer, - cis->product, - tpllen); - break; - default: - mcinfo("unknown tuple code %#x, length %d\n", tplcode, tpllen); - cisptr += tpllen; - break; - } - } - - return OK; -} - -/**************************************************************************** - * Name: cxd56_sdio_enable_cardint - * - * Description: - * Enable the card interrupt bit of the CXD56_SDHCI_IRQSIGEN and - * CXD56_SDHCI_IRQSTATEN register. - * - ****************************************************************************/ - -static int cxd56_sdio_enable_cardint(void) -{ - irqstate_t flags; - - flags = enter_critical_section(); - putreg32(getreg32(CXD56_SDHCI_IRQSIGEN) | SDHCI_INT_CINT, - CXD56_SDHCI_IRQSIGEN); - putreg32(getreg32(CXD56_SDHCI_IRQSTATEN) | SDHCI_INT_CINT, - CXD56_SDHCI_IRQSTATEN); - leave_critical_section(flags); - return OK; -} - -/**************************************************************************** - * Name: cxd56_sdhci_irq_handler - * - * Description: - * Wait for the card interrupt and run the function's irq callback. - * - ****************************************************************************/ - -static int cxd56_sdhci_irq_handler(FAR struct sdio_dev_s *dev) -{ - int ret = 0; - FAR struct sdio_softc_s *sc; - FAR struct sdio_function_s *sf0; - FAR struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - uint8_t response; - int i; - - sc = &priv->sc; - sf0 = priv->sc.fn[0]; - ret = cxd56_sdio_readb_internal(sf0, SDIO_CCCR_INTPEND, &response); - for (i = 1; i < 8; i++) - { - if (response & (1 << i)) - { - if (sc->fn[i]->irq_callback) - { - sc->fn[i]->irq_callback(&priv->dev); - } - } - } - - cxd56_sdio_enable_cardint(); - - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_register_irq - * - * Description: - * Register the func interrupt handler. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * handler - The function's irq callback handler - * - ****************************************************************************/ - -static int cxd56_sdio_register_irq(FAR struct sdio_dev_s *dev, int func_num, - FAR sdio_irqhandler_t * handler) -{ - int ret; - uint8_t reg; - uint8_t regorg; - FAR struct sdio_function_s *sf0; - FAR struct sdio_function_s *sf; - FAR struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - - DEBUGASSERT(handler); - - sf = priv->sc.fn[func_num]; - sf0 = priv->sc.fn[0]; - - if (NULL != sf->irq_callback) - { - mcerr("ERROR: Already registered a sdio callback, fn number: %d\n", - sf->number); - return -EBUSY; - } - - ret = cxd56_sdio_takesem(priv); - if (ret < 0) - { - return ret; - } - - /* enable irq in device side */ - - ret = cxd56_sdio_readb_internal(sf0, SDIO_CCCR_INTEN, ®); - if (ret) - { - goto REG_IRQ_FAIL; - } - - sf->irq_callback = handler; - - regorg = reg; - reg |= ((1 << sf->number) | (1 << 0)); - - ret = cxd56_sdio_writeb_internal(sf0, SDIO_CCCR_INTEN, reg, NULL); - if (ret) - { - cxd56_sdio_writeb_internal(sf0, SDIO_CCCR_INTEN, regorg, NULL); - goto REG_IRQ_FAIL; - } - - nxsem_post(&priv->sc.sem); - return ret; - -REG_IRQ_FAIL: - sf->irq_callback = NULL; - mcerr("ERROR: Ret: %d\n", ret); - nxsem_post(&priv->sc.sem); - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_blocksize - * - * Description: - * Set I/O block size for Function. - * - ****************************************************************************/ - -static int cxd56_sdio_blocksize(FAR struct sdio_function_s * sf, - uint32_t size) -{ - uint32_t cmd52arg; - uint32_t blksz_addr; - struct cxd56_sdiodev_s *priv = &g_sdhcdev; - - blksz_addr = sf->number * SDIO_FBR_START + 0x10; - - cmd52arg = cxd56_sdio_make_cmd52arg(blksz_addr, (size & 0xff), - NULL, true, 0); - cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, cmd52arg); - - cmd52arg = cxd56_sdio_make_cmd52arg(blksz_addr + 1, ((size >> 8) & 0xff), - NULL, true, 0); - cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, cmd52arg); - - return 0; -} - -/**************************************************************************** - * Name: cxd56_sdio_func_ready - * - * Description: - * Function will become ready, and FN0 is always ready. - * - ****************************************************************************/ - -static int cxd56_sdio_func_ready(FAR struct sdio_function_s * sf) -{ - FAR struct sdio_softc_s *sc; - FAR struct sdio_function_s *sf0; - uint8_t rv; - int ret; - - DEBUGASSERT(NULL != sf); - if (sf->number == 0) - { - return 1; /* FN0 is always ready */ - } - - sc = sf->sc; - sf0 = sc->fn[0]; - ret = cxd56_sdio_readb_internal(sf0, SDIO_CCCR_IORDY, &rv); - if (0 == ret) - { - return (rv & (1 << sf->number)) != 0; - } - - return 0; -} - -/**************************************************************************** - * Name: cxd56_sdio_function_disable - * - * Description: - * Function will be disabled, and FN0 is always enabled. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * - ****************************************************************************/ - -static int cxd56_sdio_function_disable(FAR struct sdio_dev_s *dev, - int func_num) -{ - FAR struct sdio_function_s *sf0; - FAR struct sdio_function_s *sf; - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - uint8_t rv; - int ret; - - sf = priv->sc.fn[func_num]; - sf0 = priv->sc.fn[0]; - mcinfo("I/O func's num:%d\n", sf->number); - - ret = cxd56_sdio_takesem(priv); - if (ret < 0) - { - return ret; - } - - ret = cxd56_sdio_readb_internal(sf0, SDIO_CCCR_IOEN, &rv); - if (ret) - { - goto FUNC_DIS_ERR; - } - - rv &= ~(1 << sf->number); - ret = cxd56_sdio_writeb_internal(sf0, SDIO_CCCR_IOEN, rv, NULL); - if (ret) - { - goto FUNC_DIS_ERR; - } - - nxsem_post(&priv->sc.sem); - return 0; - -FUNC_DIS_ERR: - mcerr("ERROR: Io fail ret %u\n", ret); - nxsem_post(&priv->sc.sem); - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_function_enable - * - * Description: - * Function will be enabled. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * - ****************************************************************************/ - -static int cxd56_sdio_function_enable(FAR struct sdio_dev_s *dev, - int func_num) -{ - FAR struct sdio_function_s *sf0; - FAR struct sdio_function_s *sf; - uint8_t rv; - int retry = 10; - int ret = 0; - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - - sf = priv->sc.fn[func_num]; - sf0 = priv->sc.fn[0]; - mcinfo("I/O func's num:%d\n", sf->number); - if (sf->number == 0) - { - return 0; - } - - ret = cxd56_sdio_takesem(priv); - if (ret < 0) - { - return ret; - } - - ret = cxd56_sdio_readb_internal(sf0, SDIO_CCCR_IOEN, &rv); - if (ret) - { - goto FUNC_EN_ERR; - } - - rv |= (1 << sf->number); - - /* according to sdio_rw_direct(), set NULL to rdata */ - - ret = cxd56_sdio_writeb_internal(sf0, SDIO_CCCR_IOEN, rv, NULL); - if (ret) - { - goto FUNC_EN_ERR; - } - - /* Optimize SDIO transmission speed, so set blocksize here */ - - cxd56_sdio_blocksize(sf, priv->blocksize); - while (!cxd56_sdio_func_ready(sf) && retry-- > 0) - { - up_udelay(5 * 1000); - } - - ret = (retry >= 0) ? 0 : -ETIMEDOUT; - - if (0 == ret) - { - nxsem_post(&priv->sc.sem); - return 0; - } - -FUNC_EN_ERR: - mcerr("ERROR: Io fail ret %u\n", ret); - nxsem_post(&priv->sc.sem); - return -EIO; -} - -/**************************************************************************** - * Name: cxd56_sdio_readb - * - * Description: - * Read a byte of data. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * addr - This is the address of the byte of data inside of the selected - * function to read or write - * rdata - the actual value read from that I/O location is returned - * in this field - * - ****************************************************************************/ - -static int cxd56_sdio_readb(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * rdata) -{ - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - int ret; - - ret = cxd56_sdio_takesem(priv); - if (ret >= 0) - { - ret = cxd56_sdio_readb_internal(priv->sc.fn[func_num], addr, rdata); - nxsem_post(&priv->sc.sem); - } - - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_writeb - * - * Description: - * Write a byte of data. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * addr - This is the address of the byte of data inside of the selected - * function to read or write - * data - This is the byte that is written to the selected address - * rdata - The value of the register after the write - * - ****************************************************************************/ - -static int cxd56_sdio_writeb(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, uint8_t data, - FAR uint8_t * rdata) -{ - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - int ret; - - ret = cxd56_sdio_takesem(priv); - if (ret >= 0) - { - ret = cxd56_sdio_writeb_internal(priv->sc.fn[func_num], addr, data, - data); - nxsem_post(&priv->sc.sem); - } - - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_write - * - * Description: - * Write large number data. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * addr - Start Address of I/O register to write - * data - This is the large number data that is written to the selected - * address - * size - The size of the written data - * - ****************************************************************************/ - -static int cxd56_sdio_write(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * data, - uint32_t size) -{ - uint32_t remainder = size; - int ret; - uint32_t cmd53arg; - sdio_eventset_t wkupevent; - FAR struct sdio_function_s *sf; - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - - sf = priv->sc.fn[func_num]; - mcinfo("sf->number = %d\n", sf->number); - - /* Do the bulk of the transfer using block mode (if supported). */ - - ret = cxd56_sdio_takesem(priv); - if (ret < 0) - { - return ret; - } - - if (size >= SDIO_BLOCK_SIZE) - { - while (remainder >= SDIO_BLOCK_SIZE) - { - uint32_t blocks; - blocks = MIN(remainder / SDIO_BLOCK_SIZE, 8); - size = blocks * SDIO_BLOCK_SIZE; - cxd56_blocksetup(&priv->dev, SDIO_BLOCK_SIZE, blocks); - cxd56_sdio_waitenable(&priv->dev, SDIOWAIT_TRANSFERDONE | - SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR); -#ifdef CONFIG_SDIO_DMA - if (priv->sc.dma) - { - ret = cxd56_sdio_dmasendsetup(&priv->dev, data, size); - if (ret != OK) - { - mcerr("ERROR: SDIO_DMASENDSETUP: error %d\n", ret); - goto WRITE_ERR; - } - } - else -#endif - { - cxd56_sdio_sendsetup(&priv->dev, data, size); - } - - cmd53arg = cxd56_sdio_make_cmd53arg(1, sf->number, addr, 1, blocks, - priv->blocksize); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD53 | MMCSD_MULTIBLOCK | - MMCSD_WRDATAXFR, cmd53arg); - if (ret != OK) - { - mcerr("ERROR: Send cmd53 error\n"); - goto WRITE_ERR; - } - - wkupevent = cxd56_sdio_eventwait(&priv->dev, - SDIO_BLOCK_TIMEOUT * blocks); - if ((wkupevent & (SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR)) != 0) - { - mcerr("ERROR: Sdio write time out %x\n", wkupevent); - goto WRITE_TIME_OUT; - } - - remainder -= size; - data += size; - addr += size; - } - } - - /* Write the remainder using byte mode. */ - - while (remainder > 0) - { - size = MIN(remainder, 64); - cxd56_blocksetup(&priv->dev, size, 1); - cxd56_sdio_waitenable(&priv->dev, SDIOWAIT_TRANSFERDONE | - SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR); -#ifdef CONFIG_SDIO_DMA - if (priv->sc.dma) - { - ret = cxd56_sdio_dmasendsetup(&priv->dev, data, size); - if (ret != OK) - { - mcerr("ERROR: SDIO_DMASENDSETUP: error %d\n", ret); - goto WRITE_ERR; - } - } - else -#endif - { - cxd56_sdio_sendsetup(&priv->dev, data, size); - } - - cmd53arg = cxd56_sdio_make_cmd53arg(1, sf->number, addr, 1, 0, size); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD53 | MMCSD_WRDATAXFR, - cmd53arg); - if (ret != OK) - { - mcerr("ERROR: Send cmd53 error\n"); - goto WRITE_ERR; - } - - wkupevent = cxd56_sdio_eventwait(&priv->dev, SDIO_BLOCK_TIMEOUT); - if ((wkupevent & (SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR)) != 0) - { - mcerr("ERROR: Sdio write time out %x\n", wkupevent); - goto WRITE_TIME_OUT; - } - - remainder -= size; - data += size; - addr += size; - } - - nxsem_post(&priv->sc.sem); - return 0; -WRITE_TIME_OUT: - nxsem_post(&priv->sc.sem); - return wkupevent & SDIOWAIT_TIMEOUT ? -ETIMEDOUT : -EIO; -WRITE_ERR: - nxsem_post(&priv->sc.sem); - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_read - * - * Description: - * Read large number data. - * - * Input Parameters: - * dev - An instance of the SDIO driver device state structure. - * func_num - I/O Function's num - * addr - Start Address of I/O register to read - * data - the large number data read from that I/O location is returned - * in this field - * size - The size of the read data - * - ****************************************************************************/ - -static int cxd56_sdio_read(FAR struct sdio_dev_s *dev, int func_num, - uint32_t addr, FAR uint8_t * data, uint32_t size) -{ - uint32_t remainder = size; - int ret; - uint32_t cmd53arg; - sdio_eventset_t wkupevent; - FAR struct sdio_function_s *sf; - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - - sf = priv->sc.fn[func_num]; - mcinfo("sf->number = %d\n", sf->number); - - /* Do the bulk of the transfer using block mode (if supported). */ - - ret = cxd56_sdio_takesem(priv); - if (ret < 0) - { - return ret; - } - - if (size >= SDIO_BLOCK_SIZE) - { - while (remainder >= SDIO_BLOCK_SIZE) - { - uint32_t blocks; - blocks = MIN(remainder / SDIO_BLOCK_SIZE, 8); - size = blocks * SDIO_BLOCK_SIZE; - cxd56_blocksetup(&priv->dev, SDIO_BLOCK_SIZE, blocks); - cxd56_sdio_waitenable(&priv->dev, SDIOWAIT_TRANSFERDONE | - SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR); -#ifdef CONFIG_SDIO_DMA - if (priv->sc.dma) - { - ret = cxd56_sdio_dmarecvsetup(&priv->dev, data, size); - if (ret != OK) - { - mcerr("ERROR: SDIO_DMASENDSETUP: error %d\n", ret); - goto READ_ERR; - } - } - else -#endif - { - cxd56_sdio_recvsetup(&priv->dev, data, size); - } - - cmd53arg = cxd56_sdio_make_cmd53arg(0, sf->number, addr, 1, - blocks, priv->blocksize); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD53 | MMCSD_MULTIBLOCK | - MMCSD_RDDATAXFR, cmd53arg); - if (ret != OK) - { - mcerr("ERROR: Send cmd53 error\n"); - goto READ_ERR; - } - - wkupevent = cxd56_sdio_eventwait(&priv->dev, - SDIO_BLOCK_TIMEOUT * blocks); - if ((wkupevent & (SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR)) != 0) - { - mcerr("ERROR: Sdio read time out %x\n", wkupevent); - goto READ_TIME_OUT; - } - - remainder -= size; - data += size; - addr += size; - } - } - - /* Write the remainder using byte mode. */ - - while (remainder > 0) - { - size = MIN(remainder, 64); - cxd56_blocksetup(&priv->dev, size, 1); - cxd56_sdio_waitenable(&priv->dev, SDIOWAIT_TRANSFERDONE | - SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR); -#ifdef CONFIG_SDIO_DMA - if (priv->sc.dma) - { - ret = cxd56_sdio_dmarecvsetup(&priv->dev, data, size); - if (ret != OK) - { - mcerr("ERROR: SDIO_DMASENDSETUP: error %d\n", ret); - goto READ_ERR; - } - } - else -#endif - { - cxd56_sdio_recvsetup(&priv->dev, data, size); - } - - cmd53arg = cxd56_sdio_make_cmd53arg(0, sf->number, addr, 1, 0, size); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD53 | - MMCSD_RDDATAXFR, cmd53arg); - if (ret != OK) - { - mcerr("ERROR: Send cmd53 error\n"); - goto READ_ERR; - } - - wkupevent = cxd56_sdio_eventwait(&priv->dev, SDIO_BLOCK_TIMEOUT); - if ((wkupevent & (SDIOWAIT_TIMEOUT | SDIOWAIT_ERROR)) != 0) - { - mcerr("ERROR: Sdio read time out %x\n", wkupevent); - goto READ_TIME_OUT; - } - - remainder -= size; - data += size; - addr += size; - } - - nxsem_post(&priv->sc.sem); - return 0; -READ_TIME_OUT: - nxsem_post(&priv->sc.sem); - return wkupevent & SDIOWAIT_TIMEOUT ? -ETIMEDOUT : -EIO; -READ_ERR: - nxsem_post(&priv->sc.sem); - return ret; -} - -/**************************************************************************** - * Name: cxd56_sdio_get_cis - * - * Description: - * get SDIO Card Information Structure. - * - ****************************************************************************/ - -static int cxd56_sdio_get_cis(FAR struct sdio_dev_s *dev, - int func_num, FAR struct sdio_cis_s * cis) -{ - struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; - - if (cis) - { - *cis = priv->sc.fn[func_num]->cis; - } - - return OK; -} - -/**************************************************************************** - * Name: cxd56_sdio_initialize - * - * Description: - * We believe that there is A sdio device in the slot.initialize the sdio - * device. - * - ****************************************************************************/ - -static int cxd56_sdio_initialize(struct cxd56_sdiodev_s *priv) -{ - int ret; - int i; - uint32_t response; - FAR struct sdio_function_s *fn; - - priv->sc.func_num = 1; - priv->sc.full_speed = false; - priv->blocksize = SDIO_BLOCK_SIZE; - - nxsem_init(&priv->sc.sem, 0, 1); -#ifdef CONFIG_SDIO_DMA - priv->sc.dma = true; -#endif - cxd56_sdio_attach(&priv->dev); - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_CMD5, 0x0); - - if (ret == OK) - { - ret = cxd56_sdio_recvshort(&priv->dev, SDIO_CMD5, &response); - if (ret != OK) - { - mcerr("ERROR: Recv R4 error\n"); - return ret; - } - } - else - { - mcerr("ERROR: Send cmd5 error\n"); - return ret; - } - - mcinfo("response = 0x%x, card has %d function\n", - response, (response >> 28) & 7); - mcinfo("send cmd5 again to set card ready\n"); - if (response != 0xffffffff) - { - do - { - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_CMD5, 0x300000); - if (ret == OK) - { - cxd56_sdio_recvshort(&priv->dev, SDIO_CMD5, &response); - } - - nxsig_usleep(4000); - } - while ((response == 0xffffffff) || - ((response & 0x80000000) == 0)); - - mcinfo("response = 0x%x, card is ready(MSB=1)\n", response); - priv->sc.func_num = SDIO_OCR_NUM_FUNCTIONS(response) + 1; - } - - mcinfo("send CMD3 to enter standby state\n"); - cxd56_sdio_sendcmdpoll(priv, SD_CMD3, 0); - ret = cxd56_sdio_recvshortcrc(&priv->dev, SD_CMD3, &response); - if (ret != OK) - { - return ret; - } - - mcinfo("RCA: 0x%x\n", (response >> 16)); - if (response & 0xffff) - { - mcerr("ERROR: CMD3 resp error: 0x%x\n", (response & 0xffff)); - if (response & 0x8000) - mcerr("ERROR: CRC error on previous command\n"); - } - - cxd56_sdio_sendcmdpoll(priv, MMCSD_CMD7S, response & 0xffff0000); - mcinfo("send cmd7(RCA:%x, %x) OK\n", - (response >> 16), response & 0xffff0000); - ret = cxd56_sdio_recvshortcrc(&priv->dev, MMCSD_CMD7S, &response); - if (ret != OK) - { - mcerr("ERROR: cxd56_sdio_recvshortcrc for CMD7 failed: %d\n", ret); - return ret; - } - - cxd56_sdio_changeclock(priv); - - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, 0x7 << 9); - if (ret == OK) - { - ret = cxd56_sdio_recvshort(&priv->dev, SDIO_ACMD52, &response); - if (ret != OK) - { - mcerr("ERROR: Addr:0x7, recv R5 error\n"); - return ret; - } - - mcinfo("Bus interface ctrl (@0x7):0x%x\n", response); - - cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, 0x7 << 9 | - (response & 0xff) | 0x80); - mcinfo("set CD disable = 1\n"); - } - else - { - mcerr("ERROR: Send cmd52 addr:0x7 error\n"); - return ret; - } - - ret = cxd56_sdio_sendcmdpoll(priv, SDIO_ACMD52, 0x8 << 9); - if (ret == OK) - { - cxd56_sdio_recvshort(&priv->dev, SDIO_ACMD52, &response); - if (ret != OK) - { - mcerr("ERROR: Addr:0x8, recv R5 error\n"); - return ret; - } - - mcinfo("Card capability(@0x8):0x%x\n", response); - - mcinfo("It's a %s card\n", - (response & 0x40) ? "low speed" : "full speed"); - if ((response & 0x40) == 0) - { - priv->sc.full_speed = true; - } - } - else - { - mcerr("ERROR: Send cmd52 addr:0x8 error\n"); - return ret; - } - - mcinfo("func_num = %d\n", priv->sc.func_num); - for (i = 0; i < priv->sc.func_num; i++) - { - fn = cxd56_sdio_function_alloc(&priv->sc); - if (!fn) - { - goto SDIO_INIT_ERR; - } - - fn->number = i; - - priv->sc.fn[i] = fn; - } - - for (i = 1; i < priv->sc.func_num; i++) - { - fn = priv->sc.fn[i]; - if (cxd56_sdio_read_cis(fn, &fn->cis) != 0) - { - mcerr("ERROR: Can't read CIS\n"); - goto SDIO_INIT_CIS_ERR; - } - } - - if (priv->sc.full_speed) - { - uint8_t bus_ctrl; - - /* enable 4-bits bus */ - - cxd56_sdio_readb_internal(priv->sc.fn[0], SDIO_CCCR_BUS_IF, &bus_ctrl); - bus_ctrl = (bus_ctrl & ~0x3) | 0x2; - cxd56_sdio_writeb_internal(priv->sc.fn[0], SDIO_CCCR_BUS_IF, bus_ctrl, - &bus_ctrl); - - if ((bus_ctrl & 0x3) == 2) - { - mcinfo("Set card to 4-bits mode\n"); - cxd56_sdio_widebus(&priv->dev, true); - mcinfo("Set controller to 4-bits mode\n"); - } - else - { - mcinfo("Failed to enter 4-bits mode\n"); - } - } - - return OK; - -SDIO_INIT_ERR: - return -ENOMEM; - -SDIO_INIT_CIS_ERR: - return -EIO; -} -#endif /* CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION */ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -4607,20 +3259,6 @@ FAR struct sdio_dev_s *cxd56_sdhci_initialize(int slotno) cxd56_sdio_sdhci_reset(&(priv->dev)); -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION - /* Power ON for SDIO */ - - regval = getreg32(CXD56_SDHCI_PROCTL); - regval |= 0xf << 8; - putreg32(regval, CXD56_SDHCI_PROCTL); - - up_mdelay(25); - - /* SD clock enable */ - - cxd56_sdio_clock(&(priv->dev), CLOCK_IDMODE); -#endif - #ifdef CONFIG_SDIO_DMA for (i = 0; i < sizeof(cxd56_sdhci_adma_dscr) / sizeof(cxd56_sdhci_adma_dscr[0]); @@ -4640,10 +3278,6 @@ FAR struct sdio_dev_s *cxd56_sdhci_initialize(int slotno) priv->dmasend_regcmd = 0; #endif -#ifdef CONFIG_CXD56_SDIO_ENABLE_MULTIFUNCTION - cxd56_sdio_initialize(priv); -#endif - /* In addition to the system clock, the SDHC module needs a clock for the * base for the external card clock. There are four possible sources for * this clock, selected by the SIM's SOPT2 register: @@ -4825,4 +3459,23 @@ void cxd56_sdhci_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect) mcinfo("cdstatus: %02x\n", priv->cdstatus); leave_critical_section(flags); } + +/**************************************************************************** + * Name: cxd56_sdio_resetstatus + * + * Description: + * Reset SDIO status. + * + * Input Parameters: + * dev - Device-specific state data + * + ****************************************************************************/ + +void cxd56_sdio_resetstatus(FAR struct sdio_dev_s *dev) +{ + struct cxd56_sdiodev_s *priv = (struct cxd56_sdiodev_s *)dev; + priv->cdstatus = 0; + priv->cbevents = SDIOMEDIA_INSERTED; +} + #endif /* CONFIG_CXD56_SDIO */ diff --git a/arch/arm/src/cxd56xx/cxd56_sdhci.h b/arch/arm/src/cxd56xx/cxd56_sdhci.h index 870c6a02265..9f7817960ea 100644 --- a/arch/arm/src/cxd56xx/cxd56_sdhci.h +++ b/arch/arm/src/cxd56xx/cxd56_sdhci.h @@ -496,6 +496,19 @@ void cxd56_sdhci_mediachange(FAR struct sdio_dev_s *dev); void cxd56_sdhci_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect); +/**************************************************************************** + * Name: cxd56_sdio_resetstatus + * + * Description: + * Reset SDIO status. + * + * Input Parameters: + * dev - Device-specific state data + * + ****************************************************************************/ + +void cxd56_sdio_resetstatus(FAR struct sdio_dev_s *dev); + #undef EXTERN #ifdef __cplusplus } diff --git a/arch/arm/src/cxd56xx/cxd56_serial.c b/arch/arm/src/cxd56xx/cxd56_serial.c index fe20703d646..4df8213495e 100644 --- a/arch/arm/src/cxd56xx/cxd56_serial.c +++ b/arch/arm/src/cxd56xx/cxd56_serial.c @@ -65,6 +65,7 @@ #include "cxd56_config.h" #include "cxd56_serial.h" +#include "cxd56_powermgr.h" /**************************************************************************** * Pre-processor definitions @@ -89,8 +90,14 @@ struct up_dev_s uint8_t id; /* ID=0,1,2,3 */ uint8_t irq; /* IRQ associated with this UART */ uint8_t parity; /* 0=none, 1=odd, 2=even */ - uint8_t bits; /* Number of bits (7 or 8) */ + uint8_t bits; /* Number of bits (5,6,7 or 8) */ bool stopbits2; /* true: Configure with 2 stop bits instead of 1 */ +#ifdef CONFIG_SERIAL_IFLOWCONTROL + bool iflow; /* input flow control (RTS) enabled */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + bool oflow; /* output flow control (CTS) enabled */ +#endif #ifdef HAVE_RS485 bool dtrdir; /* DTR pin is the direction bit */ #endif @@ -101,6 +108,9 @@ struct up_dev_s * Private Function Prototypes ****************************************************************************/ +#ifndef CONFIG_SUPPRESS_UART_CONFIG +static void up_set_format(struct uart_dev_s *dev); +#endif static int up_setup(FAR struct uart_dev_s *dev); static void up_shutdown(FAR struct uart_dev_s *dev); static int up_attach(FAR struct uart_dev_s *dev); @@ -187,6 +197,12 @@ static struct up_dev_s g_uart1priv = .parity = CONFIG_UART1_PARITY, .bits = CONFIG_UART1_BITS, .stopbits2 = CONFIG_UART1_2STOP, +#ifdef CONFIG_SERIAL_IFLOWCONTROL + .iflow = false, /* flow control is not supported */ +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + .oflow = false, /* flow control is not supported */ +#endif }; static uart_dev_t g_uart1port = @@ -220,6 +236,12 @@ static struct up_dev_s g_uart2priv = .parity = CONFIG_UART2_PARITY, .bits = CONFIG_UART2_BITS, .stopbits2 = CONFIG_UART2_2STOP, +#if defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_UART2_IFLOWCONTROL) + .iflow = true, +#endif +#if defined(CONFIG_SERIAL_OFLOWCONTROL) && defined(CONFIG_UART2_OFLOWCONTROL) + .oflow = true, +#endif }; static uart_dev_t g_uart2port = @@ -327,6 +349,116 @@ static inline void up_enablebreaks(FAR struct up_dev_s *priv, bool enable) up_serialout(priv, CXD56_UART_LCR_H, lcr); } +/**************************************************************************** + * Name: cxd56_serial2_pm_event + ****************************************************************************/ + +#ifdef CONFIG_CXD56_UART2 +static int cxd56_serial2_pm_event(uint8_t id) +{ + FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_uart2priv; + + switch (id) + { + case CXD56_PM_CALLBACK_ID_CLK_CHG_START: + break; + case CXD56_PM_CALLBACK_ID_CLK_CHG_END: + cxd56_setbaud(priv->uartbase, priv->basefreq, priv->baud); + break; + default: + break; + } + return 0; +} +#endif + +/**************************************************************************** + * Name: up_set_format + * + * Description: + * Set the serial line format and speed. + * + ****************************************************************************/ + +#ifndef CONFIG_SUPPRESS_UART_CONFIG +static void up_set_format(struct uart_dev_s *dev) +{ + FAR struct up_dev_s *priv = (FAR struct up_dev_s *)dev->priv; + uint32_t lcr; + uint32_t cr; + uint32_t cr_en; + irqstate_t flags; + + flags = enter_critical_section(); + + /* Get the original state of control register */ + + cr = up_serialin(priv, CXD56_UART_CR); + cr_en = cr & UART_CR_EN; + cr &= ~UART_CR_EN; + + /* Disable until the format bits and baud rate registers are updated */ + + up_serialout(priv, CXD56_UART_CR, cr); + + /* Set the BAUD divisor */ + + cxd56_setbaud(priv->uartbase, priv->basefreq, priv->baud); + + /* Set up the LCR */ + + lcr = up_serialin(priv, CXD56_UART_LCR_H); + + lcr &= ~(UART_LCR_WLEN(8) | UART_LCR_STP2 | UART_LCR_EPS | UART_LCR_PEN); + + if ((5 <= priv->bits) && (priv->bits < 8)) + { + lcr |= UART_LCR_WLEN(priv->bits); + } + else + { + lcr |= UART_LCR_WLEN(8); + } + + if (priv->stopbits2) + { + lcr |= UART_LCR_STP2; + } + + if (priv->parity == 1) + { + lcr |= (UART_LCR_PEN); + } + else if (priv->parity == 2) + { + lcr |= (UART_LCR_PEN | UART_LCR_EPS); + } + + up_serialout(priv, CXD56_UART_LCR_H, lcr); + + /* Enable Auto-RTS and Auto-CS Flow Control in the Modem Control Register */ + + cr &= ~(UART_CR_RTSEN | UART_CR_CTSEN); + cr |= UART_CR_RTS; + +#ifdef CONFIG_SERIAL_IFLOWCONTROL + if ((priv->iflow) && (priv->uartbase == CXD56_UART2_BASE)) + { + cr |= UART_CR_RTSEN; + } +#endif +#ifdef CONFIG_SERIAL_OFLOWCONTROL + if ((priv->oflow) && (priv->uartbase == CXD56_UART2_BASE)) + { + cr |= UART_CR_CTSEN; + } +#endif + up_serialout(priv, CXD56_UART_CR, cr | cr_en); + + leave_critical_section(flags); +} +#endif /* CONFIG_SUPPRESS_UART_CONFIG */ + /**************************************************************************** * Name: up_setup * @@ -356,78 +488,37 @@ static int up_setup(FAR struct uart_dev_s *dev) priv->ier = up_serialin(priv, CXD56_UART_IMSC); - /* Set the BAUD divisor */ + /* Configure the UART line format and speed. */ - cxd56_setbaud(priv->uartbase, priv->basefreq, priv->baud); + up_set_format(dev); - /* Set up the LCR */ - - lcr = 0; - if (priv->bits == 7) - { - lcr |= UART_LCR_WLEN(7); - } - else - { - lcr |= UART_LCR_WLEN(8); - } - - if (priv->stopbits2) - { - lcr |= UART_LCR_STP2; - } - - if (priv->parity == 1) - { - lcr |= (UART_LCR_PEN); - } - else if (priv->parity == 2) - { - lcr |= (UART_LCR_PEN | UART_LCR_EPS); - } - - /* Save the LCR */ - - up_serialout(priv, CXD56_UART_LCR_H, lcr); + /* Set interrupt FIFO level */ up_serialout(priv, CXD56_UART_IFLS, 0); + + /* Clear all interrupts */ + up_serialout(priv, CXD56_UART_ICR, 0x7ff); - cr = UART_CR_RXE | UART_CR_TXE; - - /* Enable Auto-RTS and Auto-CS Flow Control in the Modem Control Register */ - -# ifdef CONFIG_UART1_FLOWCONTROL - if (priv->uartbase == CXD56_UART1_BASE) - { - cr |= UART_CR_CTSEN | UART_CR_RTSEN; - } -# endif - - /* Enable Auto-RTS and Auto-CS Flow Control in UART2 */ - -# ifdef CONFIG_UART2_IFLOWCONTROL - if (priv->uartbase == CXD56_UART2_BASE) - { - cr |= UART_CR_RTSEN; - } -# endif -# ifdef CONFIG_UART2_OFLOWCONTROL - if (priv->uartbase == CXD56_UART2_BASE) - { - cr |= UART_CR_CTSEN; - } -# endif - up_serialout(priv, CXD56_UART_CR, cr); - /* Enable FIFO and UART in the last */ + lcr = up_serialin(priv, CXD56_UART_LCR_H); lcr |= UART_LCR_FEN; up_serialout(priv, CXD56_UART_LCR_H, lcr); - cr |= UART_CR_EN; + + cr = up_serialin(priv, CXD56_UART_CR); + cr |= UART_CR_RXE | UART_CR_TXE | UART_CR_EN; up_serialout(priv, CXD56_UART_CR, cr); #endif +#if defined(CONFIG_CXD56_UART2) && !defined(CONFIG_UART2_SERIAL_CONSOLE) + if ((!priv->pmhandle) && (priv->uartbase == CXD56_UART2_BASE)) + { + priv->pmhandle = cxd56_pm_register_callback(PM_CLOCK_APP_UART, + cxd56_serial2_pm_event); + } +#endif + return OK; } @@ -460,6 +551,14 @@ static void up_shutdown(FAR struct uart_dev_s *dev) default: break; } + +#ifndef CONFIG_UART2_SERIAL_CONSOLE + if ((priv->pmhandle) && (priv->uartbase == CXD56_UART2_BASE)) + { + cxd56_pm_unregister_callback(priv->pmhandle); + priv->pmhandle = NULL; + } +#endif } /**************************************************************************** @@ -669,6 +768,7 @@ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case TCGETS: { FAR struct termios *termiosp = (FAR struct termios *)arg; + irqstate_t flags; if (!termiosp) { @@ -676,18 +776,48 @@ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; } - /* TODO: Other termios fields are not yet returned. - * Note that only cfsetospeed is not necessary because we have - * knowledge that only one speed is supported. - */ + flags = enter_critical_section(); cfsetispeed(termiosp, priv->baud); + + termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) | + ((priv->parity == 1) ? PARODD : 0) | +#ifdef CONFIG_SERIAL_OFLOWCONTROL + ((priv->oflow) ? CCTS_OFLOW : 0) | +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + ((priv->iflow) ? CRTS_IFLOW : 0) | +#endif + ((priv->stopbits2) ? CSTOPB : 0); + + switch (priv->bits) + { + case 5: + termiosp->c_cflag |= CS5; + break; + + case 6: + termiosp->c_cflag |= CS6; + break; + + case 7: + termiosp->c_cflag |= CS7; + break; + + case 8: + default: + termiosp->c_cflag |= CS8; + break; + } + + leave_critical_section(flags); } break; case TCSETS: { FAR struct termios *termiosp = (FAR struct termios *)arg; + irqstate_t flags; if (!termiosp) { @@ -695,13 +825,52 @@ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; } - /* TODO: Handle other termios settings. - * Note that only cfgetispeed is used besued we have knowledge - * that only one speed is supported. - */ + flags = enter_critical_section(); + switch (termiosp->c_cflag & CSIZE) + { + case CS5: + priv->bits = 5; + break; + + case CS6: + priv->bits = 6; + break; + + case CS7: + priv->bits = 7; + break; + + case CS8: + default: + priv->bits = 8; + break; + } + + if ((termiosp->c_cflag & PARENB) != 0) + { + priv->parity = (termiosp->c_cflag & PARODD) ? 1 : 2; + } + else + { + priv->parity = 0; + } + + priv->stopbits2 = (termiosp->c_cflag & CSTOPB) != 0; + +#ifdef CONFIG_SERIAL_OFLOWCONTROL + priv->oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0; +#endif +#ifdef CONFIG_SERIAL_IFLOWCONTROL + priv->iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0; +#endif priv->baud = cfgetispeed(termiosp); - cxd56_setbaud(priv->uartbase, priv->basefreq, priv->baud); + + /* Configure the UART line format and speed. */ + + up_set_format(dev); + + leave_critical_section(flags); } break; #endif diff --git a/arch/arm/src/cxd56xx/cxd56_sfc.c b/arch/arm/src/cxd56xx/cxd56_sfc.c index b731e1ec10b..741754b453a 100644 --- a/arch/arm/src/cxd56xx/cxd56_sfc.c +++ b/arch/arm/src/cxd56xx/cxd56_sfc.c @@ -48,10 +48,10 @@ /* Prototypes for Remote API */ -int FM_RawWrite(uint32_t offset, const void *buf, uint32_t size); -int FM_RawVerifyWrite(uint32_t offset, const void *buf, uint32_t size); -int FM_RawRead(uint32_t offset, void *buf, uint32_t size); -int FM_RawEraseSector(uint32_t sector); +int fw_fm_rawwrite(uint32_t offset, const void *buf, uint32_t size); +int fw_fm_rawverifywrite(uint32_t offset, const void *buf, uint32_t size); +int fw_fm_rawread(uint32_t offset, void *buf, uint32_t size); +int fw_fm_rawerasesector(uint32_t sector); /**************************************************************************** * Pre-processor Definitions @@ -99,7 +99,7 @@ static int cxd56_erase(FAR struct mtd_dev_s *dev, off_t startblock, for (i = 0; i < nblocks; i++) { - ret = FM_RawEraseSector(startblock + i); + ret = fw_fm_rawerasesector(startblock + i); if (ret < 0) { set_errno(-ret); @@ -117,7 +117,8 @@ static ssize_t cxd56_bread(FAR struct mtd_dev_s *dev, off_t startblock, finfo("bread: %08lx (%u blocks)\n", startblock << PAGE_SHIFT, nblocks); - ret = FM_RawRead(startblock << PAGE_SHIFT, buffer, nblocks << PAGE_SHIFT); + ret = fw_fm_rawread(startblock << PAGE_SHIFT, buffer, + nblocks << PAGE_SHIFT); if (ret < 0) { set_errno(-ret); @@ -135,10 +136,10 @@ static ssize_t cxd56_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, finfo("bwrite: %08lx (%u blocks)\n", startblock << PAGE_SHIFT, nblocks); #ifdef CONFIG_CXD56_SFC_VERIFY_WRITE - ret = FM_RawVerifyWrite(startblock << PAGE_SHIFT, buffer, + ret = fw_fm_rawverifywrite(startblock << PAGE_SHIFT, buffer, nblocks << PAGE_SHIFT); #else - ret = FM_RawWrite(startblock << PAGE_SHIFT, buffer, + ret = fw_fm_rawwrite(startblock << PAGE_SHIFT, buffer, nblocks << PAGE_SHIFT); #endif if (ret < 0) @@ -157,7 +158,7 @@ static ssize_t cxd56_read(FAR struct mtd_dev_s *dev, off_t offset, finfo("read: %08lx (%u bytes)\n", offset, nbytes); - ret = FM_RawRead(offset, buffer, nbytes); + ret = fw_fm_rawread(offset, buffer, nbytes); if (ret < 0) { set_errno(-ret); @@ -176,9 +177,9 @@ static ssize_t cxd56_write(FAR struct mtd_dev_s *dev, off_t offset, finfo("write: %08lx (%u bytes)\n", offset, nbytes); #ifdef CONFIG_CXD56_SFC_VERIFY_WRITE - ret = FM_RawVerifyWrite(offset, buffer, nbytes); + ret = fw_fm_rawverifywrite(offset, buffer, nbytes); #else - ret = FM_RawWrite(offset, buffer, nbytes); + ret = fw_fm_rawwrite(offset, buffer, nbytes); #endif if (ret < 0) { @@ -236,7 +237,7 @@ static int cxd56_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) while (sec < last) { - FM_RawEraseSector(sec); + fw_fm_rawerasesector(sec); sec++; } } diff --git a/arch/arm/src/cxd56xx/cxd56_sph.c b/arch/arm/src/cxd56xx/cxd56_sph.c index f7cf5238669..b9d33b8c28d 100644 --- a/arch/arm/src/cxd56xx/cxd56_sph.c +++ b/arch/arm/src/cxd56xx/cxd56_sph.c @@ -261,6 +261,7 @@ static inline int cxd56_sphdevinit(FAR const char *devname, int num) } nxsem_init(&priv->wait, 0, 0); + nxsem_set_protocol(&priv->wait, SEM_PRIO_NONE); priv->id = num; irq_attach(CXD56_IRQ_SPH0 + num, cxd56_sphirqhandler, NULL); diff --git a/arch/arm/src/cxd56xx/cxd56_spi.c b/arch/arm/src/cxd56xx/cxd56_spi.c index 2f2bbfc5a21..67c5fd553ce 100644 --- a/arch/arm/src/cxd56xx/cxd56_spi.c +++ b/arch/arm/src/cxd56xx/cxd56_spi.c @@ -1316,6 +1316,7 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle, if (!priv->dmaenable) { nxsem_init(&priv->dmasem, 0, 0); + nxsem_set_protocol(&priv->dmasem, SEM_PRIO_NONE); priv->dmaenable = true; } } @@ -1329,6 +1330,7 @@ void cxd56_spi_dmaconfig(int port, int chtype, DMA_HANDLE handle, if (!priv->dmaenable) { nxsem_init(&priv->dmasem, 0, 0); + nxsem_set_protocol(&priv->dmasem, SEM_PRIO_NONE); priv->dmaenable = true; } } @@ -1420,7 +1422,6 @@ static void spi_dmaexchange(FAR struct spi_dev_s *dev, uint32_t regval = 0; DEBUGASSERT(priv && priv->spibase); - DEBUGASSERT(txbuffer || rxbuffer); /* Disable clock gating (clock enable) */ @@ -1593,12 +1594,12 @@ static void spi_dmatrxwait(FAR struct cxd56_spidev_s *priv) { uint32_t val; - if (nxsem_wait(&priv->dmasem) != OK) + if (nxsem_wait_uninterruptible(&priv->dmasem) != OK) { spierr("dma error\n"); } - if (nxsem_wait(&priv->dmasem) != OK) + if (nxsem_wait_uninterruptible(&priv->dmasem) != OK) { spierr("dma error\n"); } diff --git a/arch/arm/src/cxd56xx/cxd56_start.c b/arch/arm/src/cxd56xx/cxd56_start.c index b4b3bddf158..95244cf00cf 100644 --- a/arch/arm/src/cxd56xx/cxd56_start.c +++ b/arch/arm/src/cxd56xx/cxd56_start.c @@ -275,10 +275,14 @@ void fpuconfig(void) * This is the reset entry point. * ****************************************************************************/ +#define CPU_ID (CXD56_CPU_BASE + 0x40) void __start(void) { uint32_t *dest; +#ifndef CONFIG_CXD56_SUBCORE + uint32_t cpuid; +#endif /* Set MSP/PSP to IDLE stack */ @@ -289,6 +293,17 @@ void __start(void) : "r" ((uint32_t)&_ebss + CONFIG_IDLETHREAD_STACKSIZE - 4)); +#ifndef CONFIG_CXD56_SUBCORE + cpuid = getreg32(CPU_ID); + if (cpuid != 2) + { + for (; ; ) + { + __asm__ __volatile__("wfi\n"); + } + } +#endif + up_irq_disable(); if (*((uint32_t *)CXD56_BOOT_ENTRY_POINT)) diff --git a/arch/arm/src/cxd56xx/cxd56_sysctl.c b/arch/arm/src/cxd56xx/cxd56_sysctl.c index aaea716d4ee..28b22c22d43 100644 --- a/arch/arm/src/cxd56xx/cxd56_sysctl.c +++ b/arch/arm/src/cxd56xx/cxd56_sysctl.c @@ -193,6 +193,7 @@ void cxd56_sysctlinitialize(void) nxsem_init(&g_exc, 0, 1); nxsem_init(&g_sync, 0, 0); + nxsem_set_protocol(&g_sync, SEM_PRIO_NONE); cxd56_iccregisterhandler(CXD56_PROTO_SYSCTL, sysctl_rxhandler, NULL); diff --git a/arch/arm/src/cxd56xx/cxd56_timer.c b/arch/arm/src/cxd56xx/cxd56_timer.c index d518ce0acaa..097b8b2ef93 100644 --- a/arch/arm/src/cxd56xx/cxd56_timer.c +++ b/arch/arm/src/cxd56xx/cxd56_timer.c @@ -366,7 +366,7 @@ static int cxd56_getstatus(FAR struct timer_lowerhalf_s *lower, * Input Parameters: * lower - A pointer the publicly visible representation of the "lower * half" driver state structure. - * timeout - The new timeout value in milliseconds. + * timeout - The new timeout value in microseconds. * * Returned Values: * Zero on success; a negated errno value on failure. diff --git a/arch/arm/src/cxd56xx/cxd56_uart0.c b/arch/arm/src/cxd56xx/cxd56_uart0.c index 2282c6680af..848d1dc3f9e 100644 --- a/arch/arm/src/cxd56xx/cxd56_uart0.c +++ b/arch/arm/src/cxd56xx/cxd56_uart0.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -94,14 +95,14 @@ static void uart0_semgive(sem_t *id); * FarAPI prototypes ****************************************************************************/ -int PD_UartInit(int ch); -int PD_UartUninit(int ch); -int PD_UartConfiguration(int ch, int baudrate, int databits, +int fw_pd_uartinit(int ch); +int fw_pd_uartuninit(int ch); +int fw_pd_uartconfiguration(int ch, int baudrate, int databits, int parity, int stopbit, int flowctrl); -int PD_UartEnable(int ch); -int PD_UartDisable(int ch); -int PD_UartReceive(int ch, void *buf, int size, int leave); -int PD_UartSend(int ch, void *buf, int size, int leave); +int fw_pd_uartenable(int ch); +int fw_pd_uartdisable(int ch); +int fw_pd_uartreceive(int ch, void *buf, int size, int leave); +int fw_pd_uartsend(int ch, void *buf, int size, int leave); /**************************************************************************** * Private Data @@ -158,7 +159,7 @@ static int uart0_open(FAR struct file *filep) return OK; } - ret = PD_UartInit(0); + ret = fw_pd_uartinit(0); if (ret < 0) { set_errno(EFAULT); @@ -175,7 +176,7 @@ static int uart0_open(FAR struct file *filep) /* Enable UART0 pin configuration */ -#ifdef CONFIG_UART0_FLOWCONTROL +#ifdef CONFIG_CXD56_UART0_FLOWCONTROL flowctl = 1; CXD56_PIN_CONFIGS(PINCONFS_SPI2_UART0); #else @@ -183,21 +184,21 @@ static int uart0_open(FAR struct file *filep) CXD56_PIN_CONFIGS(PINCONFS_SPI2A_UART0); #endif - ret = PD_UartConfiguration(0, CONFIG_CXD56_UART0_BAUD, + ret = fw_pd_uartconfiguration(0, CONFIG_CXD56_UART0_BAUD, bits, CONFIG_CXD56_UART0_PARITY, stop, flowctl); if (ret < 0) { - PD_UartUninit(0); + fw_pd_uartuninit(0); set_errno(EINVAL); return ERROR; } - ret = PD_UartEnable(0); + ret = fw_pd_uartenable(0); if (ret < 0) { - PD_UartUninit(0); + fw_pd_uartuninit(0); set_errno(EFAULT); return ERROR; } @@ -215,12 +216,12 @@ static int uart0_close(FAR struct file *filep) if (inode->i_crefs == 1) { - PD_UartDisable(0); - PD_UartUninit(0); + fw_pd_uartdisable(0); + fw_pd_uartuninit(0); /* Disable UART0 pin by changing Hi-Z GPIO */ -#ifdef CONFIG_UART0_FLOWCONTROL +#ifdef CONFIG_CXD56_UART0_FLOWCONTROL CXD56_PIN_CONFIGS(PINCONFS_SPI2_GPIO); #else CXD56_PIN_CONFIGS(PINCONFS_SPI2A_GPIO); @@ -241,9 +242,8 @@ static ssize_t uart0_read(FAR struct file *filep, uart0_semtake(&g_lock); - /* Always blocking */ - - ret = PD_UartReceive(0, buffer, len, 0); + ret = fw_pd_uartreceive(0, buffer, len, + ((filep->f_oflags & O_NONBLOCK) != 0)); uart0_semgive(&g_lock); @@ -267,9 +267,8 @@ static ssize_t uart0_write(FAR struct file *filep, uart0_semtake(&g_lock); - /* Always blocking */ - - ret = PD_UartSend(0, (FAR void *)buffer, len, 0); + ret = fw_pd_uartsend(0, (FAR void *)buffer, len, + ((filep->f_oflags & O_NONBLOCK) != 0)); uart0_semgive(&g_lock); diff --git a/arch/arm/src/cxd56xx/hardware/cxd5602_backupmem.h b/arch/arm/src/cxd56xx/hardware/cxd5602_backupmem.h index b5d772e6544..491b3677304 100644 --- a/arch/arm/src/cxd56xx/hardware/cxd5602_backupmem.h +++ b/arch/arm/src/cxd56xx/hardware/cxd5602_backupmem.h @@ -60,7 +60,9 @@ typedef struct uint32_t chip_revision; /* 0x04400004 ~ 0x04400007 */ uint32_t sbl_version; /* 0x04400008 ~ 0x0440000b */ uint32_t sysfw_version; /* 0x0440000c ~ 0x0440000f */ - uint32_t reserved_version[4]; /* 0x04400010 ~ 0x0440001f */ + uint32_t gnssfw_version; /* 0x04400010 ~ 0x04400013 */ + uint32_t reserved_version[2]; /* 0x04400014 ~ 0x0440001b */ + uint32_t fw_free_space; /* 0x0440001c ~ 0x0440001f */ uint32_t bootcause; /* 0x04400020 ~ 0x04400023 */ uint32_t bootmask; /* 0x04400024 ~ 0x04400027 */ uint32_t bootreserve; /* 0x04400028 ~ 0x0440002b */ diff --git a/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h b/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h new file mode 100644 index 00000000000..7f575cb47d4 --- /dev/null +++ b/arch/arm/src/cxd56xx/hardware/cxd5602_isop_hadc0_highspeed.h @@ -0,0 +1,278 @@ +/* This file is generated at Mar 27 2020 12:00:17 */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const unsigned long scu_isopprog_array[] = +{ + 0xf7f8d600, 0xa2024f86, 0x0001a200, 0x18004081, + 0x00008014, 0x00000000, 0x0000a207, 0x00000000, + 0x0000a070, 0xac2d4ec6, 0xd000ac27, 0x50a2e444, + 0x70111801, 0x50011c01, 0xf350d000, 0x0004800a, + 0x40110114, 0x50031f43, 0x9ff42801, 0x90062911, + 0x8fec5043, 0x00140003, 0x40640113, 0x1f344011, + 0x9fe42121, 0xd2005001, 0x5203f35a, 0x50155004, + 0x04150845, 0x90082905, 0x2d444014, 0x00259ff2, + 0x40110115, 0x21311f54, 0xd1009fe4, 0x5ff2e824, + 0xe808d400, 0x01f8fc43, 0x07fffc33, 0xe804d000, + 0xf000d700, 0x1c431c12, 0xe800d100, 0x1c025013, + 0x0103fc40, 0x0300fc30, 0xf3dcd200, 0x1c135be4, + 0xe418d100, 0x1c105003, 0xf47250a1, 0x1c230300, + 0x0004f721, 0xf7235e61, 0xf7230005, 0xf7230016, + 0x00250017, 0x4fc10215, 0xf7531d53, 0xf753fffe, + 0x2141ffff, 0xd1009fee, 0xd209f340, 0xd000ec00, + 0x5004f4bc, 0x1c125005, 0x0304f470, 0x44020002, + 0x0308f472, 0x41a10001, 0x00020053, 0x106350a7, + 0x1c240132, 0x0004f727, 0x0005f724, 0x0016f724, + 0x0017f724, 0x1d340013, 0xfffef734, 0xfffff734, + 0x40434ff7, 0x9ff02907, 0x44014015, 0x9fca2925, + 0xd3005001, 0x5004f344, 0xf39cd200, 0x01150035, + 0x1f544011, 0x9ff62941, 0xd4005fe3, 0x5005f348, + 0x00415f67, 0x4fc30231, 0xfffef512, 0x1f154202, + 0x9ff02173, 0xf334d200, 0xf000d100, 0xd4005003, + 0x5005f53c, 0x030cf412, 0xac115001, 0xa819ac19, + 0x00470052, 0x00710112, 0x01211032, 0x00201c13, + 0x70407052, 0x1f450104, 0x00740070, 0xf350d700, + 0x01200157, 0x1e724015, 0xf7131f02, 0xa8110016, + 0x210550a0, 0x9fc44021, 0xf37ad000, 0x1000fc11, + 0x00345f02, 0x4ff30005, 0x21231014, 0x1d510245, + 0x50029ff2, 0xf334d000, 0xf000d700, 0xf45cd300, + 0x1d025004, 0xf332d000, 0x0310f470, 0x00350041, + 0x01151041, 0x0004f452, 0x0008f454, 0xf7524014, + 0xf752000c, 0x1c52000d, 0x9fe22964, 0xd2005001, + 0xfc43f330, 0xfc332020, 0x1f210327, 0x0001f721, + 0x5834d211, 0xf5711d01, 0xf77102fe, 0x1c7302fc, + 0xe412d000, 0x0004f472, 0xf4715012, 0x1f020008, + 0x0d66fa00, 0xa82da827, 0x41465000, 0x0000a070, + 0xac3d4e46, 0xf601ac37, 0x28010005, 0xf6029178, + 0xac200004, 0x10110021, 0xd100ac29, 0xa828f53c, + 0x10300120, 0x7050ac18, 0x1e150101, 0xfa000050, + 0x00500ddc, 0x29006fb0, 0x0050901a, 0xfa004010, + 0x00500dcc, 0xfa004020, 0x00500dc4, 0xfa004030, + 0xd1000dbc, 0x5010e000, 0x08501811, 0x28010401, + 0xac15906c, 0x0128fa00, 0x5003a822, 0xf6205005, + 0xa8110004, 0xfa004062, 0xa8230290, 0xf53cd400, + 0x91022900, 0x5021a818, 0xf334d700, 0x1c410104, + 0xf6305011, 0x1a720004, 0x05120801, 0xf6301d72, + 0xf7400005, 0x28000016, 0x500090dc, 0x00320041, + 0x01524010, 0xf6220151, 0xf7120006, 0x00050006, + 0x0005f632, 0x24256ff5, 0x80ba9fe4, 0xd100a822, + 0xf620e404, 0x18110004, 0x28016201, 0xd3009028, + 0x6ff0f330, 0x0001f631, 0x90222101, 0x6ff01e30, + 0x901a2910, 0x0ccefa00, 0x5030a822, 0xf330d100, + 0x800a1f10, 0xf330d000, 0x1f015001, 0x0004f620, + 0xf000d100, 0x01011050, 0x0005f620, 0x0024f213, + 0xac1b2800, 0x0024f211, 0x905a0050, 0xac100015, + 0x03b2fa00, 0x0053a814, 0x904a2910, 0x60f31243, + 0x61f34013, 0x903e2803, 0x5002a818, 0x60f05001, + 0x0030ac18, 0x00470043, 0xf41cd400, 0x10234011, + 0xf2430134, 0x1a440002, 0x0152a81d, 0x0125a825, + 0x0006f652, 0x00741f42, 0x00031f32, 0x6ff20012, + 0x9fd02432, 0xa83da837, 0xa07041c6, 0xac4d4dc6, + 0xd000ac47, 0xfc41e400, 0x18000400, 0x28000410, + 0x5000915e, 0xf33cd100, 0x0e10ac18, 0xfc41ac10, + 0xd0000400, 0xac21e804, 0xd1001c01, 0x1810e080, + 0xe084d100, 0x00021811, 0xf76260f2, 0x00620018, + 0x0018fc02, 0x00040023, 0x13007022, 0x70131284, + 0x1f346034, 0xf5611d20, 0x1301001c, 0xe088d000, + 0xf5615012, 0x1c02001e, 0x0018f265, 0x6ff5ac2d, + 0xfa000050, 0xa82f02e0, 0xd100a812, 0x2910f41c, + 0x10259086, 0xf000d000, 0x12870013, 0x0100fc41, + 0x40170150, 0x0280f000, 0x04106ff7, 0x29005001, + 0x50009032, 0x28070023, 0x0062905e, 0x40101011, + 0x0018fc02, 0x0018f664, 0xf2210112, 0x10240002, + 0x2000fc34, 0x1d311d41, 0x6ff10001, 0x9fdc2471, + 0x50008036, 0x28070035, 0xf662902e, 0x00530018, + 0x40101011, 0x01231022, 0x0002f232, 0x00641a33, + 0x0018fc04, 0xf6410114, 0x1f310003, 0x00011f21, + 0x24716ff1, 0xd0009fd6, 0x1800e400, 0x0410a821, + 0x900c2800, 0x4010a818, 0x2c40ac18, 0xf6619f02, + 0x50000018, 0x90142c41, 0x4fc00010, 0x90062e30, + 0x80085010, 0x00fafc01, 0xd1000010, 0x1811e404, + 0x28016201, 0xd5009022, 0x6ff0f330, 0x0001f651, + 0x901c2101, 0x6ff01e50, 0x90142910, 0x0ad6fa00, + 0x1f505030, 0xd000800a, 0x5001f330, 0xa8471f01, + 0x4246a84d, 0x4e06a070, 0xac3fac45, 0xe400d300, + 0xfc431834, 0x04340200, 0x90322804, 0xd400ac21, + 0x1841e404, 0x28016201, 0xd1009032, 0xf614f330, + 0x21040001, 0x1e11902e, 0x29316ff1, 0xd0009026, + 0xf001f000, 0x701102c8, 0x02c8f401, 0xe808d000, + 0x05311801, 0x50001c01, 0xd1008108, 0x5003f330, + 0x10501f13, 0xf000d100, 0xe808d300, 0xfdfffc45, + 0xfffffc35, 0x01015007, 0xf210ac19, 0x18340026, + 0xfc450454, 0x12c00200, 0xd3001c34, 0x1c35e804, + 0x0026f213, 0xf214ac10, 0xf2100026, 0xf2150026, + 0x12830026, 0x124512c4, 0x601060f3, 0x01326034, + 0x28006075, 0x902a4014, 0x00615003, 0x40131017, + 0x0014fc01, 0x01711e20, 0x0001f627, 0x10804022, + 0x08500570, 0x00371d10, 0x24476ff7, 0x80289fde, + 0x00605003, 0x40131017, 0x0014fc00, 0x01701e21, + 0x0001f627, 0x10874022, 0x08570517, 0x00371d07, + 0x24476ff7, 0xa8119fde, 0xf262a820, 0xd3000014, + 0x1081e004, 0xfc211102, 0x05010300, 0xd2000521, + 0x1c31e008, 0xfc000060, 0xf2610014, 0x70200018, + 0x11011a00, 0x1c210501, 0xe00cd100, 0xf020a81a, + 0x1c100028, 0xe010d100, 0x002cf020, 0xd1001c10, + 0xf020e014, 0x1c100030, 0xd1005010, 0x1c10e018, + 0xa845a83f, 0xa0704206, 0xac354e86, 0xa83dac2f, + 0x0002ac1a, 0x2805ac12, 0xac21901e, 0x1801a820, + 0xa81a0020, 0x001cfa00, 0xa821a812, 0x4ff5a818, + 0x40412905, 0xa82f9fe6, 0x5010a835, 0xa0704186, + 0xac2d4ec6, 0xac12ac27, 0x0005ac19, 0x0036fa00, + 0x90282910, 0x1025a810, 0x90102800, 0xf41cd000, + 0x1a000150, 0x1c01a819, 0xa8198012, 0xf33cd000, + 0x2000fc35, 0x1d510e00, 0xa8271d01, 0x4146a82d, + 0xd200a070, 0x0001f000, 0x00231020, 0x50100103, + 0x0280f033, 0x28036033, 0x29239078, 0x0014904c, + 0xd3001021, 0x0112f37a, 0xf0211014, 0x01430280, + 0x12415094, 0x40a16031, 0x081460f1, 0xe404d100, + 0x04141811, 0x904c2804, 0x50001a31, 0x90422801, + 0x1000fc10, 0x90442101, 0x0280f020, 0xfc201280, + 0x1d300fff, 0xa0705010, 0x90242913, 0x01121021, + 0xf0205091, 0xd2000280, 0x1240e404, 0x40a06030, + 0x080160f0, 0x04011820, 0xa3002901, 0x5000a070, + 0xfc11a070, 0x1d311000, 0x4ff1a070, 0x1d315010, + 0x4e46a070, 0xac37ac3d, 0x18450004, 0x901e2905, + 0xe404d000, 0x18032801, 0xd0000017, 0x90a0e410, + 0x60431802, 0x90b42803, 0x809e7042, 0x93322915, + 0xf6410017, 0x6ff10004, 0x00400012, 0x01201022, + 0x0019f602, 0x0018f603, 0x90262123, 0xd2001051, + 0x0112f000, 0x0020f021, 0x0020f022, 0x13821301, + 0x61f267f1, 0x0018f701, 0x40110121, 0x0019f701, + 0xd200ac17, 0x5041e444, 0x18232807, 0xd7000871, + 0x0513f000, 0xd800d100, 0xd3001c23, 0xa432d400, + 0x0023a512, 0x0004f641, 0x00740045, 0x105176c3, + 0xf0410114, 0x50040020, 0x00141c34, 0x0400fc24, + 0x902e2804, 0x03fffc21, 0x1000fc31, 0x18028026, + 0x28036023, 0x70229110, 0xd0001c02, 0xfc11e804, + 0x1c010400, 0xf8005000, 0x5fb10524, 0x80faac24, + 0x704267f1, 0x50121c21, 0x1c325001, 0xd410d200, + 0x0018f604, 0xf754ac25, 0xf7510017, 0x00030005, + 0xd810d100, 0xa810ac1b, 0x00302800, 0xf601a512, + 0x6ff10019, 0x0041ac29, 0x6ff1a82b, 0x915a2513, + 0x10114014, 0x0018f704, 0x01140074, 0x0160f247, + 0x0160f245, 0x607512c5, 0xf2430051, 0x40110160, + 0x0100fc23, 0x90102803, 0xf603a820, 0x01130005, + 0x0005f703, 0xfc04a818, 0x0e530160, 0x90082903, + 0x07fffc27, 0x00738026, 0xfc232821, 0x1c2305ff, + 0x28159016, 0x00719012, 0xfc214ff5, 0x4ff501ff, + 0x29051c21, 0xfc279ffa, 0x1c2703ff, 0xf000d700, + 0xf6041a41, 0xfc210018, 0x28010800, 0xf6019f7a, + 0x25410019, 0x101490d4, 0xc000d200, 0xf2710147, + 0xfc210160, 0x2121e000, 0xfc0790ba, 0x1a710160, + 0x40116ff1, 0x001af501, 0x0018f601, 0xf7014011, + 0x80a60018, 0x5fd1ac24, 0xd1000412, 0x1c02e400, + 0x18115000, 0x03fffc21, 0xf9002801, 0x50a20410, + 0x51432807, 0xf000d500, 0xa534a424, 0x000cf053, + 0xd4000943, 0x0413f35a, 0x00450031, 0x011561f1, + 0x29511e51, 0x1253900a, 0x1e410134, 0x20214051, + 0x5013903c, 0xe804d400, 0x08135012, 0x00141c43, + 0x1024a823, 0xf2340143, 0x2804001a, 0xd1009020, + 0x1814e408, 0xf655a825, 0x08520004, 0x1c120542, + 0x001af231, 0xf5314ff1, 0x83a0001a, 0x50a30012, + 0x20326ff2, 0xa8249396, 0xf7415010, 0x1c400004, + 0x50018dc6, 0x001af501, 0xf640a824, 0x28000005, + 0xa8139016, 0xd438d200, 0xd838d100, 0x28034ff0, + 0x1c20a512, 0xa8128014, 0xd438d100, 0xd838d000, + 0x51f22802, 0x1c12a501, 0xe404d000, 0xfc201800, + 0x28000200, 0xd000908e, 0x5011e41b, 0xe408d500, + 0x18521f01, 0x0004f643, 0x08314103, 0xe808d300, + 0xfc420521, 0xfc32fff8, 0x1c51ffff, 0xfffffc41, + 0x1ffffc31, 0x4000fc15, 0x2800a810, 0x1832a521, + 0x04122800, 0xfc131c32, 0xfc422000, 0xa4310001, + 0xe804d300, 0xd200a521, 0x28008000, 0xfc411c31, + 0xa5120004, 0xfc412800, 0x1c320002, 0x5005a452, + 0x1c32a512, 0x0004f642, 0x10220041, 0xf5150121, + 0xf642001a, 0xf7120017, 0xfa000018, 0xa824051a, + 0xa812801c, 0xe000d100, 0x0007fc40, 0xe808d300, + 0x28025025, 0x1832a501, 0x1c320512, 0xa8111c45, + 0x92942925, 0xe400d000, 0x28010047, 0x00131804, + 0xfc429022, 0x04240004, 0x902a2804, 0xfc421801, + 0x04210001, 0x901e2901, 0xfc411800, 0x04100002, + 0xfc2481c6, 0x28048000, 0x1801900c, 0x2000fc21, + 0x91ae2801, 0xfc410032, 0xfc31ffff, 0xfc401fff, + 0xfc30fff8, 0xd300ffff, 0xfc45e808, 0x28020004, + 0xa501ac12, 0xac292802, 0x04101830, 0x2000fc11, + 0xfc401c30, 0xa4140001, 0x8000d300, 0xd000a504, + 0x2802e804, 0xa5531c04, 0x00711c03, 0x0005f615, + 0x902e2805, 0xd500a810, 0xd700d410, 0x2800d810, + 0x5007a575, 0x00100072, 0x6ff24017, 0x1e520120, + 0x0006f702, 0xf6120070, 0x6ff00005, 0x9fe62420, + 0xe404d000, 0x18000017, 0x0200fc20, 0x90602800, + 0xe41bd000, 0x1f025012, 0xe408d000, 0x00751801, + 0xf657ac25, 0x41070004, 0x05120872, 0xd2001c02, + 0x1820e808, 0x0410a829, 0xe804d100, 0x00171c20, + 0x4000fc11, 0x0002fc42, 0x1c731c74, 0xa8105003, + 0xa5212800, 0xf6521c71, 0x00510004, 0x01211022, + 0x001af513, 0x0017f652, 0x0018f712, 0xa8108160, + 0xd46cd100, 0xd86cd200, 0x28005004, 0x1c14a521, + 0xe804d400, 0xd4001c43, 0x5013e408, 0x00751841, + 0x0004f652, 0x50420823, 0x08020513, 0xd4001c43, + 0x0723e444, 0x04321842, 0xfa001c42, 0x0050038a, + 0xd3005031, 0x1c01f000, 0x0004f602, 0x10520031, + 0xf0170121, 0x00710020, 0x603112c1, 0x90562801, + 0x50124ff1, 0x08121287, 0xe414d100, 0xac2a6307, + 0x01370724, 0xfc071812, 0x042402bc, 0x1f1460f4, + 0x0004f604, 0x01431054, 0x0024f234, 0x0024f233, + 0x124360f4, 0x60f30104, 0x40134064, 0x4ff31e45, + 0x29034014, 0x40171f75, 0xa82b9ff4, 0x60f20532, + 0x800a1f12, 0xfaff0005, 0x0050f53a, 0x80a65005, + 0xfc201800, 0x28004000, 0xd10090aa, 0x2803d46c, + 0xd86cd000, 0xa5015014, 0x1c105000, 0xe408d100, + 0x18120035, 0x2805ac27, 0x0004f673, 0x08344103, + 0x1c140524, 0xfffffc44, 0x1ffffc34, 0xfff8fc41, + 0xfffffc31, 0xd400a442, 0xa512e808, 0x28051843, + 0x0001fc41, 0x1c430423, 0x2000fc13, 0x4000fc14, + 0xd300a432, 0xa5128000, 0xe804d100, 0x1c122805, + 0x0004fc42, 0x2805a523, 0x0002fc42, 0xa4431c13, + 0x1c13a523, 0x0004f671, 0x10210072, 0xf5200112, + 0xf670001a, 0xf7200017, 0x00500018, 0x0268fa00, + 0x5005a820, 0x29051c05, 0xa837a300, 0x41c6a83d, + 0x5025a070, 0x8ff01c75, 0xac6d4cc6, 0xac2aac67, + 0xd100ac21, 0xfc44e808, 0xfc34fdff, 0x2623ffff, + 0x04421812, 0x0200fc44, 0xd2001c12, 0x5001e804, + 0xa8741c24, 0x9014ac34, 0x90322803, 0x90382913, + 0xf000d100, 0x0268f011, 0x28338052, 0x29439038, + 0xd200903e, 0xf021f000, 0xa82b0274, 0x903c2913, + 0x0278f022, 0xe010d300, 0x80301c32, 0xf000d100, + 0x0264f011, 0x29238026, 0xd1009022, 0xf011f000, + 0x8018026c, 0xf000d100, 0x0270f011, 0x2953800e, + 0xd100900a, 0xf011f000, 0xd200027c, 0x1c21e00c, + 0x2801a831, 0xa829911e, 0xd4005003, 0x1081e400, + 0xac190501, 0xf33cd100, 0xac100e10, 0xa8210030, + 0xe004d500, 0x01011020, 0x00011810, 0x1101a81a, + 0x1c520512, 0x2911a829, 0x1300900a, 0xe008d100, + 0xd0001c10, 0x5011e018, 0x1c01ac3b, 0xfc401841, + 0x04010400, 0x9ff62801, 0x04011841, 0x28015010, + 0xfc4190b8, 0xd2000400, 0xac58e804, 0xe084d000, + 0x1c21ac51, 0xe080d100, 0x18155012, 0xe088d100, + 0x60f5ac4d, 0xac401800, 0x00501c12, 0xf836faff, + 0x90702910, 0x1025a84c, 0xf000d100, 0x0100fc42, + 0x00400151, 0x0280f011, 0x0300fc20, 0x28010421, + 0xd2009016, 0x1384f41c, 0xf2230152, 0x1a220002, + 0x1f341f24, 0x00528010, 0xfc321304, 0x1d242000, + 0x1d24a812, 0x902c2800, 0x901c2801, 0xf41cd000, + 0xf2010150, 0x1a000002, 0xfc22a842, 0x1282ff00, + 0x1f121f02, 0xa841800e, 0x2000fc35, 0xa8101d51, + 0xd4001d01, 0x1840e400, 0x0410a851, 0xa8582800, + 0x2c409008, 0x9f4c4010, 0xa830a83b, 0x21034013, + 0xfc409efc, 0xd1000200, 0x1c10e804, 0xa8675010, + 0x4346a86d, 0xd000a070, 0xd200f000, 0xf201e404, + 0x401102fe, 0x02fef501, 0x62011821, 0x901c2801, + 0xf330d100, 0x29021e12, 0x5012901a, 0xf0021f12, + 0x60f202c4, 0x0001f712, 0xd100800a, 0x5002f330, + 0xd1001f12, 0x5082e440, 0xd1001d12, 0xd200e400, + 0x8012dc80, 0xf0041823, 0x12e40260, 0xfc3463c4, + 0x1d432000, 0xfc441813, 0x04430080, 0x9ff62803, + 0xd0008fe4, 0x1801e414, 0x00126071, 0x1f027082, + 0xa0701f01, 0xe404d100, 0x18112800, 0x60419012, + 0x90262801, 0xe410d000, 0x70411801, 0x60218010, + 0x90162801, 0xe410d000, 0x70211801, 0xd0001c01, + 0xfc12e804, 0x1c020400, 0xd100a070, 0x0101f000, + 0xf6111020, 0x00130314, 0x60130002, 0x2000fc02, + 0x900e2803, 0xfc311011, 0xfc212000, 0x800621fc, + 0xf33cd100, 0xf41cd300, 0x1d320103, 0x0002f531, + 0x0000a070, +}; +const unsigned long sizeof_scu_isopprog_array = 4276; /* 0x000010b4 */ diff --git a/boards/arm/cxd56xx/common/src/Make.defs b/boards/arm/cxd56xx/common/src/Make.defs index 48d8496aab3..929aba45dfb 100644 --- a/boards/arm/cxd56xx/common/src/Make.defs +++ b/boards/arm/cxd56xx/common/src/Make.defs @@ -150,6 +150,10 @@ ifeq ($(CONFIG_CXD56_I2C_DRIVER),y) CSRCS += cxd56_i2cdev.c endif +ifeq ($(CONFIG_CXD56_SPI_DRIVER),y) +CSRCS += cxd56_spidev.c +endif + ifeq ($(CONFIG_VIDEO_ISX012),y) CSRCS += cxd56_isx012.c endif @@ -158,6 +162,18 @@ ifeq ($(CONFIG_CXD56_IMAGEPROC),y) CSRCS += cxd56_imageproc.c endif +ifeq ($(CONFIG_BCM20706),y) + CSRCS += cxd56_bcm20706.c +endif + +ifeq ($(CONFIG_CXD56_EMMC),y) + CSRCS += cxd56_emmcdev.c +endif + +ifeq ($(CONFIG_CXD56_SPISD),y) + CSRCS += cxd56_spisd.c +endif + DEPPATH += --dep-path src VPATH += :src CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) diff --git a/boards/arm/cxd56xx/common/src/cxd56_ak09912_scu.c b/boards/arm/cxd56xx/common/src/cxd56_ak09912_scu.c index 2245eff66c8..735cf78aeb3 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_ak09912_scu.c +++ b/boards/arm/cxd56xx/common/src/cxd56_ak09912_scu.c @@ -50,7 +50,7 @@ #include -#ifdef CONFIG_CXD56_DECI_AK09912 +#ifdef CONFIG_SENSORS_AK09912_SCU_DECI # define MAG_NR_SEQS 3 #else # define MAG_NR_SEQS 1 diff --git a/boards/arm/cxd56xx/common/src/cxd56_bcm20706.c b/boards/arm/cxd56xx/common/src/cxd56_bcm20706.c new file mode 100644 index 00000000000..8f704362496 --- /dev/null +++ b/boards/arm/cxd56xx/common/src/cxd56_bcm20706.c @@ -0,0 +1,165 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_bcm20706.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 +#include +#include +#include + +#include "cxd56_gpio.h" +#include "cxd56_sysctl.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define BCM20707_RST_N PIN_SEN_IRQ_IN +#define BCM20707_DEV_WAKE PIN_EMMC_DATA3 + +#define BCM20707_RST_DELAY (50 * 1000) /* ms */ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_bluetooth_pin_cfg + * + * Description: + * Setup pin configuration for bcm20706. + * + ****************************************************************************/ + +int board_bluetooth_pin_cfg(void) +{ + int ret = 0; + + ret = cxd56_gpio_config(BCM20707_RST_N, false); + + if (ret != 0) + { + return ret; + } + + cxd56_gpio_write(BCM20707_RST_N, false); + + ret = cxd56_gpio_config(BCM20707_DEV_WAKE, false); + + if (ret != 0) + { + return ret; + } + + cxd56_gpio_write(BCM20707_DEV_WAKE, true); + + return ret; +} + +/**************************************************************************** + * Name: board_bluetooth_uart_pin_cfg + * + * Description: + * Setup UART pin configuration for bcm20706. + * + ****************************************************************************/ + +int board_bluetooth_uart_pin_cfg(void) +{ + int ret = 0; + + /* BCM20706 evaluation board might set pull-down. + * Set float for UART2 CTS + */ + + ret = board_gpio_config(PIN_UART2_CTS, 1, 1, 0, 0); + + return ret; +} + +/**************************************************************************** + * Name: board_bluetooth_reset + * + * Description: + * Reset BCM20706. + * + ****************************************************************************/ + +void board_bluetooth_reset(void) +{ + cxd56_gpio_write(BCM20707_RST_N, false); + usleep(BCM20707_RST_DELAY); + cxd56_gpio_write(BCM20707_RST_N, true); + usleep(BCM20707_RST_DELAY); +} + +/**************************************************************************** + * Name: board_bluetooth_power_control + * + * Description: + * Power ON/OFF BCM20706. + * + ****************************************************************************/ + +int board_bluetooth_power_control(bool en) +{ + int ret = 0; + ret = board_power_control(POWER_BTBLE, en); + return ret; +} + +/**************************************************************************** + * Name: board_bluetooth_enable_sleep + * + * Description: + * Sleep mode ON/OFF BCM20706. + * + ****************************************************************************/ + +void board_bluetooth_enable_sleep(bool en) +{ + cxd56_gpio_write(BCM20707_DEV_WAKE, en); +} diff --git a/boards/arm/cxd56xx/common/src/cxd56_bm1422gmv_scu.c b/boards/arm/cxd56xx/common/src/cxd56_bm1422gmv_scu.c index 37bfd520a6e..42ff991beda 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_bm1422gmv_scu.c +++ b/boards/arm/cxd56xx/common/src/cxd56_bm1422gmv_scu.c @@ -50,7 +50,7 @@ #include "cxd56_i2c.h" -#ifdef CONFIG_CXD56_DECI_BM1422GMV +#ifdef CONFIG_SENSORS_BM1422GMV_SCU_DECI # define BM1422GMV_PATH_CNT 3 #else # define BM1422GMV_PATH_CNT 1 diff --git a/boards/arm/cxd56xx/common/src/cxd56_bmi160_i2c.c b/boards/arm/cxd56xx/common/src/cxd56_bmi160_i2c.c index 6649c8e2f48..d08f84fa8a4 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_bmi160_i2c.c +++ b/boards/arm/cxd56xx/common/src/cxd56_bmi160_i2c.c @@ -48,17 +48,9 @@ #include "cxd56_i2c.h" -#ifdef CONFIG_CXD56_DECI_GYRO -#define GYRO_NR_SEQS 3 -#else -#define GYRO_NR_SEQS 1 -#endif - -#ifdef CONFIG_CXD56_DECI_ACCEL -#define ACCEL_NR_SEQS 3 -#else -#define ACCEL_NR_SEQS 1 -#endif +/**************************************************************************** + * Public Functions + ****************************************************************************/ int board_bmi160_initialize(int bus) { diff --git a/boards/arm/cxd56xx/common/src/cxd56_bmi160_scu.c b/boards/arm/cxd56xx/common/src/cxd56_bmi160_scu.c index 04da76d3c73..74d83bc8adc 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_bmi160_scu.c +++ b/boards/arm/cxd56xx/common/src/cxd56_bmi160_scu.c @@ -48,15 +48,19 @@ #include #include +#if defined(CONFIG_SENSORS_BMI160_SCU_SPI) #include "cxd56_spi.h" +#else +#include "cxd56_i2c.h" +#endif -#ifdef CONFIG_CXD56_DECI_GYRO +#ifdef CONFIG_SENSORS_BMI160_SCU_DECI_GYRO # define GYRO_NR_SEQS 3 #else # define GYRO_NR_SEQS 1 #endif -#ifdef CONFIG_CXD56_DECI_ACCEL +#ifdef CONFIG_SENSORS_BMI160_SCU_DECI_ACCEL # define ACCEL_NR_SEQS 3 #else # define ACCEL_NR_SEQS 1 @@ -67,6 +71,7 @@ ****************************************************************************/ #if defined(CONFIG_SENSORS_BMI160_SCU) +#if defined(CONFIG_SENSORS_BMI160_SCU_SPI) int board_bmi160_initialize(int bus) { @@ -120,4 +125,59 @@ int board_bmi160_initialize(int bus) return ret; } -#endif +#else /* !CONFIG_SENSORS_BMI160_SCU_SPI */ + +int board_bmi160_initialize(int bus) +{ + int ret; + FAR struct i2c_master_s *i2c; + + sninfo("Initializing BMI160..\n"); + + /* Initialize i2c deivce */ + + i2c = cxd56_i2cbus_initialize(bus); + if (!i2c) + { + snerr("ERROR: Failed to initialize i2c%d.\n", bus); + return -ENODEV; + } + + int i; + + ret = bmi160_init(i2c, bus); + if (ret < 0) + { + snerr("Error initialize BMI160\n"); + return ret; + } + + /* Create char devices for each FIFOs */ + + for (i = 0; i < GYRO_NR_SEQS; i++) + { + ret = bmi160gyro_register("/dev/gyro", i, i2c, bus); + if (ret < 0) + { + snerr("Error registering gyroscope. %d\n", ret); + return ret; + } + } + + /* Create char devices for each FIFOs */ + + for (i = 0; i < ACCEL_NR_SEQS; i++) + { + ret = bmi160accel_register("/dev/accel", i, i2c, bus); + if (ret < 0) + { + snerr("Error registering accelerometer. %d\n", ret); + return ret; + } + } + + return ret; +} + +#endif /* CONFIG_SENSORS_BMI160_SCU_SPI */ +#endif /* CONFIG_SENSORS_BMI160_SCU */ diff --git a/boards/arm/cxd56xx/common/src/cxd56_bmi160_spi.c b/boards/arm/cxd56xx/common/src/cxd56_bmi160_spi.c index fd8d29968d7..ba3b70d8d90 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_bmi160_spi.c +++ b/boards/arm/cxd56xx/common/src/cxd56_bmi160_spi.c @@ -49,18 +49,6 @@ #include "cxd56_spi.h" -#ifdef CONFIG_CXD56_DECI_GYRO -# define GYRO_NR_SEQS 3 -#else -# define GYRO_NR_SEQS 1 -#endif - -#ifdef CONFIG_CXD56_DECI_ACCEL -# define ACCEL_NR_SEQS 3 -#else -# define ACCEL_NR_SEQS 1 -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/boards/arm/cxd56xx/common/src/cxd56_bmp280_scu.c b/boards/arm/cxd56xx/common/src/cxd56_bmp280_scu.c index b6486d2192e..bfbd05e41f5 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_bmp280_scu.c +++ b/boards/arm/cxd56xx/common/src/cxd56_bmp280_scu.c @@ -50,13 +50,13 @@ #include "cxd56_i2c.h" -#ifdef CONFIG_CXD56_DECI_PRESS +#ifdef CONFIG_SENSORS_BMP280_SCU_DECI_PRESS # define PRESS_NR_SEQS 3 #else # define PRESS_NR_SEQS 1 #endif -#ifdef CONFIG_CXD56_DECI_TEMP +#ifdef CONFIG_SENSORS_BMP280_SCU_DECI_TEMP # define TEMP_NR_SEQS 3 #else # define TEMP_NR_SEQS 1 diff --git a/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c new file mode 100644 index 00000000000..32f3e26a6db --- /dev/null +++ b/boards/arm/cxd56xx/common/src/cxd56_emmcdev.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_emmcdev.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 + +#include +#include +#include +#include +#include +#include +#include "cxd56_emmc.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef CONFIG_SFC_DEVNO +# define CONFIG_SFC_DEVNO 0 +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_emmc_initialize + * + * Description: + * Initialize the eMMC device and mount the file system. + * + ****************************************************************************/ + +int board_emmc_initialize(void) +{ + int ret; + + /* Power on the eMMC device */ + + ret = board_power_control(POWER_EMMC, true); + if (ret) + { + ferr("ERROR: Failed to power on eMMC. %d\n", ret); + return -ENODEV; + } + + /* Initialize the eMMC deivce */ + + ret = cxd56_emmcinitialize(); + if (ret < 0) + { + ferr("ERROR: Failed to initialize eMMC. %d\n ", ret); + return -ENODEV; + } + + /* Mount the eMMC deivce */ + + ret = mount("/dev/emmc0", "/mnt/emmc", "vfat", 0, NULL); + if (ret < 0) + { + ferr("ERROR: Failed to mount the eMMC. %d\n", errno); + } + + return ret; +} diff --git a/boards/arm/cxd56xx/common/src/cxd56_ili9340.c b/boards/arm/cxd56xx/common/src/cxd56_ili9340.c index ae5b66799ab..b7b1255f642 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_ili9340.c +++ b/boards/arm/cxd56xx/common/src/cxd56_ili9340.c @@ -426,3 +426,7 @@ FAR struct lcd_dev_s *board_lcd_getdev(int lcddev) return NULL; } + +void board_lcd_uninitialize(void) +{ +} diff --git a/boards/arm/cxd56xx/common/src/cxd56_isx012.c b/boards/arm/cxd56xx/common/src/cxd56_isx012.c index f083b8417bf..c608fe65c44 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_isx012.c +++ b/boards/arm/cxd56xx/common/src/cxd56_isx012.c @@ -71,8 +71,6 @@ #define SLEEP_CANCEL_TIME (13*1000) /* ms */ #define POWER_CHECK_TIME (1*1000) /* ms */ -#define ALL_POWERON (7) -#define ALL_POWEROFF (0) #define POWER_CHECK_RETRY (10) /**************************************************************************** @@ -88,11 +86,8 @@ FAR struct i2c_master_s *i2c; int board_isx012_power_on(void) { int ret; - uint32_t stat; int i; - /* 'POWER_IMAGE_SENSOR==PMIC_GPO(4/5/7)' */ - ret = board_power_control(POWER_IMAGE_SENSOR, true); if (ret) { @@ -103,17 +98,15 @@ int board_isx012_power_on(void) ret = -ETIMEDOUT; for (i = 0; i < POWER_CHECK_RETRY; i++) { - stat = 0; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(4)) << 0; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(5)) << 1; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(7)) << 2; - if (stat == ALL_POWERON) + /* Need to wait for a while after power-on */ + + nxsig_usleep(POWER_CHECK_TIME); + + if (true == board_power_monitor(POWER_IMAGE_SENSOR)) { ret = OK; break; } - - nxsig_usleep(POWER_CHECK_TIME); } return ret; @@ -122,11 +115,8 @@ int board_isx012_power_on(void) int board_isx012_power_off(void) { int ret; - uint32_t stat; int i; - /* POWER_IMAGE_SENSOR==PMIC_GPO(4/5/7) */ - ret = board_power_control(POWER_IMAGE_SENSOR, false); if (ret) { @@ -137,11 +127,7 @@ int board_isx012_power_off(void) ret = -ETIMEDOUT; for (i = 0; i < POWER_CHECK_RETRY; i++) { - stat = 0; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(4)) << 0; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(5)) << 1; - stat |= (uint32_t)board_power_monitor(PMIC_GPO(7)) << 2; - if (stat == ALL_POWEROFF) + if (false == board_power_monitor(POWER_IMAGE_SENSOR)) { ret = OK; break; diff --git a/boards/arm/cxd56xx/common/src/cxd56_kx022_scu.c b/boards/arm/cxd56xx/common/src/cxd56_kx022_scu.c index 7bab6a794a6..cc59a6b156e 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_kx022_scu.c +++ b/boards/arm/cxd56xx/common/src/cxd56_kx022_scu.c @@ -50,7 +50,7 @@ #include "cxd56_i2c.h" -#ifdef CONFIG_CXD56_DECI_KX022 +#ifdef CONFIG_SENSORS_KX022_SCU_DECI # define KX022_FIFO_CNT 3 #else # define KX022_FIFO_CNT 1 diff --git a/boards/arm/cxd56xx/common/src/cxd56_lpm013m091a.c b/boards/arm/cxd56xx/common/src/cxd56_lpm013m091a.c index 9a2283310a2..128e1478833 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_lpm013m091a.c +++ b/boards/arm/cxd56xx/common/src/cxd56_lpm013m091a.c @@ -89,12 +89,13 @@ * Private Data ****************************************************************************/ -struct lpm013m091a_lcd_s +struct lpm013m091a4ws_lcd_s { struct lpm013m091a_lcd_s dev; struct spi_dev_s *spi; }; -static struct lpm013m091a_lcd_s g_lcddev; + +static struct lpm013m091a4ws_lcd_s g_lcddev; static struct lcd_dev_s *g_lcd = NULL; /**************************************************************************** @@ -116,7 +117,8 @@ static struct lcd_dev_s *g_lcd = NULL; static void cxd56_lpm013m091a4ws_select(FAR struct lpm013m091a_lcd_s *lcd) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; SPI_LOCK(priv->spi, true); SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), true); @@ -137,7 +139,8 @@ static void cxd56_lpm013m091a4ws_select(FAR struct lpm013m091a_lcd_s *lcd) static void cxd56_lpm013m091a4ws_deselect(FAR struct lpm013m091a_lcd_s *lcd) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; SPI_SELECT(priv->spi, SPIDEV_DISPLAY(0), false); SPI_LOCK(priv->spi, false); @@ -193,7 +196,8 @@ static int cxd56_lpm013m091a4ws_backlight(FAR struct lpm013m091a_lcd_s *lcd, static int cxd56_lpm013m091a4ws_sendcmd(FAR struct lpm013m091a_lcd_s *lcd, const uint8_t cmd) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; lcdinfo("%02x\n", cmd); @@ -229,7 +233,8 @@ static int cxd56_lpm013m091a4ws_sendcmd(FAR struct lpm013m091a_lcd_s *lcd, static int cxd56_lpm013m091a4ws_sendparam(FAR struct lpm013m091a_lcd_s *lcd, const uint8_t param) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; cxd56_gpio_write(DISPLAY_DC, true); /* Indicate DATA */ SPI_SEND(priv->spi, param); @@ -256,7 +261,8 @@ static int cxd56_lpm013m091a4ws_sendparam(FAR struct lpm013m091a_lcd_s *lcd, static int cxd56_lpm013m091a4ws_sendgram(FAR struct lpm013m091a_lcd_s *lcd, const uint16_t *wd, uint32_t nwords) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; lcdinfo("lcd:%p, wd=%p, nwords=%d\n", lcd, wd, nwords); @@ -284,7 +290,8 @@ static int cxd56_lpm013m091a4ws_sendgram(FAR struct lpm013m091a_lcd_s *lcd, static int cxd56_lpm013m091a4ws_recvparam(FAR struct lpm013m091a_lcd_s *lcd, uint8_t *param) { - FAR struct lpm013m091a_lcd_s *priv = (FAR struct lpm013m091a_lcd_s *)lcd; + FAR struct lpm013m091a4ws_lcd_s *priv + = (FAR struct lpm013m091a4ws_lcd_s *)lcd; cxd56_gpio_write(DISPLAY_DC, true); /* Indicate DATA */ *param = (uint8_t)(SPI_SEND(priv->spi, param) & 0xff); @@ -332,7 +339,7 @@ static int cxd56_lpm013m091a4ws_recvgram(FAR struct lpm013m091a_lcd_s *lcd, int board_lcd_initialize(void) { - FAR struct lpm013m091a_lcd_s *priv = &g_lcddev; + FAR struct lpm013m091a4ws_lcd_s *priv = &g_lcddev; FAR struct spi_dev_s *spi; #if defined(CONFIG_CXD56_DMAC) DMA_HANDLE hdl; diff --git a/boards/arm/cxd56xx/common/src/cxd56_sensors.c b/boards/arm/cxd56xx/common/src/cxd56_sensors.c index d625e5c871e..0308e9ed715 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_sensors.c +++ b/boards/arm/cxd56xx/common/src/cxd56_sensors.c @@ -192,7 +192,7 @@ struct sensor_device_s static struct sensor_device_s sensor_device[] = { #if defined(CONFIG_SENSORS_BMI160) || defined(CONFIG_SENSORS_BMI160_SCU) -# ifdef CONFIG_SENSORS_BMI160_I2C +# if defined(CONFIG_SENSORS_BMI160_I2C) || defined(CONFIG_SENSORS_BMI160_SCU_I2C) _I2C_DEVICE_WOPATH(bmi160), /* Accel + Gyro */ # else /* CONFIG_SENSORS_BMI160_SPI */ _SPI_DEVICE_WOPATH(bmi160), diff --git a/boards/arm/cxd56xx/common/src/cxd56_spidev.c b/boards/arm/cxd56xx/common/src/cxd56_spidev.c new file mode 100644 index 00000000000..012d62aae56 --- /dev/null +++ b/boards/arm/cxd56xx/common/src/cxd56_spidev.c @@ -0,0 +1,84 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_spidev.c + * + * Copyright 2020 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 + +#include +#include +#include +#include + +#include "cxd56_spi.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spidev_initialize + * + * Description: + * Initialize and register spi driver for the specified spi port + * + ****************************************************************************/ + +int board_spidev_initialize(int port) +{ + int ret; + FAR struct spi_dev_s *spi; + + _info("Initializing /dev/spi%d..\n", port); + + /* Initialize spi device */ + + spi = cxd56_spibus_initialize(port); + if (!spi) + { + _err("ERROR: Failed to initialize spi%d.\n", port); + return -ENODEV; + } + + ret = spi_register(spi, port); + if (ret < 0) + { + _err("ERROR: Failed to register spi%d: %d\n", port, ret); + } + + return ret; +} diff --git a/boards/arm/cxd56xx/common/src/cxd56_spisd.c b/boards/arm/cxd56xx/common/src/cxd56_spisd.c new file mode 100644 index 00000000000..31a075a06f2 --- /dev/null +++ b/boards/arm/cxd56xx/common/src/cxd56_spisd.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * boards/arm/cxd56xx/common/src/cxd56_spisd.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 + +#include +#include +#include +#include +#include "cxd56_spi.h" +#include "cxd56_gpio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +#ifndef CONFIG_CXD56_SPISD_SLOT_NO +# define CONFIG_CXD56_SPISD_SLOT_NO 0 +#endif + +/* Please configure the pin assignment for your board */ + +#ifndef MMCSD_DETECT +# define MMCSD_DETECT PIN_I2S0_DATA_OUT +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_spisd_initialize + * + * Description: + * Initialize the SPI-based SD card. + * + ****************************************************************************/ + +int board_spisd_initialize(int minor, int bus) +{ + int ret; + FAR struct spi_dev_s *spi; + + /* Enable input of detect pin */ + + cxd56_gpio_config(MMCSD_DETECT, true); + + /* Initialize spi deivce */ + + spi = cxd56_spibus_initialize(bus); + if (!spi) + { + ferr("ERROR: Failed to initialize spi%d.\n", bus); + return -ENODEV; + } + + /* Get the SPI driver instance for the SD chip select */ + + finfo("Initializing SPI for the MMC/SD slot\n"); + + ret = mmcsd_spislotinitialize(minor, CONFIG_CXD56_SPISD_SLOT_NO, spi); + if (ret < 0) + { + ferr("ERROR: Failed to bind SPI device to MMC/SD slot %d: %d\n", + CONFIG_CXD56_SPISD_SLOT_NO, ret); + return ret; + } + + /* Mount filesystem */ + + ret = mount("/dev/mmcsd0", "/mnt/sd0", "vfat", 0, NULL); + if (ret < 0) + { + _err("ERROR: Failed to mount the SDCARD. %d\n", errno); + } + + return OK; +} + +/**************************************************************************** + * Name: board_spisd_status + * + * Description: + * Get the status whether SD Card is present or not. + * This function is called only from cxd56_spi.c. + * + * Returned Value: + * Return SPI_STATUS_PRESENT if SD Card is present. Otherwise, return 0. + * + ****************************************************************************/ + +uint8_t board_spisd_status(FAR struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t ret = 0; + + if (devid == SPIDEV_MMCSD(0)) + { + /* MMCSD_DETECT is mapping to SD Card detect pin + * MMCSD_DETECT = 0: Inserted + * MMCSD_DETECT = 1: Removed + */ + + ret = cxd56_gpio_read(MMCSD_DETECT) ? 0 : SPI_STATUS_PRESENT; + } + + return ret; +} diff --git a/boards/arm/cxd56xx/drivers/audio/Make.defs b/boards/arm/cxd56xx/drivers/audio/Make.defs index 39f15d20e39..c3c553a0a3e 100644 --- a/boards/arm/cxd56xx/drivers/audio/Make.defs +++ b/boards/arm/cxd56xx/drivers/audio/Make.defs @@ -33,6 +33,10 @@ # ############################################################################ +ARCH_SRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(ARCH_SRCDIR)$(DELIM)chip) +CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(ARCH_SRCDIR)$(DELIM)common) + ifeq ($(CONFIG_CXD56_AUDIO),y) CSRCS += cxd56_audio.c CSRCS += cxd56_audio_config.c diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio.c b/boards/arm/cxd56xx/drivers/audio/cxd56_audio.c index 818f7783a52..f1ec5ae6b88 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio.c +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio.c @@ -1,4 +1,4 @@ -/*************************************************************************** +/**************************************************************************** * boards/arm/cxd56xx/drivers/audio/cxd56_audio.c * * Copyright 2018 Sony Semiconductor Solutions Corporation @@ -33,7 +33,7 @@ * ****************************************************************************/ -/*************************************************************************** +/**************************************************************************** * Included Files ****************************************************************************/ @@ -59,14 +59,14 @@ #include "cxd56_audio_ac_reg.h" #include "cxd56_audio_bca_reg.h" -/*************************************************************************** +/**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define AUDIO_DNC_ID_NUM (CXD56_AUDIO_DNC_ID_FF + 1) #define AUDIO_VOL_ID_NUM (CXD56_AUDIO_VOLID_MIXER_OUT + 1) -/*************************************************************************** +/**************************************************************************** * Private Types ****************************************************************************/ @@ -141,7 +141,7 @@ struct power_on_param_s struct data_path_s path; }; -/*************************************************************************** +/**************************************************************************** * Private Data ****************************************************************************/ @@ -219,11 +219,11 @@ static struct power_on_param_s g_pwon_param = } }; -/*************************************************************************** +/**************************************************************************** * Public Data ****************************************************************************/ -/*************************************************************************** +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -760,7 +760,8 @@ CXD56_AUDIO_ECODE cxd56_audio_unmute_vol(cxd56_audio_volid_t id) return ret; } -CXD56_AUDIO_ECODE cxd56_audio_mute_vol_fade(cxd56_audio_volid_t id, bool wait) +CXD56_AUDIO_ECODE cxd56_audio_mute_vol_fade(cxd56_audio_volid_t id, + bool wait) { CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK; @@ -1041,8 +1042,9 @@ CXD56_AUDIO_ECODE cxd56_audio_set_dmacb(cxd56_audio_dma_t handle, return ret; } -CXD56_AUDIO_ECODE cxd56_audio_get_dmamstate(cxd56_audio_dma_t handle, - FAR cxd56_audio_dma_mstate_t *state) +CXD56_AUDIO_ECODE +cxd56_audio_get_dmamstate(cxd56_audio_dma_t handle, + FAR cxd56_audio_dma_mstate_t *state) { CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK; diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c index b430c9c08fa..3f2b7589f7c 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c @@ -354,7 +354,7 @@ typedef enum * Public Function Prototypes ****************************************************************************/ -extern uint32_t as_aca_control(uint8_t type, uint32_t param); +extern uint32_t fw_as_acacontrol(uint8_t type, uint32_t param); /**************************************************************************** * Private Functions @@ -636,7 +636,7 @@ void get_pwon_out_param(as_aca_pulco_out_param_t *param) CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void) { - if (as_aca_control(AS_ACA_CHECK_ID, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_CHECK_ID, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_CHKID; } @@ -644,7 +644,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void) as_aca_pulco_param_t pwon_param; get_pwon_param(&pwon_param); - if (as_aca_control(AS_ACA_POWER_ON_COMMON, (uint32_t)&pwon_param) != 0) + if (fw_as_acacontrol(AS_ACA_POWER_ON_COMMON, (uint32_t)&pwon_param) != 0) { return CXD56_AUDIO_ECODE_ANA_PWON; } @@ -652,7 +652,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void) as_ser_des_param_t serial_param; get_serial_param(&serial_param); - if (as_aca_control(AS_ACA_SET_SERDES, (uint32_t)&serial_param) != 0) + if (fw_as_acacontrol(AS_ACA_SET_SERDES, (uint32_t)&serial_param) != 0) { return CXD56_AUDIO_ECODE_ANA_SERIAL; } @@ -662,7 +662,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void) CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff(void) { - if (as_aca_control(AS_ACA_POWER_OFF_COMMON, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_POWER_OFF_COMMON, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_PWOFF; } @@ -672,7 +672,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff(void) CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_micbias(void) { - if (as_aca_control(AS_ACA_POWER_ON_MICBIAS, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_POWER_ON_MICBIAS, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_PWON_MBIAS; } @@ -687,7 +687,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_input( get_input_param(&pwon_input_param, gain); - if (as_aca_control(AS_ACA_POWER_ON_INPUT, + if (fw_as_acacontrol(AS_ACA_POWER_ON_INPUT, (uint32_t)&pwon_input_param) != 0) { return CXD56_AUDIO_ECODE_ANA_PWON_INPUT; @@ -702,7 +702,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_set_smaster(void) get_smaster_param(&smaster_param); - if (as_aca_control(AS_ACA_SET_SMASTER, (uint32_t)&smaster_param) != 0) + if (fw_as_acacontrol(AS_ACA_SET_SMASTER, (uint32_t)&smaster_param) != 0) { return CXD56_AUDIO_ECODE_ANA_SET_SMASTER; } @@ -716,7 +716,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_output(void) get_pwon_out_param(&pwon_output_param); - if (as_aca_control(AS_ACA_POWER_ON_OUTPUT, + if (fw_as_acacontrol(AS_ACA_POWER_ON_OUTPUT, (uint32_t)&pwon_output_param) != 0) { return CXD56_AUDIO_ECODE_ANA_PWON_OUTPUT; @@ -727,7 +727,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_output(void) CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_input(void) { - if (as_aca_control(AS_ACA_POWER_OFF_INPUT, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_POWER_OFF_INPUT, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_PWOFF_INPUT; } @@ -737,7 +737,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_input(void) CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_output(void) { - if (as_aca_control(AS_ACA_POWER_OFF_OUTPUT, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_POWER_OFF_OUTPUT, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_PWOFF_OUTPUT; } @@ -747,7 +747,8 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_output(void) CXD56_AUDIO_ECODE cxd56_audio_aca_enable_output(void) { - if (as_aca_control(AS_ACA_SET_OUTPUT_DEVICE, (uint32_t)AS_OUT_DEV_SP) != 0) + if (fw_as_acacontrol(AS_ACA_SET_OUTPUT_DEVICE, + (uint32_t)AS_OUT_DEV_SP) != 0) { return CXD56_AUDIO_ECODE_ANA_ENABLE_OUTPUT; } @@ -757,7 +758,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_enable_output(void) CXD56_AUDIO_ECODE cxd56_audio_aca_disable_output(void) { - if (as_aca_control(AS_ACA_SET_OUTPUT_DEVICE, + if (fw_as_acacontrol(AS_ACA_SET_OUTPUT_DEVICE, (uint32_t)AS_OUT_DEV_OFF) != 0) { return CXD56_AUDIO_ECODE_ANA_DISABLE_OUTPUT; @@ -773,7 +774,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_set_micgain( get_input_param(&mic_gain_param, gain); - if (as_aca_control(AS_ACA_INIT_AMIC, (uint32_t)&mic_gain_param) != 0) + if (fw_as_acacontrol(AS_ACA_INIT_AMIC, (uint32_t)&mic_gain_param) != 0) { return CXD56_AUDIO_ECODE_ANA_SET_MICGAIN; } @@ -783,7 +784,7 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_set_micgain( CXD56_AUDIO_ECODE cxd56_audio_aca_notify_micbootdone(void) { - if (as_aca_control(AS_ACA_SET_AMIC_BOOT_DONE, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(AS_ACA_SET_AMIC_BOOT_DONE, (uint32_t)NULL) != 0) { return CXD56_AUDIO_ECODE_ANA_NOTIFY_MICBOOT; } @@ -793,12 +794,12 @@ CXD56_AUDIO_ECODE cxd56_audio_aca_notify_micbootdone(void) CXD56_AUDIO_ECODE cxd56_audio_aca_read_reg(as_aca_pulco_reg_param_t *param) { - as_aca_control(AS_ACA_GET_REGISTER, (uint32_t)param); + fw_as_acacontrol(AS_ACA_GET_REGISTER, (uint32_t)param); return CXD56_AUDIO_ECODE_OK; } CXD56_AUDIO_ECODE cxd56_audio_aca_write_reg(as_aca_pulco_reg_param_t *param) { - as_aca_control(AS_ACA_SET_REGISTER, (uint32_t)param); + fw_as_acacontrol(AS_ACA_SET_REGISTER, (uint32_t)param); return CXD56_AUDIO_ECODE_OK; } diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c index a0d5b9002d1..036a558971f 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c @@ -51,6 +51,7 @@ #include "cxd56_audio_config.h" #include "cxd56_audio_analog.h" #include "cxd56_audio_aca.h" +#include "cxd56_clock.h" /**************************************************************************** * Pre-processor Definitions @@ -58,14 +59,6 @@ #define AUD_MCLK_EXT (0u<<16) /* External XTAL */ -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -void cxd56_audio_clock_enable(uint32_t clk, uint32_t div); -void cxd56_audio_clock_disable(void); -bool cxd56_audio_clock_is_enabled(void); - /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c index 93945d3ed7d..8a0b377dbc1 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c @@ -649,7 +649,7 @@ bool cxd56_audio_bca_reg_is_dma_fifo_empty(cxd56_audio_dma_t handle) break; default: - reg_id = BCA_I2S2_OUT_RTF_TRG; + reg_id = BCA_I2S2_OUT_RTD_TRG; break; } @@ -878,7 +878,7 @@ void cxd56_audio_bca_reg_set_sample_no(cxd56_audio_dma_t handle, break; case CXD56_AUDIO_DMAC_I2S0_DOWN: - reg_id = BCA_I2S2_OUT_SAMPLE_NO; + reg_id = BCA_I2S1_OUT_SAMPLE_NO; break; default: @@ -902,11 +902,11 @@ void cxd56_audio_bca_reg_start_dma(cxd56_audio_dma_t handle, break; case CXD56_AUDIO_DMAC_I2S0_DOWN: - reg_id = BCA_I2S1_OUT_RTF_TRG; + reg_id = BCA_I2S1_OUT_RTD_TRG; break; default: - reg_id = BCA_I2S2_OUT_RTF_TRG; + reg_id = BCA_I2S2_OUT_RTD_TRG; break; } @@ -924,11 +924,11 @@ void cxd56_audio_bca_reg_stop_dma(cxd56_audio_dma_t handle) break; case CXD56_AUDIO_DMAC_I2S0_DOWN: - reg_id = BCA_I2S1_OUT_RTF_TRG; + reg_id = BCA_I2S1_OUT_RTD_TRG; break; default: - reg_id = BCA_I2S2_OUT_RTF_TRG; + reg_id = BCA_I2S2_OUT_RTD_TRG; break; } @@ -1152,11 +1152,11 @@ uint32_t cxd56_audio_bca_reg_get_dma_state(cxd56_audio_dma_t handle) break; case CXD56_AUDIO_DMAC_I2S0_DOWN: - reg_id = BCA_I2S1_OUT_RTF_TRG; + reg_id = BCA_I2S1_OUT_RTD_TRG; break; default: - reg_id = BCA_I2S2_OUT_RTF_TRG; + reg_id = BCA_I2S2_OUT_RTD_TRG; break; } diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h old mode 100644 new mode 100755 index 6eb26c16e9d..55bbcc28a4a --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h @@ -111,7 +111,7 @@ typedef enum BCA_I2S2_IN_MON_MONBUF, BCA_I2S1_OUT_START_ADR, BCA_I2S1_OUT_SAMPLE_NO, - BCA_I2S1_OUT_RTF_TRG, + BCA_I2S1_OUT_RTD_TRG, BCA_I2S1_OUT_NOINTR, BCA_I2S1_OUT_BITWT, BCA_I2S1_OUT_SD1_R_SEL, @@ -121,7 +121,7 @@ typedef enum BCA_I2S1_OUT_MON_MONBUF, BCA_I2S2_OUT_START_ADR, BCA_I2S2_OUT_SAMPLE_NO, - BCA_I2S2_OUT_RTF_TRG, + BCA_I2S2_OUT_RTD_TRG, BCA_I2S2_OUT_NOINTR, BCA_I2S2_OUT_BITWT, BCA_I2S2_OUT_SD1_R_SEL, diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h index 258b8f1f2d4..6122ecef1fa 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h @@ -78,5 +78,6 @@ CXD56_AUDIO_ECODE cxd56_audio_dma_start(cxd56_audio_dma_t handle, uint32_t addr, uint32_t sample); CXD56_AUDIO_ECODE cxd56_audio_dma_stop(cxd56_audio_dma_t handle); +void cxd56_audio_dma_int_handler(void); #endif /* __BOARDS_ARM_CXD56XX_DRIVERS_AUDIO_CXD56_AUDIO_DMA_H */ diff --git a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c index 0e424f5fc4b..44788f9ab5f 100644 --- a/boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c +++ b/boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c @@ -42,12 +42,7 @@ #include #include "cxd56_audio_irq.h" - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -extern void cxd56_audio_dma_int_handler(void); +#include "cxd56_audio_dma.h" /**************************************************************************** * Public Functions diff --git a/boards/arm/cxd56xx/drivers/sensors/Kconfig b/boards/arm/cxd56xx/drivers/sensors/Kconfig index 1f075368dd2..26aa52e46c6 100644 --- a/boards/arm/cxd56xx/drivers/sensors/Kconfig +++ b/boards/arm/cxd56xx/drivers/sensors/Kconfig @@ -11,17 +11,23 @@ if SCU_SENSORS config SENSORS_AK09912_SCU bool "Asahi AK09911/AK09912 Compass Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on !SENSORS_AK09912 && (CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ) ---help--- Enable driver for AK09911/AK09912 Compass sensor. NOTE: This sensor is connected to the SCU unit +if SENSORS_AK09912_SCU + +config SENSORS_AK09912_SCU_DECI + bool "AK09912 Magnetometer to decimator" + default n + +endif + config SENSORS_APDS9930_SCU bool "Avago APDS9930 Proximity and Ambient light Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for APDS9930 proximity and ambient light sensor. @@ -29,7 +35,7 @@ if SENSORS_APDS9930_SCU config SENSORS_APDS9930_PROXIMITY_INTERRUPT bool "Use Proximity interrupt" - default y + default n ---help--- Use Interrupt when the threshold is exceeded. In this case, SCU sequencer is not used. @@ -39,32 +45,28 @@ endif config SENSORS_BH1721FVC_SCU bool "Rohm BH1721FVC Ambient Light Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for the Rohm BH1721FVC light sensor. config SENSORS_BH1745NUC_SCU bool "Rohm BH1745NUC Color Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for BH1745NUC color sensor. config SENSORS_BM1383GLV_SCU bool "Rohm BM1383GLV/BM1383AGLV Pressure Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for BM1383GLV/BM1383AGLV pressure sensor. config SENSORS_BM1422GMV_SCU bool "Rohm BM1422GMV/BM1422AGMV Magnetic Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for BM1422GMV/BM1422AGMV magnetic sensor. @@ -81,12 +83,17 @@ config BM1422GMV_SLAVE_ADDRESS_0F bool "0x0F" endchoice + +config SENSORS_BM1422GMV_SCU_DECI + bool "BM1422GMV Magnetometer to decimator" + default n + endif # SENSORS_BM1422GMV_SCU config SENSORS_BMI160_SCU bool "Bosch BMI160 Sensor support" default n - select CXD56_SCU + depends on !SENSORS_BMI160 && (CXD56_SPI3_SCUSEQ || CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ) ---help--- Enable driver support for the Bosch BMI160 sensor. @@ -98,32 +105,51 @@ choice config SENSORS_BMI160_SCU_SPI bool "BMI160 SPI Interface" - select CXD56_SPI + depends on CXD56_SPI3_SCUSEQ ---help--- Enables support for the SPI interface. config SENSORS_BMI160_SCU_I2C bool "BMI160 I2C Interface" - select CXD56_I2C + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enables support for the I2C interface endchoice -endif # CONFIG_SENSORS_BMI160_SCU + +config SENSORS_BMI160_SCU_DECI_GYRO + bool "BMI160 Gyroscope to decimator" + default n + +config SENSORS_BMI160_SCU_DECI_ACCEL + bool "BMI160 Accelerometer to decimator" + default n + +endif # SENSORS_BMI160_SCU config SENSORS_BMP280_SCU bool "Bosch BMP280 Barometic Pressure Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on !SENSORS_BMP280 && (CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ) ---help--- Enable driver for the Bosch BMP280 barometic pressure sensor. +if SENSORS_BMP280_SCU + +config SENSORS_BMP280_SCU_DECI_PRESS + bool "BMP280 Pressure to decimator" + default n + +config SENSORS_BMP280_SCU_DECI_TEMP + bool "BMI280 Temperature to decimator" + default n + +endif + config SENSORS_KX022_SCU bool "Kionix KX022/KX122 Acceleration Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for the Kionix KX022/KX122 acceleration sensor. @@ -135,13 +161,16 @@ config SENSORS_KX122 ---help--- Use KX122 which has the register upper compatibility with KX022. +config SENSORS_KX022_SCU_DECI + bool "KX022 Accelerometer to decimator" + default n + endif # SENSORS_KX022 config SENSORS_LT1PA01_SCU bool "Murata LT1PA01 Proximity and Ambient light Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for LT1PA01 proximity and ambient light sensor. @@ -149,7 +178,7 @@ if SENSORS_LT1PA01_SCU config LT1PA01_PROXIMITY_INTERRUPT bool "Use Proximity interrupt" - default y + default n ---help--- Use Interrupt when the threshold is exceeded. In this case, SCU sequencer is not used. @@ -159,8 +188,7 @@ endif # SENSORS_LT1PA01_SCU config SENSORS_RPR0521RS_SCU bool "Rohm RPR0521RS Proximity and Ambient light Sensor" default n - select CXD56_I2C - select CXD56_SCU + depends on CXD56_I2C0_SCUSEQ || CXD56_I2C1_SCUSEQ ---help--- Enable driver for RPR0521RS proximity and ambient light sensor. @@ -168,7 +196,7 @@ if SENSORS_RPR0521RS_SCU config RPR0521RS_PROXIMITY_INTERRUPT bool "Use Proximity interrupt" - default y + default n ---help--- Use Interrupt when the threshold is exceeded. In this case, SCU sequencer is not used. diff --git a/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c b/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c index 25fba7fb9c3..c7841955913 100644 --- a/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/ak09912_scu.c @@ -58,7 +58,7 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_CXD56_DECI_AK09912 +#ifdef CONFIG_SENSORS_AK09912_SCU_DECI # define MAG_SEQ_TYPE SEQ_TYPE_DECI #else # define MAG_SEQ_TYPE SEQ_TYPE_NORMAL diff --git a/boards/arm/cxd56xx/drivers/sensors/bm1383glv_scu.c b/boards/arm/cxd56xx/drivers/sensors/bm1383glv_scu.c index a679a836481..0d775d268b3 100644 --- a/boards/arm/cxd56xx/drivers/sensors/bm1383glv_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/bm1383glv_scu.c @@ -124,9 +124,10 @@ static int bm1383glv_open(FAR struct file *filep); static int bm1383glv_close(FAR struct file *filep); static ssize_t bm1383glv_read(FAR struct file *filep, FAR char *buffer, size_t buflen); -static ssize_t bm1383glv_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); -static int bm1383glv_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static ssize_t bm1383glv_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen); +static int bm1383glv_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); /**************************************************************************** * Private Data @@ -298,8 +299,8 @@ static int bm1383glv_seqinit(FAR struct bm1383glv_dev_s *priv) } seq_setinstruction(priv->seq, inst, nr); - seq_setsample(priv->seq, BM1383GLV_BYTESPERSAMPLE, 0, BM1383GLV_ELEMENTSIZE, - false); + seq_setsample(priv->seq, BM1383GLV_BYTESPERSAMPLE, 0, + BM1383GLV_ELEMENTSIZE, false); return OK; } @@ -330,7 +331,8 @@ static int bm1383glv_open(FAR struct file *filep) /* goto reset mode */ - bm1383glv_putreg8(priv, BM1383GLV_POWER_DOWN, BM1383GLV_POWER_DOWN_PWR_DOWN); + bm1383glv_putreg8(priv, BM1383GLV_POWER_DOWN, + BM1383GLV_POWER_DOWN_PWR_DOWN); up_mdelay(1); /* goto stand-by mode */ @@ -428,8 +430,8 @@ static ssize_t bm1383glv_read(FAR struct file *filep, FAR char *buffer, * Name: bm1383glv_write ****************************************************************************/ -static ssize_t bm1383glv_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) +static ssize_t bm1383glv_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen) { return -ENOSYS; } @@ -438,7 +440,8 @@ static ssize_t bm1383glv_write(FAR struct file *filep, FAR const char *buffer, * Name: bm1383glv_ioctl ****************************************************************************/ -static int bm1383glv_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int bm1383glv_ioctl(FAR struct file *filep, int cmd, + unsigned long arg) { FAR struct inode *inode = filep->f_inode; FAR struct bm1383glv_dev_s *priv = inode->i_private; diff --git a/boards/arm/cxd56xx/drivers/sensors/bm1422gmv_scu.c b/boards/arm/cxd56xx/drivers/sensors/bm1422gmv_scu.c index 157c3994bcb..d4355d9c7d2 100644 --- a/boards/arm/cxd56xx/drivers/sensors/bm1422gmv_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/bm1422gmv_scu.c @@ -58,7 +58,7 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_CXD56_DECI_BM1422GMV +#ifdef CONFIG_SENSORS_BM1422GMV_SCU_DECI # define BM1422GMV_SEQ_TYPE SEQ_TYPE_DECI #else # define BM1422GMV_SEQ_TYPE SEQ_TYPE_NORMAL @@ -138,9 +138,10 @@ static int bm1422gmv_open(FAR struct file *filep); static int bm1422gmv_close(FAR struct file *filep); static ssize_t bm1422gmv_read(FAR struct file *filep, FAR char *buffer, size_t buflen); -static ssize_t bm1422gmv_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); -static int bm1422gmv_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +static ssize_t bm1422gmv_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen); +static int bm1422gmv_ioctl(FAR struct file *filep, int cmd, + unsigned long arg); /**************************************************************************** * Private Data @@ -301,8 +302,8 @@ static int bm1422gmv_seqinit(FAR struct bm1422gmv_dev_s *priv) /* Set instruction and sample data information to sequencer */ seq_setinstruction(priv->seq, g_bm1422gmvinst, itemsof(g_bm1422gmvinst)); - seq_setsample(priv->seq, BM1422GMV_BYTESPERSAMPLE, 0, BM1422GMV_ELEMENTSIZE, - false); + seq_setsample(priv->seq, BM1422GMV_BYTESPERSAMPLE, 0, + BM1422GMV_ELEMENTSIZE, false); return OK; } @@ -413,8 +414,8 @@ static ssize_t bm1422gmv_read(FAR struct file *filep, FAR char *buffer, * Name: bm1422gmv_write ****************************************************************************/ -static ssize_t bm1422gmv_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) +static ssize_t bm1422gmv_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen) { return -ENOSYS; } @@ -423,7 +424,8 @@ static ssize_t bm1422gmv_write(FAR struct file *filep, FAR const char *buffer, * Name: bm1422gmv_ioctl ****************************************************************************/ -static int bm1422gmv_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int bm1422gmv_ioctl(FAR struct file *filep, int cmd, + unsigned long arg) { FAR struct inode *inode = filep->f_inode; FAR struct bm1422gmv_dev_s *priv = inode->i_private; diff --git a/boards/arm/cxd56xx/drivers/sensors/bmi160_scu.c b/boards/arm/cxd56xx/drivers/sensors/bmi160_scu.c index 8f4c1e1da92..8abc4a0d62d 100644 --- a/boards/arm/cxd56xx/drivers/sensors/bmi160_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/bmi160_scu.c @@ -58,17 +58,13 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_SENSORS_BMI160_SCU_I2C -#define CONFIG_SENSORS_BMI160_I2C -#endif - -#ifdef CONFIG_CXD56_DECI_GYRO +#ifdef CONFIG_SENSORS_BMI160_SCU_DECI_GYRO # define GYRO_SEQ_TYPE SEQ_TYPE_DECI #else # define GYRO_SEQ_TYPE SEQ_TYPE_NORMAL #endif -#ifdef CONFIG_CXD56_DECI_ACCEL +#ifdef CONFIG_SENSORS_BMI160_SCU_DECI_ACCEL # define ACCEL_SEQ_TYPE SEQ_TYPE_DECI #else # define ACCEL_SEQ_TYPE SEQ_TYPE_NORMAL @@ -247,7 +243,7 @@ uint32_t g_pmu_stat; struct bmi160_dev_s { -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C FAR struct i2c_master_s *i2c; /* I2C interface */ uint8_t addr; /* BMP280 I2C address */ int freq; /* BMP280 Frequency <= 3.4MHz */ @@ -255,7 +251,7 @@ struct bmi160_dev_s FAR struct seq_s *seq; /* Sequencer */ int fifoid; /* Sequencer id */ -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ FAR struct spi_dev_s *spi; /* SPI interface */ FAR struct seq_s *seq; /* Sequencer */ int fifoid; /* Sequencer id */ @@ -285,13 +281,13 @@ static int bmi160_ioctl(FAR struct file *filep, int cmd, static int bmi160_checkid(FAR struct bmi160_dev_s *priv); -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C static int bmi160_devregister(FAR const char *devpath, FAR struct i2c_master_s *dev, int minor, const struct file_operations *fops, int port); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ static int bmi160_devregister(FAR const char *devpath, FAR struct spi_dev_s *dev, int minor, @@ -369,9 +365,9 @@ static uint8_t bmi160_getreg8(FAR struct bmi160_dev_s *priv, uint8_t regaddr) inst[0] = SCU_INST_SEND(regaddr | 0x80); inst[1] = SCU_INST_RECV(1) | SCU_INST_LAST; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C scu_i2ctransfer(priv->port, priv->addr, inst, 2, ®val, 1); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ scu_spitransfer(0, inst, 2, ®val, 1); #endif @@ -408,9 +404,9 @@ static uint8_t bmi160_getregs(FAR struct bmi160_dev_s *priv, ilen = 2; } -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C scu_i2ctransfer(priv->port, priv->addr, inst, ilen, buffer, len); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ scu_spitransfer(0, inst, ilen, buffer, len); #endif return OK; @@ -435,9 +431,9 @@ static void bmi160_putreg8(FAR struct bmi160_dev_s *priv, inst[0] = SCU_INST_SEND(regaddr); inst[1] = SCU_INST_SEND(regval) | SCU_INST_LAST; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C scu_i2ctransfer(priv->port, priv->addr, inst, 2, NULL, 0); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ scu_spitransfer(0, inst, 2, NULL, 0); #endif } @@ -471,10 +467,10 @@ static int bmi160_seqinit_gyro(FAR struct bmi160_dev_s *priv) /* Open sequencer */ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C g_seq_gyro = seq_open(GYRO_SEQ_TYPE, (priv->port == 0) ? SCU_BUS_I2C0 : SCU_BUS_I2C1); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ g_seq_gyro = seq_open(GYRO_SEQ_TYPE, SCU_BUS_SPI); #endif if (!g_seq_gyro) @@ -484,9 +480,9 @@ static int bmi160_seqinit_gyro(FAR struct bmi160_dev_s *priv) priv->seq = g_seq_gyro; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C seq_setaddress(priv->seq, priv->addr); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ seq_setaddress(priv->seq, 0); #endif @@ -510,10 +506,10 @@ static int bmi160_seqinit_accel(FAR struct bmi160_dev_s *priv) /* Open sequencer */ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C g_seq_accel = seq_open(ACCEL_SEQ_TYPE, (priv->port == 0) ? SCU_BUS_I2C0 : SCU_BUS_I2C1); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ g_seq_accel = seq_open(ACCEL_SEQ_TYPE, SCU_BUS_SPI); #endif if (!g_seq_accel) @@ -523,9 +519,9 @@ static int bmi160_seqinit_accel(FAR struct bmi160_dev_s *priv) priv->seq = g_seq_accel; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C seq_setaddress(priv->seq, priv->addr); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ seq_setaddress(priv->seq, 0); #endif @@ -805,13 +801,13 @@ static int bmi160_checkid(FAR struct bmi160_dev_s *priv) * ****************************************************************************/ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C static int bmi160_devregister(FAR const char *devpath, FAR struct i2c_master_s *dev, int minor, const struct file_operations *fops, int port) -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ static int bmi160_devregister(FAR const char *devpath, FAR struct spi_dev_s *dev, int minor, @@ -829,7 +825,7 @@ static int bmi160_devregister(FAR const char *devpath, return -ENOMEM; } -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C priv->i2c = dev; priv->seq = NULL; priv->fifoid = minor; @@ -837,7 +833,7 @@ static int bmi160_devregister(FAR const char *devpath, priv->freq = BMI160_I2C_FREQ; priv->port = port; -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ priv->spi = dev; priv->seq = NULL; priv->fifoid = minor; @@ -1001,9 +997,9 @@ static int bmi160_set_accel_odr(FAR struct bmi160_dev_s *priv, int odr) * ****************************************************************************/ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C int bmi160_init(FAR struct i2c_master_s *dev, int port) -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ int bmi160_init(FAR struct spi_dev_s *dev) #endif { @@ -1011,7 +1007,7 @@ int bmi160_init(FAR struct spi_dev_s *dev) struct bmi160_dev_s *priv = &tmp; int ret; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C /* Setup temporary device structure for initialization */ priv->i2c = dev; @@ -1019,7 +1015,7 @@ int bmi160_init(FAR struct spi_dev_s *dev) priv->freq = BMI160_I2C_FREQ; priv->port = port; -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ /* Configure SPI for the BMI160 */ SPI_SETMODE(dev, SPIDEV_MODE3); @@ -1065,19 +1061,19 @@ int bmi160_init(FAR struct spi_dev_s *dev) * ****************************************************************************/ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C int bmi160gyro_register(FAR const char *devpath, int minor, FAR struct i2c_master_s *dev, int port) -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ int bmi160gyro_register(FAR const char *devpath, int minor, FAR struct spi_dev_s *dev) #endif { int ret; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C ret = bmi160_devregister(devpath, dev, minor, &g_bmi160gyrofops, port); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ ret = bmi160_devregister(devpath, dev, minor, &g_bmi160gyrofops); #endif if (ret < 0) @@ -1105,19 +1101,19 @@ int bmi160gyro_register(FAR const char *devpath, int minor, * ****************************************************************************/ -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C int bmi160accel_register(FAR const char *devpath, int minor, FAR struct i2c_master_s *dev, int port) -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ int bmi160accel_register(FAR const char *devpath, int minor, FAR struct spi_dev_s *dev) #endif { int ret; -#ifdef CONFIG_SENSORS_BMI160_I2C +#ifdef CONFIG_SENSORS_BMI160_SCU_I2C ret = bmi160_devregister(devpath, dev, minor, &g_bmi160accelfops, port); -#else /* CONFIG_SENSORS_BMI160_SPI */ +#else /* CONFIG_SENSORS_BMI160_SCU_SPI */ ret = bmi160_devregister(devpath, dev, minor, &g_bmi160accelfops); #endif if (ret < 0) diff --git a/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c b/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c index 3861e0eaaf3..956e279dd99 100644 --- a/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/bmp280_scu.c @@ -51,18 +51,18 @@ #include #include -#if defined(CONFIG_I2C) && defined(CONFIG_BMP280_SCU) +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP280_SCU) /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_CXD56_DECI_PRESS +#ifdef CONFIG_SENSORS_BMI280_SCU_DECI_PRESS # define PRESS_SEQ_TYPE SEQ_TYPE_DECI #else # define PRESS_SEQ_TYPE SEQ_TYPE_NORMAL #endif -#ifdef CONFIG_CXD56_DECI_TEMP +#ifdef CONFIG_SENSORS_BMI280_SCU_DECI_TEMP # define TEMP_SEQ_TYPE SEQ_TYPE_DECI #else # define TEMP_SEQ_TYPE SEQ_TYPE_NORMAL @@ -883,7 +883,7 @@ static int bmp280_ioctl_temp(FAR struct file *filep, int cmd, int bmp280_init(FAR struct i2c_master_s *i2c, int port) { struct bmp280_dev_s tmp; - struct *priv = &tmp; + struct bmp280_dev_s *priv = &tmp; int ret; /* Setup temporary device structure for initialization */ diff --git a/boards/arm/cxd56xx/drivers/sensors/kx022_scu.c b/boards/arm/cxd56xx/drivers/sensors/kx022_scu.c index 0ed5a7ffa13..c7c75c8850a 100644 --- a/boards/arm/cxd56xx/drivers/sensors/kx022_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/kx022_scu.c @@ -58,7 +58,7 @@ * Pre-processor Definitions ****************************************************************************/ -#ifdef CONFIG_CXD56_DECI_KX022 +#ifdef CONFIG_SENSORS_KX022_SCU_DECI # define KX022_SEQ_TYPE SEQ_TYPE_DECI #else # define KX022_SEQ_TYPE SEQ_TYPE_NORMAL diff --git a/boards/arm/cxd56xx/drivers/sensors/rpr0521rs_scu.c b/boards/arm/cxd56xx/drivers/sensors/rpr0521rs_scu.c index fe23bd10a4c..c1dfac37868 100644 --- a/boards/arm/cxd56xx/drivers/sensors/rpr0521rs_scu.c +++ b/boards/arm/cxd56xx/drivers/sensors/rpr0521rs_scu.c @@ -52,7 +52,7 @@ #include #include -#if defined(CONFIG_I2C) && defined(CONFIG_RPR0521RS) && defined(CONFIG_CXD56_SCU) +#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_RPR0521RS_SCU) /**************************************************************************** * Pre-processor Definitions diff --git a/boards/arm/cxd56xx/spresense/Kconfig b/boards/arm/cxd56xx/spresense/Kconfig index 380bf852b0a..f2507a5659e 100644 --- a/boards/arm/cxd56xx/spresense/Kconfig +++ b/boards/arm/cxd56xx/spresense/Kconfig @@ -5,6 +5,19 @@ if ARCH_BOARD_SPRESENSE +config BOARD_CUSTOM_PINCONFIG + bool + default y + +config BOARD_USB_DISABLE_IN_DEEP_SLEEPING + bool + default y + ---help--- + Due to the system specification, it's impossible to enter the deep + sleeping mode for the power saving as long as USB is attached. As + the workaround for this restriction, this configuration forces to be + disable the USB function in deep sleeping. + config CXD56_SPIFLASHSIZE hex default 0x400000 @@ -505,43 +518,43 @@ endif comment "LTE Options" menuconfig CXD56_LTE - bool "LTE" - default n + bool "LTE" + default n if CXD56_LTE choice - prompt "LTE SPI selection" - default CXD56_LTE_SPI4 + prompt "LTE SPI selection" + default CXD56_LTE_SPI4 config CXD56_LTE_SPI4 - bool "Use SPI4" - select CXD56_SPI4 + bool "Use SPI4" + select CXD56_SPI4 config CXD56_LTE_SPI5 - bool "Use SPI5" - select CXD56_SPI5 + bool "Use SPI5" + select CXD56_SPI5 endchoice if CXD56_LTE_SPI4 config CXD56_LTE_SPI4_DMAC - bool "Use DMAC for SPI4" - default y - select CXD56_DMAC_SPI4_TX - select CXD56_DMAC_SPI4_RX + bool "Use DMAC for SPI4" + default y + select CXD56_DMAC_SPI4_TX + select CXD56_DMAC_SPI4_RX endif # CXD56_LTE_SPI4 if CXD56_LTE_SPI5 config CXD56_LTE_SPI5_DMAC - bool "Use DMAC for SPI5" - default y - select CXD56_DMAC_SPI5_TX - select CXD56_DMAC_SPI5_RX + bool "Use DMAC for SPI5" + default y + select CXD56_DMAC_SPI5_TX + select CXD56_DMAC_SPI5_RX -endif # CXD56_LTE_SPI4 +endif # CXD56_LTE_SPI5 endif # CXD56_LTE diff --git a/boards/arm/cxd56xx/spresense/configs/audio/defconfig b/boards/arm/cxd56xx/spresense/configs/audio/defconfig index 33ebcf59216..93bfa4ce460 100644 --- a/boards/arm/cxd56xx/spresense/configs/audio/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/audio/defconfig @@ -43,7 +43,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 @@ -69,6 +68,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/audio_sdk/defconfig b/boards/arm/cxd56xx/spresense/configs/audio_sdk/defconfig index ccad7cfab3e..fe7cb712b1d 100644 --- a/boards/arm/cxd56xx/spresense/configs/audio_sdk/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/audio_sdk/defconfig @@ -26,7 +26,6 @@ CONFIG_CXD56_AUDIO=y CONFIG_CXD56_BINARY=y CONFIG_CXD56_I2C0=y CONFIG_CXD56_I2C=y -CONFIG_CXD56_SDIO=y CONFIG_CXD56_SPI4=y CONFIG_CXD56_SPI5=y CONFIG_CXD56_SPI=y @@ -42,7 +41,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_LIBM=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 @@ -68,6 +66,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/camera/defconfig b/boards/arm/cxd56xx/spresense/configs/camera/defconfig index d7bc922597e..bfa5183405f 100644 --- a/boards/arm/cxd56xx/spresense/configs/camera/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/camera/defconfig @@ -67,6 +67,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/elf/defconfig b/boards/arm/cxd56xx/spresense/configs/elf/defconfig index 66bb6f9c567..215c9346b63 100644 --- a/boards/arm/cxd56xx/spresense/configs/elf/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/elf/defconfig @@ -30,7 +30,6 @@ CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y -CONFIG_I2C=y CONFIG_LIB_BOARDCTL=y CONFIG_LIB_ENVPATH=y CONFIG_MAX_TASKS=16 diff --git a/boards/arm/cxd56xx/spresense/configs/example_camera/defconfig b/boards/arm/cxd56xx/spresense/configs/example_camera/defconfig index 78d2ebbd238..2f00b498760 100644 --- a/boards/arm/cxd56xx/spresense/configs/example_camera/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/example_camera/defconfig @@ -26,7 +26,6 @@ CONFIG_CXD56_CISIF=y CONFIG_CXD56_I2C0=y CONFIG_CXD56_I2C2=y CONFIG_CXD56_I2C=y -CONFIG_CXD56_SDIO=y CONFIG_CXD56_SPI4=y CONFIG_CXD56_SPI5=y CONFIG_CXD56_SPI=y @@ -68,6 +67,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/example_lcd/defconfig b/boards/arm/cxd56xx/spresense/configs/example_lcd/defconfig index 07ed23ae155..4434054cc20 100644 --- a/boards/arm/cxd56xx/spresense/configs/example_lcd/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/example_lcd/defconfig @@ -55,7 +55,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_LCD=y CONFIG_LCD_ILI9340=y CONFIG_LCD_ILI9340_IFACE0=y @@ -87,6 +86,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/lcd/defconfig b/boards/arm/cxd56xx/spresense/configs/lcd/defconfig index 1d763bd041e..33bf728c0fa 100644 --- a/boards/arm/cxd56xx/spresense/configs/lcd/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/lcd/defconfig @@ -46,7 +46,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_LCD=y CONFIG_LCD_ILI9340=y CONFIG_LCD_ILI9340_IFACE0=y @@ -75,6 +74,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/lte/defconfig b/boards/arm/cxd56xx/spresense/configs/lte/defconfig index 2336d75283a..dc815b40291 100644 --- a/boards/arm/cxd56xx/spresense/configs/lte/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/lte/defconfig @@ -40,7 +40,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MMCSD=y @@ -67,6 +66,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/module/defconfig b/boards/arm/cxd56xx/spresense/configs/module/defconfig index a03b4a85500..f5616ad5aaa 100644 --- a/boards/arm/cxd56xx/spresense/configs/module/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/module/defconfig @@ -30,7 +30,6 @@ CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y -CONFIG_I2C=y CONFIG_LIBC_EXECFUNCS=y CONFIG_LIB_BOARDCTL=y CONFIG_LIB_ENVPATH=y diff --git a/boards/arm/cxd56xx/spresense/configs/mpy/defconfig b/boards/arm/cxd56xx/spresense/configs/mpy/defconfig index b4cf63c7d73..314ff225ae6 100644 --- a/boards/arm/cxd56xx/spresense/configs/mpy/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/mpy/defconfig @@ -52,7 +52,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MMCSD=y @@ -77,6 +76,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/nsh/defconfig b/boards/arm/cxd56xx/spresense/configs/nsh/defconfig index 50a56261241..184fcffb2bc 100644 --- a/boards/arm/cxd56xx/spresense/configs/nsh/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/nsh/defconfig @@ -30,7 +30,6 @@ CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_NFILE_DESCRIPTORS=8 diff --git a/boards/arm/cxd56xx/spresense/configs/posix_spawn/defconfig b/boards/arm/cxd56xx/spresense/configs/posix_spawn/defconfig index 9a66417acb7..bc6223bbc0f 100644 --- a/boards/arm/cxd56xx/spresense/configs/posix_spawn/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/posix_spawn/defconfig @@ -34,7 +34,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_ROMFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_LIBC_EXECFUNCS=y CONFIG_LIB_BOARDCTL=y CONFIG_LIB_ENVPATH=y diff --git a/boards/arm/cxd56xx/spresense/configs/rndis/defconfig b/boards/arm/cxd56xx/spresense/configs/rndis/defconfig index 9a3636f947a..f19d3d10d0e 100644 --- a/boards/arm/cxd56xx/spresense/configs/rndis/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/rndis/defconfig @@ -114,6 +114,7 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RNDIS=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y +CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y diff --git a/boards/arm/cxd56xx/spresense/configs/smp/defconfig b/boards/arm/cxd56xx/spresense/configs/smp/defconfig index be55e31bce2..9c08da650ea 100644 --- a/boards/arm/cxd56xx/spresense/configs/smp/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/smp/defconfig @@ -31,7 +31,6 @@ CONFIG_FS_PROCFS=y CONFIG_FS_PROCFS_REGISTER=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_NFILE_DESCRIPTORS=8 diff --git a/boards/arm/cxd56xx/spresense/configs/usbmsc/defconfig b/boards/arm/cxd56xx/spresense/configs/usbmsc/defconfig index ea19120b532..2f42b1311d4 100644 --- a/boards/arm/cxd56xx/spresense/configs/usbmsc/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/usbmsc/defconfig @@ -47,7 +47,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MMCSD=y @@ -72,6 +71,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/usbnsh/defconfig b/boards/arm/cxd56xx/spresense/configs/usbnsh/defconfig index 85e8dca76ef..d7135f79c90 100644 --- a/boards/arm/cxd56xx/spresense/configs/usbnsh/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/usbnsh/defconfig @@ -40,7 +40,6 @@ CONFIG_FS_PROCFS_REGISTER=y CONFIG_FS_SMARTFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y -CONFIG_I2C=y CONFIG_MAX_TASKS=16 CONFIG_MAX_WDOGPARMS=2 CONFIG_MMCSD=y @@ -65,6 +64,8 @@ CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y CONFIG_RTC_DRIVER=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y CONFIG_SMARTFS_ALIGNED_ACCESS=y diff --git a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig index 6a850b738f5..e25ebea062e 100644 --- a/boards/arm/cxd56xx/spresense/configs/wifi/defconfig +++ b/boards/arm/cxd56xx/spresense/configs/wifi/defconfig @@ -41,7 +41,6 @@ CONFIG_EXAMPLES_FTPC=y CONFIG_EXAMPLES_FTPD=y CONFIG_EXAMPLES_HELLO=m CONFIG_EXAMPLES_TCPBLASTER=y -CONFIG_EXAMPLES_TCPBLASTER_GROUPSIZE=500 CONFIG_EXAMPLES_TCPBLASTER_SENDSIZE=1400 CONFIG_EXAMPLES_TCPBLASTER_SERVER=y CONFIG_EXAMPLES_TCPBLASTER_SERVERIP=0xc0a80a10 @@ -115,6 +114,7 @@ CONFIG_RAM_START=0x0d000000 CONFIG_READLINE_CMD_HISTORY=y CONFIG_RR_INTERVAL=200 CONFIG_RTC=y +CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORKPRIORITY=60 CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y diff --git a/boards/arm/cxd56xx/spresense/include/board.h b/boards/arm/cxd56xx/spresense/include/board.h index 26fa4507496..5364e161bf8 100644 --- a/boards/arm/cxd56xx/spresense/include/board.h +++ b/boards/arm/cxd56xx/spresense/include/board.h @@ -52,6 +52,7 @@ #include "cxd56_charger.h" #include "cxd56_gs2200m.h" #include "cxd56_i2cdev.h" +#include "cxd56_spidev.h" #include "cxd56_sdcard.h" #include "cxd56_wdt.h" #include "cxd56_gpioif.h" @@ -61,12 +62,15 @@ #include "cxd56_ak09912.h" #include "cxd56_apds9930.h" #include "cxd56_apds9960.h" +#include "cxd56_bcm20706.h" #include "cxd56_bh1721fvc.h" #include "cxd56_bh1745nuc.h" #include "cxd56_bm1383glv.h" #include "cxd56_bm1422gmv.h" #include "cxd56_bmi160.h" #include "cxd56_bmp280.h" +#include "cxd56_emmcdev.h" +#include "cxd56_spisd.h" #include "cxd56_kx022.h" #include "cxd56_lt1pa01.h" #include "cxd56_rpr0521rs.h" @@ -184,7 +188,7 @@ enum board_power_device POWER_AUDIO_AVDD = PMIC_GPO(1), POWER_AUDIO_MUTE = PMIC_GPO(6), - POWER_IMAGE_SENSOR = PMIC_GPO(4) | PMIC_GPO(5) | PMIC_GPO(7), + POWER_IMAGE_SENSOR = PMIC_GPO(4), POWER_BTBLE = PMIC_NONE, POWER_SENSOR = PMIC_NONE, @@ -192,6 +196,11 @@ enum board_power_device POWER_LTE = PMIC_GPO(2), }; +/* Power Off Level definitions **********************************************/ + +#define BOARD_POWEROFF_DEEP (0) +#define BOARD_POWEROFF_COLD (1) + /* CXD5247 audio control definitions ****************************************/ #define CXD5247_XRST PIN_SPI3_CS2_X diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_bcm20706.h b/boards/arm/cxd56xx/spresense/include/cxd56_bcm20706.h new file mode 100644 index 00000000000..4097b4fc01c --- /dev/null +++ b/boards/arm/cxd56xx/spresense/include/cxd56_bcm20706.h @@ -0,0 +1,126 @@ +/**************************************************************************** + * boards/arm/cxd56xx/spresense/include/cxd56_bcm20706.h + * + * Copyright 2019 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 __BSP_BOARD_COMMON_INCLUDE_CXD56_BCM20706_H +#define __BSP_BOARD_COMMON_INCLUDE_CXD56_BCM20706_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/**************************************************************************** + * 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 + ****************************************************************************/ + +#ifdef CONFIG_BCM20706 + +/**************************************************************************** + * Name: board_bluetooth_pin_cfg + * + * Description: + * Initialize bcm20707 control pins, it must be called before any operation + * to do power control, wake up and reset. + * + ****************************************************************************/ + +int board_bluetooth_pin_cfg(void); + +/**************************************************************************** + * Name: board_bluetooth_uart_pin_cfg + * + * Description: + * Setup UART pin configuration for bcm20706. + * + ****************************************************************************/ + +int board_bluetooth_uart_pin_cfg(void); + +/**************************************************************************** + * Name: board_bluetooth_reset + * + * Description: + * Reset bcm20707 chip + * + ****************************************************************************/ + +void board_bluetooth_reset(void); + +/**************************************************************************** + * Name: board_bluetooth_power_control + * + * Description: + * Power on/off bcm20707 chip + * + ****************************************************************************/ + +int board_bluetooth_power_control(bool en); + +/**************************************************************************** + * Name: board_bluetooth_enable_sleep + * + * Description: + * Enable/disable bcm20707 enters sleep mode + * + ****************************************************************************/ + +void board_bluetooth_enable_sleep(bool en); +#endif /* CONFIG_BCM20706 */ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BSP_BOARD_COMMON_INCLUDE_CXD56_BCM20706_H */ diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h b/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h new file mode 100644 index 00000000000..817e6b71b1f --- /dev/null +++ b/boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.h @@ -0,0 +1,86 @@ +/**************************************************************************** + * boards/arm/cxd56xx/spresense/include/cxd56_emmcdev.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 __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_EMMCDEV_H +#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_EMMCDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * 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_emmc_initialize + * + * Description: + * Initialize the eMMC device and mount the file system. + * + ****************************************************************************/ + +#ifdef CONFIG_CXD56_EMMC +int board_emmc_initialize(void); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_EMMCDEV_H */ diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_power.h b/boards/arm/cxd56xx/spresense/include/cxd56_power.h index f8b5811f31b..35ec56ce1d5 100644 --- a/boards/arm/cxd56xx/spresense/include/cxd56_power.h +++ b/boards/arm/cxd56xx/spresense/include/cxd56_power.h @@ -133,6 +133,24 @@ int board_power_setup(int status); int board_power_control(int target, bool en); +/**************************************************************************** + * Name: board_power_control_tristate + * + * Description: + * Power on/off/HiZ the device on the board. + * (HiZ is available only for PMIC_TYPE_GPO.) + * + * Input Parameter: + * target : PMIC channel + * value : 1 (ON), 0 (OFF), -1(HiZ) + * + * Returned Value: + * 0 on success, else a negative error code + * + ****************************************************************************/ + +int board_power_control_tristate(int target, int value); + /**************************************************************************** * Name: board_power_monitor * @@ -143,6 +161,22 @@ int board_power_control(int target, bool en); bool board_power_monitor(int target); +/**************************************************************************** + * Name: board_power_monitor_tristate + * + * Description: + * Get status of Power on/off/HiZ the device on the board. + * + * Input Parameter: + * target : PMIC channel + * + * Returned Value: + * 1 (ON), 0 (OFF), -1(HiZ) + * + ****************************************************************************/ + +int board_power_monitor_tristate(int target); + /**************************************************************************** * Name: board_flash_power_control * diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_spidev.h b/boards/arm/cxd56xx/spresense/include/cxd56_spidev.h new file mode 100644 index 00000000000..f3b284dff40 --- /dev/null +++ b/boards/arm/cxd56xx/spresense/include/cxd56_spidev.h @@ -0,0 +1,84 @@ +/**************************************************************************** + * boards/arm/cxd56xx/spresense/include/cxd56_spidev.h + * + * Copyright 2020 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 __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPIDEV_H +#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPIDEV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * 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_spidev_initialize + * + * Description: + * Initialize spi driver and register the /dev/spi device. + * + ****************************************************************************/ + +int board_spidev_initialize(int bus); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPIDEV_H */ diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_spisd.h b/boards/arm/cxd56xx/spresense/include/cxd56_spisd.h new file mode 100644 index 00000000000..bfa92f40e93 --- /dev/null +++ b/boards/arm/cxd56xx/spresense/include/cxd56_spisd.h @@ -0,0 +1,98 @@ +/**************************************************************************** + * boards/arm/cxd56xx/spresense/include/cxd56_spisd.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 __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPISD_H +#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPISD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * 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_spisd_initialize + * + * Description: + * Initialize the SPI-based SD card. + * + ****************************************************************************/ + +#ifdef CONFIG_CXD56_SPISD +int board_spisd_initialize(int minor, int bus); +#endif + +/**************************************************************************** + * Name: board_spisd_status + * + * Description: + * Get the status whether SD Card is present or not. + * + ****************************************************************************/ + +#ifdef CONFIG_CXD56_SPISD +uint8_t board_spisd_status(FAR struct spi_dev_s *dev, uint32_t devid); +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SPISD_H */ diff --git a/boards/arm/cxd56xx/spresense/scripts/Make.defs b/boards/arm/cxd56xx/spresense/scripts/Make.defs index 4dcbc692794..142e27703b1 100644 --- a/boards/arm/cxd56xx/spresense/scripts/Make.defs +++ b/boards/arm/cxd56xx/spresense/scripts/Make.defs @@ -117,3 +117,11 @@ ifeq ($(CONFIG_CYGWIN_WINTOOL),y) else LDFLAGS += -Map=$(TOPDIR)/nuttx.map --cref endif + +ifneq ($(CONFIG_ASMP_MEMSIZE),) + LDFLAGS += --defsym=__reserved_ramsize=$(CONFIG_ASMP_MEMSIZE) +endif + +HOSTCC = gcc +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe + diff --git a/boards/arm/cxd56xx/spresense/scripts/ramconfig.ld b/boards/arm/cxd56xx/spresense/scripts/ramconfig.ld index 631b275b56c..f35530f6df9 100644 --- a/boards/arm/cxd56xx/spresense/scripts/ramconfig.ld +++ b/boards/arm/cxd56xx/spresense/scripts/ramconfig.ld @@ -59,9 +59,9 @@ SECTIONS *(.got) *(.gcc_except_table) *(.gnu.linkonce.r.*) - Image$$MODLIST$$Base = .; + _image_modlist_base = .; KEEP(*(.modulelist)) - Image$$MODLIST$$Limit = .; + _image_modlist_limit = .; _etext = ABSOLUTE(.); } > ram @@ -104,6 +104,9 @@ SECTIONS /* __stack symbol is referred from mkspk tool * and means the end address of heap region */ PROVIDE(__stack = ORIGIN(ram) + LENGTH(ram)); + __stack -= DEFINED(__reserved_ramsize) ? __reserved_ramsize : 0; + + ASSERT(_ebss < __stack, "Error: Out of memory") /* Stabs debugging sections. */ .stab 0 : { *(.stab) } diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c index 2b87f389b9a..ec24ecc3c84 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c @@ -102,7 +102,7 @@ #endif #ifdef CONFIG_PWM -# include "cxd56_pwm.h" +# include #endif #ifdef CONFIG_CXD56_ADC @@ -121,6 +121,10 @@ # include "cxd56_geofence.h" #endif +#ifdef CONFIG_VIDEO_FB +# include +#endif + #include "spresense.h" /**************************************************************************** @@ -247,6 +251,31 @@ int cxd56_bringup(void) } #endif + cxd56_uart_initialize(); + cxd56_timerisr_initialize(); + +#ifdef CONFIG_CXD56_CPUFIFO + ret = cxd56_pm_bootup(); + if (ret < 0) + { + _err("ERROR: Failed to powermgr bootup.\n"); + } +#endif + +#ifndef CONFIG_CXD56_SUBCORE + /* Initialize CPU clock to max frequency */ + + board_clock_initialize(); + + /* Setup the power of external device */ + + board_power_setup(0); +#endif + +#ifdef CONFIG_CXD56_SCU + scu_initialize(); +#endif + #ifdef CONFIG_CXD56_I2C_DRIVER #ifdef CONFIG_CXD56_I2C0 ret = board_i2cdev_initialize(0); @@ -273,27 +302,30 @@ int cxd56_bringup(void) #endif #endif - cxd56_uart_initialize(); - cxd56_timerisr_initialize(); - -#ifdef CONFIG_CXD56_CPUFIFO - ret = cxd56_pm_bootup(); +#ifdef CONFIG_SYSTEM_SPITOOL +# ifdef CONFIG_CXD56_SPI3 + ret = board_spidev_initialize(3); if (ret < 0) { - _err("ERROR: Failed to powermgr bootup.\n"); + _err("ERROR: Failed to initialize SPI3.\n"); } -#endif +# endif - /* Initialize CPU clock to max frequency */ +# ifdef CONFIG_CXD56_SPI4 + ret = board_spidev_initialize(4); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI4.\n"); + } +# endif - board_clock_initialize(); - - /* Setup the power of external device */ - - board_power_setup(0); - -#ifdef CONFIG_CXD56_SCU - scu_initialize(); +# ifdef CONFIG_CXD56_SPI5 + ret = board_spidev_initialize(5); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI5.\n"); + } +# endif #endif #ifdef CONFIG_FS_PROCFS @@ -370,14 +402,7 @@ int cxd56_bringup(void) } #endif /* CONFIG_VIDEO_ISX012 */ -#ifdef CONFIG_VIDEO_STREAM - ret = video_initialize("/dev/video", devops); - if (ret < 0) - { - _err("ERROR: Failed to initialize video stream driver. \n"); - } -#endif - +#if defined(CONFIG_CXD56_SDIO) /* In order to prevent Hi-Z from being input to the SD Card controller, * Initialize SDIO pins to GPIO low output with internal pull-down. */ @@ -390,7 +415,6 @@ int cxd56_bringup(void) cxd56_gpio_write(PIN_SDIO_DATA2, false); cxd56_gpio_write(PIN_SDIO_DATA3, false); -#if defined(CONFIG_CXD56_SDIO) ret = board_sdcard_initialize(); if (ret < 0) { @@ -398,6 +422,17 @@ int cxd56_bringup(void) } #endif +#ifdef CONFIG_CXD56_SPISD + /* Mount the SPI-based MMC/SD block driver */ + + ret = board_spisd_initialize(0, CONFIG_CXD56_SPISD_SPI_CH); + if (ret < 0) + { + _err("ERROR: Failed to initialize SPI device to MMC/SD: %d\n", + ret); + } +#endif + #ifdef CONFIG_CPUFREQ_RELEASE_LOCK /* Enable dynamic clock control and CPU clock down for power saving */ @@ -417,14 +452,6 @@ int cxd56_bringup(void) usbdev_rndis_initialize(mac); #endif -#ifdef CONFIG_MODEM_ALTMDM - ret = board_altmdm_initialize("/dev/altmdm"); - if (ret < 0) - { - _err("ERROR: Failed to initialize Altair modem. \n"); - } -#endif - #ifdef CONFIG_WL_GS2200M ret = board_gs2200m_initialize("/dev/gs2200m", 5); if (ret < 0) @@ -449,11 +476,19 @@ int cxd56_bringup(void) } #endif -#ifdef CONFIG_SENSORS_BMI160_I2C - ret = board_bmi160_initialize(0); +#ifdef CONFIG_SENSORS + ret = board_sensors_initialize(); if (ret < 0) { - _err("ERROR: Failed to initialize BMI160. \n"); + _err("ERROR: Failed to initialize sensors.\n"); + } +#endif + +#ifdef CONFIG_VIDEO_FB + ret = fb_register(0, 0); + if (ret < 0) + { + _err("ERROR: Failed to initialize Frame Buffer Driver.\n"); } #endif diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c b/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c index 05806481731..3453b935d92 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_ioctl.c @@ -46,9 +46,9 @@ #include #include #include +#include -#include "chip.h" -#include "cxd56_uart.h" +#include "cxd56_usbdev.h" #ifdef CONFIG_BOARDCTL_IOCTL diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_power.c b/boards/arm/cxd56xx/spresense/src/cxd56_power.c index cae375da386..870afb46852 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_power.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_power.c @@ -225,6 +225,42 @@ int board_power_control(int target, bool en) return ret; } +/**************************************************************************** + * Name: board_power_control_tristate + * + * Description: + * Power on/off/HiZ the device on the board. + * (HiZ is available only for PMIC_TYPE_GPO.) + * + * Input Parameter: + * target : PMIC channel + * value : 1 (ON), 0 (OFF), -1(HiZ) + * + * Returned Value: + * 0 on success, else a negative error code + * + ****************************************************************************/ + +int board_power_control_tristate(int target, int value) +{ + int ret = 0; + bool en; + + if ((PMIC_GET_TYPE(target) == PMIC_TYPE_GPO) && (value < 0)) + { + /* set HiZ to PMIC GPO channel */ + + ret = cxd56_pmic_set_gpo_hiz(PMIC_GET_CH(target)); + } + else + { + en = value ? true : false; + ret = board_power_control(target, en); + } + + return ret; +} + /**************************************************************************** * Name: board_power_monitor * @@ -263,6 +299,38 @@ bool board_power_monitor(int target) return ret; } +/**************************************************************************** + * Name: board_power_monitor_tristate + * + * Description: + * Get status of Power on/off/HiZ the device on the board. + * + * Input Parameter: + * target : PMIC channel + * + * Returned Value: + * 1 (ON), 0 (OFF), -1(HiZ) + * + ****************************************************************************/ + +int board_power_monitor_tristate(int target) +{ + int ret = 0; + bool en; + + if (PMIC_GET_TYPE(target) == PMIC_TYPE_GPO) + { + ret = cxd56_pmic_get_gpo_hiz(PMIC_GET_CH(target)); + } + else + { + en = board_power_monitor(target); + ret = en ? 1 : 0; + } + + return ret; +} + /**************************************************************************** * Name: board_flash_power_control * @@ -326,7 +394,7 @@ int board_xtal_power_control(bool en) /* Get exclusive access to the lna / tcxo power control */ - nxsem_wait(&g_ltsem); + nxsem_wait_uninterruptible(&g_ltsem); if (en) { @@ -384,7 +452,7 @@ int board_lna_power_control(bool en) /* Get exclusive access to the lna / tcxo power control */ - nxsem_wait(&g_ltsem); + nxsem_wait_uninterruptible(&g_ltsem); if (en) { diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c index a2d5a63bc98..46cc830b794 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_sdcard.c @@ -172,6 +172,7 @@ static void board_sdcard_enable(FAR void *arg) else { _err("ERROR: Failed to mount the SDCARD. %d\n", errno); + cxd56_sdio_resetstatus(g_sdhci.sdhci); goto release_frequency_lock; } } @@ -284,7 +285,7 @@ static int board_sdcard_detect_int(int irq, FAR void *context, FAR void *arg) if (up_interrupt_context()) { - DEBUGASSERT(work_available(&g_sdcard_work)); + work_cancel(HPWORK, &g_sdcard_work); if (inserted) { work_queue(HPWORK, &g_sdcard_work, board_sdcard_enable, diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_spi.c b/boards/arm/cxd56xx/spresense/src/cxd56_spi.c index 2c8d86008ba..fc1c48d87b0 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_spi.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_spi.c @@ -138,7 +138,12 @@ void cxd56_spi4select(FAR struct spi_dev_s *dev, uint32_t devid, uint8_t cxd56_spi4status(FAR struct spi_dev_s *dev, uint32_t devid) { - return 0; + uint8_t ret = 0; + +# if defined(CONFIG_CXD56_SPISD) && (CONFIG_CXD56_SPISD_SPI_CH == 4) + ret = board_spisd_status(dev, devid); +# endif + return ret; } #endif @@ -152,6 +157,11 @@ void cxd56_spi5select(FAR struct spi_dev_s *dev, uint32_t devid, uint8_t cxd56_spi5status(FAR struct spi_dev_s *dev, uint32_t devid) { - return 0; + uint8_t ret = 0; + +# if defined(CONFIG_CXD56_SPISD) && (CONFIG_CXD56_SPISD_SPI_CH == 5) + ret = board_spisd_status(dev, devid); +# endif + return ret; } #endif diff --git a/boards/arm/cxd56xx/spresense/src/spresense.h b/boards/arm/cxd56xx/spresense/src/spresense.h index 47d3a55eefc..ebc1e81ea3c 100644 --- a/boards/arm/cxd56xx/spresense/src/spresense.h +++ b/boards/arm/cxd56xx/spresense/src/spresense.h @@ -43,23 +43,11 @@ #include /**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public data + * Public Function Prototypes ****************************************************************************/ #ifndef __ASSEMBLY__ -/**************************************************************************** - * Public Functions - ****************************************************************************/ - /**************************************************************************** * Name: cxd56_bringup * diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c index 866fab9a9cb..07b0e98926f 100644 --- a/drivers/audio/cxd56.c +++ b/drivers/audio/cxd56.c @@ -119,7 +119,7 @@ #define CXD56_ACA_OSC_49_152MHZ 3 /* 49.152MHz */ #define CXD56_ACA_OSC_49_152MHZ_HIRES 4 /* 49.152MHz, Hi-Res */ -/* Control IDs for external as_aca_control */ +/* Control IDs for external fw_as_acacontrol */ #define CXD56_ACA_CTL_CHECK_ID 0 #define CXD56_ACA_CTL_POWER_ON_COMMON 1 #define CXD56_ACA_CTL_POWER_ON_INPUT 2 @@ -193,7 +193,7 @@ extern bool cxd56_audio_clock_is_enabled(void); /* Located in arch/arm/src/cxd56xx/cxd56_farapistub.S */ -extern uint32_t as_aca_control(uint8_t type, uint32_t param); +extern uint32_t fw_as_acacontrol(uint8_t type, uint32_t param); /**************************************************************************** * Private Types @@ -1511,7 +1511,7 @@ static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol) { /* Disable analog out */ - ret = as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE, + ret = fw_as_acacontrol(CXD56_ACA_CTL_SET_OUTPUT_DEVICE, (uint32_t)CXD56_OUT_DEV_OFF); if (ret != CXD56_AUDIO_ECODE_OK) { @@ -1523,7 +1523,7 @@ static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol) { /* Enable analog out */ - ret = as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE, + ret = fw_as_acacontrol(CXD56_ACA_CTL_SET_OUTPUT_DEVICE, (uint32_t)CXD56_OUT_DEV_SP); if (ret != CXD56_AUDIO_ECODE_OK) { @@ -1711,7 +1711,7 @@ static int cxd56_power_on_aca(uint32_t samplerate) uint8_t mic_sel; uint8_t i; - if (as_aca_control(CXD56_ACA_CTL_CHECK_ID, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(CXD56_ACA_CTL_CHECK_ID, (uint32_t)NULL) != 0) { return -ENXIO; } @@ -1735,7 +1735,7 @@ static int cxd56_power_on_aca(uint32_t samplerate) pwon_param.mclk_ds = CXD56_MCLKOUT_DS; pwon_param.gpo_ds = CXD56_GPO_A_DS; - if (as_aca_control(CXD56_ACA_CTL_POWER_ON_COMMON, + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_ON_COMMON, (uint32_t)&pwon_param) != 0) { return -EBUSY; @@ -1763,7 +1763,7 @@ static int cxd56_power_on_aca(uint32_t samplerate) ser_param.sel_ch.in[i] = (enum cxd56_pulco_ser_sel_ch_id_e)mic_sel; } - if (as_aca_control(CXD56_ACA_CTL_SET_SERDES, (uint32_t)&ser_param) != 0) + if (fw_as_acacontrol(CXD56_ACA_CTL_SET_SERDES, (uint32_t)&ser_param) != 0) { return -EBUSY; } @@ -1802,13 +1802,13 @@ static int cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev) pwon_param.sp_spliton = CXD56_SP_SPLIT_ON; pwon_param.sp_drv = CXD56_SP_DRIVER; - if (as_aca_control(CXD56_ACA_CTL_SET_SMASTER, + if (fw_as_acacontrol(CXD56_ACA_CTL_SET_SMASTER, (uint32_t)&smaster_param) != 0) { return -EBUSY; } - if (as_aca_control(CXD56_ACA_CTL_POWER_ON_OUTPUT, + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_ON_OUTPUT, (uint32_t)&pwon_param) != 0) { return -EBUSY; @@ -1939,7 +1939,7 @@ static int cxd56_power_on_micbias(FAR struct cxd56_dev_s *dev) { struct timespec start; - if (as_aca_control(CXD56_ACA_CTL_POWER_ON_MICBIAS, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_ON_MICBIAS, (uint32_t)NULL) != 0) { return -EBUSY; } @@ -2207,7 +2207,7 @@ static int cxd56_power_on_input(FAR struct cxd56_dev_s *dev) cxd56_set_mic_gains(120, ¶m); - if (as_aca_control(CXD56_ACA_CTL_POWER_ON_INPUT, + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_ON_INPUT, (uint32_t)¶m) != 0) { return -EBUSY; @@ -2423,7 +2423,7 @@ static int cxd56_power_off(FAR struct cxd56_dev_s *dev) cxd56_audio_clock_disable(); - if (as_aca_control(CXD56_ACA_CTL_POWER_OFF_COMMON, (uint32_t)NULL) != 0) + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_OFF_COMMON, (uint32_t)NULL) != 0) { return -EBUSY; } @@ -2857,7 +2857,7 @@ static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv) /* Disable input */ - if (as_aca_control(CXD56_ACA_CTL_POWER_OFF_INPUT, + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_OFF_INPUT, (uint32_t)NULL) != 0) { return -EBUSY; @@ -2881,7 +2881,7 @@ static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv) write_reg(REG_AC_NSPMUTE, 1); write_reg(REG_AC_PDN_SMSTR, 1); - if (as_aca_control(CXD56_ACA_CTL_POWER_OFF_OUTPUT, + if (fw_as_acacontrol(CXD56_ACA_CTL_POWER_OFF_OUTPUT, (uint32_t)NULL) != 0) { return -EBUSY;