Lines Matching refs:cfg

38 static inline void spi_smartbond_enable(const struct spi_smartbond_cfg *cfg, bool enable)  in spi_smartbond_enable()  argument
41 cfg->regs->SPI_CTRL_REG |= SPI_SPI_CTRL_REG_SPI_ON_Msk; in spi_smartbond_enable()
42 cfg->regs->SPI_CTRL_REG &= ~SPI_SPI_CTRL_REG_SPI_RST_Msk; in spi_smartbond_enable()
44 cfg->regs->SPI_CTRL_REG &= ~SPI_SPI_CTRL_REG_SPI_ON_Msk; in spi_smartbond_enable()
45 cfg->regs->SPI_CTRL_REG |= SPI_SPI_CTRL_REG_SPI_RST_Msk; in spi_smartbond_enable()
49 static inline bool spi_smartbond_isenabled(const struct spi_smartbond_cfg *cfg) in spi_smartbond_isenabled() argument
51 return (!!(cfg->regs->SPI_CTRL_REG & SPI_SPI_CTRL_REG_SPI_ON_Msk)) && in spi_smartbond_isenabled()
52 (!(cfg->regs->SPI_CTRL_REG & SPI_SPI_CTRL_REG_SPI_RST_Msk)); in spi_smartbond_isenabled()
55 static inline int spi_smartbond_set_speed(const struct spi_smartbond_cfg *cfg, in spi_smartbond_set_speed() argument
62 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_speed()
63 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_CLK_Msk) | in spi_smartbond_set_speed()
66 cfg->regs->SPI_CTRL_REG = (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_CLK_Msk); in spi_smartbond_set_speed()
68 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_speed()
69 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_CLK_Msk) | in spi_smartbond_set_speed()
72 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_speed()
73 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_CLK_Msk) | in spi_smartbond_set_speed()
79 static inline int spi_smartbond_set_word_size(const struct spi_smartbond_cfg *cfg, in spi_smartbond_set_word_size() argument
86 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_word_size()
87 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_WORD_Msk); in spi_smartbond_set_word_size()
91 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_word_size()
92 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_WORD_Msk) | in spi_smartbond_set_word_size()
97 cfg->regs->SPI_CTRL_REG = in spi_smartbond_set_word_size()
98 (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_WORD_Msk) | in spi_smartbond_set_word_size()
109 static int spi_smartbond_configure(const struct spi_smartbond_cfg *cfg, in spi_smartbond_configure() argument
140 if (spi_smartbond_isenabled(cfg)) { in spi_smartbond_configure()
141 spi_smartbond_enable(cfg, false); in spi_smartbond_configure()
144 rc = spi_smartbond_set_speed(cfg, spi_cfg->frequency); in spi_smartbond_configure()
149 cfg->regs->SPI_CTRL_REG = in spi_smartbond_configure()
151 ? (cfg->regs->SPI_CTRL_REG | SPI_SPI_CTRL_REG_SPI_POL_Msk) in spi_smartbond_configure()
152 : (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_POL_Msk); in spi_smartbond_configure()
154 cfg->regs->SPI_CTRL_REG = in spi_smartbond_configure()
156 ? (cfg->regs->SPI_CTRL_REG | SPI_SPI_CTRL_REG_SPI_PHA_Msk) in spi_smartbond_configure()
157 : (cfg->regs->SPI_CTRL_REG & ~SPI_SPI_CTRL_REG_SPI_PHA_Msk); in spi_smartbond_configure()
159 rc = spi_smartbond_set_word_size(cfg, data, spi_cfg->operation); in spi_smartbond_configure()
164 cfg->regs->SPI_CTRL_REG &= ~(SPI_SPI_CTRL_REG_SPI_FIFO_MODE_Msk); in spi_smartbond_configure()
166 spi_smartbond_enable(cfg, true); in spi_smartbond_configure()
168 cfg->regs->SPI_CTRL_REG &= ~SPI_SPI_CTRL_REG_SPI_MINT_Msk; in spi_smartbond_configure()
179 const struct spi_smartbond_cfg *cfg = dev->config; in spi_smartbond_transceive() local
186 rc = spi_smartbond_configure(cfg, data, spi_cfg); in spi_smartbond_transceive()
194 cfg->regs->SPI_RX_TX_REG = (*(uint32_t *)ctx->tx_buf) & bitmask; in spi_smartbond_transceive()
197 cfg->regs->SPI_RX_TX_REG = 0UL; in spi_smartbond_transceive()
200 while (!(cfg->regs->SPI_CTRL_REG & SPI_SPI_CTRL_REG_SPI_INT_BIT_Msk)) { in spi_smartbond_transceive()
203 (*(uint32_t *)ctx->rx_buf) = cfg->regs->SPI_RX_TX_REG & bitmask; in spi_smartbond_transceive()
206 (void)cfg->regs->SPI_RX_TX_REG; in spi_smartbond_transceive()
208 cfg->regs->SPI_CLEAR_INT_REG = 1UL; in spi_smartbond_transceive()
252 const struct spi_smartbond_cfg *cfg = dev->config; in spi_smartbond_init() local
256 CRG_COM->RESET_CLK_COM_REG = cfg->periph_clock_config << 1; in spi_smartbond_init()
257 CRG_COM->SET_CLK_COM_REG = cfg->periph_clock_config; in spi_smartbond_init()
259 rc = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in spi_smartbond_init()