2009-08-25 07:38:31     BF-548 wakeup on UART activities

Document created by Aaronwu Employee on Aug 18, 2013Last modified by Aaronwu Employee on Aug 18, 2013
Version 2Show Document
  • View in full screen mode

2009-08-25 07:38:31     BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79169   

 

Hello!

 

I have problems with wakeup on UART activities from standby (sleep) mode.

I will try to explain our situation.

Our device must wake up on any incoming data on the port UART3.

 

I have attached my kernel config file.

 

That is some parts of the config about power management and uart options.

 

#

# Power management options

#

CONFIG_PM=y

CONFIG_PM_DEBUG=y

CONFIG_PM_VERBOSE=y

CONFIG_CAN_PM_TRACE=y

CONFIG_PM_SLEEP=y

CONFIG_SUSPEND=y

# CONFIG_PM_TEST_SUSPEND is not set

CONFIG_SUSPEND_FREEZER=y

CONFIG_ARCH_SUSPEND_POSSIBLE=y

# CONFIG_PM_BFIN_SLEEP_DEEPER is not set

CONFIG_PM_BFIN_SLEEP=y

 

....

 

#

# Serial drivers

#

# CONFIG_SERIAL_8250 is not set

 

#

# Non-8250 serial port support

#

CONFIG_SERIAL_BFIN=y

CONFIG_SERIAL_BFIN_CONSOLE=y

CONFIG_SERIAL_BFIN_DMA=y

# CONFIG_SERIAL_BFIN_PIO is not set

CONFIG_SERIAL_BFIN_UART0=y

# CONFIG_BFIN_UART0_CTSRTS is not set

CONFIG_SERIAL_BFIN_UART1=y

# CONFIG_BFIN_UART1_CTSRTS is not set

CONFIG_SERIAL_BFIN_UART2=y

# CONFIG_BFIN_UART2_CTSRTS is not set

CONFIG_SERIAL_BFIN_UART3=y

# CONFIG_BFIN_UART3_CTSRTS is not set

CONFIG_SERIAL_CORE=y

CONFIG_SERIAL_CORE_CONSOLE=y

# CONFIG_SERIAL_BFIN_SPORT is not set

CONFIG_UNIX98_PTYS=y

# CONFIG_LEGACY_PTYS is not set

# CONFIG_BFIN_OTP is not set

 

I have read   docs.blackfin.uclinux.org/doku.php?id=power_management_support#cause_wakeup_event_by_interrupt

and added following code to my custom driver:

 

/// in the module_init section

ret = request_irq(IRQ_UART3_RX, unsleep_sof, IRQF_TRIGGER_FALLING, DRV_NAME, NULL);

if ( ret ) {

     printk("Can't register IRQ handler\n");

     return ret;

}

 

enable_irq_wake(IRQ_UART3_RX);

 

static irqreturn_t unsleep_sof(int irq, void *dev_id)

{

     return IRQ_HANDLED;

}

 

But the blackfin doesn't perform wakeup.

 

I have tried to wake up by GPIO (IRQ_PD15) by same way and it is working fine.

 

Do you have any ideas how to fix this problem?

 

Log of the standby is following:

root:/> echo standby > /sys/power/state

PM: Syncing filesystems ... done.

PM: Preparing system for standby sleep

Freezing user space processes ... (elapsed 0.00 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.

PM: Entering standby sleep

Suspending console(s) (use no_console_suspend to debug)

 

My configuration is following:

Processor: BF-548 B-0.2

Linux kernel: svn revision 6259

uclinux-dist: 2008R1.5-RC3

toolchains: 08r1.5-14

 

I can provide more information if you need.

 

Best regards,

Vladimir Davydov

 

config.bf548

QuoteReplyEditDelete

 

 

2009-08-25 08:08:46     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79170    I'm sorry for bad formatting. Is it a problem of my browser or forum engine? In first case I can repost message.

QuoteReplyEditDelete

 

 

2009-08-25 08:29:44     Re: BF-548 wakeup on UART activities

Mike Frysinger (UNITED STATES)

Message: 79181   

 

ive fixed the formatting for you

 

are you using opera ?  it's known to be broken

QuoteReplyEditDelete

 

 

2009-08-25 08:30:42     Re: BF-548 wakeup on UART activities

Mike Frysinger (UNITED STATES)

Message: 79182   

 

what do you mean "custom driver" ?  there is a Blackfin serial driver already that should handle all of the irqs and wake up stuff.  you shouldnt be requesting irqs outside of it.

QuoteReplyEditDelete

 

 

2009-08-25 08:45:05     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79183    I'm using kunqueror and opera. The behaviour is the same. What browser do you suggest for linux?

QuoteReplyEditDelete

 

 

2009-08-25 08:50:29     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79184    "Custom driver" is my driver for device specific hardware. You are right, that is bad practic to put this code to my driver. But where should I put enable_irq_wake() call?

QuoteReplyEditDelete

 

 

2009-08-25 08:53:40     Re: BF-548 wakeup on UART activities

Michael Hennerich (GERMANY)

Message: 79185    I'm using Mozilla Firefox

QuoteReplyEditDelete

 

 

2009-08-25 09:01:42     Re: BF-548 wakeup on UART activities

Mike Frysinger (UNITED STATES)

Message: 79186   

 

reading the serial code indicates that it already calls enable_irq_wake() when needed

 

did you enable things in userspace via sysfs like the documentation said to ?

QuoteReplyEditDelete

 

 

2009-08-25 09:17:02     Re: BF-548 wakeup on UART activities

Michael Hennerich (GERMANY)

Message: 79188    > Mike,

 

I tried it here - and it seems to fail...

 

root:/> echo enabled > /sys/class/tty/ttyBF0/power/wakeup

root:/> echo standby > /sys/power/state

PM: Syncing filesystems ... done.

Freezing user space processes ... (elapsed 0.00 seconds) done.

Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done.

Suspending console(s) (use no_console_suspend to debug)

 

No wakeup upon serial traffic

QuoteReplyEditDelete

 

 

2009-08-25 09:21:34     Re: BF-548 wakeup on UART activities

Mike Frysinger (UNITED STATES)

Message: 79189   

 

the code looks correct to me, but i only glanced over things quickly.  i guess open a tracker for sonic or you to look at ;).

