From patchwork Mon Sep 17 09:03:00 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: 184355 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 0D6C62C0083 for ; Mon, 17 Sep 2012 19:27:21 +1000 (EST) Received: from localhost ([::1]:33276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDXFv-0003vm-Ki for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 05:04:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDXFj-0003d4-IX for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDXFd-0001fg-8m for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:27 -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 1TDXFd-0001XC-4L for qemu-devel@nongnu.org; Mon, 17 Sep 2012 05:04:21 -0400 Received: by mail-ie0-f173.google.com with SMTP id c10so8784577ieb.4 for ; Mon, 17 Sep 2012 02:04:20 -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=EPZPEYJG18cq0s12UW0/tw9OmoxKxpzVKDev9Ntiv/k=; b=W4TLtzsIb5/KC74EoMixOZMGP4/u5Qsu/rwBqhnHlWtC/omdS1ANEaZmp0ojX7lAlJ hMst6kerG+PBVJAhxF6mHgB4vnoEBlVfwekQ9243NGGAPsKBnJaZ2jyidlBCifnanQYO q1MoLN/HF9wWqGuBpREcsvRBjr8kB4BIaW4XODozQ7i7cYp9ZTs10Qs+2COilYl8syfw fku7yTx2tcmgjwYqqvnX1SwKRkP++frYOO8BHuyT+9yMMxVrYNeY7TR66OWSyJCEg2Q0 7hGESY+Pk8fqppyQ68pB7eNptOBCkSvspaAsf65A6Ql3DhJaTQQbKc12dSsdEe3QDkCg ve/Q== Received: by 10.50.168.106 with SMTP id zv10mr6119058igb.13.1347872660829; Mon, 17 Sep 2012 02:04:20 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id a10sm16601885igd.1.2012.09.17.02.04.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 02:04:20 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, edgar.iglesias@gmail.com Date: Mon, 17 Sep 2012 19:03:00 +1000 Message-Id: <524fcc5ddac9a69c2fc9f7a7de23a9eb57f7fe6f.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: ALoCoQn/UTquI+j1GazwSyIyRwTrFJDCghtTkspiOIkIVDsqeRumOK7XICddCIelqI7TsWiJUMmE 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 08/10] 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.c | 45 +++++++++++++++++++++++++++++++++++++++++++ hw/fdt_generic_devices.h | 8 +++++++ hw/microblaze/Makefile.objs | 1 + 3 files changed, 54 insertions(+), 0 deletions(-) create mode 100644 hw/fdt_generic_devices.c create mode 100644 hw/fdt_generic_devices.h diff --git a/hw/fdt_generic_devices.c b/hw/fdt_generic_devices.c new file mode 100644 index 0000000..91b3c5b --- /dev/null +++ b/hw/fdt_generic_devices.c @@ -0,0 +1,45 @@ + +#include "blockdev.h" + +#include "fdt_generic_util.h" +#include "fdt_generic_devices.h" + +#define FLASH_SECTOR_SIZE (64 * 1024) + +/* FIXME: This file should go away. When these devices are properly QOMified + * then these FDT creations should happen automatically without need for these + * explict shim functions + */ + +int pflash_cfi01_fdt_init(char *node_path, FDTMachineInfo *fdti, void *opaque) +{ + + int flash_base = 0; + int flash_size = 0; + Error *errp = NULL; + + int be = *((int *)opaque); + + DriveInfo *dinfo; + int bank_width; + + flash_base = qemu_devtree_getprop_cell(fdti->fdt, node_path, "reg", 0, + false, &errp); + flash_size = qemu_devtree_getprop_cell(fdti->fdt, node_path, "reg", 1, + false, &errp); + bank_width = qemu_devtree_getprop_cell(fdti->fdt, node_path, "bank-width", + 0, false, &errp); + assert_no_error(errp); + + printf("FDT: FLASH: baseaddr: 0x%x, size: 0x%x\n", + flash_base, flash_size); + + dinfo = drive_get_next(IF_PFLASH); + pflash_cfi01_register(flash_base, NULL, node_path, flash_size, + dinfo ? dinfo->bdrv : NULL, FLASH_SECTOR_SIZE, + flash_size/FLASH_SECTOR_SIZE, + bank_width, 0x89, 0x18, 0x0000, 0x0, be); + return 0; +} + +#endif /* CONFIG_FDT */ 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/microblaze/Makefile.objs b/hw/microblaze/Makefile.objs index 23f9cbb..ef2d6b7 100644 --- a/hw/microblaze/Makefile.objs +++ b/hw/microblaze/Makefile.objs @@ -8,5 +8,6 @@ obj-$(CONFIG_FDT) += ../device_tree.o obj-$(CONFIG_FDT_GENERIC) += fdt_generic.o obj-$(CONFIG_FDT_GENERIC) += fdt_generic_util.o +obj-$(CONFIG_FDT_GENERIC) += fdt_generic_devices.o obj-y := $(addprefix ../,$(obj-y))