qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Maksim Kozlov <m.kozlov@samsung.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kyungmin.park@samsung.com,
	Maksim Kozlov <m.kozlov@samsung.com>
Subject: [Qemu-devel] [PATCH v3 2/2] exynos4210: UART: Added using of CMU-callback functionality
Date: Wed, 04 Jul 2012 13:22:01 +0400	[thread overview]
Message-ID: <1341393721-3606-3-git-send-email-m.kozlov@samsung.com> (raw)
In-Reply-To: <1341393721-3606-1-git-send-email-m.kozlov@samsung.com>

Add using of functionality provided by CMU - get_rate and register_clock_handler.

Signed-off-by: Maksim Kozlov <m.kozlov@samsung.com>
---
 hw/exynos4210_uart.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
index ccc4780..10581bd 100644
--- a/hw/exynos4210_uart.c
+++ b/hw/exynos4210_uart.c
@@ -307,6 +307,7 @@ static void exynos4210_uart_update_parameters(Exynos4210UartState *s)
     uint64_t uclk_rate;
 
     if (s->reg[I_(UBRDIV)] == 0) {
+        PRINT_DEBUG("Baud rate division value is 0\n");
         return;
     }
 
@@ -332,7 +333,23 @@ static void exynos4210_uart_update_parameters(Exynos4210UartState *s)
 
     frame_size += data_bits + stop_bits;
 
-    uclk_rate = 24000000;
+    switch (s->channel) {
+    case 0:
+        uclk_rate = exynos4210_cmu_get_rate(EXYNOS4210_SCLK_UART0);
+        break;
+    case 1:
+        uclk_rate = exynos4210_cmu_get_rate(EXYNOS4210_SCLK_UART1);
+        break;
+    case 2:
+        uclk_rate = exynos4210_cmu_get_rate(EXYNOS4210_SCLK_UART2);
+        break;
+    case 3:
+        uclk_rate = exynos4210_cmu_get_rate(EXYNOS4210_SCLK_UART3);
+        break;
+    default:
+        hw_error("%s: Incorrect UART channel: %d\n",
+                 __func__, s->channel);
+    }
 
     speed = uclk_rate / ((16 * (s->reg[I_(UBRDIV)]) & 0xffff) +
             (s->reg[I_(UFRACVAL)] & 0x7) + 16);
@@ -348,6 +365,15 @@ static void exynos4210_uart_update_parameters(Exynos4210UartState *s)
                 s->channel, speed, parity, data_bits, stop_bits);
 }
 
+static void uclk_rate_changed(void *opaque)
+{
+    Exynos4210UartState *s = opaque;
+
+    PRINT_DEBUG("Clock sclk_uart%d was changed\n", s->channel);
+
+    exynos4210_uart_update_parameters(s);
+}
+
 static void exynos4210_uart_write(void *opaque, target_phys_addr_t offset,
                                uint64_t val, unsigned size)
 {
@@ -542,6 +568,7 @@ static void exynos4210_uart_reset(DeviceState *dev)
             container_of(dev, Exynos4210UartState, busdev.qdev);
     int regs_number = sizeof(exynos4210_uart_regs)/sizeof(Exynos4210UartReg);
     int i;
+    Exynos4210Clock clock_id;
 
     for (i = 0; i < regs_number; i++) {
         s->reg[I_(exynos4210_uart_regs[i].offset)] =
@@ -551,6 +578,25 @@ static void exynos4210_uart_reset(DeviceState *dev)
     fifo_reset(&s->rx);
     fifo_reset(&s->tx);
 
+    switch (s->channel) {
+    case 0:
+        clock_id = EXYNOS4210_SCLK_UART0;
+        break;
+    case 1:
+        clock_id = EXYNOS4210_SCLK_UART1;
+        break;
+    case 2:
+        clock_id = EXYNOS4210_SCLK_UART2;
+        break;
+    case 3:
+        clock_id = EXYNOS4210_SCLK_UART3;
+        break;
+    default:
+        hw_error("Wrong channel number: %d.\n", s->channel);
+    }
+
+    exynos4210_register_clock_handler(uclk_rate_changed, clock_id, s);
+
     PRINT_DEBUG("UART%d: Rx FIFO size: %d\n", s->channel, s->rx.size);
 }
 
-- 
1.7.5.4

      parent reply	other threads:[~2012-07-04  9:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  9:21 [Qemu-devel] [PATCH v3 0/2] ARM: Samsung Exynos4210 CMU support Maksim Kozlov
2012-07-04  9:22 ` [Qemu-devel] [PATCH v3 1/2] ARM: exynos4210: " Maksim Kozlov
2012-07-04 10:38   ` Dunrong Huang
2012-07-04 13:45     ` Maksim Kozlov
2012-07-04 13:54       ` Peter Maydell
2012-07-04 14:12         ` Maksim Kozlov
2012-07-04 14:14       ` Dunrong Huang
2012-07-04 14:53         ` Maksim Kozlov
2012-07-04  9:22 ` Maksim Kozlov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341393721-3606-3-git-send-email-m.kozlov@samsung.com \
    --to=m.kozlov@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).