QuoteReplyEditDelete

 

 

2009-08-25 09:38:00     Re: BF-548 wakeup on UART activities

Michael Hennerich (GERMANY)

Message: 79191    Mike,

 

The problem is most likely in the UART serial driver, so Sonic should

take a look.

 

-Michael

QuoteReplyEditDelete

 

 

2009-08-25 10:56:03     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79201   

 

reading the serial code indicates that it already calls enable_irq_wake() when needed

 

did you enable things in userspace via sysfs like the documentation said to ?

 

---

 

Thank you for advice! I didn't know about it.

 

I have checked it and wakeup doesn't work.

 

I have tried to debug the code of serial, it properly calls enable_irq_wake() with IRQ_UARTx_RX values when the driver goes to standby state.

 

I have tested on following serials: UART1, UART3.

QuoteReplyEditDelete

 

 

2009-08-26 04:07:17     Re: BF-548 wakeup on UART activities

Sonic Zhang (CHINA)

Message: 79223   

 

In PIO mode, keep inputing ramdom chars by 2 hands in the console as faster as possible. It will wake up sometime later.

 

But, in DMA mode, no such luck.

 

Very strange behavior.

QuoteReplyEditDelete

 

 

2009-08-26 04:37:00     Re: BF-548 wakeup on UART activities

Michael Hennerich (GERMANY)

Message: 79226    Vladimir,

 

Try Standby Power Saving Mode (Sleep) with Serial Driver in PIO mode.

This should work.

 

Some details:

 

A wake from suspend standby is triggered by an UART Interrupt.

Before going into standby we enable the corresponding bit in the SIC_IWR

registers.

 

There are two different cases you need to take into considerations:

 

1) Standby Power Saving Mode (Sleep)

This mode works immediately in UART PIO mode, and in DMA mode when the

DMA interrupt triggers.

This is typically the case when DMA count expires. So you have to enter

more than one char.

SCLK continues to operate with the standard frequency.

 

 

2) Standby Power Saving Mode (Sleep Deeper)

In this mode we set SCLK to a minimum of approx 3.3MHz - this means that

the UART won't receive chars at the default BAUD rate. So when using

wakeups from peripherals that require precise SLCK timings Standby Power

Saving Mode (Sleep) is the option of choice.

 

-Michael

QuoteReplyEditDelete

 

 

2009-08-27 00:32:19     Re: BF-548 wakeup on UART activities

Sonic Zhang (CHINA)

Message: 79265   

 

Because the sclk in sleep_deep mode is only 3.3MHz. UART clocks can't be generated accurately by UART divisor. You will get malformed data over uart in this sclk. So, don't try to wake up from serial in sleep_deep mode.

QuoteReplyEditDelete

 

 

2009-08-27 11:11:48     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79306   

 

In PIO mode, keep inputing ramdom chars by 2 hands in the console as faster as possible. It will wake up sometime later.

 

But, in DMA mode, no such luck.

 

Very strange behavior.

 

---zc

 

Thank you Sonic!

 

It is working in PIO mode. I think, that DMA mode on uarts is not a critical feature for our device.

 

Is it possible to change the mode from DMA to PIO in the suspend callback of the serial driver? How do you think?

 

It can be unbad workaround.

 

With best regards,

 

Vladimir.

QuoteReplyEditDelete

 

 

2009-08-27 12:23:24     Re: BF-548 wakeup on UART activities

Vladimir Davydov (BELARUS)

Message: 79310   

 

Michael,

 

Thank you for your explanations.

 

I read about SIC_IWR. I have tried to enter a lot of chars in DMA mode and it was not working.

 

 

 

Vladimir.

QuoteReplyEditDelete

 

 

2009-08-27 23:56:15     Re: BF-548 wakeup on UART activities

Sonic Zhang (CHINA)

Message: 79334   

 

I don't think we have this plan to switch DMA to PIO in sleep mode.

Attachments

Outcomes