From patchwork Mon Sep 17 09:03:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 184354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C72142C0086 for ; Mon, 17 Sep 2012 19:25:28 +1000 (EST) Received: from localhost ([::1]:48093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDXa2-0004LO-Te for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 05:25:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDXFv-00043H-JR for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDXFp-0001if-PJ for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:39 -0400 Received: from mail-ie0-f173.google.com ([209.85.223.173]:39068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDXFp-0001XC-KY for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:33 -0400 Received: by mail-ie0-f173.google.com with SMTP id c10so8784577ieb.4 for ; Mon, 17 Sep 2012 02:04:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=J/XNczIHoCKDgnivgtfEhEVCs9E9mtuTTN3+IJx3smU=; b=lhaf96fgi3ewbtKqLUheW0ch/XYYrcOHiXKzJZaeFLqlZmoGpn4fivIVCHn4AvtMuo 72k2uApDJKNHZ7b7VO17Az7ZhnCcpr4Z7KK+jHEKMVFdwACHZqL2w66RuC3knj9q/DkT vuUtxNs1o8tAzz0q9GXpNus/fIm6YlamF+K+urbV2gjILkS44t7XjaEMGuT08WBzH4La jsAuJ4C6fM17PNgmAx+t/al53W9mVnl5BIF+cw5hft42xAJM5FNexT43VUPOXvimqcZ6 ZeMAlS3+bSaj8/CpRP/Fk6j9pw56ZlXP6Ef+klN0+Txonqw7aB9U32zCYG8klROZtAzy wDoA== Received: by 10.50.149.195 with SMTP id uc3mr5658967igb.14.1347872673355; Mon, 17 Sep 2012 02:04:33 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id fu4sm6910014igc.4.2012.09.17.02.04.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:04:32 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, edgar.iglesias@gmail.com Date: Mon, 17 Sep 2012 19:03:02 +1000 Message-Id: <88d10b59ef3c263839df252ff4469ff57c68de17.1347871922.git.peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlkG1mVI/uG1t+DL7p+KnmdVGzFRZsZE10ejxN5i3LUYEzB6TuO+K5YOgB3dXszgBd8msqz X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.223.173 Cc: peter.crosthwaite@petalogix.com, crwulff@gmail.com Subject: [Qemu-devel] [RFC v0 10/10] serial: added fdt generic platform support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org fdt generic platform support for 16550 uarts. Signed-off-by: Peter A. G. Crosthwaite --- hw/fdt_generic_devices.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/hw/fdt_generic_devices.c b/hw/fdt_generic_devices.c index 91b3c5b..69017e8 100644 --- a/hw/fdt_generic_devices.c +++ b/hw/fdt_generic_devices.c @@ -1,4 +1,3 @@ - #include "blockdev.h" #include "fdt_generic_util.h" @@ -42,4 +41,40 @@ int pflash_cfi01_fdt_init(char *node_path, FDTMachineInfo *fdti, void *opaque) return 0; } -#endif /* CONFIG_FDT */ +static int uart16550_fdt_init(char *node_path, FDTMachineInfo *fdti, + void *priv) +{ + /* FIXME: Pass in dynamically */ + MemoryRegion *address_space_mem = get_system_memory(); + target_phys_addr_t base; + int baudrate; + qemu_irq irqline; + char irq_info[1024]; + void *serial = NULL; + Error *errp = NULL; + + base = qemu_devtree_getprop_cell(fdti->fdt, node_path, "reg", 0, + false, &errp); + base += qemu_devtree_getprop_cell(fdti->fdt, node_path, "reg-offset", 0, + false, &errp); + assert_no_error(errp); + base &= ~3ULL; /* qemu uart16550 model starts with 3* 8bit offset */ + + baudrate = qemu_devtree_getprop_cell(fdti->fdt, node_path, "current-speed", + 0, false, &errp); + if (errp) { + baudrate = 115200; + } + + irqline = fdt_get_irq_info(fdti, node_path, 0 , NULL, irq_info); + printf("FDT: UART16550a: baseaddr: 0x" + TARGET_FMT_plx ", irq: %s, baud %d\n", base, irq_info, baudrate); + + /* it_shift = 2, reg-shift in DTS - for Xilnx IP is hardcoded */ + serial = serial_mm_init(address_space_mem, base, 2, irqline, baudrate, + qemu_char_get_next_serial(), DEVICE_LITTLE_ENDIAN); + return 0; +} + +fdt_register_compatibility_n(uart16550_fdt_init, "ns16550", 0); +fdt_register_compatibility_n(uart16550_fdt_init, "ns16550a", 1);