Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions arch/arm64/src/imx9/hardware/imx9_lpspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,11 @@
#define LPSPI_TCR_BYSW (1 << 22) /* Bit 22: Byte Swap (BYSW) */
#define LPSPI_TCR_LSBF (1 << 23) /* Bit 23: LSB First (LSBF) */
# define LPSPI_TCR_MSBF (0 << 23) /* MSB First */
#define LPSPI_TCR_PCS_SHIFT (24) /* Bits 24-26: Peripheral Chip Select (PCS) */
#define LPSPI_TCR_PCS_MASK (0x07 << LPSPI_TCR_PCS_SHIFT)
#define LPSPI_TCR_PCS_SHIFT (24) /* Bits 24-25: Peripheral Chip Select (PCS) */
#define LPSPI_TCR_PCS_MASK (0x03 << LPSPI_TCR_PCS_SHIFT)
# define LPSPI_TCR_PCS_0 (0x00 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[0] */
# define LPSPI_TCR_PCS_1 (0x01 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[1] */
# define LPSPI_TCR_PCS_2 (0x02 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[2] */
# define LPSPI_TCR_PCS_3 (0x03 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[3] */
# define LPSPI_TCR_PCS_4 (0x04 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[4] */
# define LPSPI_TCR_PCS_5 (0x05 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[5] */
# define LPSPI_TCR_PCS_6 (0x06 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[6] */
# define LPSPI_TCR_PCS_7 (0x07 << LPSPI_TCR_PCS_SHIFT) /* Transfer using PCS[7] */

#define LPSPI_TCR_PRESCALE_SHIFT (27) /* Bits 27-29: Prescaler Value (PRESCALE) */
#define LPSPI_TCR_PRESCALE_MASK (0x07 << LPSPI_TCR_PRESCALE_SHIFT)
Expand Down
34 changes: 34 additions & 0 deletions arch/arm64/src/imx9/imx9_lpspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2094,4 +2094,38 @@ void imx9_lpspi_uninitialize(struct spi_dev_s *dev)
}
}

/****************************************************************************
* Name: imx9_lpspi_select_cs
*
* Description:
* Assert or de-assert internal PCS0 or PCS1 line. Can be called by
* board-specific chip-select logic. Assertion of the CS is done at the
* start of the next transfer and de-assertion after this function is
* called again to de-assert the cs and the transfer has ended.
*
* Input Parameters:
* dev - Device-specific state data
* cs - Chip select 0 or 1
* select - true: assert CS, false: de-assert CS
*
* Returned Value:
* None
*
****************************************************************************/

void imx9_lpspi_select_cs(struct spi_dev_s *dev, int cs, bool select)
{
struct imx9_lpspidev_s *priv = (struct imx9_lpspidev_s *)dev;

if (select)
{
uint32_t pcs = (cs << LPSPI_TCR_PCS_SHIFT) & LPSPI_TCR_PCS_MASK;
imx9_lpspi_modifytcr(priv, LPSPI_TCR_PCS_MASK, pcs | LPSPI_TCR_CONT);
}
else
{
imx9_lpspi_modifytcr(priv, LPSPI_TCR_CONT, 0);
}
}

#endif /* CONFIG_IMX9_LPSPI */
21 changes: 21 additions & 0 deletions arch/arm64/src/imx9/imx9_lpspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,27 @@ int imx9_lpspi_register(struct spi_dev_s *dev,
void *arg);
#endif

/****************************************************************************
* Name: imx9_lpspi_select_cs
*
* Description:
* Assert or de-assert internal PCS0 or PCS1 line. Can be called by
* board-specific chip-select logic. Assertion of the CS is done at the
* start of the next transfer and de-assertion after this function is
* called again to de-assert the cs and the transfer has ended.
*
* Input Parameters:
* dev - Device-specific state data
* cs - Chip select 0 or 1
* select - true: assert CS, false: de-assert CS
*
* Returned Value:
* None
*
****************************************************************************/

void imx9_lpspi_select_cs(struct spi_dev_s *dev, int cs, bool select);

#undef EXTERN
#if defined(__cplusplus)
}
Expand Down
Loading