From patchwork Thu Aug 25 06:41:11 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: 111472 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 44A7BB6F6F for ; Thu, 25 Aug 2011 16:44:01 +1000 (EST) Received: from localhost ([::1]:43093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTfQ-0001Hu-O6 for incoming@patchwork.ozlabs.org; Thu, 25 Aug 2011 02:43:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTf2-00009H-L7 for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwTf1-0003yk-5u for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:32 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:34522) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwTf0-0003yc-Sf for qemu-devel@nongnu.org; Thu, 25 Aug 2011 02:43:31 -0400 Received: by yih10 with SMTP id 10so1693869yih.4 for ; Wed, 24 Aug 2011 23:43:30 -0700 (PDT) Received: by 10.90.168.7 with SMTP id q7mr5857050age.30.1314254610037; Wed, 24 Aug 2011 23:43:30 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id h8sm102950anb.49.2011.08.24.23.43.26 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Aug 2011 23:43:29 -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:11 +1000 Message-Id: <1314254480-22438-6-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.218.45 Cc: "Peter A. G. Crosthwaite" Subject: [Qemu-devel] [RFC PATCH V1 05/14] pflash_cfi01: 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 Added fdt generic platform support. Note that this does not add the fdt init handler to the table of registered models as this needs to be handled in a platform dependent way (due to target endianness issues). Fdt generic machine models are required to register this device should it be supported. Signed-off-by: Peter A. G. Crosthwaite --- hw/fdt_generic_devices.h | 8 ++++++++ hw/pflash_cfi01.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-) create mode 100644 hw/fdt_generic_devices.h diff --git a/hw/fdt_generic_devices.h b/hw/fdt_generic_devices.h new file mode 100644 index 0000000..3bb4c05 --- /dev/null +++ b/hw/fdt_generic_devices.h @@ -0,0 +1,8 @@ +#ifndef FDT_GENERIC_DEVICES_H +#define FDT_GENERIC_DEVICES_H + +#include "fdt_generic.h" + +int pflash_cfi01_fdt_init(char *node_path, FDTMachineInfo *fdti, void *opaque); + +#endif /* FDT_GENERIC_DEVICES_H */ diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 90e1301..5cc6c17 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -724,3 +724,40 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off, return pfl; } + +#ifdef CONFIG_FDT + +#include "blockdev.h" + +#include "fdt_generic_util.h" +#include "fdt_generic_devices.h" + +int pflash_cfi01_fdt_init(char *node_path, FDTMachineInfo *fdti, void *opaque) { + + ram_addr_t phys_flash; + int flash_base = 0; + int flash_size = 0; + + int be = *((int*)opaque); + + DriveInfo *dinfo; + int bank_width; + + flash_base = qemu_devtree_getprop(fdti->fdt, NULL, node_path, "reg", 0, 0); + flash_size = qemu_devtree_getprop(fdti->fdt, NULL, node_path, "reg", 1, 0); + bank_width = qemu_devtree_getprop(fdti->fdt, NULL, node_path, "bank-width", + 0, 0); + + printf("FDT: FLASH: baseaddr: 0x%x, size: 0x%x\n", + flash_base, flash_size); + + phys_flash = qemu_ram_alloc(NULL, "mb.flash", flash_size); + dinfo = drive_get(IF_PFLASH, 0, 0); + pflash_cfi01_register(flash_base, phys_flash, + dinfo ? dinfo->bdrv : NULL, (64 * 1024), + flash_size >> 16, + bank_width, 0x89, 0x18, 0x0000, 0x0, be); + return 0; +} + +#endif /* CONFIG_FDT */