@@ -216,6 +216,18 @@ static void pmz_maybe_update_regs(struct uart_pmac_port *uap)
216216 }
217217}
218218
219+ static void pmz_interrupt_control (struct uart_pmac_port * uap , int enable )
220+ {
221+ if (enable ) {
222+ uap -> curregs [1 ] |= INT_ALL_Rx | TxINT_ENAB ;
223+ if (!ZS_IS_EXTCLK (uap ))
224+ uap -> curregs [1 ] |= EXT_INT_ENAB ;
225+ } else {
226+ uap -> curregs [1 ] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK );
227+ }
228+ write_zsreg (uap , R1 , uap -> curregs [1 ]);
229+ }
230+
219231static struct tty_struct * pmz_receive_chars (struct uart_pmac_port * uap )
220232{
221233 struct tty_struct * tty = NULL ;
@@ -339,9 +351,7 @@ static struct tty_struct *pmz_receive_chars(struct uart_pmac_port *uap)
339351
340352 return tty ;
341353 flood :
342- uap -> curregs [R1 ] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK );
343- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
344- zssync (uap );
354+ pmz_interrupt_control (uap , 0 );
345355 pmz_error ("pmz: rx irq flood !\n" );
346356 return tty ;
347357}
@@ -990,12 +1000,9 @@ static int pmz_startup(struct uart_port *port)
9901000 if (ZS_IS_IRDA (uap ))
9911001 pmz_irda_reset (uap );
9921002
993- /* Enable interrupts emission from the chip */
1003+ /* Enable interrupt requests for the channel */
9941004 spin_lock_irqsave (& port -> lock , flags );
995- uap -> curregs [R1 ] |= INT_ALL_Rx | TxINT_ENAB ;
996- if (!ZS_IS_EXTCLK (uap ))
997- uap -> curregs [R1 ] |= EXT_INT_ENAB ;
998- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
1005+ pmz_interrupt_control (uap , 1 );
9991006 spin_unlock_irqrestore (& port -> lock , flags );
10001007
10011008 pmz_debug ("pmz: startup() done.\n" );
@@ -1015,6 +1022,25 @@ static void pmz_shutdown(struct uart_port *port)
10151022
10161023 mutex_lock (& pmz_irq_mutex );
10171024
1025+ spin_lock_irqsave (& port -> lock , flags );
1026+
1027+ if (!ZS_IS_ASLEEP (uap )) {
1028+ /* Disable interrupt requests for the channel */
1029+ pmz_interrupt_control (uap , 0 );
1030+
1031+ if (!ZS_IS_CONS (uap )) {
1032+ /* Disable receiver and transmitter */
1033+ uap -> curregs [R3 ] &= ~RxENABLE ;
1034+ uap -> curregs [R5 ] &= ~TxENABLE ;
1035+
1036+ /* Disable break assertion */
1037+ uap -> curregs [R5 ] &= ~SND_BRK ;
1038+ pmz_maybe_update_regs (uap );
1039+ }
1040+ }
1041+
1042+ spin_unlock_irqrestore (& port -> lock , flags );
1043+
10181044 /* Release interrupt handler */
10191045 free_irq (uap -> port .irq , uap );
10201046
@@ -1025,29 +1051,8 @@ static void pmz_shutdown(struct uart_port *port)
10251051 if (!ZS_IS_OPEN (uap -> mate ))
10261052 pmz_get_port_A (uap )-> flags &= ~PMACZILOG_FLAG_IS_IRQ_ON ;
10271053
1028- /* Disable interrupts */
1029- if (!ZS_IS_ASLEEP (uap )) {
1030- uap -> curregs [R1 ] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK );
1031- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
1032- zssync (uap );
1033- }
1034-
1035- if (ZS_IS_CONS (uap ) || ZS_IS_ASLEEP (uap )) {
1036- spin_unlock_irqrestore (& port -> lock , flags );
1037- mutex_unlock (& pmz_irq_mutex );
1038- return ;
1039- }
1040-
1041- /* Disable receiver and transmitter. */
1042- uap -> curregs [R3 ] &= ~RxENABLE ;
1043- uap -> curregs [R5 ] &= ~TxENABLE ;
1044-
1045- /* Disable all interrupts and BRK assertion. */
1046- uap -> curregs [R5 ] &= ~SND_BRK ;
1047- pmz_maybe_update_regs (uap );
1048-
1049- /* Shut the chip down */
1050- pmz_set_scc_power (uap , 0 );
1054+ if (!ZS_IS_ASLEEP (uap ) && !ZS_IS_CONS (uap ))
1055+ pmz_set_scc_power (uap , 0 ); /* Shut the chip down */
10511056
10521057 spin_unlock_irqrestore (& port -> lock , flags );
10531058
@@ -1352,19 +1357,15 @@ static void pmz_set_termios(struct uart_port *port, struct ktermios *termios,
13521357 spin_lock_irqsave (& port -> lock , flags );
13531358
13541359 /* Disable IRQs on the port */
1355- uap -> curregs [R1 ] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK );
1356- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
1360+ pmz_interrupt_control (uap , 0 );
13571361
13581362 /* Setup new port configuration */
13591363 __pmz_set_termios (port , termios , old );
13601364
13611365 /* Re-enable IRQs on the port */
1362- if (ZS_IS_OPEN (uap )) {
1363- uap -> curregs [R1 ] |= INT_ALL_Rx | TxINT_ENAB ;
1364- if (!ZS_IS_EXTCLK (uap ))
1365- uap -> curregs [R1 ] |= EXT_INT_ENAB ;
1366- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
1367- }
1366+ if (ZS_IS_OPEN (uap ))
1367+ pmz_interrupt_control (uap , 1 );
1368+
13681369 spin_unlock_irqrestore (& port -> lock , flags );
13691370}
13701371
@@ -1671,14 +1672,17 @@ static int pmz_suspend(struct macio_dev *mdev, pm_message_t pm_state)
16711672 spin_lock_irqsave (& uap -> port .lock , flags );
16721673
16731674 if (ZS_IS_OPEN (uap ) || ZS_IS_CONS (uap )) {
1674- /* Disable receiver and transmitter. */
1675+ /* Disable interrupt requests for the channel */
1676+ pmz_interrupt_control (uap , 0 );
1677+
1678+ /* Disable receiver and transmitter */
16751679 uap -> curregs [R3 ] &= ~RxENABLE ;
16761680 uap -> curregs [R5 ] &= ~TxENABLE ;
16771681
1678- /* Disable all interrupts and BRK assertion. */
1679- uap -> curregs [R1 ] &= ~(EXT_INT_ENAB | TxINT_ENAB | RxINT_MASK );
1682+ /* Disable break assertion */
16801683 uap -> curregs [R5 ] &= ~SND_BRK ;
16811684 pmz_load_zsregs (uap , uap -> curregs );
1685+
16821686 uap -> flags |= PMACZILOG_FLAG_IS_ASLEEP ;
16831687 mb ();
16841688 }
@@ -1738,14 +1742,6 @@ static int pmz_resume(struct macio_dev *mdev)
17381742 /* Take care of config that may have changed while asleep */
17391743 __pmz_set_termios (& uap -> port , & uap -> termios_cache , NULL );
17401744
1741- if (ZS_IS_OPEN (uap )) {
1742- /* Enable interrupts */
1743- uap -> curregs [R1 ] |= INT_ALL_Rx | TxINT_ENAB ;
1744- if (!ZS_IS_EXTCLK (uap ))
1745- uap -> curregs [R1 ] |= EXT_INT_ENAB ;
1746- write_zsreg (uap , R1 , uap -> curregs [R1 ]);
1747- }
1748-
17491745 spin_unlock_irqrestore (& uap -> port .lock , flags );
17501746
17511747 if (ZS_IS_CONS (uap ))
@@ -1757,6 +1753,12 @@ static int pmz_resume(struct macio_dev *mdev)
17571753 enable_irq (uap -> port .irq );
17581754 }
17591755
1756+ if (ZS_IS_OPEN (uap )) {
1757+ spin_lock_irqsave (& uap -> port .lock , flags );
1758+ pmz_interrupt_control (uap , 1 );
1759+ spin_unlock_irqrestore (& uap -> port .lock , flags );
1760+ }
1761+
17601762 bail :
17611763 mutex_unlock (& state -> port .mutex );
17621764 mutex_unlock (& pmz_irq_mutex );
0 commit comments