From patchwork Thu Aug 25 06:41:14 2011 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: 111479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 27DFDB6F18 for ; Thu, 25 Aug 2011 17:06:05 +1000 (EST) Received: from localhost ([::1]:38781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwU0o-0002iL-5o for incoming@patchwork.ozlabs.org; Thu, 25 Aug 2011 03:06:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTfh-0002S2-Uo for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwTfg-00043S-AP for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:44:13 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:48349) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTfg-00041F-7x for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:44:12 -0400 Received: by yxt3 with SMTP id 3so1680259yxt.4 for ; Wed, 24 Aug 2011 23:43:51 -0700 (PDT) Received: by 10.236.177.72 with SMTP id c48mr25279284yhm.79.1314254631712; Wed, 24 Aug 2011 23:43:51 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id f48sm471766yhh.42.2011.08.24.23.43.48 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Aug 2011 23:43:51 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com, edgar.iglesias@gmail.com, john.williams@petalogix.com, michal.simek@petalogix.com Date: Thu, 25 Aug 2011 16:41:14 +1000 Message-Id: <1314254480-22438-9-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.3.2 In-Reply-To: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> References: <1314254480-22438-1-git-send-email-peter.crosthwaite@petalogix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.173 Cc: "Peter A. G. Crosthwaite" Subject: [Qemu-devel] [RFC PATCH V1 08/14] xilinx_timer: 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 Signed-off-by: Peter A. G. Crosthwaite --- hw/xilinx_timer.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c index f1c7abc..8fe32f6 100644 --- a/hw/xilinx_timer.c +++ b/hw/xilinx_timer.c @@ -215,9 +215,11 @@ static int xilinx_timer_init(SysBusDevice *dev) return 0; } +#define QDEV_NAME "xilinx,timer" + static SysBusDeviceInfo xilinx_timer_info = { .init = xilinx_timer_init, - .qdev.name = "xilinx,timer", + .qdev.name = QDEV_NAME, .qdev.size = sizeof(struct timerblock), .qdev.props = (Property[]) { DEFINE_PROP_UINT32("frequency", struct timerblock, freq_hz, 0), @@ -232,3 +234,38 @@ static void xilinx_timer_register(void) } device_init(xilinx_timer_register) + +#ifdef CONFIG_FDT + +#include "fdt_generic_qdev.h" + +#define FREQ_HZ (62 * 1000000) + +static FDTQDevPropMapping * +xilinx_timer_fdt_qdev_map(char *node_path, FDTMachineInfo *fdti) +{ + FDTQDevPropMapping *ret = g_malloc0(sizeof(*ret) * 3); + struct FDTQDevPropMapping sprops [] = { + { + .name = "frequency", + .src.u32 = FREQ_HZ + },{ + .name = "nr-timers", + .src.u32 = 2 - qemu_devtree_getprop(fdti->fdt, NULL, node_path, + "xlnx,one-timer-only", 0, 0) + },{ + .name = NULL + } + }; + return memcpy(ret, sprops, sizeof(*ret) * 3); +} + +FDTQDevOps xilinx_timer_fdt_qdev_ops = { + .dev_name = QDEV_NAME, + .map = xilinx_timer_fdt_qdev_map, +}; + +fdt_qdev_register_compatibility(&xilinx_timer_fdt_qdev_ops, + "xlnx,xps-timer-1.00.a"); + +#endif /* CONFIG_FDT */