pl011: added clock management feature
PATCH 1/1 pl011: added clock management feature
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using set_termios callback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
---
This patch depends on the DMA support, just because it's adjacent in the file in some functions. If it's desired to have them in the reverse order, this can be arranged for.
Maybe this shouldn't even be an optional Kconfig option, something like this should be expected when you set the baud rate to zero really. Comments welcome.
--- drivers/serial/Kconfig | 9 ++ drivers/serial/amba-pl011.c | 183 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 189 insertions(+), 3 deletions(-)
drivers/serial/Kconfig +9 -0
@@ -323,6 +323,15 @@ config SERIAL_AMBA_PL011_CONSOLE your boot loader (lilo or loadlin) about how to pass options to the kernel at boot time.) +config SERIAL_AMBA_PL011_CLOCK_CONTROL + bool "Support for clock control on AMBA serial port" + depends on SERIAL_AMBA_PL011 + select CONSOLE_POLL + ---help--- + Say Y here if you wish to use amba set_termios function to control + the pl011 clock. Any positive baudrate passed enables clock, + otherwise disables (baudrate = B0 -> hangup) + config SERIAL_SB1250_DUART tristate "BCM1xxx on-chip DUART serial support" depends on SIBYTE_SB1xxx_SOC=y
drivers/serial/amba-pl011.c +180 -3
243 lines not on this page · raw message
Signature · 1 line
1.6.3.3
PATCH 1/1 pl011: added clock management feature
Quoted 6 lines · Linus Walleij
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
Why not just close the port to save power - the clock in that case will automatically be turned off.
It's not like the port can be used without the baud rate correctly set - or indeed characters transmitted or received without the clock running. So all the time that the clock is disabled, the port is inoperable.
If you want to maintain the modem control line settings while the port is closed, why not clear the HUPCL termios flag?
PATCH 1/1 pl011: added clock management feature
In reply to Linus WalleijQuoted 6 lines · Linus Walleij
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. Why not just power down ports that are not open instead?
thanks,
greg k-h
PATCH 1/1 pl011: added clock management feature
Quoted 11 lines · Greg KH
Quoted 6 lines · Linus Walleij
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. Why not just power down ports that are not open instead?
We already do. My question to Linus (in a previous message) is why this isn't sufficient.
PATCH 1/1 pl011: added clock management feature
Quoted 9 lines · Greg KH
Quoted 8 lines · Linus Walleij
Quoted 6 lines
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
Quoted 5 lines
Quoted 3 lines
That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. Why not just power down ports that are not open instead?
We already do. My question to Linus (in a previous message) is why this isn't sufficient.
The main goal was to disable/enable clock while port open. This is usefull for scenario, where some higher level driver wants to control the power consumption (using set_termios). In the same time a user-space app (eg. hciattach) is still bounded to the specific /dev/tty* device associated with particular uart. From user POV device is always open, and app does not have to respawn, and we can save power.
I hope it's clear explanation.
PATCH 1/1 pl011: added clock management feature
In reply to Russell King - ARM LinuxQuoted 9 lines · Greg KH
Quoted 8 lines · Linus Walleij
Quoted 6 lines
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
Quoted 5 lines
Quoted 3 lines
That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. Why not just power down ports that are not open instead?
We already do. My question to Linus (in a previous message) is why this isn't sufficient.
The main goal was to disable/enable clock while port open. This is usefull for scenario, where some higher level driver wants to control the power consumption (using set_termios). In the same time a user-space app (eg. hciattach) is still bounded to the specific /dev/tty* device associated with particular uart. From user POV device is always open, and app does not have to respawn, and we can save power.
I hope it's clear explanation.
PATCH 1/1 pl011: added clock management feature
Quoted 15 lines · On Wed, Nov 10, 2010 at 10:15:53AM +0200, [email protected] wrote:
Quoted 9 lines · Greg KH
Quoted 8 lines · Linus Walleij
Quoted 6 lines
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.Quoted 5 lines
Quoted 3 lines
That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. Why not just power down ports that are not open instead?
We already do. My question to Linus (in a previous message) is why this isn't sufficient.
Quoted 7 lines
The main goal was to disable/enable clock while port open. This is usefull for scenario, where some higher level driver wants to control the power consumption (using
set_termios). In the same time a user-space app (eg. hciattach) is still bounded to the specific/dev/tty*device associated with particular uart. From user POV device is always open, and app does not have to respawn, and we can save power.
That is nice, but again, you are overloading a common interface (one defined by POSIX I think) to do something else at the same time. That might cause problems with some users that expect you to be able to use a baud rate of 0 :)
I like the idea, but not the overloading, sorry.
thanks,
greg k-h
PATCH 1/1 pl011: added clock management feature
In reply to Grzegorz.Sygieda at tieto.comQuoted 6 lines · Grzegorz.Sygieda at tieto.com
The main goal was to disable/enable clock while port open. This is usefull for scenario, where some higher level driver wants to control the power consumption (using
set_termios). In the same time a user-space app (eg. hciattach) is still bounded to the specific/dev/tty*device associated with particular uart. From user POV device is always open, and app does not have to respawn, and we can save power.
If a port is open, and bound (eg to a bluetooth hci), how does the higher level decide whether to place the port in low power mode? How does it know that there isn't going to be characters sent to the port?
When the port is in this low power mode, it's as good as closed from the external world point of view.
I don't like this idea because I really can't see how it could be used effectively - there isn't really any way for a bound protocol to know whether there's characters expected to be received or not. Either the port is open and in use, or it isn't.
Let's take an example of a modem waiting for an incoming call. It spends most of its time waiting for the call. You could argue that you could shut the clock off to the port to save power - but then how do you receive the "RING" message from the modem? As you've shut the clock off, you're not going to detect the activity on the receive line.
I'm sure that also applies to bluetooth as well, especially if you're a 'client' device - as long as the port is attached, bluetooth probably expects to be able to listen to what's going on so the device can be discovered.
It's all very well adding hooks to the transmit path to ensure that there clock is on while there's characters to be sent, but this really doesn't help you on the receive side.
I'm worried...
PATCH 1/1 pl011: added clock management feature
Quoted 6 lines
If a port is open, and bound (eg to a bluetooth hci), how does the higher level decide whether to place the port in low power mode? How does it know that there isn't going to be > >characters sent to the port?
When the port is in this low power mode, it's as good as closed from the external world point of view.
I don't like this idea because I really can't see how it could be used effectively - there isn't really any way for a bound protocol to know whether there's characters expected to be received > or not. Either the port is open and in use, or it isn't.
Quoted 7 lines
Let's take an example of a modem waiting for an incoming call. It spends most of its time waiting for the call. You could argue that you could shut the clock off to the port to save > power - but then how do you receive the "RING" message from the modem? As you've shut the clock off, you're not going to detect the activity on the receive line.
I'm sure that also applies to bluetooth as well, especially if you're a 'client' device - as long as the port is attached, bluetooth probably expects to be able to listen to what's going on so >the device can be discovered.
It's all very well adding hooks to the transmit path to ensure that there clock is on while there's characters to be sent, but this really doesn't help you on the receive side.
I'm worried...
We have chip which acts (is registred) as platform_device, and have knowledge about its status through GPIO, (eg. Wake-up line), as well as it can control low power mode. This driver registers to hci discipline, thus gives posibliity to invoke tty functions, including set_termios. And this is what we are actualy doing. We think that this is best way to keep clock control without closing the uart.
We don't think, if it possible to shutdown and then startup the uart port completly, from the chip's driver level.
Correct us if We're wrong.
PATCH 1/1 pl011: added clock management feature
In reply to Greg KHQuoted 11 lines · Greg KH
Quoted 6 lines · Linus Walleij
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. ?Why not just power down ports that are not open instead?
I like the idea as well and this is definitely gonna help conserving the power for Bluetooth UARTs.
But using baud rate 0 is something I don't like. Why don't you stop the clocks if RTS is cleared? This would have allowed the line discipline driver to implicitly control the UART clock and there will be no risk of losing data, as well as no non-standard behavior involved. In fact, you'll be transparent to the upper layers in this case.
~Vitaly
PATCH 1/1 pl011: added clock management feature
Quoted 9 lines · Vitaly Wool
Quoted 8 lines · Greg KH
Quoted 6 lines · Linus Walleij
From: Grzegorz Sygieda <[email protected]>
This patch allows to control the pl011 clock using
set_termioscallback. Any positive baudrate passed enables clock, otherwise disables. This saves a lot of power on submicron designs since we can clock off and disable unused UARTs.
Quoted 8 lines
Quoted 3 lines
That's nice, but it seems like an overload of what people traditionally think of when it comes to baud rates. ?Why not just power down ports that are not open instead?
I like the idea as well and this is definitely gonna help conserving the power for Bluetooth UARTs.
But using baud rate 0 is something I don't like.
You can't use the baud rate of 0 to power down ports - that already has a POSIX-defined function (hang up).
Quoted 6 lines
Why don't you stop
the clocks if RTS is cleared? This would have allowed the line discipline driver to implicitly control the UART clock and there will be no risk of losing data, as well as no non-standard behavior involved. In fact, you'll be transparent to the upper layers in this case.
I've no idea what you're thinking, but you can't stop the UART clock because RTS is deasserted - or DTR for that matter. Neither of those two define whether characters will be transmitted or received.
There are specialist protocols and devices out there which require RTS and DTR to be held at certain non-standard states for them to work. One range of devices are car OBD-II interfaces, where RTS controls the L line and sometimes the TX/RX direction on the bidirectional K data line.
Similar things are done with DTR, and there's protocols which use DTR as a handshake.
PATCH 1/1 pl011: added clock management feature
Hi Russell,
Quoted 10 lines · Russell King - ARM Linux
Quoted 6 lines
Why don't you stop
the clocks if RTS is cleared? This would have allowed the line discipline driver to implicitly control the UART clock and there will be no risk of losing data, as well as no non-standard behavior involved. In fact, you'll be transparent to the upper layers in this case.I've no idea what you're thinking, but you can't stop the UART clock because RTS is deasserted - or DTR for that matter. ?Neither of those two define whether characters will be transmitted or received.
What I'm mostly up to (and I guess Par also is) is how to conserve power for the Bluetooth UARTs. For a Bluetooth UART, there usually is a kind of signalling protocol, either inband or out-of-band, that allows the host and the chip to negotiate about power conservation during inactivity periods. These protocols do not belong to UART implementation and are usually implemented as line discipline drivers. While BT chip is sleeping, we don't need the UART clock running but we need to have a decent way of telling the UART driver it can shut those off. Using RTS for that, even though not being applicable in all the cases, seems to work pretty well for Bluetooth UARTs. So if we just add a flag if an UART is used for BT or not and then use RTS for this kind of communication, will it be okay with you?
Thanks,
Vitaly
PATCH 1/1 pl011: added clock management feature
Quoted 15 lines · Vitaly Wool
Hi Russell,
Quoted 10 lines · Russell King - ARM Linux
Quoted 6 lines
Why don't you stop
the clocks if RTS is cleared? This would have allowed the line discipline driver to implicitly control the UART clock and there will be no risk of losing data, as well as no non-standard behavior involved. In fact, you'll be transparent to the upper layers in this case.I've no idea what you're thinking, but you can't stop the UART clock because RTS is deasserted - or DTR for that matter. ?Neither of those two define whether characters will be transmitted or received.
Quoted 12 lines
What I'm mostly up to (and I guess Par also is) is how to conserve power for the Bluetooth UARTs. For a Bluetooth UART, there usually is a kind of signalling protocol, either inband or out-of-band, that allows the host and the chip to negotiate about power conservation during inactivity periods. These protocols do not belong to UART implementation and are usually implemented as line discipline drivers. While BT chip is sleeping, we don't need the UART clock running but we need to have a decent way of telling the UART driver it can shut those off. Using RTS for that, even though not being applicable in all the cases, seems to work pretty well for Bluetooth UARTs. So if we just add a flag if an UART is used for BT or not and then use RTS for this kind of communication, will it be okay with you?
So you want to teach each UART driver a protocol-specific method of handling power management rather than implementing a sane API to do this?
Please, come up with a sane API for power management of UARTs rather than trying to hack protocol specific stuff into UART drivers.
PATCH 1/1 pl011: added clock management feature
Hi Russell,
Quoted 45 lines
-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: den 6 december 2010 11:14
To: Vitaly Wool
Cc: Greg KH; Linus WALLEIJ; Par-Gunnar HJALMDAHL; Greg Kroah-Hartman; Lukasz Rymanowski; Grzegorz Sygieda; linux-serial at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH] pl011: added clock management featureQuoted 7 lines · Vitaly Wool
Hi Russell,
Quoted 3 lines · Russell King - ARM Linux
Quoted 3 lines
Why don't you stop
the clocks if RTS is cleared? This would have allowed the line discipline driver to implicitly control the UART clock and therewill
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
be no risk of losing data, as well as no non-standard behavior involved. In fact, you'll be transparent to the upper layers in
this
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
case.
I've no idea what you're thinking, but you can't stop the UART
clock
Quoted 1 line
Quoted 1 line
because RTS is deasserted - or DTR for that matter. ?Neither of
those
Quoted 8 lines
Quoted 1 line
two define whether characters will be transmitted or received.
What I'm mostly up to (and I guess Par also is) is how to conserve power for the Bluetooth UARTs. For a Bluetooth UART, there usually is a kind of signalling protocol, either inband or out-of-band, that allows the host and the chip to negotiate about power conservation during inactivity periods. These protocols do not belong to UART implementation and are usually implemented as line discipline
drivers.
Quoted 1 line
While BT chip is sleeping, we don't need the UART clock running but
we
Quoted 1 line
need to have a decent way of telling the UART driver it can shut
those
Quoted 4 lines
off. Using RTS for that, even though not being applicable in all the cases, seems to work pretty well for Bluetooth UARTs. So if we just add a flag if an UART is used for BT or not and then use RTS for this kind of communication, will it be okay with you?
Quoted 6 lines
So you want to teach each UART driver a protocol-specific method of handling power management rather than implementing a sane API to do this?
Please, come up with a sane API for power management of UARTs rather than trying to hack protocol specific stuff into UART drivers.
So I guess the best solution would then be to add function(s) to struct tty_operations in tty_driver.h? Something like void (*clk_enable)(struct tty_struct *tty);
void (*clk_disable)(struct tty_struct *tty);
and then it is up to each UART driver to implement them? Would such a solution be OK?
/P-G