From patchwork Tue Sep 18 02:10:58 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: 184581 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 286732C007A for ; Tue, 18 Sep 2012 12:11:57 +1000 (EST) Received: from localhost ([::1]:46535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDnI2-0003Ih-TD for incoming@patchwork.ozlabs.org; Mon, 17 Sep 2012 22:11:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45571) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDnHs-0003Da-Qg for qemu-devel@nongnu.org; Mon, 17 Sep 2012 22:11:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TDnHr-0004MP-Nu for qemu-devel@nongnu.org; Mon, 17 Sep 2012 22:11:44 -0400 Received: from mail-oa0-f45.google.com ([209.85.219.45]:60268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TDnHr-0004LZ-Ib for qemu-devel@nongnu.org; Mon, 17 Sep 2012 22:11:43 -0400 Received: by mail-oa0-f45.google.com with SMTP id n12so5201914oag.4 for ; Mon, 17 Sep 2012 19:11:43 -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=idhUAhAYuonxzIV/hYOBEErCXqrXDp+6MyH2HkxEWqdEwMG7PDv6NbHf2/Lp3ekkVd bUWptezzkBUDCHSKwVTGgbo93CWpQ5vDg9E3UjSxSS4b5M5waHEInilSBpJYXdWpoBxa gOr+FGlE1vvYs0IZN/5tCF913x1coi8JwOuxjNIKHS7ofRMUWmJgm04dpeo/9ORGN50w 8RzjOXr81iggv3Zrlgq+uDoMOzGw4MyJorGzov6TRxLD6sHbQ9nSabpMgkEIGdUZzO2Y 6QB/2FQ19i3E1pYNRTEpoanQawdFc0ljldiGoR0urPaCbqAt5OdJ2VuuhZsNS7F1QqXx 1cxQ== Received: by 10.60.10.225 with SMTP id l1mr14082651oeb.28.1347934303303; Mon, 17 Sep 2012 19:11:43 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id q6sm10378913oec.7.2012.09.17.19.11.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 19:11:42 -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: Tue, 18 Sep 2012 12:10:58 +1000 Message-Id: X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQl3n88ZMUui7egX3lykE6INht9ToFD1bC0JFKcPpwbaF0ghtEjBJjbneSQS0x/qLZfECyT5 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.219.45 Cc: "Peter A. G. Crosthwaite" , i.mitsyanko@samsung.com Subject: [Qemu-devel] [PATCH v6 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)