Merged in david_s5/nuttx/upstream_kinetis (pull request #392)

Upstream kinetis

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
David Sidrane 2017-06-14 04:22:44 +00:00 committed by Gregory Nutt
commit 9edf43abc1
9 changed files with 1317 additions and 10 deletions

View File

@ -140,6 +140,10 @@ ifeq ($(CONFIG_KINETIS_SDHC),y)
CHIP_CSRCS += kinetis_sdhc.c
endif
ifeq ($(CONFIG_SPI),y)
CHIP_CSRCS += kinetis_spi.c
endif
ifeq ($(CONFIG_USBDEV),y)
CHIP_CSRCS += kinetis_usbdev.c
endif

View File

@ -140,7 +140,7 @@
#define SPI_MCR_PCSIS_SHIFT (16) /* Bits 16-21: Peripheral Chip Select x Inactive State */
#define SPI_MCR_PCSIS_MASK (0x3f << SPI_MCR_PCSIS_SHIFT)
# define SPI_MCR_PCSIS_CS(n) ((1 << (n)) << SPI_MCR_PCSIS_SHIFT)
/* Bits 2223: Reserved */
/* Bits 22-23: Reserved */
#define SPI_MCR_ROOE (1 << 24) /* Bit 24: Receive FIFO Overflow Overwrite Enable */
#define SPI_MCR_PCSSE (1 << 25) /* Bit 25: Peripheral Chip Select Strobe Enable */
#define SPI_MCR_MTFE (1 << 26) /* Bit 26: Modified Timing Format Enable */
@ -165,6 +165,7 @@
#define SPI_CTARM_BR_SHIFT (0) /* Bits 0-3: Baud Rate Scaler */
#define SPI_CTARM_BR_MASK (15 << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR(n) ((((n) & 0xf)) << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_2 (0 << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_4 (1 << SPI_CTARM_BR_SHIFT)
# define SPI_CTARM_BR_6 (2 << SPI_CTARM_BR_SHIFT)
@ -205,6 +206,7 @@
# define SPI_CTARM_CSSCK_65536 (15 << SPI_CTARM_CSSCK_SHIFT)
#define SPI_CTARM_PBR_SHIFT (16) /* Bits 16-17: Baud Rate Prescaler */
#define SPI_CTARM_PBR_MASK (3 << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR(n) (((n) & 0x3) << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_2 (0 << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_3 (1 << SPI_CTARM_PBR_SHIFT)
# define SPI_CTARM_PBR_5 (2 << SPI_CTARM_PBR_SHIFT)
@ -231,6 +233,7 @@
/* Bits 25-26: See common bits above */
#define SPI_CTARM_FMSZ_SHIFT (27) /* Bits 27-30: Frame Size */
#define SPI_CTARM_FMSZ_MASK (15 << SPI_CTARM_FMSZ_SHIFT)
#define SPI_CTARM_FMSZ(n) ((((n) & 0xf)) << SPI_CTARM_FMSZ_SHIFT)
#define SPI_CTARM_DBR (1 << 31) /* Bit 31: Double Baud Rate */
/* DSPI Clock and Transfer Attributes Register (Slave Mode) */
@ -281,6 +284,7 @@
#define SPI_PUSHR_TXDATA_SHIFT (0) /* Bits 0-15: Transmit Data */
#define SPI_PUSHR_TXDATA_MASK (0xffff << SPI_PUSHR_TXDATA_SHIFT)
# define SPI_PUSHR_TXDATA(d) (((d) & 0xffff) << SPI_PUSHR_TXDATA_SHIFT)
#define SPI_PUSHR_PCS_SHIFT (16) /* Bits 16-21: Select PCS signals to assert */
#define SPI_PUSHR_PCS_MASK (0x3f << SPI_PUSHR_PCS_SHIFT)
# define SPI_PUSHR_PCS(n) ((1 << (n)) << SPI_PUSHR_PCS_SHIFT)

View File

@ -63,11 +63,9 @@
#include "up_arch.h"
#include "up_internal.h"
#include "kinetis_config.h"
#include "chip.h"
#include "kinetis.h"
#include "chip/kinetis_lpuart.h"
#include "chip/kinetis_pinmux.h"
#include "kinetis.h"
/****************************************************************************
* Pre-processor Definitions

File diff suppressed because it is too large Load Diff

View File

@ -348,6 +348,24 @@
#define PIN_I2C0_SCL PIN_I2C0_SCL_3
#define PIN_I2C0_SDA PIN_I2C0_SDA_3
/* RF/WIFI
*
* J6 Pin Name K66 Name
* ------ ----- ------ ---------
* 1 GND
* 2 P3V3
* 3 CE PTB20 PTB20
* 4 CS PTD4 SPI1_PCS0 (use as GPIO)
* 5 SCK PTD5 SPI1_SCK
* 6 MOSI PTD6 SPI1_MOSI
* 7 MISO PTD7 SPI1_MISO
* 8 IRQ PTC18 PTC18
*/
#define PIN_SPI1_SCK PIN_SPI1_SCK_3
#define PIN_SPI1_OUT PIN_SPI1_SOUT_3
#define PIN_SPI1_SIN PIN_SPI1_SIN_3
/*
* Ethernet MAC/KSZ8081 PHY
* ------------------------

View File

@ -223,7 +223,7 @@ CONFIG_KINETIS_UART4=y
# CONFIG_KINETIS_FLEXCAN0 is not set
# CONFIG_KINETIS_FLEXCAN1 is not set
# CONFIG_KINETIS_SPI0 is not set
# CONFIG_KINETIS_SPI1 is not set
CONFIG_KINETIS_SPI1=y
# CONFIG_KINETIS_SPI2 is not set
CONFIG_KINETIS_I2C0=y
# CONFIG_KINETIS_I2C1 is not set
@ -546,7 +546,15 @@ CONFIG_I2C_DRIVER=y
# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set
# CONFIG_ARCH_HAVE_SPI_CS_CONTROL is not set
# CONFIG_ARCH_HAVE_SPI_BITORDER is not set
# CONFIG_SPI is not set
CONFIG_SPI=y
# CONFIG_SPI_SLAVE is not set
CONFIG_SPI_EXCHANGE=y
# CONFIG_SPI_CMDDATA is not set
# CONFIG_SPI_CALLBACK is not set
# CONFIG_SPI_HWFEATURES is not set
CONFIG_SPI_CS_DELAY_CONTROL=y
# CONFIG_SPI_DRIVER is not set
# CONFIG_SPI_BITBANG is not set
# CONFIG_I2S is not set
#
@ -576,6 +584,7 @@ CONFIG_INPUT=y
# CONFIG_INPUT_ADS7843E is not set
# CONFIG_INPUT_MXT is not set
# CONFIG_INPUT_STMPE811 is not set
# CONFIG_INPUT_CYPRESS_MBR3108 is not set
CONFIG_BUTTONS=y
CONFIG_BUTTONS_LOWER=y
CONFIG_BUTTONS_NPOLLWAITERS=2
@ -607,6 +616,7 @@ CONFIG_MMCSD_NSLOTS=1
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
CONFIG_MMCSD_MMCSUPPORT=y
CONFIG_MMCSD_HAVECARDDETECT=y
# CONFIG_MMCSD_SPI is not set
CONFIG_ARCH_HAVE_SDIO=y
# CONFIG_SDIO_DMA is not set
# CONFIG_ARCH_HAVE_SDIOWAIT_WRCOMPLETE is not set

View File

@ -57,6 +57,7 @@
#define HAVE_PROC 1
#define HAVE_MMCSD 1
#define HAVE_AUTOMOUNTER 1
#define HAVE_SPI 1
#define HAVE_USBDEV 1
#if defined(CONFIG_KINETIS_RTC)
@ -173,6 +174,11 @@
# undef CONFIG_KINETIS_SPI2
#endif
#if !defined(CONFIG_KINETIS_SPI0) && !defined(CONFIG_KINETIS_SPI1) && \
!defined(CONFIG_KINETIS_SPI3)
# undef HAVE_SPI
#endif
/* FREEDOM-K66F GPIOs ****************************************************************/
/* A micro Secure Digital (SD) card slot is available on the FRDM-K66F connected to
* the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro
@ -223,6 +229,11 @@
#define GPIO_LED_G (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTE | PIN6)
#define GPIO_LED_B (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTA | PIN11)
/* SPI1 on J6 */
#define PIN_CE (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTB | PIN20)
#define PIN_SPI1_PCS0 (GPIO_LOWDRIVE | GPIO_OUTPUT_ONE | PIN_PORTD | PIN4)
/************************************************************************************
* Public data
************************************************************************************/

View File

@ -47,8 +47,10 @@
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/spi/spi.h>
#include <nuttx/input/buttons.h>
#include "kinetis_spi.h"
#include "freedom-k66f.h"
#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE)
@ -67,6 +69,9 @@
int k66_bringup(void)
{
#ifdef HAVE_SPI
FAR struct spi_dev_s *spi1;
#endif
int ret;
#ifdef HAVE_PROC
@ -151,8 +156,20 @@ int k66_bringup(void)
}
#endif
#ifdef HAVE_SPI
/* Verify we can initialize SPI bus 1 */
spi1 = kinetis_spibus_initialize(1);
if (!spi1)
{
syslog(LOG_ERR, "ERROR:FAILED to initialize SPI port 1\n");
return -ENODEV;
}
#endif
UNUSED(ret);
return OK;
}
#endif /* CONFIG_LIB_BOARDCTL CONFIG_BOARD_INITIALIZE */

View File

@ -53,7 +53,7 @@
#include "freedom-k66f.h"
#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || \
defined(CONFIG_KINETIS_SPI2)
defined(CONFIG_KINETIS_SPI2)
/************************************************************************************
* Public Functions
@ -69,7 +69,10 @@
void weak_function k66_spidev_initialize(void)
{
# warning "Missing logic"
/* Initialize the CE CS pins on J6 RF/WIFI connector */
kinetis_pinconfig(PIN_CE);
kinetis_pinconfig(PIN_SPI1_PCS0);
}
/************************************************************************************
@ -118,7 +121,7 @@ uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, uint32_t devid)
void kinetis_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
# warning "Missing logic"
kinetis_gpiowrite(PIN_SPI1_PCS0, !selected);
}
uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, uint32_t devid)