diff options
author | xpulury <xpulury@tieto.com> | 2010-06-01 10:14:55 +0200 |
---|---|---|
committer | John Rigby <john.rigby@linaro.org> | 2010-09-02 22:45:37 -0600 |
commit | 9f4c407f72548f824ed970e7d84d0b9808079bba (patch) | |
tree | a7dff82aac283210b184d8cefdac18861d047715 | |
parent | 62b3b5d2a34fb82ddb794131b6803281ac20c982 (diff) |
BT: Set baudrate zero to UART when BT chip is powered down.
When BT chip is down then we can turn off UART clock. This is done by setting 0 baudrate.
ST-Ericsson ID WP262054.
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Change-Id: Ief5b5dad7b55982222e6ed8a35bf048cd13e58a3
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/2426
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
-rw-r--r-- | drivers/mfd/ste_conn/ste_conn_ccd.c | 71 |
1 files changed, 38 insertions, 33 deletions
diff --git a/drivers/mfd/ste_conn/ste_conn_ccd.c b/drivers/mfd/ste_conn/ste_conn_ccd.c index a334d562a15..ba4530488a6 100644 --- a/drivers/mfd/ste_conn/ste_conn_ccd.c +++ b/drivers/mfd/ste_conn/ste_conn_ccd.c @@ -104,6 +104,7 @@ enum ccd_transport { #define CCD_BAUD_RATE_4000000 0x2B /* Baud rate defines */ +#define CCD_ZERO_BAUD_RATE 0 #define CCD_DEFAULT_BAUD_RATE 115200 #define CCD_HIGH_BAUD_RATE 921600 @@ -470,48 +471,52 @@ void ste_conn_ccd_set_chip_power(bool chip_on) STE_CONN_INFO("ste_conn_ccd_set_chip_power: %s", (chip_on ? "ENABLE" : "DISABLE")); switch (ste_conn_transport) { - case CCD_TRANSPORT_UART: + case CCD_TRANSPORT_UART: { + int uart_baudrate = uart_default_baud; + struct ktermios *old_termios; + struct tty_struct *tty = NULL; + if (chip_on) { ste_conn_devices_enable_chip(); } else { - struct ktermios *old_termios; - struct tty_struct *tty = NULL; - ste_conn_devices_disable_chip(); + /* Setting baud rate to 0 will tell UART driver to shut off its clocks.*/ + uart_baudrate = CCD_ZERO_BAUD_RATE; + } - /* Now we have to put the digital baseband UART back - * to default baudrate since we have powered off the - * chip - */ - if (ccd_info->c_uart && ccd_info->c_uart->tty) { - tty = ccd_info->c_uart->tty; - } else { - STE_CONN_ERR("Important structs not allocated!"); - return; - } + /* Now we have to set the digital baseband UART + * to default baudrate if chip is ON or to zero baudrate if + * chip is turning OFF. + */ + if (ccd_info->c_uart && ccd_info->c_uart->tty) { + tty = ccd_info->c_uart->tty; + } else { + STE_CONN_ERR("Important structs not allocated!"); + return; + } - old_termios = kzalloc(sizeof(*old_termios), GFP_ATOMIC); - if (!old_termios) { - STE_CONN_ERR("Could not allocate termios"); - return; - } + old_termios = kmalloc(sizeof(*old_termios), GFP_ATOMIC); + if (!old_termios) { + STE_CONN_ERR("Could not allocate termios"); + return; + } - mutex_lock(&(tty->termios_mutex)); - /* Now set the termios struct to the default baudrate. - * Start by storing the old termios. - */ - memcpy(old_termios, tty->termios, sizeof(*old_termios)); - /* Now set the default baudrate */ - tty_encode_baud_rate(tty, uart_default_baud, - uart_default_baud); - /* Finally inform the driver */ - if (tty->ops->set_termios) { - tty->ops->set_termios(tty, old_termios); - } - mutex_unlock(&(tty->termios_mutex)); - kfree(old_termios); + mutex_lock(&(tty->termios_mutex)); + /* Now set the termios struct to the default or zero baudrate. + * Start by storing the old termios. + */ + memcpy(old_termios, tty->termios, sizeof(*old_termios)); + /* Now set the default baudrate or zero if chip is turning OFF.*/ + tty_encode_baud_rate(tty, uart_baudrate, + uart_baudrate); + /* Finally inform the driver */ + if (tty->ops->set_termios) { + tty->ops->set_termios(tty, old_termios); } + mutex_unlock(&(tty->termios_mutex)); + kfree(old_termios); break; + } case CCD_TRANSPORT_CHAR_DEV: /* Nothing to be done in test mode. */ break; |