From patchwork Tue Mar 30 16:49:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 411747 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4623529jai; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAEVyKw9p7QBmvSL6VgYaYlsGCvK4/g/3uriAOUjh7wgEaGdqIc8CehHyaMV5l94yLai7P X-Received: by 2002:aa7:db95:: with SMTP id u21mr34519697edt.152.1617123002089; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617123002; cv=none; d=google.com; s=arc-20160816; b=WvV5shXrKcgOxLtJM2Q3j3INpmQHzy74HDIMQSIjuhdKo6rEA9QgkuLLqAN8OXiXjR Olsef5LBPdOxSqr2XhGNHpIzyifT/H1047AGfm/iGAXRxnLPKE6LL3NLeAEEClGJuz/Z yOPG6n7MQDEeFOaRvY/KU+/gXk/QTYM73diSYJoiNdHHGFVkDzQ5KohnDmMOZZq2FEXc bg84pdT2crv7rhMBjskpv7FTX+HtuQrM0R9Des+oSmgBMQW7/PcqdCNMNNu09TF8QhLU QwLkEwu0clPqFyT/RmIYGCoDPFoqijkpRcJVoOlMP/kDcNfJ+tHsYawLgdeTqp2RfCPX LrPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=DwuBPFGLSpKihZVKEG15+3y/R2q1McqdWhbHkRumoJ0=; b=lXaiB2KIuiLzHPmgr/NDyHt/OFb8aCqf2W1Jq/yOm0XvFVwseJUkGabarT6m9QSjQc I+xp3+B9XelZobGV0pkGl5hT+A1iB1NIO9IJEMDwUl2XQGRqfDSboT4euqixLP5FLsoF /2fS30xwcQGIDZFxElcIgKIrL+Jo5i2LDtvaq69CizAQceBlrC67QU8ieZkhWaj2eiHR FoIu9jZjXQFDo/8t83/enCksCHqxwp6RWoNKXxbxbwTBoghuXJVm2LS78anDpmByg/qo JiDQQdxwUSb4mxyUJE/ZijqoX/oNMQix7sHeMd3yPyVJX/wdVWQ0Am2JaQG0TnxK6ISJ 3wMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vm8j58rb; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si14968854eds.27.2021.03.30.09.50.01; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vm8j58rb; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232265AbhC3Qt2 (ORCPT + 1 other); Tue, 30 Mar 2021 12:49:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232562AbhC3QtQ (ORCPT ); Tue, 30 Mar 2021 12:49:16 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DBBC061574 for ; Tue, 30 Mar 2021 09:49:15 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id b4so24786698lfi.6 for ; Tue, 30 Mar 2021 09:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DwuBPFGLSpKihZVKEG15+3y/R2q1McqdWhbHkRumoJ0=; b=Vm8j58rbTFraz7ojmqwXZHv94P4XwE3m03Okzpw2JV2WFtRBqde2VYPWB28tRlPya9 fRTd20ByT76bFES+dlFLszeXm4rwYkpEViff/l+Gv/qFKEbDOqTPlgY04G4LoOZY6Fre ZqPwKXu5CgQJrTrQJxla6XxpD0/zZOqliZgQSTSsxLwQGldgebDkducWBtLe3Gq0TN0B KIsxsuxOr+GJv3UE6IiAWpjEdtCZeLxCkQVkEPCqNn+k2EtF++Hu4tC2Tq6eA2z5HR/v WvBqZrgZCA7mOKIHnVENyo8B5r4p+snbE+dUomlKKQ2z3ge2hqkORIM2MP4kwB0p55eP 2CNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DwuBPFGLSpKihZVKEG15+3y/R2q1McqdWhbHkRumoJ0=; b=ptNoioxopbtT/li5tawgAPGMri+R5KyiaYHot2b8fDTBujd5CrLQ0uqyFDhpHUeCzL C7gnaRwg6CpsICY2x832JKPWL+FP5Vye9tvh+oX3ieXmz1smFM1HU1VV+wPvXbWePcHV dn3bEv2UpxQUW3CHppcKmrY97aTFS6KB/j1CWfLU5OKCf6pP0Ru2wgzVq2O/NpisBV4U n1pWlGEnb1uz6aTm3vledtSSzM+NG02sbU6jqz+zN2HDE1TujtFl9KG0s5TjDShJcTH1 PTSiJvb/QEwPSVlr6ON4viR4YdTh2fzTq7dI1jlgv4bMoaPuiW8kZ6QCyLBb3+vF0nsO Xv5g== X-Gm-Message-State: AOAM531rz5B3EMA+Ci27hYK6TkymnSK/p6Noi1rh4L9taiu2YxWyapGQ CdFbmQduZaigPi48kDU8tEMZ+c8VtNJEyRmi X-Received: by 2002:a19:234a:: with SMTP id j71mr19798896lfj.448.1617122953538; Tue, 30 Mar 2021 09:49:13 -0700 (PDT) Received: from localhost.localdomain (c-14cb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.203.20]) by smtp.gmail.com with ESMTPSA id m19sm2839025ljb.10.2021.03.30.09.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 09:49:13 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 1/3] spi: pl022: Drop custom per-chip cs_control Date: Tue, 30 Mar 2021 18:49:05 +0200 Message-Id: <20210330164907.2346010-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Drop the custom cs_control() assigned through platform data, we have no in-tree users and the only out-of-tree use I have ever seen of this facility is to pull GPIO lines, which is something the driver can already do for us. Signed-off-by: Linus Walleij --- drivers/spi/spi-pl022.c | 26 ++------------------------ include/linux/amba/pl022.h | 3 --- 2 files changed, 2 insertions(+), 27 deletions(-) -- 2.29.2 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index faaca7373b40..e5dd7756c2ea 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -412,7 +412,6 @@ struct pl022 { * @enable_dma: Whether to enable DMA or not * @read: function ptr to be used to read when doing xfer for this chip * @write: function ptr to be used to write when doing xfer for this chip - * @cs_control: chip select callback provided by chip * @xfer_type: polling/interrupt/DMA * * Runtime state of the SSP controller, maintained per chip, @@ -427,22 +426,9 @@ struct chip_data { bool enable_dma; enum ssp_reading read; enum ssp_writing write; - void (*cs_control) (u32 command); int xfer_type; }; -/** - * null_cs_control - Dummy chip select function - * @command: select/delect the chip - * - * If no chip select function is provided by client this is used as dummy - * chip select - */ -static void null_cs_control(u32 command) -{ - pr_debug("pl022: dummy chip select control, CS=0x%x\n", command); -} - /** * internal_cs_control - Control chip select signals via SSP_CSR. * @pl022: SSP driver private data structure @@ -470,8 +456,6 @@ static void pl022_cs_control(struct pl022 *pl022, u32 command) internal_cs_control(pl022, command); else if (gpio_is_valid(pl022->cur_cs)) gpio_set_value(pl022->cur_cs, command); - else - pl022->cur_chip->cs_control(command); } /** @@ -1829,7 +1813,6 @@ static const struct pl022_config_chip pl022_default_chip_info = { .ctrl_len = SSP_BITS_8, .wait_state = SSP_MWIRE_WAIT_ZERO, .duplex = SSP_MICROWIRE_CHANNEL_FULL_DUPLEX, - .cs_control = null_cs_control, }; /** @@ -1940,13 +1923,8 @@ static int pl022_setup(struct spi_device *spi) /* Now set controller state based on controller data */ chip->xfer_type = chip_info->com_mode; - if (!chip_info->cs_control) { - chip->cs_control = null_cs_control; - if (!gpio_is_valid(pl022->chipselects[spi->chip_select])) - dev_warn(&spi->dev, - "invalid chip select\n"); - } else - chip->cs_control = chip_info->cs_control; + if (!gpio_is_valid(pl022->chipselects[spi->chip_select])) + dev_warn(&spi->dev, "invalid chip select\n"); /* Check bits per word with vendor specific range */ if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) { diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index 131b27c97209..29274cedefde 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h @@ -265,8 +265,6 @@ struct pl022_ssp_controller { * @duplex: Microwire interface: Full/Half duplex * @clkdelay: on the PL023 variant, the delay in feeback clock cycles * before sampling the incoming line - * @cs_control: function pointer to board-specific function to - * assert/deassert I/O port to control HW generation of devices chip-select. */ struct pl022_config_chip { enum ssp_interface iface; @@ -280,7 +278,6 @@ struct pl022_config_chip { enum ssp_microwire_wait_state wait_state; enum ssp_duplex duplex; enum ssp_clkdelay clkdelay; - void (*cs_control) (u32 control); }; #endif /* _SSP_PL022_H */ From patchwork Tue Mar 30 16:49:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 411746 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4623519jai; Tue, 30 Mar 2021 09:50:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz7JX0a1UfL+Vzq11W3kGtrQYB/oqxBp4ERAtNTlWCgvNLPYG6U0M5rgNoY8M7eKiO1/7V X-Received: by 2002:a17:906:828e:: with SMTP id h14mr34478617ejx.529.1617123001365; Tue, 30 Mar 2021 09:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617123001; cv=none; d=google.com; s=arc-20160816; b=WmeI5rJ6u+eV5YCS3VFrGnqjFe9FtyxcFnAHwyTB4yzchaE8mowrqmdZWTfJzVpoXd tZcwb9/OS/lyP/6H2fOsiMnNPozO8Rug6a5W/Sja4rzxvuQvToHC/me9rFPWSryeYFI6 gRS3WuIw2R+4t6TQmDaT19pvefVD8eYkreYoR/R4FxEWy4iHAeJIfErbj+5NJDmgSJA2 FBQzkgwRScSoO/XIGgVHPxPFXcO7KygzjQQRVQKN7w3FP2KV3Cmbd9SNLQCQKvV2zVxG 4sW7qP/GrsummOwLVZtj5oz4YlevmHDMvQJ7ydWTpWcpDiTXEmwmjv2zx5+JJ+lE4Uzp B+ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Ek1wb23w4C4IXdQ+bpI1DTLG50A/SfcGdFR/A0Yd9I=; b=wVD/25dzTrEvhINX64JV2Vzlc/FucW0ujbgDqckCPFmADm14shZRHLIsUNFM2k8duQ zXcKVUkXO9xfLTVnvKeJtASS73+ugUIUtOEpQsqq+QF0azcSzZpS0YEaNjssYworNL7j FMYyQ5KGzfJ6gq9ZN31q5Nu28cof3u7DBKrXU0APxu2VlR3Lhwz0N8TzN6pSt3cMLeec OxP6SzCQBMjpmtzFQWh0LKgQLo9Aycez8l7NKnpJW+/uU1N8yVdb5+E5Fgdeu2X8hYui w2QoAwjBIyJbfYMTRuBK2C9UDMElNP/jZom23tivxJ/JxoP2aGaMWlWNcUAcsh94fucT 0pKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZOsHOyx; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si14968854eds.27.2021.03.30.09.50.01; Tue, 30 Mar 2021 09:50:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZOsHOyx; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232101AbhC3Qt3 (ORCPT + 1 other); Tue, 30 Mar 2021 12:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232059AbhC3QtS (ORCPT ); Tue, 30 Mar 2021 12:49:18 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 642DEC061574 for ; Tue, 30 Mar 2021 09:49:17 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id a1so20664386ljp.2 for ; Tue, 30 Mar 2021 09:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Ek1wb23w4C4IXdQ+bpI1DTLG50A/SfcGdFR/A0Yd9I=; b=yZOsHOyxekGvLSWpeVNG2VLZPXkSWCD/XCTNPggFQLo2nU7bQUJq1SlPm5NK7XFRqY 50aTxsRv8Wzj2f6GFws+MbbDiIb3qtodL16cBHUx7yskNWk3cloLexVSuym1R43Jw3Le ulZl1Mr4dA5tRVxRLZqqJ59CvdEkeqjm0YAPdbUQjZT+vv9SI5gxQibSUc4KvbsYflF1 rqcmqgC585S7Zy3X9/ohUhrUqcMOmqxAj23eB5njuZ7dDHRFqwJ/aLR6XN7hOPHH9+5U eWrAMUD7HSSo+bXJdKLMQV9adwQK4HRexv+ceEUdbWeWbU1dcw9aFoQs71ts32IEKPMQ AhVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Ek1wb23w4C4IXdQ+bpI1DTLG50A/SfcGdFR/A0Yd9I=; b=PbEl9izDeR64fYT8Du62EaRk6ybdTJAjYhSpTnEJwSjsMD1bZzW4avAaQbcMr60mN3 JPGTetxQdliyiybmIzR+Mn1y9AQOXNYbdYkCSFApq30hQw5Q4JgscvNioHFTsbEj9WhD EtwaJhjf4TiLKRN7vucw6Tog8E/Tbzq3rX87MZc9WQP42K/vmY0NiygIrio1J9xm5dNH 3EqELXMJCFXub59v4P5jmMZ0viVJp8q9zXk6I4afoZyLWU4JZrhzeJ+/DO4gaZ9uK1DJ LxmbxqRhsbyrtexn8YDbxLGd6WWRAB2pV7NqbfZTVYky7abKIvlNkhcrrOixOsKJoYIu 5mQw== X-Gm-Message-State: AOAM532w0zd0matQpi/aUky9fWXGTT9ndrJlUMJ4rsCLqsausbMNX8iy iiB2mmWaV0gR1z/Wmto2MYVDfQ== X-Received: by 2002:a2e:964e:: with SMTP id z14mr22194995ljh.333.1617122955905; Tue, 30 Mar 2021 09:49:15 -0700 (PDT) Received: from localhost.localdomain (c-14cb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.203.20]) by smtp.gmail.com with ESMTPSA id m19sm2839025ljb.10.2021.03.30.09.49.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 09:49:15 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 2/3] spi: pl022: Use GPIOs looked up by the core Date: Tue, 30 Mar 2021 18:49:06 +0200 Message-Id: <20210330164907.2346010-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210330164907.2346010-1-linus.walleij@linaro.org> References: <20210330164907.2346010-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The SPI core looks up GPIO lines from the device tree, so let's stop trying to do that on our own and rely on the core to do this for us. In addition to the GPIO line we also need to keep track of the chip select index separately, as the native chip select needs this index. The driver was reusing the same GPIO array for native chip select indices, so keep this in a separate state variable instead. The facility to pass in custom GPIO lines from the platform data can go, because even if we do have out-of-tree code that want to use platform data, they can soon pass in GPIOs using machine GPIO descriptor tables which will be available after the next step when we convert the driver to using GPIO descriptors. The implicit inclusion of is made explicit as we no longer need to include . Signed-off-by: Linus Walleij --- drivers/spi/spi-pl022.c | 70 ++++++-------------------------------- include/linux/amba/pl022.h | 7 ---- 2 files changed, 10 insertions(+), 67 deletions(-) -- 2.29.2 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index e5dd7756c2ea..84ffed2a3554 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include /* @@ -362,8 +362,8 @@ struct vendor_data { * @sgt_tx: scattertable for the TX transfer * @dummypage: a dummy page used for driving data on the bus with DMA * @dma_running: indicates whether DMA is in operation - * @cur_cs: current chip select (gpio) - * @chipselects: list of chipselects (gpios) + * @cur_cs: current chip select index + * @cur_gpio: current chip select GPIO line */ struct pl022 { struct amba_device *adev; @@ -398,7 +398,7 @@ struct pl022 { bool dma_running; #endif int cur_cs; - int *chipselects; + int cur_gpio; }; /** @@ -454,8 +454,8 @@ static void pl022_cs_control(struct pl022 *pl022, u32 command) { if (pl022->vendor->internal_cs_ctrl) internal_cs_control(pl022, command); - else if (gpio_is_valid(pl022->cur_cs)) - gpio_set_value(pl022->cur_cs, command); + else if (gpio_is_valid(pl022->cur_gpio)) + gpio_set_value(pl022->cur_gpio, command); } /** @@ -1580,7 +1580,9 @@ static int pl022_transfer_one_message(struct spi_master *master, /* Setup the SPI using the per chip configuration */ pl022->cur_chip = spi_get_ctldata(msg->spi); - pl022->cur_cs = pl022->chipselects[msg->spi->chip_select]; + pl022->cur_cs = msg->spi->chip_select; + /* This is always available but may be set to -ENOENT */ + pl022->cur_gpio = msg->spi->cs_gpio; restore_state(pl022); flush(pl022); @@ -1923,8 +1925,6 @@ static int pl022_setup(struct spi_device *spi) /* Now set controller state based on controller data */ chip->xfer_type = chip_info->com_mode; - if (!gpio_is_valid(pl022->chipselects[spi->chip_select])) - dev_warn(&spi->dev, "invalid chip select\n"); /* Check bits per word with vendor specific range */ if ((bits <= 3) || (bits > pl022->vendor->max_bpw)) { @@ -2072,7 +2072,6 @@ pl022_platform_data_dt_get(struct device *dev) { struct device_node *np = dev->of_node; struct pl022_ssp_controller *pd; - u32 tmp = 0; if (!np) { dev_err(dev, "no dt node defined\n"); @@ -2085,8 +2084,6 @@ pl022_platform_data_dt_get(struct device *dev) pd->bus_id = -1; pd->enable_dma = 1; - of_property_read_u32(np, "num-cs", &tmp); - pd->num_chipselect = tmp; of_property_read_u32(np, "pl022,autosuspend-delay", &pd->autosuspend_delay); pd->rt = of_property_read_bool(np, "pl022,rt"); @@ -2101,8 +2098,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) dev_get_platdata(&adev->dev); struct spi_master *master; struct pl022 *pl022 = NULL; /*Data for this driver */ - struct device_node *np = adev->dev.of_node; - int status = 0, i, num_cs; + int status = 0; dev_info(&adev->dev, "ARM PL022 driver, device ID: 0x%08x\n", adev->periphid); @@ -2114,13 +2110,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) return -ENODEV; } - if (platform_info->num_chipselect) { - num_cs = platform_info->num_chipselect; - } else { - dev_err(dev, "probe: no chip select defined\n"); - return -ENODEV; - } - /* Allocate master with space for data */ master = spi_alloc_master(dev, sizeof(struct pl022)); if (master == NULL) { @@ -2133,19 +2122,12 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) pl022->master_info = platform_info; pl022->adev = adev; pl022->vendor = id->data; - pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int), - GFP_KERNEL); - if (!pl022->chipselects) { - status = -ENOMEM; - goto err_no_mem; - } /* * Bus Number Which has been Assigned to this SSP controller * on this board */ master->bus_num = platform_info->bus_id; - master->num_chipselect = num_cs; master->cleanup = pl022_cleanup; master->setup = pl022_setup; master->auto_runtime_pm = true; @@ -2154,36 +2136,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) master->rt = platform_info->rt; master->dev.of_node = dev->of_node; - if (platform_info->num_chipselect && platform_info->chipselects) { - for (i = 0; i < num_cs; i++) - pl022->chipselects[i] = platform_info->chipselects[i]; - } else if (pl022->vendor->internal_cs_ctrl) { - for (i = 0; i < num_cs; i++) - pl022->chipselects[i] = i; - } else if (IS_ENABLED(CONFIG_OF)) { - for (i = 0; i < num_cs; i++) { - int cs_gpio = of_get_named_gpio(np, "cs-gpios", i); - - if (cs_gpio == -EPROBE_DEFER) { - status = -EPROBE_DEFER; - goto err_no_gpio; - } - - pl022->chipselects[i] = cs_gpio; - - if (gpio_is_valid(cs_gpio)) { - if (devm_gpio_request(dev, cs_gpio, "ssp-pl022")) - dev_err(&adev->dev, - "could not request %d gpio\n", - cs_gpio); - else if (gpio_direction_output(cs_gpio, 1)) - dev_err(&adev->dev, - "could not set gpio %d as output\n", - cs_gpio); - } - } - } - /* * Supports mode 0-3, loopback, and active low CS. Transfers are * always MS bit first on the original pl022. @@ -2286,8 +2238,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) err_no_ioremap: amba_release_regions(adev); err_no_ioregion: - err_no_gpio: - err_no_mem: spi_master_put(master); return status; } diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index 29274cedefde..9bf58aac0df2 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h @@ -223,10 +223,6 @@ struct dma_chan; /** * struct pl022_ssp_master - device.platform_data for SPI controller devices. * @bus_id: identifier for this bus - * @num_chipselect: chipselects are used to distinguish individual - * SPI slaves, and are numbered from zero to num_chipselects - 1. - * each slave has a chipselect signal, but it's common that not - * every chipselect is connected to a slave. * @enable_dma: if true enables DMA driven transfers. * @dma_rx_param: parameter to locate an RX DMA channel. * @dma_tx_param: parameter to locate a TX DMA channel. @@ -235,18 +231,15 @@ struct dma_chan; * indicates no delay and the device will be suspended immediately. * @rt: indicates the controller should run the message pump with realtime * priority to minimise the transfer latency on the bus. - * @chipselects: list of chip select gpios */ struct pl022_ssp_controller { u16 bus_id; - u8 num_chipselect; u8 enable_dma:1; bool (*dma_filter)(struct dma_chan *chan, void *filter_param); void *dma_rx_param; void *dma_tx_param; int autosuspend_delay; bool rt; - int *chipselects; }; /** From patchwork Tue Mar 30 16:49:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 411748 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp4623545jai; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdgNQV+RD2XmbRCfCijqO8NgvOrARKzfMghthtLVb7AU8VdTFOu53H+Bpgka0sRLW8wzir X-Received: by 2002:a05:6402:17d6:: with SMTP id s22mr34463541edy.232.1617123002591; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617123002; cv=none; d=google.com; s=arc-20160816; b=PrsTlQhTuuaeFWp1zL+GPA5XlITfDV0x035PE4CaDhuAmoDHpl9Ix3pNz9xcom4muJ FKHE9/eh2ZxMKzRUDLfdD2g4j1KcPIcwcXey/APN5vo8docbzPVDHga80y4sDsFtzVJs HMSoF/NU4oqkBpKoCul0ABNhTdGhRiWoph7drKvYWYsUhuvoEv49eEzoTJQF0LJvPD6+ nrpnppXidVkaJ+sSgDovVNZCXxlfIN3BPatxQ+AiSK8s7K54wjR/9r3yRYeHtty29pGE xfwW7R4hEujpY6QUm/ZdWntKgE/EQRo2g1ofTvG7GT0CHS8z9ihW/NPxqiX41SxTryNh PHBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mH0nCRARtN5+w9TZoOp1Qm7Svfh+hhUeE/MFDUeNtKE=; b=reK1y4n/wzoLSW0FZNxNhgKPXScQRbhQqRcCQ4lBwKdp97THSZvmWGWZdS9efhTT6+ FNqL/8j6h9906CRuciCiwaQmxJy7aD9F1tLlpFQwXX6LhJKDgnOzOAxwOu11KOboud+i PKRYViFfvBfD83RTePt3agJBdZTX71H8qdk9XUO+LBrl2xqNZmH9cbgEXrwe7odSY86p yX0cMlD2G5I4JQIorGu9j7Fj3oZPu1+PfVYS4Kbo16UOwcITYq1sBiUgsJgxS5GLVq6r BpWg048BORWPBG7lHXajcNCJgK60U5fVCp28kFQcqrChH+R3wq0p/tFL7HOfxrx0bboZ ++pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bUuRgnlZ; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g25si14968854eds.27.2021.03.30.09.50.02; Tue, 30 Mar 2021 09:50:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bUuRgnlZ; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbhC3Qt3 (ORCPT + 1 other); Tue, 30 Mar 2021 12:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232543AbhC3QtT (ORCPT ); Tue, 30 Mar 2021 12:49:19 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30832C061574 for ; Tue, 30 Mar 2021 09:49:19 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id n138so24818610lfa.3 for ; Tue, 30 Mar 2021 09:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mH0nCRARtN5+w9TZoOp1Qm7Svfh+hhUeE/MFDUeNtKE=; b=bUuRgnlZm6jAkUUpJk08qnJq9UxPnc7IQPVHVqsd7d/3JOeNGWNnFYeHW12l90f6Rn xDiLdkuL5BejI4Ym2rBJcN833LJttSJeN0hHNsvawtSP+f1+FeB3bLiONrhWAniYFnqG 7QL0FXdm6qizdOJNpZ72xv7N+PtNprgcLd0pQm0ucFuUJv8vZvd2tdZr/npMbd9J3kFW n5PgF5NDDvIuIcCryMxbbYi8SPYHesBn9Eb31LVWqPjsEwb27Hex1qgvCN1TqBWaB58S RMhqzzjA8hV52YlSMgbGc17VpM8YMqYSu2o9SwOMSIVaLmskOcifUvFCrSL2UOgRc9hj PBEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mH0nCRARtN5+w9TZoOp1Qm7Svfh+hhUeE/MFDUeNtKE=; b=XCZBpC75p2by12dU4cI5kOMbEe7anmcYTesxTh72eSy2CEOtEZl9UNVaalo6q8OsO+ s/+d/SAcjkl09vlwe44ReuBrmY4yBWg49ZxaqFOov3OCZSSou8eId2ZqdgAKL2Qlfq4a lZnHdhSSVG7QjLAKEC/sbiFlX0CHnezK3CE9d6470p/Liq1hqlSrDG/3x63c5YdJTF+b 6wP57HG1Rx7JPLuVI2but98zs9dh/GmdHrk7g3YnyYbCdewJXJe1UQLE4jVWwn2my0Hr Qia5iWZCHBldl4jTRJtWFq9IhhZDXHdG4KEjhxTDzn20NzWBSL+7DmfrJORjK0Nw/984 6cvA== X-Gm-Message-State: AOAM531rUfFklZK6bGqSK9xgmxtQtPA+H1+LWynj6ICXvg3qdvB2gtOZ 7H5mBI1rnbNdScyRe0aq/jiNYT/k4xxmDEd4 X-Received: by 2002:ac2:4142:: with SMTP id c2mr19717206lfi.125.1617122957748; Tue, 30 Mar 2021 09:49:17 -0700 (PDT) Received: from localhost.localdomain (c-14cb225c.014-348-6c756e10.bbcust.telenor.se. [92.34.203.20]) by smtp.gmail.com with ESMTPSA id m19sm2839025ljb.10.2021.03.30.09.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 09:49:17 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 3/3] spi: pl022: Convert to use GPIO descriptors Date: Tue, 30 Mar 2021 18:49:07 +0200 Message-Id: <20210330164907.2346010-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210330164907.2346010-1-linus.walleij@linaro.org> References: <20210330164907.2346010-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This converts the PL022 driver to use GPIO descriptors instead of the old global GPIO numberspace. Since the driver handles messages on its own it needs to manage the GPIO descriptor directly. Signed-off-by: Linus Walleij --- drivers/spi/spi-pl022.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.29.2 diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 84ffed2a3554..fda025a5ec06 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -363,7 +362,7 @@ struct vendor_data { * @dummypage: a dummy page used for driving data on the bus with DMA * @dma_running: indicates whether DMA is in operation * @cur_cs: current chip select index - * @cur_gpio: current chip select GPIO line + * @cur_gpiod: current chip select GPIO descriptor */ struct pl022 { struct amba_device *adev; @@ -398,7 +397,7 @@ struct pl022 { bool dma_running; #endif int cur_cs; - int cur_gpio; + struct gpio_desc *cur_gpiod; }; /** @@ -454,8 +453,16 @@ static void pl022_cs_control(struct pl022 *pl022, u32 command) { if (pl022->vendor->internal_cs_ctrl) internal_cs_control(pl022, command); - else if (gpio_is_valid(pl022->cur_gpio)) - gpio_set_value(pl022->cur_gpio, command); + else if (pl022->cur_gpiod) + /* + * This needs to be inverted since with GPIOLIB in + * control, the inversion will be handled by + * GPIOLIB's active low handling. The "command" + * passed into this function will be SSP_CHIP_SELECT + * which is enum:ed to 0, so we need the inverse + * (1) to activate chip select. + */ + gpiod_set_value(pl022->cur_gpiod, !command); } /** @@ -1582,7 +1589,7 @@ static int pl022_transfer_one_message(struct spi_master *master, pl022->cur_chip = spi_get_ctldata(msg->spi); pl022->cur_cs = msg->spi->chip_select; /* This is always available but may be set to -ENOENT */ - pl022->cur_gpio = msg->spi->cs_gpio; + pl022->cur_gpiod = msg->spi->cs_gpiod; restore_state(pl022); flush(pl022); @@ -2135,6 +2142,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) master->unprepare_transfer_hardware = pl022_unprepare_transfer_hardware; master->rt = platform_info->rt; master->dev.of_node = dev->of_node; + master->use_gpio_descriptors = true; /* * Supports mode 0-3, loopback, and active low CS. Transfers are