Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1655885ybm; Sat, 30 May 2020 16:23:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyfFJWtHVnOuQdQYn0xoVn4txZm72Mk9a2Q69jrekjuhe0dSw0eEu7u6JiEQaZ14ODD9+p X-Received: by 2002:a05:6402:1c1e:: with SMTP id ck30mr14537738edb.154.1590880987372; Sat, 30 May 2020 16:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590880987; cv=none; d=google.com; s=arc-20160816; b=Px0uu5aabEHXSDirBt7Np8wAyBnrQaS+kWq4vfpVFOFklt2y3FZENmvaFI4EWvaTQb 9CHkeupcJRj2PFFqeLXT3CVQ4AwAhGiow46tjxb+cD+mZM0G75BqPNDdXr0B9wE2fP5S 0f+lW5LPPGOk7e55C/wlvZBh6L/oe2f1nGbwctfmhFQB7PYG1reot0Z4ZJ1NLwE0L1pp khyMqtXov8D8qp/78MsgtI0AzzTtf2MttW9MNAgwXl38mdwGxFQLlQLIaHO8J+3d3XuA gZNCvsl3KCZFKl7ygZwdwH3jSCpeaiKosl/JX4zJI0K9N27DCUGpouhnwAa0nrVsyaMc dd5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=D1ItZgP66NN7fYxMkwMbxkMmJMZ1f0EHHArvbPLGX+w=; b=wyN/qq/J5zm/pHuy+8bpxXv9rG0dkxKGkjPiNOvoZLpTYLUpp9QTcGtWl+8rPeuems GFtc4wB9cepOfSfbtmoY+gQ5/d2pjjI9ANGLRIL8fDBhc37JgvYQKNQzoio+Es1Da/GS Ty6tCo2HXIVkyxSxXche+1LqNmWozUIGaA/Yt/Mrgs/APAs8p7ErQ3x02mFPXhXW4ZV0 0pMVZD1z1oaHiCKY+AVzgNhQ7SGMud56TH75ogyl65Y37UcuHtw3Zq0zOfEP4cxFi8Ew eYMhPvN9beLPs4KBpjGYhEnjvolWMgR3GJpkg9/xUofFjrESaY37Lu27Xh+X/ZSAUpM9 A43g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i90si8911824edd.55.2020.05.30.16.22.45; Sat, 30 May 2020 16:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbgE3XUx (ORCPT + 99 others); Sat, 30 May 2020 19:20:53 -0400 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:51248 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729565AbgE3XUf (ORCPT ); Sat, 30 May 2020 19:20:35 -0400 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id A668428009; Sat, 30 May 2020 19:20:34 -0400 (EDT) To: Benjamin Herrenschmidt Cc: Joshua Thompson , linux-m68k@lists.linux-m68k.org, "Geert Uytterhoeven" , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Message-Id: <0fb7fdcd99d7820bb27faf1f27f7f6f1923914ef.1590880623.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH 8/8] macintosh/adb-iop: Implement SRQ autopolling Date: Sun, 31 May 2020 09:17:03 +1000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The adb_driver.autopoll method is needed during ADB bus scan and device address assignment. Implement this method so that the IOP's list of device addresses can be updated. When the list is empty, disable SRQ autopolling. Cc: Joshua Thompson Cc: Geert Uytterhoeven Tested-by: Stan Johnson Signed-off-by: Finn Thain --- arch/m68k/include/asm/adb_iop.h | 1 + drivers/macintosh/adb-iop.c | 32 ++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/arch/m68k/include/asm/adb_iop.h b/arch/m68k/include/asm/adb_iop.h index 195d7fb1268c..6aecd020e2fc 100644 --- a/arch/m68k/include/asm/adb_iop.h +++ b/arch/m68k/include/asm/adb_iop.h @@ -29,6 +29,7 @@ #define ADB_IOP_EXPLICIT 0x80 /* nonzero if explicit command */ #define ADB_IOP_AUTOPOLL 0x40 /* auto/SRQ polling enabled */ +#define ADB_IOP_SET_AUTOPOLL 0x20 /* set autopoll device list */ #define ADB_IOP_SRQ 0x04 /* SRQ detected */ #define ADB_IOP_TIMEOUT 0x02 /* nonzero if timeout */ diff --git a/drivers/macintosh/adb-iop.c b/drivers/macintosh/adb-iop.c index 8594e4f9a830..f3d1a460fbce 100644 --- a/drivers/macintosh/adb-iop.c +++ b/drivers/macintosh/adb-iop.c @@ -7,10 +7,6 @@ * 1999-07-01 (jmt) - First implementation for new driver architecture. * * 1999-07-31 (jmt) - First working version. - * - * TODO: - * - * o Implement SRQ handling. */ #include @@ -28,6 +24,7 @@ static struct adb_request *current_req; static struct adb_request *last_req; +static unsigned int autopoll_devs; static enum adb_iop_state { idle, @@ -123,7 +120,7 @@ static void adb_iop_listen(struct iop_msg *msg) amsg->flags & ADB_IOP_AUTOPOLL); } - msg->reply[0] = ADB_IOP_AUTOPOLL; + msg->reply[0] = autopoll_devs ? ADB_IOP_AUTOPOLL : 0; iop_complete_message(msg); if (req_done) @@ -231,9 +228,32 @@ static int adb_iop_write(struct adb_request *req) return 0; } +static void adb_iop_set_ap_complete(struct iop_msg *msg) +{ + struct adb_iopmsg *amsg = (struct adb_iopmsg *)msg->message; + + autopoll_devs = (amsg->data[1] << 8) | amsg->data[0]; +} + static int adb_iop_autopoll(int devs) { - /* TODO: how do we enable/disable autopoll? */ + struct adb_iopmsg amsg; + unsigned long flags; + unsigned int mask = (unsigned int)devs & 0xFFFE; + + local_irq_save(flags); + + amsg.flags = ADB_IOP_SET_AUTOPOLL | (mask ? ADB_IOP_AUTOPOLL : 0); + amsg.count = 2; + amsg.cmd = 0; + amsg.data[0] = mask & 0xFF; + amsg.data[1] = (mask >> 8) & 0xFF; + + iop_send_message(ADB_IOP, ADB_CHAN, NULL, sizeof(amsg), (__u8 *)&amsg, + adb_iop_set_ap_complete); + + local_irq_restore(flags); + return 0; } -- 2.26.2