From patchwork Mon Sep 24 09:18:31 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: 186335 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 B648F2C0081 for ; Mon, 24 Sep 2012 19:19:12 +1000 (EST) Received: from localhost ([::1]:38073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4oo-0001gh-PC for incoming@patchwork.ozlabs.org; Mon, 24 Sep 2012 05:19:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4od-0001Zb-FV for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:19:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TG4oc-0002c2-Cg for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:18:59 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:48792) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TG4oc-0002bX-6l for qemu-devel@nongnu.org; Mon, 24 Sep 2012 05:18:58 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so896912pbb.4 for ; Mon, 24 Sep 2012 02:18:57 -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=kBRX7lS4sQCR/YrCrcOIk8H3Wj5N5gZYjPW+/MV4Fso=; b=mbtNAgbZ/ZtAa18sTMez0yBBp0XnKeNk9Lf1GZMm84Q4Wnh8xXHubxaPcXPT0ng+6q N4CdDJm2H515zDfEj1gvt9+B/OPrLKG4yugqM70J6jdeKxxUBvzHDABFD/+vxD1oQsYD 7FS57XuKCFExzQMhTXKlQ3Y5YKo1FRSMQrNv5z6Zx9fCSIjNI7VuUJ3kE+hguGkmi4Kp BX3qKEMrcRPFcKW/IqJTwgZxT5+1tz61iMx2+cXeqM87nE2WTipfwHI0dyvYh7XNFC+u mo3gvSYBT26hGrTDvGxlN12sNY99zcvvlla52BWCk9LR0PUrTWIIdGWyxL9RpcTEi8wW jIcQ== Received: by 10.68.222.37 with SMTP id qj5mr34627874pbc.132.1348478337864; Mon, 24 Sep 2012 02:18:57 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id bt7sm8476087pab.14.2012.09.24.02.18.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 24 Sep 2012 02:18:56 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, paul@codesourcery.com, edgar.iglesias@gmail.com, peter.maydell@linaro.org, stefanha@gmail.com Date: Mon, 24 Sep 2012 19:18:31 +1000 Message-Id: <58f77993bb76858202f272222b0d742a04c81bde.1348104012.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: ALoCoQm+3CUfZ9KVtRzVeqJK8EacknggcRL4PbhGK8+1AsN32VmiEHascXcHPnk+L16v2xspc+93 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: blauwirbel@gmail.com, "Peter A. G. Crosthwaite" , i.mitsyanko@samsung.com Subject: [Qemu-devel] [PATCH v7 01/13] ssi: Support for multiple attached devices 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 Removed assertion that only one device is attached to the SSI bus. When multiple devices are attached, all slaves have their transfer function called for transfers. Each device is responsible for knowing whether or not its CS is active, and if not returning 0. The returned data is the logical or of all responses from the (mulitple) devices. Signed-off-by: Peter A. G. Crosthwaite --- hw/ssi.c | 24 +++++++++--------------- 1 files changed, 9 insertions(+), 15 deletions(-) diff --git a/hw/ssi.c b/hw/ssi.c index e5f14a0..35d0a04 100644 --- a/hw/ssi.c +++ b/hw/ssi.c @@ -2,6 +2,8 @@ * QEMU Synchronous Serial Interface support * * Copyright (c) 2009 CodeSourcery. + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) + * Copyright (c) 2012 PetaLogix Pty Ltd. * Written by Paul Brook * * This code is licensed under the GNU GPL v2. @@ -29,14 +31,6 @@ static int ssi_slave_init(DeviceState *dev) { SSISlave *s = SSI_SLAVE(dev); SSISlaveClass *ssc = SSI_SLAVE_GET_CLASS(s); - SSIBus *bus; - BusChild *kid; - - bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev)); - kid = QTAILQ_FIRST(&bus->qbus.children); - if (kid->child != dev || QTAILQ_NEXT(kid, sibling) != NULL) { - hw_error("Too many devices on SSI bus"); - } return ssc->init(s); } @@ -74,16 +68,16 @@ SSIBus *ssi_create_bus(DeviceState *parent, const char *name) uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { BusChild *kid; - SSISlave *slave; SSISlaveClass *ssc; + uint32_t r = 0; - kid = QTAILQ_FIRST(&bus->qbus.children); - if (!kid) { - return 0; + QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) { + SSISlave *slave = SSI_SLAVE(kid->child); + ssc = SSI_SLAVE_GET_CLASS(slave); + r |= ssc->transfer(slave, val); } - slave = SSI_SLAVE(kid->child); - ssc = SSI_SLAVE_GET_CLASS(slave); - return ssc->transfer(slave, val); + + return r; } static void ssi_slave_register_types(void)