From patchwork Tue Sep 18 22:45:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trent Piepho X-Patchwork-Id: 10604971 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 1CBDC161F for ; Tue, 18 Sep 2018 22:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3DA2BF06 for ; Tue, 18 Sep 2018 22:46:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F284A2BF27; Tue, 18 Sep 2018 22:46:07 +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 5EB592BF24 for ; Tue, 18 Sep 2018 22:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725875AbeISEUw (ORCPT ); Wed, 19 Sep 2018 00:20:52 -0400 Received: from mail-co1nam03on0091.outbound.protection.outlook.com ([104.47.40.91]:50176 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725829AbeISEUw (ORCPT ); Wed, 19 Sep 2018 00:20:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=impinj.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+yTr7ZQNGwiGHXZL0a7a8Gfd+5hc1fQJl0X1xCHu834=; b=mz/ei8Tuk2JUMoJkML7T9qjzc5jrLCsyypALOLTXGma16ES7/ob05fSPCIud1QyLmUHJ7Ba3+4xacBdoF66AgS2vt5h1klDeEIOGAckZwwwiROHkyAf7XZOVdHSd4aRpsM0hUao5QDnRGyJA0u3s+svBwWkjCy+za2/FuQVIETg= Received: from MWHPR0601MB3708.namprd06.prod.outlook.com (10.167.236.38) by MWHPR0601MB3627.namprd06.prod.outlook.com (10.167.236.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.15; Tue, 18 Sep 2018 22:45:49 +0000 Received: from MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48]) by MWHPR0601MB3708.namprd06.prod.outlook.com ([fe80::eca3:1c00:bc20:bc48%4]) with mapi id 15.20.1143.017; Tue, 18 Sep 2018 22:45:49 +0000 From: Trent Piepho To: "linux-spi@vger.kernel.org" CC: Henry Gomersall , Geert Uytterhoeven , Kyle Roeschley , Mark Brown , Trent Piepho Subject: [PATCH 0/2] device tree spidev solution - driver_override for SPI Thread-Topic: [PATCH 0/2] device tree spidev solution - driver_override for SPI Thread-Index: AQHUT6FYr0K1b6sphEygZZY9B56U8g== Date: Tue, 18 Sep 2018 22:45:49 +0000 Message-ID: <20180918224525.28001-1-tpiepho@impinj.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CY4PR22CA0071.namprd22.prod.outlook.com (2603:10b6:903:ae::33) To MWHPR0601MB3708.namprd06.prod.outlook.com (2603:10b6:301:7c::38) authentication-results: spf=none (sender IP is ) smtp.mailfrom=tpiepho@impinj.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [216.207.205.253] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR0601MB3627;6:F5Ut+FPYLxqQBbQr6eHY+ApuHLBZnbOVf1UDuL8a6X0EU8flLwUguVBngpxCOzb1RIh/3cm2Uv5VpC7ZN56L7UZfh8xL4AEXBpJsA90LS4eh/Ijs/ZirFWw5D6u7JtrVv1H8pRZX+CSikKrhDbxIM0lL8pqnoAISlKSuPSzUQQqznOkT0sWlh/t2XflbYAb9Aei0BdzxBjF9UgMfqo2meZnEs1jQ7xSMEa0CbrT2SHfvliEHIbN2FubsSEnZRwfGcYK9Tjs5IwRG/SmoYUmp1rh3tClRCdkx33QU4Hdwo+ifIaarcPU82xODG7L1dfBQAAJCfHwHVbZBXxln/F532Yz/jVxLRoq3kzKUwMxgJyH5pQz4XLQC07M6lZlAIjc/Pypt/s34xRVuiVB2MOM7CvxqaqKDMSn37bvKtB+VUvOaPGBnmBXnazifLaX7e6BmOjIto8ci4st65aBa0JHf9g==;5:uPH6kpgj+LioafBU/mvCkGyUcbsTBsa/nbZOv2xLp15zWuIHlLuDqwQXbhPuTXsQtYA1tsWWrC2QlyFtcJBjywuu9deQHz9Bt8vwNiAMQDCe2Nzni5iB8h/FuprKWScaLZpzGQGdeyjoNvHscZaGPCpQdNXvzfKks6AQoFchZEI=;7:aHBbCAC5ZXFr7dvPS3OjvwmurtmA7x7vcGa5cLcqhdGpwUP/2TXTNfqqVV97KnQyRjGC45WHejHiFJsef4zK1ESqp81EfiNbjyvyVUCuxqjXy+HcIuJCchtYOiSQCNTuhc9o+E77dFaOaXdhWkeQxulwhojq391025Btk6CuCHBCRQMqP90TENK5FsBy081YMUfAgnh53jWFBwPVOCJ1k7NPrIGZKnxfLrWGoArxnL4MjiJRbaJPh5VJstuNawlz x-ms-office365-filtering-correlation-id: c07f7b93-ec86-401e-ec76-08d61db87ab9 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020);SRVR:MWHPR0601MB3627; x-ms-traffictypediagnostic: MWHPR0601MB3627: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(20161123560045)(20161123564045)(201708071742011)(7699050);SRVR:MWHPR0601MB3627;BCL:0;PCL:0;RULEID:;SRVR:MWHPR0601MB3627; x-forefront-prvs: 0799B1B2D7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(376002)(39850400004)(136003)(366004)(346002)(189003)(199004)(256004)(305945005)(6512007)(14454004)(486006)(2900100001)(2906002)(508600001)(53936002)(6486002)(2616005)(8676002)(7736002)(4326008)(8936002)(2501003)(66066001)(97736004)(476003)(5640700003)(68736007)(36756003)(14444005)(6116002)(3846002)(6916009)(26005)(2351001)(1076002)(6506007)(386003)(102836004)(186003)(52116002)(5250100002)(86362001)(81156014)(6436002)(25786009)(54906003)(99286004)(81166006)(316002)(5660300001)(105586002)(107886003)(106356001);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR0601MB3627;H:MWHPR0601MB3708.namprd06.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: impinj.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: TYSoyxGNO0ANj5xNd8T7wP0GFJCCAMtPnc5zZEUdaOxGbfL+8XI83LiBImbVkDlQPBdnitf8ZuZj7MV87kVNgPHZ6O4zNZ+FHgFZRFJF/EYu1Dde+UxYDFkCwexbtHH9pR+OiKPC26WcFXTyAhjCHNqR/GZ9lclSaQvTdhH+AYpSsL2b0p/gk24Jf6Wp+jMDmKA1sSOOEog7hOIQglWs1RzdXDUUDXeXlmipUTfUL6iwhL4Vn+7+oZR/lSuqccv511Na9xAY7DXKqeccGhSUH34g8RbD+oK2FomFIKV8yaw0RgNSSq4ySU9StJum5/lN+LkNgxvkKf1AjNvw0WzWCFYbrWrTAfoMScVXy8MxGGg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: impinj.com X-MS-Exchange-CrossTenant-Network-Message-Id: c07f7b93-ec86-401e-ec76-08d61db87ab9 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2018 22:45:49.6511 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 6de70f0f-7357-4529-a415-d8cbb7e93e5e X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR0601MB3627 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 This is an attempt to solve the problem of binding spidev to a device on a device-tree system. Explicitly listing spidev in the "compatible" property of a device is not allowed, as it not type of the device but rather a Linux specific driver name. The current solution is to list every possible device spidev can be bound to, but this is highly unsatisfactory. 1. Needing to patch and compile the kernel is a significant barrier to many who could otherwise make use of embedded dev kits, such as RPi, that have SPI hardware. 2. Up-streaming a new spi device ID is a lengthy undertaking even to those who know how. This causes unneeded delay in upstream kernel support for a new device. 3. Maintaining a list of obscure and one-off device IDs in the spidev driver is largely a waste of effort to nearly every developer to use the driver. 4. It's not possible to bind a device that has a kernel SPI driver to spidev instead of its normal driver. This is quite useful to debug hardware problems, development of the kernel driver, and testing SPI bus timing, impedance, etc. It can also be used to access device features, like a one time programming step, that the device's kernel driver does not necessary need to support. This approach should solve these problems. Three existing Linux busses - AMBA, PCI, and platform - give device's a "driver_override" attribute, which can be used to bind them to a driver without requiring a match against the driver's device ID table. This can be used to bind spidev to a device without needing to add the device to some list inside the spidev driver. Udev rules can be written to make this automatic, example: ACTION=="add|change",, SUBSYSTEM=="spi", ENV{MODALIAS}=="spi:adrf6820", ATTR{driver_override}+="spidev" This will automatically bind a device that claims (likely via device-tree compatible value) to be an "adrf6820" to spidev. Additional rules could be imagined to bind specific spi bus chip selects, or any device on a certain bus, or via the device's node name in the device tree, to spidev. Trent Piepho (2): spi: Add driver_override SPI device attribute spi: spidev: Fix OF tree warning logic drivers/spi/spi.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ drivers/spi/spidev.c | 5 +++-- include/linux/spi/spi.h | 1 + 3 files changed, 57 insertions(+), 2 deletions(-)