Lines Matching +full:tx +full:- +full:mask

1 /* uart_xlnx_ps.c - Xilinx Zynq family serial driver */
6 * SPDX-License-Identifier: Apache-2.0
19 * - the following macro for the number of bytes between register addresses:
42 * Comp. Xilinx Zynq-7000 Technical Reference Manual (ug585), chap. B.33
50 #define XUARTPS_IMR_OFFSET 0x0010U /**< Interrupt Mask [12:0] */
61 #define XUARTPS_TXWM_OFFSET 0x0044U /**< TX FIFO Trigger Level [5:0] */
68 #define XUARTPS_CR_TX_DIS 0x00000020U /**< TX disabled. */
69 #define XUARTPS_CR_TX_EN 0x00000010U /**< TX enabled */
72 #define XUARTPS_CR_EN_DIS_MASK 0x0000003CU /**< Enable/disable Mask */
73 #define XUARTPS_CR_TXRST 0x00000002U /**< TX logic reset */
83 #define XUARTPS_MR_CHMODE_MASK 0x00000300U /**< Mode mask */
88 #define XUARTPS_MR_STOPMODE_MASK 0x000000A0U /**< Stop bits mask */
95 #define XUARTPS_MR_PARITY_MASK 0x00000038U /**< Parity mask */
100 #define XUARTPS_MR_CHARLEN_MASK 0x00000006U /**< Data length mask */
105 #define XUARTPS_IXR_TOVR 0x00001000U /**< Tx FIFO Overflow interrupt */
106 #define XUARTPS_IXR_TNFUL 0x00000800U /**< Tx FIFO Nearly Full interrupt */
107 #define XUARTPS_IXR_TTRIG 0x00000400U /**< Tx Trig interrupt */
113 #define XUARTPS_IXR_TXFULL 0x00000010U /**< TX FIFO full interrupt. */
114 #define XUARTPS_IXR_TXEMPTY 0x00000008U /**< TX FIFO empty interrupt. */
118 #define XUARTPS_IXR_MASK 0x00003FFFU /**< Valid bit mask */
123 #define XUARTPS_MODEMCR_FCM_MASK 0x00000020 /**< Hardware flow control mask. */
128 #define XUARTPS_SR_TNFUL 0x00004000U /**< TX FIFO Nearly Full Status */
129 #define XUARTPS_SR_TTRIG 0x00002000U /**< TX FIFO Trigger Status */
131 #define XUARTPS_SR_TACTIVE 0x00000800U /**< TX active */
133 #define XUARTPS_SR_TXFULL 0x00000010U /**< TX FIFO full */
134 #define XUARTPS_SR_TXEMPTY 0x00000008U /**< TX FIFO empty */
167 * @brief Disables the UART's RX and TX function.
169 * Writes 'Disable RX' and 'Disable TX' command bits into the respective
176 * of the UART are modified at run-time.
191 * @brief Enables the UART's RX and TX function.
193 * Writes 'Enable RX' and 'Enable TX' command bits into the respective
200 * of the UART are being modified at run-time.
222 * registers is described in the Zynq-7000 TRM, chapter 19.2.3 'Baud Rate
230 const struct uart_xlnx_ps_dev_config *dev_cfg = dev->config; in set_baudrate()
231 uint32_t baud = dev_cfg->baud_rate; in set_baudrate()
232 uint32_t clk_freq = dev_cfg->sys_clk_freq; in set_baudrate()
253 bauderr = baud - tmpbaud; in set_baudrate()
255 bauderr = tmpbaud - baud; in set_baudrate()
264 * -> This function is always called from a context in which in set_baudrate()
284 const struct uart_xlnx_ps_dev_config *dev_cfg = dev->config; in uart_xlnx_ps_init()
293 /* Disable RX/TX before changing any configuration data */ in uart_xlnx_ps_init()
297 err = pinctrl_apply_state(dev_cfg->pincfg, PINCTRL_STATE_DEFAULT); in uart_xlnx_ps_init()
318 set_baudrate(dev, dev_cfg->baud_rate); in uart_xlnx_ps_init()
326 dev_cfg->irq_config_func(dev); in uart_xlnx_ps_init()
341 * @return 0 if a character arrived, -1 if the input buffer if empty.
352 return -1; in uart_xlnx_ps_poll_in()
388 * @brief Converts a parity enum value to a Mode Register bit mask.
392 * into a bit mask within the Mode Register.
400 * @param parity Enumeration value to be converted to a bit mask.
443 * @brief Converts a stop bit enum value to a Mode Register bit mask.
447 * into a bit mask within the Mode Register.
455 * @param stopbits Enumeration value to be converted to a bit mask.
493 * @brief Converts a data bit enum value to a Mode Register bit mask.
497 * into a bit mask within the Mode Register.
505 * @param databits Enumeration value to be converted to a bit mask.
544 * Register bit mask.
548 * setting into a bit mask within the Modem Control Register.
557 * @param hwctrl Enumeration value to be converted to a bit mask.
587 * @brief Configures the UART device at run-time.
589 * Configures the UART device at run-time according to the
602 (struct uart_xlnx_ps_dev_config *)dev->config; in uart_xlnx_ps_configure()
612 /* Mask out all items that might be re-configured */ in uart_xlnx_ps_configure()
619 if ((!uart_xlnx_ps_cfg2ll_parity(&mode_reg, cfg->parity)) || in uart_xlnx_ps_configure()
620 (!uart_xlnx_ps_cfg2ll_stopbits(&mode_reg, cfg->stop_bits)) || in uart_xlnx_ps_configure()
621 (!uart_xlnx_ps_cfg2ll_databits(&mode_reg, cfg->data_bits)) || in uart_xlnx_ps_configure()
622 (!uart_xlnx_ps_cfg2ll_hwctrl(&modemcr_reg, cfg->flow_ctrl))) { in uart_xlnx_ps_configure()
623 return -ENOTSUP; in uart_xlnx_ps_configure()
630 set_baudrate(dev, cfg->baudrate); in uart_xlnx_ps_configure()
631 dev_cfg->baud_rate = cfg->baudrate; in uart_xlnx_ps_configure()
637 /* Re-enable the controller */ in uart_xlnx_ps_configure()
645 * @brief Converts a Mode Register bit mask to a parity configuration
648 * Converts a bit mask representing the UART's parity setting within
664 * 000b : even -> reset value in uart_xlnx_ps_ll2cfg_parity()
687 * @brief Converts a Mode Register bit mask to a stop bit configuration
690 * Converts a bit mask representing the UART's stop bit setting within
706 * 00b : 1 stop bit -> reset value in uart_xlnx_ps_ll2cfg_stopbits()
724 * @brief Converts a Mode Register bit mask to a data bit configuration
727 * Converts a bit mask representing the UART's data bit setting within
743 * 0xb : 8 data bits -> reset value in uart_xlnx_ps_ll2cfg_databits()
760 * @brief Converts a Modem Control Register bit mask to a flow control
763 * Converts a bit mask representing the UART's flow control setting within
779 * 0b : no flow control -> reset value in uart_xlnx_ps_ll2cfg_hwctrl()
793 * @brief Returns the current configuration of the UART at run-time.
795 * Returns the current configuration of the UART at run-time by obtaining
808 const struct uart_xlnx_ps_dev_config *dev_cfg = dev->config; in uart_xlnx_ps_config_get()
812 * Read the Mode & Modem control registers - they contain in uart_xlnx_ps_config_get()
820 cfg->baudrate = dev_cfg->baud_rate; in uart_xlnx_ps_config_get()
821 cfg->parity = uart_xlnx_ps_ll2cfg_parity(mode_reg); in uart_xlnx_ps_config_get()
822 cfg->stop_bits = uart_xlnx_ps_ll2cfg_stopbits(mode_reg); in uart_xlnx_ps_config_get()
823 cfg->data_bits = uart_xlnx_ps_ll2cfg_databits(mode_reg); in uart_xlnx_ps_config_get()
824 cfg->flow_ctrl = uart_xlnx_ps_ll2cfg_hwctrl(modemcr_reg); in uart_xlnx_ps_config_get()
849 while (size--) { in uart_xlnx_ps_fifo_fill()
886 * @brief Enable TX interrupt in IER
900 * @brief Disable TX interrupt in IER
914 * @brief Check if Tx IRQ has been raised
1076 struct uart_xlnx_ps_dev_data_t *dev_data = dev->data; in uart_xlnx_ps_irq_callback_set()
1078 dev_data->user_cb = cb; in uart_xlnx_ps_irq_callback_set()
1079 dev_data->user_data = cb_data; in uart_xlnx_ps_irq_callback_set()
1091 const struct uart_xlnx_ps_dev_data_t *data = dev->data; in uart_xlnx_ps_isr()
1093 if (data->user_cb) { in uart_xlnx_ps_isr()
1094 data->user_cb(dev, data->user_data); in uart_xlnx_ps_isr()