From patchwork Fri Apr 12 05:02:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 10897261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BB0C17E0 for ; Fri, 12 Apr 2019 05:03:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF2E628E52 for ; Fri, 12 Apr 2019 05:03:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D308028E58; Fri, 12 Apr 2019 05:03:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85FAB28E52 for ; Fri, 12 Apr 2019 05:02:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726685AbfDLFCf (ORCPT ); Fri, 12 Apr 2019 01:02:35 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:40509 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbfDLFCf (ORCPT ); Fri, 12 Apr 2019 01:02:35 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 7E0C5886BF; Fri, 12 Apr 2019 17:02:31 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1555045351; bh=Ls2tXwAMaV7wyywwyHomFSGRAS+Typ9HE+EUMymXylw=; h=From:To:Cc:Subject:Date; b=O+tpvtQmhDfTWfUGOJw/Rg5Eu72dA4GBEf0mRa0z/EvIdKVLig+gmCKCYE+V6Em9b nsIKqHjucdfGSpr8VrhKC2uw+axB3DY1k8WOOLKevgrhSOPExnhOvWwGKHqy6nNkkK xwry6solroVu8vvHoa1p9XRiaXTv4a5G6AoiN/X3o/BHjKOMwfT0U5sty96BPQ71Mf jSGoPR7mmXEH3N4KzJK+8Xy6Sqwa7Rv28/RbQtYGK/WjqPmVyIVkJ6rxIVdfk89V/9 xrzCB50J1nWuHWosUtJlell0HGo5CvcqoXgdMLcn4S4QbtZTiM0gHz3+vVhfdYcH/f MhgQL2V+noiMw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 12 Apr 2019 17:02:31 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 7CEE513ED56; Fri, 12 Apr 2019 17:02:26 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 3CA6F1E1D9C; Fri, 12 Apr 2019 17:02:26 +1200 (NZST) From: Chris Packham To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: Hamish Martin , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 0/3] spi: SPI bus multiplexer Date: Fri, 12 Apr 2019 17:02:10 +1200 Message-Id: <20190412050213.17698-1-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi All, I have a hardware design where a single SPI chip select is steered by a GPIO being asserted or de-asserted. On older kernels I was able to (ab)use a gpio-hog and cs-gpios to deal with this. Unfortunately recent changes have stopped my hacks from working. I've tried adapting cs-gpios to work with my particular hardware but I came to the realisation that the current cs-gpios support assumes a 1:1 mapping of gpio to SPI device whereas my hardware used the state of the gpio selecting the device i.e. a 1:2 mapping. This is my attempt to implement a driver to deal with this. One nice property is that it is pretty much self contained. The only change to the core SPI infrastructure is exposing a function I needed to lookup the spi_controller instance. Chris Packham (3): dt-bindings: spi: Add spi-mux-gpio spi: Make of_find_spi_controller_by_node visible spi: Add SPI bus gpio multiplexer .../devicetree/bindings/spi/spi-mux-gpio.txt | 46 +++++ drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-mux-gpio.c | 169 ++++++++++++++++++ drivers/spi/spi.c | 7 +- include/linux/spi/spi.h | 7 + 6 files changed, 234 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/spi-mux-gpio.txt create mode 100644 drivers/spi/spi-mux-gpio.c