From patchwork Thu Feb 1 22:31:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatolij Gustschin X-Patchwork-Id: 10196135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1701B605F5 for ; Thu, 1 Feb 2018 22:31:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC79728BDD for ; Thu, 1 Feb 2018 22:31:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBBED28BE1; Thu, 1 Feb 2018 22:31:55 +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=-6.9 required=2.0 tests=BAYES_00,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 8F1F428BE7 for ; Thu, 1 Feb 2018 22:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752074AbeBAWbT (ORCPT ); Thu, 1 Feb 2018 17:31:19 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:46634 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752054AbeBAWbR (ORCPT ); Thu, 1 Feb 2018 17:31:17 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 3zXZb82vWqz1qvNt; Thu, 1 Feb 2018 23:31:16 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 3zXZb82W4qz1qqkq; Thu, 1 Feb 2018 23:31:16 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bblOJwjfkIiD; Thu, 1 Feb 2018 23:31:15 +0100 (CET) X-Auth-Info: guAuTGA/tFkGMpPf8CS5TOscbd4KSAyE6lxD1jW2RaE= Received: from crub.?040none?041 (p4FCB4189.dip0.t-ipconnect.de [79.203.65.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Thu, 1 Feb 2018 23:31:15 +0100 (CET) From: Anatolij Gustschin To: linux-fpga@vger.kernel.org Cc: Alan Tull , Moritz Fischer , Joshua Clayton Subject: [PATCH] fpga-manager: altera-ps-spi: enable usage on non-dt platforms Date: Thu, 1 Feb 2018 23:31:15 +0100 Message-Id: <20180201223115.16420-1-agust@denx.de> X-Mailer: git-send-email 2.11.0 Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Driver probing fails on non-dt platforms since of_match_device() always returns NULL here. Add device names and matching driver data to the spi_device_id table. This allows driver binding to dynamically added PS-SPI devices (e.g. added via spi_new_device() after hot-plugging). Signed-off-by: Anatolij Gustschin --- drivers/fpga/altera-ps-spi.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c index 14f14efdf0d5..c593f33d8db9 100644 --- a/drivers/fpga/altera-ps-spi.c +++ b/drivers/fpga/altera-ps-spi.c @@ -238,16 +238,25 @@ static int altera_ps_probe(struct spi_device *spi) { struct altera_ps_conf *conf; const struct of_device_id *of_id; + const struct spi_device_id *id; conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL); if (!conf) return -ENOMEM; - of_id = of_match_device(of_ef_match, &spi->dev); - if (!of_id) - return -ENODEV; + if (spi->dev.of_node) { + of_id = of_match_device(of_ef_match, &spi->dev); + if (!of_id) + return -ENODEV; + + conf->data = of_id->data; + } else { + id = spi_get_device_id(spi); + if (!id) + return -ENODEV; + conf->data = (struct altera_ps_data *)id->driver_data; + } - conf->data = of_id->data; conf->spi = spi; conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW); if (IS_ERR(conf->config)) { @@ -285,7 +294,9 @@ static int altera_ps_remove(struct spi_device *spi) } static const struct spi_device_id altera_ps_spi_ids[] = { - {"cyclone-ps-spi", 0}, + {"cyclone-ps-spi", (kernel_ulong_t)&c5_data}, + {"fpga-passive-serial", (kernel_ulong_t)&c5_data}, + {"fpga-arria10-passive-serial", (kernel_ulong_t)&a10_data}, {} }; MODULE_DEVICE_TABLE(spi, altera_ps_spi_ids);