Lines Matching refs:port

75 #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))  argument
80 static irqreturn_t mpc5xxx_uart_process_int(struct uart_port *port);
87 void (*fifo_init)(struct uart_port *port);
88 unsigned int (*raw_rx_rdy)(struct uart_port *port);
89 unsigned int (*raw_tx_rdy)(struct uart_port *port);
90 unsigned int (*rx_rdy)(struct uart_port *port);
91 unsigned int (*tx_rdy)(struct uart_port *port);
92 unsigned int (*tx_empty)(struct uart_port *port);
93 void (*stop_rx)(struct uart_port *port);
94 void (*start_tx)(struct uart_port *port);
95 void (*stop_tx)(struct uart_port *port);
96 void (*rx_clr_irq)(struct uart_port *port);
97 void (*tx_clr_irq)(struct uart_port *port);
98 void (*write_char)(struct uart_port *port, unsigned char c);
99 unsigned char (*read_char)(struct uart_port *port);
100 void (*cw_disable_ints)(struct uart_port *port);
101 void (*cw_restore_ints)(struct uart_port *port);
102 unsigned int (*set_baudrate)(struct uart_port *port,
105 int (*clock_alloc)(struct uart_port *port);
106 void (*clock_relse)(struct uart_port *port);
107 int (*clock)(struct uart_port *port, int enable);
111 irqreturn_t (*handle_irq)(struct uart_port *port);
112 u16 (*get_status)(struct uart_port *port);
113 u8 (*get_ipcr)(struct uart_port *port);
114 void (*command)(struct uart_port *port, u8 cmd);
115 void (*set_mode)(struct uart_port *port, u8 mr1, u8 mr2);
116 void (*set_rts)(struct uart_port *port, int state);
117 void (*enable_ms)(struct uart_port *port);
118 void (*set_sicr)(struct uart_port *port, u32 val);
119 void (*set_imr)(struct uart_port *port, u16 val);
120 u8 (*get_mr1)(struct uart_port *port);
133 static u16 mpc52xx_psc_get_status(struct uart_port *port) in mpc52xx_psc_get_status() argument
135 return in_be16(&PSC(port)->mpc52xx_psc_status); in mpc52xx_psc_get_status()
138 static u8 mpc52xx_psc_get_ipcr(struct uart_port *port) in mpc52xx_psc_get_ipcr() argument
140 return in_8(&PSC(port)->mpc52xx_psc_ipcr); in mpc52xx_psc_get_ipcr()
143 static void mpc52xx_psc_command(struct uart_port *port, u8 cmd) in mpc52xx_psc_command() argument
145 out_8(&PSC(port)->command, cmd); in mpc52xx_psc_command()
148 static void mpc52xx_psc_set_mode(struct uart_port *port, u8 mr1, u8 mr2) in mpc52xx_psc_set_mode() argument
150 out_8(&PSC(port)->command, MPC52xx_PSC_SEL_MODE_REG_1); in mpc52xx_psc_set_mode()
151 out_8(&PSC(port)->mode, mr1); in mpc52xx_psc_set_mode()
152 out_8(&PSC(port)->mode, mr2); in mpc52xx_psc_set_mode()
155 static void mpc52xx_psc_set_rts(struct uart_port *port, int state) in mpc52xx_psc_set_rts() argument
158 out_8(&PSC(port)->op1, MPC52xx_PSC_OP_RTS); in mpc52xx_psc_set_rts()
160 out_8(&PSC(port)->op0, MPC52xx_PSC_OP_RTS); in mpc52xx_psc_set_rts()
163 static void mpc52xx_psc_enable_ms(struct uart_port *port) in mpc52xx_psc_enable_ms() argument
165 struct mpc52xx_psc __iomem *psc = PSC(port); in mpc52xx_psc_enable_ms()
172 port->read_status_mask |= MPC52xx_PSC_IMR_IPC; in mpc52xx_psc_enable_ms()
173 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_enable_ms()
176 static void mpc52xx_psc_set_sicr(struct uart_port *port, u32 val) in mpc52xx_psc_set_sicr() argument
178 out_be32(&PSC(port)->sicr, val); in mpc52xx_psc_set_sicr()
181 static void mpc52xx_psc_set_imr(struct uart_port *port, u16 val) in mpc52xx_psc_set_imr() argument
183 out_be16(&PSC(port)->mpc52xx_psc_imr, val); in mpc52xx_psc_set_imr()
186 static u8 mpc52xx_psc_get_mr1(struct uart_port *port) in mpc52xx_psc_get_mr1() argument
188 out_8(&PSC(port)->command, MPC52xx_PSC_SEL_MODE_REG_1); in mpc52xx_psc_get_mr1()
189 return in_8(&PSC(port)->mode); in mpc52xx_psc_get_mr1()
193 #define FIFO_52xx(port) ((struct mpc52xx_psc_fifo __iomem *)(PSC(port)+1)) argument
194 static void mpc52xx_psc_fifo_init(struct uart_port *port) in mpc52xx_psc_fifo_init() argument
196 struct mpc52xx_psc __iomem *psc = PSC(port); in mpc52xx_psc_fifo_init()
197 struct mpc52xx_psc_fifo __iomem *fifo = FIFO_52xx(port); in mpc52xx_psc_fifo_init()
204 port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; in mpc52xx_psc_fifo_init()
205 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_fifo_init()
208 static unsigned int mpc52xx_psc_raw_rx_rdy(struct uart_port *port) in mpc52xx_psc_raw_rx_rdy() argument
210 return in_be16(&PSC(port)->mpc52xx_psc_status) in mpc52xx_psc_raw_rx_rdy()
214 static unsigned int mpc52xx_psc_raw_tx_rdy(struct uart_port *port) in mpc52xx_psc_raw_tx_rdy() argument
216 return in_be16(&PSC(port)->mpc52xx_psc_status) in mpc52xx_psc_raw_tx_rdy()
221 static unsigned int mpc52xx_psc_rx_rdy(struct uart_port *port) in mpc52xx_psc_rx_rdy() argument
223 return in_be16(&PSC(port)->mpc52xx_psc_isr) in mpc52xx_psc_rx_rdy()
224 & port->read_status_mask in mpc52xx_psc_rx_rdy()
228 static unsigned int mpc52xx_psc_tx_rdy(struct uart_port *port) in mpc52xx_psc_tx_rdy() argument
230 return in_be16(&PSC(port)->mpc52xx_psc_isr) in mpc52xx_psc_tx_rdy()
231 & port->read_status_mask in mpc52xx_psc_tx_rdy()
235 static unsigned int mpc52xx_psc_tx_empty(struct uart_port *port) in mpc52xx_psc_tx_empty() argument
237 u16 sts = in_be16(&PSC(port)->mpc52xx_psc_status); in mpc52xx_psc_tx_empty()
242 static void mpc52xx_psc_start_tx(struct uart_port *port) in mpc52xx_psc_start_tx() argument
244 port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; in mpc52xx_psc_start_tx()
245 out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_start_tx()
248 static void mpc52xx_psc_stop_tx(struct uart_port *port) in mpc52xx_psc_stop_tx() argument
250 port->read_status_mask &= ~MPC52xx_PSC_IMR_TXRDY; in mpc52xx_psc_stop_tx()
251 out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_stop_tx()
254 static void mpc52xx_psc_stop_rx(struct uart_port *port) in mpc52xx_psc_stop_rx() argument
256 port->read_status_mask &= ~MPC52xx_PSC_IMR_RXRDY; in mpc52xx_psc_stop_rx()
257 out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_stop_rx()
260 static void mpc52xx_psc_rx_clr_irq(struct uart_port *port) in mpc52xx_psc_rx_clr_irq() argument
264 static void mpc52xx_psc_tx_clr_irq(struct uart_port *port) in mpc52xx_psc_tx_clr_irq() argument
268 static void mpc52xx_psc_write_char(struct uart_port *port, unsigned char c) in mpc52xx_psc_write_char() argument
270 out_8(&PSC(port)->mpc52xx_psc_buffer_8, c); in mpc52xx_psc_write_char()
273 static unsigned char mpc52xx_psc_read_char(struct uart_port *port) in mpc52xx_psc_read_char() argument
275 return in_8(&PSC(port)->mpc52xx_psc_buffer_8); in mpc52xx_psc_read_char()
278 static void mpc52xx_psc_cw_disable_ints(struct uart_port *port) in mpc52xx_psc_cw_disable_ints() argument
280 out_be16(&PSC(port)->mpc52xx_psc_imr, 0); in mpc52xx_psc_cw_disable_ints()
283 static void mpc52xx_psc_cw_restore_ints(struct uart_port *port) in mpc52xx_psc_cw_restore_ints() argument
285 out_be16(&PSC(port)->mpc52xx_psc_imr, port->read_status_mask); in mpc52xx_psc_cw_restore_ints()
288 static unsigned int mpc5200_psc_set_baudrate(struct uart_port *port, in mpc5200_psc_set_baudrate() argument
296 baud = uart_get_baud_rate(port, new, old, in mpc5200_psc_set_baudrate()
297 port->uartclk / (32 * 0xffff) + 1, in mpc5200_psc_set_baudrate()
298 port->uartclk / 32); in mpc5200_psc_set_baudrate()
299 divisor = (port->uartclk + 16 * baud) / (32 * baud); in mpc5200_psc_set_baudrate()
302 mpc52xx_set_divisor(PSC(port), 0xdd00, divisor); in mpc5200_psc_set_baudrate()
306 static unsigned int mpc5200b_psc_set_baudrate(struct uart_port *port, in mpc5200b_psc_set_baudrate() argument
316 baud = uart_get_baud_rate(port, new, old, in mpc5200b_psc_set_baudrate()
317 port->uartclk / (32 * 0xffff) + 1, in mpc5200b_psc_set_baudrate()
318 port->uartclk / 4); in mpc5200b_psc_set_baudrate()
319 divisor = (port->uartclk + 2 * baud) / (4 * baud); in mpc5200b_psc_set_baudrate()
328 mpc52xx_set_divisor(PSC(port), prescaler, divisor); in mpc5200b_psc_set_baudrate()
332 static void mpc52xx_psc_get_irq(struct uart_port *port, struct device_node *np) in mpc52xx_psc_get_irq() argument
334 port->irqflags = 0; in mpc52xx_psc_get_irq()
335 port->irq = irq_of_parse_and_map(np, 0); in mpc52xx_psc_get_irq()
339 static irqreturn_t mpc52xx_psc_handle_irq(struct uart_port *port) in mpc52xx_psc_handle_irq() argument
341 return mpc5xxx_uart_process_int(port); in mpc52xx_psc_handle_irq()
407 #define FIFO_512x(port) ((struct mpc512x_psc_fifo __iomem *)(PSC(port)+1)) argument
422 static void mpc512x_psc_fifo_init(struct uart_port *port) in mpc512x_psc_fifo_init() argument
425 out_be16(&PSC(port)->mpc52xx_psc_clock_select, 0xdd00); in mpc512x_psc_fifo_init()
427 out_be32(&FIFO_512x(port)->txcmd, MPC512x_PSC_FIFO_RESET_SLICE); in mpc512x_psc_fifo_init()
428 out_be32(&FIFO_512x(port)->txcmd, MPC512x_PSC_FIFO_ENABLE_SLICE); in mpc512x_psc_fifo_init()
429 out_be32(&FIFO_512x(port)->txalarm, 1); in mpc512x_psc_fifo_init()
430 out_be32(&FIFO_512x(port)->tximr, 0); in mpc512x_psc_fifo_init()
432 out_be32(&FIFO_512x(port)->rxcmd, MPC512x_PSC_FIFO_RESET_SLICE); in mpc512x_psc_fifo_init()
433 out_be32(&FIFO_512x(port)->rxcmd, MPC512x_PSC_FIFO_ENABLE_SLICE); in mpc512x_psc_fifo_init()
434 out_be32(&FIFO_512x(port)->rxalarm, 1); in mpc512x_psc_fifo_init()
435 out_be32(&FIFO_512x(port)->rximr, 0); in mpc512x_psc_fifo_init()
437 out_be32(&FIFO_512x(port)->tximr, MPC512x_PSC_FIFO_ALARM); in mpc512x_psc_fifo_init()
438 out_be32(&FIFO_512x(port)->rximr, MPC512x_PSC_FIFO_ALARM); in mpc512x_psc_fifo_init()
441 static unsigned int mpc512x_psc_raw_rx_rdy(struct uart_port *port) in mpc512x_psc_raw_rx_rdy() argument
443 return !(in_be32(&FIFO_512x(port)->rxsr) & MPC512x_PSC_FIFO_EMPTY); in mpc512x_psc_raw_rx_rdy()
446 static unsigned int mpc512x_psc_raw_tx_rdy(struct uart_port *port) in mpc512x_psc_raw_tx_rdy() argument
448 return !(in_be32(&FIFO_512x(port)->txsr) & MPC512x_PSC_FIFO_FULL); in mpc512x_psc_raw_tx_rdy()
451 static unsigned int mpc512x_psc_rx_rdy(struct uart_port *port) in mpc512x_psc_rx_rdy() argument
453 return in_be32(&FIFO_512x(port)->rxsr) in mpc512x_psc_rx_rdy()
454 & in_be32(&FIFO_512x(port)->rximr) in mpc512x_psc_rx_rdy()
458 static unsigned int mpc512x_psc_tx_rdy(struct uart_port *port) in mpc512x_psc_tx_rdy() argument
460 return in_be32(&FIFO_512x(port)->txsr) in mpc512x_psc_tx_rdy()
461 & in_be32(&FIFO_512x(port)->tximr) in mpc512x_psc_tx_rdy()
465 static unsigned int mpc512x_psc_tx_empty(struct uart_port *port) in mpc512x_psc_tx_empty() argument
467 return in_be32(&FIFO_512x(port)->txsr) in mpc512x_psc_tx_empty()
471 static void mpc512x_psc_stop_rx(struct uart_port *port) in mpc512x_psc_stop_rx() argument
475 rx_fifo_imr = in_be32(&FIFO_512x(port)->rximr); in mpc512x_psc_stop_rx()
477 out_be32(&FIFO_512x(port)->rximr, rx_fifo_imr); in mpc512x_psc_stop_rx()
480 static void mpc512x_psc_start_tx(struct uart_port *port) in mpc512x_psc_start_tx() argument
484 tx_fifo_imr = in_be32(&FIFO_512x(port)->tximr); in mpc512x_psc_start_tx()
486 out_be32(&FIFO_512x(port)->tximr, tx_fifo_imr); in mpc512x_psc_start_tx()
489 static void mpc512x_psc_stop_tx(struct uart_port *port) in mpc512x_psc_stop_tx() argument
493 tx_fifo_imr = in_be32(&FIFO_512x(port)->tximr); in mpc512x_psc_stop_tx()
495 out_be32(&FIFO_512x(port)->tximr, tx_fifo_imr); in mpc512x_psc_stop_tx()
498 static void mpc512x_psc_rx_clr_irq(struct uart_port *port) in mpc512x_psc_rx_clr_irq() argument
500 out_be32(&FIFO_512x(port)->rxisr, in_be32(&FIFO_512x(port)->rxisr)); in mpc512x_psc_rx_clr_irq()
503 static void mpc512x_psc_tx_clr_irq(struct uart_port *port) in mpc512x_psc_tx_clr_irq() argument
505 out_be32(&FIFO_512x(port)->txisr, in_be32(&FIFO_512x(port)->txisr)); in mpc512x_psc_tx_clr_irq()
508 static void mpc512x_psc_write_char(struct uart_port *port, unsigned char c) in mpc512x_psc_write_char() argument
510 out_8(&FIFO_512x(port)->txdata_8, c); in mpc512x_psc_write_char()
513 static unsigned char mpc512x_psc_read_char(struct uart_port *port) in mpc512x_psc_read_char() argument
515 return in_8(&FIFO_512x(port)->rxdata_8); in mpc512x_psc_read_char()
518 static void mpc512x_psc_cw_disable_ints(struct uart_port *port) in mpc512x_psc_cw_disable_ints() argument
520 port->read_status_mask = in mpc512x_psc_cw_disable_ints()
521 in_be32(&FIFO_512x(port)->tximr) << 16 | in mpc512x_psc_cw_disable_ints()
522 in_be32(&FIFO_512x(port)->rximr); in mpc512x_psc_cw_disable_ints()
523 out_be32(&FIFO_512x(port)->tximr, 0); in mpc512x_psc_cw_disable_ints()
524 out_be32(&FIFO_512x(port)->rximr, 0); in mpc512x_psc_cw_disable_ints()
527 static void mpc512x_psc_cw_restore_ints(struct uart_port *port) in mpc512x_psc_cw_restore_ints() argument
529 out_be32(&FIFO_512x(port)->tximr, in mpc512x_psc_cw_restore_ints()
530 (port->read_status_mask >> 16) & 0x7f); in mpc512x_psc_cw_restore_ints()
531 out_be32(&FIFO_512x(port)->rximr, port->read_status_mask & 0x7f); in mpc512x_psc_cw_restore_ints()
534 static unsigned int mpc512x_psc_set_baudrate(struct uart_port *port, in mpc512x_psc_set_baudrate() argument
555 baud = uart_get_baud_rate(port, new, old, in mpc512x_psc_set_baudrate()
556 port->uartclk / (16 * 0xffff) + 1, in mpc512x_psc_set_baudrate()
557 port->uartclk / 16); in mpc512x_psc_set_baudrate()
558 divisor = (port->uartclk + 8 * baud) / (16 * baud); in mpc512x_psc_set_baudrate()
561 mpc52xx_set_divisor(PSC(port), 0xdd00, divisor); in mpc512x_psc_set_baudrate()
638 static irqreturn_t mpc512x_psc_handle_irq(struct uart_port *port) in mpc512x_psc_handle_irq() argument
647 psc_num = (port->mapbase & 0xf00) >> 8; in mpc512x_psc_handle_irq()
650 return mpc5xxx_uart_process_int(port); in mpc512x_psc_handle_irq()
659 static int mpc512x_psc_alloc_clock(struct uart_port *port) in mpc512x_psc_alloc_clock() argument
665 psc_num = (port->mapbase & 0xf00) >> 8; in mpc512x_psc_alloc_clock()
667 clk = devm_clk_get(port->dev, "mclk"); in mpc512x_psc_alloc_clock()
669 dev_err(port->dev, "Failed to get MCLK!\n"); in mpc512x_psc_alloc_clock()
675 dev_err(port->dev, "Failed to enable MCLK!\n"); in mpc512x_psc_alloc_clock()
680 clk = devm_clk_get(port->dev, "ipg"); in mpc512x_psc_alloc_clock()
682 dev_err(port->dev, "Failed to get IPG clock!\n"); in mpc512x_psc_alloc_clock()
688 dev_err(port->dev, "Failed to enable IPG clock!\n"); in mpc512x_psc_alloc_clock()
708 static void mpc512x_psc_relse_clock(struct uart_port *port) in mpc512x_psc_relse_clock() argument
713 psc_num = (port->mapbase & 0xf00) >> 8; in mpc512x_psc_relse_clock()
726 static int mpc512x_psc_endis_clock(struct uart_port *port, int enable) in mpc512x_psc_endis_clock() argument
732 if (uart_console(port)) in mpc512x_psc_endis_clock()
735 psc_num = (port->mapbase & 0xf00) >> 8; in mpc512x_psc_endis_clock()
738 dev_err(port->dev, "Failed to get PSC clock entry!\n"); in mpc512x_psc_endis_clock()
742 dev_dbg(port->dev, "mclk %sable\n", enable ? "en" : "dis"); in mpc512x_psc_endis_clock()
746 dev_err(port->dev, "Failed to enable MCLK!\n"); in mpc512x_psc_endis_clock()
754 static void mpc512x_psc_get_irq(struct uart_port *port, struct device_node *np) in mpc512x_psc_get_irq() argument
756 port->irqflags = IRQF_SHARED; in mpc512x_psc_get_irq()
757 port->irq = psc_fifoc_irq; in mpc512x_psc_get_irq()
760 #define PSC_5125(port) ((struct mpc5125_psc __iomem *)((port)->membase)) argument
761 #define FIFO_5125(port) ((struct mpc512x_psc_fifo __iomem *)(PSC_5125(port)+1)) argument
763 static void mpc5125_psc_fifo_init(struct uart_port *port) in mpc5125_psc_fifo_init() argument
766 out_8(&PSC_5125(port)->mpc52xx_psc_clock_select, 0xdd); in mpc5125_psc_fifo_init()
768 out_be32(&FIFO_5125(port)->txcmd, MPC512x_PSC_FIFO_RESET_SLICE); in mpc5125_psc_fifo_init()
769 out_be32(&FIFO_5125(port)->txcmd, MPC512x_PSC_FIFO_ENABLE_SLICE); in mpc5125_psc_fifo_init()
770 out_be32(&FIFO_5125(port)->txalarm, 1); in mpc5125_psc_fifo_init()
771 out_be32(&FIFO_5125(port)->tximr, 0); in mpc5125_psc_fifo_init()
773 out_be32(&FIFO_5125(port)->rxcmd, MPC512x_PSC_FIFO_RESET_SLICE); in mpc5125_psc_fifo_init()
774 out_be32(&FIFO_5125(port)->rxcmd, MPC512x_PSC_FIFO_ENABLE_SLICE); in mpc5125_psc_fifo_init()
775 out_be32(&FIFO_5125(port)->rxalarm, 1); in mpc5125_psc_fifo_init()
776 out_be32(&FIFO_5125(port)->rximr, 0); in mpc5125_psc_fifo_init()
778 out_be32(&FIFO_5125(port)->tximr, MPC512x_PSC_FIFO_ALARM); in mpc5125_psc_fifo_init()
779 out_be32(&FIFO_5125(port)->rximr, MPC512x_PSC_FIFO_ALARM); in mpc5125_psc_fifo_init()
782 static unsigned int mpc5125_psc_raw_rx_rdy(struct uart_port *port) in mpc5125_psc_raw_rx_rdy() argument
784 return !(in_be32(&FIFO_5125(port)->rxsr) & MPC512x_PSC_FIFO_EMPTY); in mpc5125_psc_raw_rx_rdy()
787 static unsigned int mpc5125_psc_raw_tx_rdy(struct uart_port *port) in mpc5125_psc_raw_tx_rdy() argument
789 return !(in_be32(&FIFO_5125(port)->txsr) & MPC512x_PSC_FIFO_FULL); in mpc5125_psc_raw_tx_rdy()
792 static unsigned int mpc5125_psc_rx_rdy(struct uart_port *port) in mpc5125_psc_rx_rdy() argument
794 return in_be32(&FIFO_5125(port)->rxsr) & in mpc5125_psc_rx_rdy()
795 in_be32(&FIFO_5125(port)->rximr) & MPC512x_PSC_FIFO_ALARM; in mpc5125_psc_rx_rdy()
798 static unsigned int mpc5125_psc_tx_rdy(struct uart_port *port) in mpc5125_psc_tx_rdy() argument
800 return in_be32(&FIFO_5125(port)->txsr) & in mpc5125_psc_tx_rdy()
801 in_be32(&FIFO_5125(port)->tximr) & MPC512x_PSC_FIFO_ALARM; in mpc5125_psc_tx_rdy()
804 static unsigned int mpc5125_psc_tx_empty(struct uart_port *port) in mpc5125_psc_tx_empty() argument
806 return in_be32(&FIFO_5125(port)->txsr) & MPC512x_PSC_FIFO_EMPTY; in mpc5125_psc_tx_empty()
809 static void mpc5125_psc_stop_rx(struct uart_port *port) in mpc5125_psc_stop_rx() argument
813 rx_fifo_imr = in_be32(&FIFO_5125(port)->rximr); in mpc5125_psc_stop_rx()
815 out_be32(&FIFO_5125(port)->rximr, rx_fifo_imr); in mpc5125_psc_stop_rx()
818 static void mpc5125_psc_start_tx(struct uart_port *port) in mpc5125_psc_start_tx() argument
822 tx_fifo_imr = in_be32(&FIFO_5125(port)->tximr); in mpc5125_psc_start_tx()
824 out_be32(&FIFO_5125(port)->tximr, tx_fifo_imr); in mpc5125_psc_start_tx()
827 static void mpc5125_psc_stop_tx(struct uart_port *port) in mpc5125_psc_stop_tx() argument
831 tx_fifo_imr = in_be32(&FIFO_5125(port)->tximr); in mpc5125_psc_stop_tx()
833 out_be32(&FIFO_5125(port)->tximr, tx_fifo_imr); in mpc5125_psc_stop_tx()
836 static void mpc5125_psc_rx_clr_irq(struct uart_port *port) in mpc5125_psc_rx_clr_irq() argument
838 out_be32(&FIFO_5125(port)->rxisr, in_be32(&FIFO_5125(port)->rxisr)); in mpc5125_psc_rx_clr_irq()
841 static void mpc5125_psc_tx_clr_irq(struct uart_port *port) in mpc5125_psc_tx_clr_irq() argument
843 out_be32(&FIFO_5125(port)->txisr, in_be32(&FIFO_5125(port)->txisr)); in mpc5125_psc_tx_clr_irq()
846 static void mpc5125_psc_write_char(struct uart_port *port, unsigned char c) in mpc5125_psc_write_char() argument
848 out_8(&FIFO_5125(port)->txdata_8, c); in mpc5125_psc_write_char()
851 static unsigned char mpc5125_psc_read_char(struct uart_port *port) in mpc5125_psc_read_char() argument
853 return in_8(&FIFO_5125(port)->rxdata_8); in mpc5125_psc_read_char()
856 static void mpc5125_psc_cw_disable_ints(struct uart_port *port) in mpc5125_psc_cw_disable_ints() argument
858 port->read_status_mask = in mpc5125_psc_cw_disable_ints()
859 in_be32(&FIFO_5125(port)->tximr) << 16 | in mpc5125_psc_cw_disable_ints()
860 in_be32(&FIFO_5125(port)->rximr); in mpc5125_psc_cw_disable_ints()
861 out_be32(&FIFO_5125(port)->tximr, 0); in mpc5125_psc_cw_disable_ints()
862 out_be32(&FIFO_5125(port)->rximr, 0); in mpc5125_psc_cw_disable_ints()
865 static void mpc5125_psc_cw_restore_ints(struct uart_port *port) in mpc5125_psc_cw_restore_ints() argument
867 out_be32(&FIFO_5125(port)->tximr, in mpc5125_psc_cw_restore_ints()
868 (port->read_status_mask >> 16) & 0x7f); in mpc5125_psc_cw_restore_ints()
869 out_be32(&FIFO_5125(port)->rximr, port->read_status_mask & 0x7f); in mpc5125_psc_cw_restore_ints()
881 static unsigned int mpc5125_psc_set_baudrate(struct uart_port *port, in mpc5125_psc_set_baudrate() argument
893 baud = uart_get_baud_rate(port, new, old, in mpc5125_psc_set_baudrate()
894 port->uartclk / (16 * 0xffff) + 1, in mpc5125_psc_set_baudrate()
895 port->uartclk / 16); in mpc5125_psc_set_baudrate()
896 divisor = (port->uartclk + 8 * baud) / (16 * baud); in mpc5125_psc_set_baudrate()
899 mpc5125_set_divisor(PSC_5125(port), 0xdd, divisor); in mpc5125_psc_set_baudrate()
907 static u16 mpc5125_psc_get_status(struct uart_port *port) in mpc5125_psc_get_status() argument
909 return in_be16(&PSC_5125(port)->mpc52xx_psc_status); in mpc5125_psc_get_status()
912 static u8 mpc5125_psc_get_ipcr(struct uart_port *port) in mpc5125_psc_get_ipcr() argument
914 return in_8(&PSC_5125(port)->mpc52xx_psc_ipcr); in mpc5125_psc_get_ipcr()
917 static void mpc5125_psc_command(struct uart_port *port, u8 cmd) in mpc5125_psc_command() argument
919 out_8(&PSC_5125(port)->command, cmd); in mpc5125_psc_command()
922 static void mpc5125_psc_set_mode(struct uart_port *port, u8 mr1, u8 mr2) in mpc5125_psc_set_mode() argument
924 out_8(&PSC_5125(port)->mr1, mr1); in mpc5125_psc_set_mode()
925 out_8(&PSC_5125(port)->mr2, mr2); in mpc5125_psc_set_mode()
928 static void mpc5125_psc_set_rts(struct uart_port *port, int state) in mpc5125_psc_set_rts() argument
931 out_8(&PSC_5125(port)->op1, MPC52xx_PSC_OP_RTS); in mpc5125_psc_set_rts()
933 out_8(&PSC_5125(port)->op0, MPC52xx_PSC_OP_RTS); in mpc5125_psc_set_rts()
936 static void mpc5125_psc_enable_ms(struct uart_port *port) in mpc5125_psc_enable_ms() argument
938 struct mpc5125_psc __iomem *psc = PSC_5125(port); in mpc5125_psc_enable_ms()
945 port->read_status_mask |= MPC52xx_PSC_IMR_IPC; in mpc5125_psc_enable_ms()
946 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); in mpc5125_psc_enable_ms()
949 static void mpc5125_psc_set_sicr(struct uart_port *port, u32 val) in mpc5125_psc_set_sicr() argument
951 out_be32(&PSC_5125(port)->sicr, val); in mpc5125_psc_set_sicr()
954 static void mpc5125_psc_set_imr(struct uart_port *port, u16 val) in mpc5125_psc_set_imr() argument
956 out_be16(&PSC_5125(port)->mpc52xx_psc_imr, val); in mpc5125_psc_set_imr()
959 static u8 mpc5125_psc_get_mr1(struct uart_port *port) in mpc5125_psc_get_mr1() argument
961 return in_8(&PSC_5125(port)->mr1); in mpc5125_psc_get_mr1()
1043 mpc52xx_uart_tx_empty(struct uart_port *port) in mpc52xx_uart_tx_empty() argument
1045 return psc_ops->tx_empty(port) ? TIOCSER_TEMT : 0; in mpc52xx_uart_tx_empty()
1049 mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) in mpc52xx_uart_set_mctrl() argument
1051 psc_ops->set_rts(port, mctrl & TIOCM_RTS); in mpc52xx_uart_set_mctrl()
1055 mpc52xx_uart_get_mctrl(struct uart_port *port) in mpc52xx_uart_get_mctrl() argument
1058 u8 status = psc_ops->get_ipcr(port); in mpc52xx_uart_get_mctrl()
1069 mpc52xx_uart_stop_tx(struct uart_port *port) in mpc52xx_uart_stop_tx() argument
1072 psc_ops->stop_tx(port); in mpc52xx_uart_stop_tx()
1076 mpc52xx_uart_start_tx(struct uart_port *port) in mpc52xx_uart_start_tx() argument
1079 psc_ops->start_tx(port); in mpc52xx_uart_start_tx()
1083 mpc52xx_uart_stop_rx(struct uart_port *port) in mpc52xx_uart_stop_rx() argument
1086 psc_ops->stop_rx(port); in mpc52xx_uart_stop_rx()
1090 mpc52xx_uart_enable_ms(struct uart_port *port) in mpc52xx_uart_enable_ms() argument
1092 psc_ops->enable_ms(port); in mpc52xx_uart_enable_ms()
1096 mpc52xx_uart_break_ctl(struct uart_port *port, int ctl) in mpc52xx_uart_break_ctl() argument
1099 spin_lock_irqsave(&port->lock, flags); in mpc52xx_uart_break_ctl()
1102 psc_ops->command(port, MPC52xx_PSC_START_BRK); in mpc52xx_uart_break_ctl()
1104 psc_ops->command(port, MPC52xx_PSC_STOP_BRK); in mpc52xx_uart_break_ctl()
1106 spin_unlock_irqrestore(&port->lock, flags); in mpc52xx_uart_break_ctl()
1110 mpc52xx_uart_startup(struct uart_port *port) in mpc52xx_uart_startup() argument
1115 ret = psc_ops->clock(port, 1); in mpc52xx_uart_startup()
1121 ret = request_irq(port->irq, mpc52xx_uart_int, in mpc52xx_uart_startup()
1122 port->irqflags, "mpc52xx_psc_uart", port); in mpc52xx_uart_startup()
1127 psc_ops->command(port, MPC52xx_PSC_RST_RX); in mpc52xx_uart_startup()
1128 psc_ops->command(port, MPC52xx_PSC_RST_TX); in mpc52xx_uart_startup()
1137 psc_ops->set_sicr(port, 0); /* UART mode DCD ignored */ in mpc52xx_uart_startup()
1139 psc_ops->fifo_init(port); in mpc52xx_uart_startup()
1141 psc_ops->command(port, MPC52xx_PSC_TX_ENABLE); in mpc52xx_uart_startup()
1142 psc_ops->command(port, MPC52xx_PSC_RX_ENABLE); in mpc52xx_uart_startup()
1148 mpc52xx_uart_shutdown(struct uart_port *port) in mpc52xx_uart_shutdown() argument
1151 psc_ops->command(port, MPC52xx_PSC_RST_RX); in mpc52xx_uart_shutdown()
1152 if (!uart_console(port)) in mpc52xx_uart_shutdown()
1153 psc_ops->command(port, MPC52xx_PSC_RST_TX); in mpc52xx_uart_shutdown()
1155 port->read_status_mask = 0; in mpc52xx_uart_shutdown()
1156 psc_ops->set_imr(port, port->read_status_mask); in mpc52xx_uart_shutdown()
1159 psc_ops->clock(port, 0); in mpc52xx_uart_shutdown()
1162 psc_ops->cw_disable_ints(port); in mpc52xx_uart_shutdown()
1165 free_irq(port->irq, port); in mpc52xx_uart_shutdown()
1169 mpc52xx_uart_set_termios(struct uart_port *port, struct ktermios *new, in mpc52xx_uart_set_termios() argument
1217 spin_lock_irqsave(&port->lock, flags); in mpc52xx_uart_set_termios()
1226 while (!mpc52xx_uart_tx_empty(port) && --j) in mpc52xx_uart_set_termios()
1235 psc_ops->command(port, MPC52xx_PSC_RST_RX); in mpc52xx_uart_set_termios()
1236 psc_ops->command(port, MPC52xx_PSC_RST_TX); in mpc52xx_uart_set_termios()
1239 psc_ops->set_mode(port, mr1, mr2); in mpc52xx_uart_set_termios()
1240 baud = psc_ops->set_baudrate(port, new, old); in mpc52xx_uart_set_termios()
1243 uart_update_timeout(port, new->c_cflag, baud); in mpc52xx_uart_set_termios()
1245 if (UART_ENABLE_MS(port, new->c_cflag)) in mpc52xx_uart_set_termios()
1246 mpc52xx_uart_enable_ms(port); in mpc52xx_uart_set_termios()
1249 psc_ops->command(port, MPC52xx_PSC_TX_ENABLE); in mpc52xx_uart_set_termios()
1250 psc_ops->command(port, MPC52xx_PSC_RX_ENABLE); in mpc52xx_uart_set_termios()
1253 spin_unlock_irqrestore(&port->lock, flags); in mpc52xx_uart_set_termios()
1257 mpc52xx_uart_type(struct uart_port *port) in mpc52xx_uart_type() argument
1263 return port->type == PORT_MPC52xx ? "MPC5xxx PSC" : NULL; in mpc52xx_uart_type()
1267 mpc52xx_uart_release_port(struct uart_port *port) in mpc52xx_uart_release_port() argument
1270 psc_ops->clock_relse(port); in mpc52xx_uart_release_port()
1273 if (port->flags & UPF_IOREMAP) { in mpc52xx_uart_release_port()
1274 iounmap(port->membase); in mpc52xx_uart_release_port()
1275 port->membase = NULL; in mpc52xx_uart_release_port()
1278 release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc)); in mpc52xx_uart_release_port()
1282 mpc52xx_uart_request_port(struct uart_port *port) in mpc52xx_uart_request_port() argument
1286 if (port->flags & UPF_IOREMAP) /* Need to remap ? */ in mpc52xx_uart_request_port()
1287 port->membase = ioremap(port->mapbase, in mpc52xx_uart_request_port()
1290 if (!port->membase) in mpc52xx_uart_request_port()
1293 err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc), in mpc52xx_uart_request_port()
1300 err = psc_ops->clock_alloc(port); in mpc52xx_uart_request_port()
1308 release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc)); in mpc52xx_uart_request_port()
1310 if (port->flags & UPF_IOREMAP) { in mpc52xx_uart_request_port()
1311 iounmap(port->membase); in mpc52xx_uart_request_port()
1312 port->membase = NULL; in mpc52xx_uart_request_port()
1318 mpc52xx_uart_config_port(struct uart_port *port, int flags) in mpc52xx_uart_config_port() argument
1321 && (mpc52xx_uart_request_port(port) == 0)) in mpc52xx_uart_config_port()
1322 port->type = PORT_MPC52xx; in mpc52xx_uart_config_port()
1326 mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser) in mpc52xx_uart_verify_port() argument
1331 if ((ser->irq != port->irq) || in mpc52xx_uart_verify_port()
1333 (ser->baud_base != port->uartclk) || in mpc52xx_uart_verify_port()
1334 (ser->iomem_base != (void *)port->mapbase) || in mpc52xx_uart_verify_port()
1368 mpc52xx_uart_int_rx_chars(struct uart_port *port) in mpc52xx_uart_int_rx_chars() argument
1370 struct tty_port *tport = &port->state->port; in mpc52xx_uart_int_rx_chars()
1375 while (psc_ops->raw_rx_rdy(port)) { in mpc52xx_uart_int_rx_chars()
1377 ch = psc_ops->read_char(port); in mpc52xx_uart_int_rx_chars()
1380 if (uart_handle_sysrq_char(port, ch)) in mpc52xx_uart_int_rx_chars()
1386 port->icount.rx++; in mpc52xx_uart_int_rx_chars()
1388 status = psc_ops->get_status(port); in mpc52xx_uart_int_rx_chars()
1396 uart_handle_break(port); in mpc52xx_uart_int_rx_chars()
1397 port->icount.brk++; in mpc52xx_uart_int_rx_chars()
1400 port->icount.parity++; in mpc52xx_uart_int_rx_chars()
1404 port->icount.frame++; in mpc52xx_uart_int_rx_chars()
1408 psc_ops->command(port, MPC52xx_PSC_RST_ERR_STAT); in mpc52xx_uart_int_rx_chars()
1419 port->icount.overrun++; in mpc52xx_uart_int_rx_chars()
1425 return psc_ops->raw_rx_rdy(port); in mpc52xx_uart_int_rx_chars()
1429 mpc52xx_uart_int_tx_chars(struct uart_port *port) in mpc52xx_uart_int_tx_chars() argument
1433 return uart_port_tx(port, ch, in mpc52xx_uart_int_tx_chars()
1434 psc_ops->raw_tx_rdy(port), in mpc52xx_uart_int_tx_chars()
1435 psc_ops->write_char(port, ch)); in mpc52xx_uart_int_tx_chars()
1439 mpc5xxx_uart_process_int(struct uart_port *port) in mpc5xxx_uart_process_int() argument
1450 psc_ops->rx_clr_irq(port); in mpc5xxx_uart_process_int()
1451 if (psc_ops->rx_rdy(port)) in mpc5xxx_uart_process_int()
1452 keepgoing |= mpc52xx_uart_int_rx_chars(port); in mpc5xxx_uart_process_int()
1454 psc_ops->tx_clr_irq(port); in mpc5xxx_uart_process_int()
1455 if (psc_ops->tx_rdy(port)) in mpc5xxx_uart_process_int()
1456 keepgoing |= mpc52xx_uart_int_tx_chars(port); in mpc5xxx_uart_process_int()
1458 status = psc_ops->get_ipcr(port); in mpc5xxx_uart_process_int()
1460 uart_handle_dcd_change(port, !(status & MPC52xx_PSC_DCD)); in mpc5xxx_uart_process_int()
1463 uart_handle_cts_change(port, !(status & MPC52xx_PSC_CTS)); in mpc5xxx_uart_process_int()
1477 struct uart_port *port = dev_id; in mpc52xx_uart_int() local
1480 spin_lock(&port->lock); in mpc52xx_uart_int()
1482 ret = psc_ops->handle_irq(port); in mpc52xx_uart_int()
1484 spin_unlock(&port->lock); in mpc52xx_uart_int()
1496 mpc52xx_console_get_options(struct uart_port *port, in mpc52xx_console_get_options() argument
1501 pr_debug("mpc52xx_console_get_options(port=%p)\n", port); in mpc52xx_console_get_options()
1504 mr1 = psc_ops->get_mr1(port); in mpc52xx_console_get_options()
1534 struct uart_port *port = &mpc52xx_uart_ports[co->index]; in mpc52xx_console_write() local
1538 psc_ops->cw_disable_ints(port); in mpc52xx_console_write()
1542 while (!mpc52xx_uart_tx_empty(port) && --j) in mpc52xx_console_write()
1549 psc_ops->write_char(port, '\r'); in mpc52xx_console_write()
1552 psc_ops->write_char(port, *s); in mpc52xx_console_write()
1556 while (!mpc52xx_uart_tx_empty(port) && --j) in mpc52xx_console_write()
1561 psc_ops->cw_restore_ints(port); in mpc52xx_console_write()
1568 struct uart_port *port = &mpc52xx_uart_ports[co->index]; in mpc52xx_console_setup() local
1610 spin_lock_init(&port->lock); in mpc52xx_console_setup()
1611 port->uartclk = uartclk; in mpc52xx_console_setup()
1612 port->ops = &mpc52xx_uart_ops; in mpc52xx_console_setup()
1613 port->mapbase = res.start; in mpc52xx_console_setup()
1614 port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc)); in mpc52xx_console_setup()
1615 port->irq = irq_of_parse_and_map(np, 0); in mpc52xx_console_setup()
1617 if (port->membase == NULL) in mpc52xx_console_setup()
1621 (void *)port->mapbase, port->membase, in mpc52xx_console_setup()
1622 port->irq, port->uartclk); in mpc52xx_console_setup()
1628 mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); in mpc52xx_console_setup()
1633 return uart_set_options(port, co, baud, parity, bits, flow); in mpc52xx_console_setup()
1703 struct uart_port *port = NULL; in mpc52xx_uart_of_probe() local
1726 port = &mpc52xx_uart_ports[idx]; in mpc52xx_uart_of_probe()
1728 spin_lock_init(&port->lock); in mpc52xx_uart_of_probe()
1729 port->uartclk = uartclk; in mpc52xx_uart_of_probe()
1730 port->fifosize = 512; in mpc52xx_uart_of_probe()
1731 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MPC52xx_CONSOLE); in mpc52xx_uart_of_probe()
1732 port->iotype = UPIO_MEM; in mpc52xx_uart_of_probe()
1733 port->flags = UPF_BOOT_AUTOCONF | in mpc52xx_uart_of_probe()
1734 (uart_console(port) ? 0 : UPF_IOREMAP); in mpc52xx_uart_of_probe()
1735 port->line = idx; in mpc52xx_uart_of_probe()
1736 port->ops = &mpc52xx_uart_ops; in mpc52xx_uart_of_probe()
1737 port->dev = &op->dev; in mpc52xx_uart_of_probe()
1744 port->mapbase = res.start; in mpc52xx_uart_of_probe()
1745 if (!port->mapbase) { in mpc52xx_uart_of_probe()
1750 psc_ops->get_irq(port, op->dev.of_node); in mpc52xx_uart_of_probe()
1751 if (port->irq == 0) { in mpc52xx_uart_of_probe()
1757 (void *)port->mapbase, port->irq, port->uartclk); in mpc52xx_uart_of_probe()
1760 ret = uart_add_one_port(&mpc52xx_uart_driver, port); in mpc52xx_uart_of_probe()
1764 platform_set_drvdata(op, (void *)port); in mpc52xx_uart_of_probe()
1771 struct uart_port *port = platform_get_drvdata(op); in mpc52xx_uart_of_remove() local
1773 if (port) in mpc52xx_uart_of_remove()
1774 uart_remove_one_port(&mpc52xx_uart_driver, port); in mpc52xx_uart_of_remove()
1783 struct uart_port *port = platform_get_drvdata(op); in mpc52xx_uart_of_suspend() local
1785 if (port) in mpc52xx_uart_of_suspend()
1786 uart_suspend_port(&mpc52xx_uart_driver, port); in mpc52xx_uart_of_suspend()
1794 struct uart_port *port = platform_get_drvdata(op); in mpc52xx_uart_of_resume() local
1796 if (port) in mpc52xx_uart_of_resume()
1797 uart_resume_port(&mpc52xx_uart_driver, port); in mpc52xx_uart_of_resume()