From patchwork Wed Jul 29 21:48:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247257 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1854523ilg; Wed, 29 Jul 2020 14:50:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ANG2h8ilS2HGa7NfkUKYm2sMjBRKu+O6TP5L3EfU0wOlyS9ejxegjqAsvRFMhpBMmIYA X-Received: by 2002:a50:93a2:: with SMTP id o31mr276467eda.203.1596059426957; Wed, 29 Jul 2020 14:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596059426; cv=none; d=google.com; s=arc-20160816; b=vx6Mtk2c52c/XWfEbPD9VpG+/urGH2fUv1SC6lmwaunVKHzpqYh7VOfassQV8LnLlR fofYFvv6by/cPP1AFs0+azFB+jEW7CM2nnFuNWrrpme51aXUslwhH9nbJNogspLm5aDV 4AdnLfwGhotEfdPmiTTzrt0CeP5P/3Cw1G9wKZlWGohAnrFCZlUbMjffgSdaELCLRiu3 y+hRYvNe29eEpVsS/yE4Y/ZC7h5vuSodjfq17zdESo503I02Cpc4peMmMsXw/02tNaGl yThXmjUm+JUGVN/QuoE3GrFzzwVB+GqAo2dC5uMUJluAagaMWymeFI64JwO6uCRV0rbp xSFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ABsiYs0xtuCZ6hmXzQfLGo3rLtmdSeGHh35xe8wn6Rs=; b=t+0lydHb851u9j+wXxYRGdQ0SPHB6fLHi/QtXn2js8xfTXvQoyNuv31JZHzpPPE5i9 4nOgkvWypJKR4Tpt+kQCx3A9wPBBcLvXe2Ks+cWgLX6GtdCl/JLmEP0g1tKTHPGn2l2j m49W9+eiu/PxdwSWnoMSAePAeoGee2o532Yzy+/L+W0rrrmTMGHwBXHe7LsGlOSibxJg q9A4E/AOKKc/sk8YbSr7NR37fFuZx8UKBh42V12bYOrjxBJ+Qbv862+P4nXasx6zCIwy 3ek6ni2auJ0l+D2Fun9NY/bXG1fKMXkaqQ9fyMGpmQYor9d4b7oeoTvc3BVQOwCr2EC4 loPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u04DHoZ3; 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 h22si1757230ejj.363.2020.07.29.14.50.26; Wed, 29 Jul 2020 14:50:26 -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=u04DHoZ3; 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 S1726476AbgG2Vu0 (ORCPT + 2 others); Wed, 29 Jul 2020 17:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2VuZ (ORCPT ); Wed, 29 Jul 2020 17:50:25 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DF3C061794 for ; Wed, 29 Jul 2020 14:50:25 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id f5so26679889ljj.10 for ; Wed, 29 Jul 2020 14:50:25 -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=ABsiYs0xtuCZ6hmXzQfLGo3rLtmdSeGHh35xe8wn6Rs=; b=u04DHoZ38wDI2FD7GTuIgjow7521smerbPKc25OViIMHrGmECaq1sGrhYP1aE0jE02 dmfkSB97CtI/1yB6iaWc645e87z3Z0aNzadxKbBVlG6H1Gf0PXcWxFXDFwYVGdszNIF4 Qhrt2ufxhSBCcYnuCJG60VR1qqm3BAtpEc+RdVgIeLjgH/rbLnJglksioSrg4Vkx3vCK ic3W44gDXZuZ/Kgfiv6r031u3AOZvCqdnDY1F6G5KO9Vuvd52W+9gjpJsX3Op8zS4RY1 4BUOZJNXYpmzz0rDg1g9mhfrZrfYGJf8RNHZ5URyPFOdpA+v4HW1mcWZqGP146jMIRp2 K/Eg== 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=ABsiYs0xtuCZ6hmXzQfLGo3rLtmdSeGHh35xe8wn6Rs=; b=PN+gXHAc7573rN+vVSvhbqqOUyj3dejHURd1sz/ms+aqS8MiksxL+v/9KIxW3v7ChK AG2W5+I1lpb7n622RektURDKZP+vxFwmtFf3fOpUYQywaHqrjqksYdNzPfyF8tgKIi+5 BIjC4ahgIr8JiH/kCkNHmtV1qlPh9y7rfFONA3F0YPU5KTOUPVzQ9ljSVMYYAAsw3SFJ AlelsBF8b2YnfpAhEyvFBctW4JgP1hQOjXNi/fIsxpl/BKwqS7cZc6He4Dwir4GYVnWJ a+giLTDswG7jKhTahWUKQGGMYuZgpFfkYsl/DSSF/0x+9eItS+nBIXvrwXbXH92EjiZj AHUA== X-Gm-Message-State: AOAM533Nmp59hq/Hd/gobA+8O04Prp3110+FNzl4O706jHASnfnqEAwb Y+WFldDYA9e6BjqxYatZW4IRmPvlRO93QQ== X-Received: by 2002:a2e:b306:: with SMTP id o6mr145133lja.361.1596059423830; Wed, 29 Jul 2020 14:50:23 -0700 (PDT) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id l26sm721262lfj.22.2020.07.29.14.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 14:50:22 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , =?utf-8?q?Uwe_Kleine-K=C3=B6?= =?utf-8?q?nig?= , Anatolij Gustschin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/2] spi: mpc512x-psc: Use the framework .set_cs() Date: Wed, 29 Jul 2020 23:48:16 +0200 Message-Id: <20200729214817.478834-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The mpc512x-psc is rolling its own chip select control code, but the SPI master framework can handle this. It was also evaluating the CS status for each transfer but the CS change should be per-message not per-transfer. Switch to use the core .set_cs() to control the chip select. Cc: Uwe Kleine-König Cc: Anatolij Gustschin Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Linus Walleij --- drivers/spi/spi-mpc512x-psc.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) -- 2.26.2 diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index ea1b07953d38..35313a77f977 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -89,7 +89,7 @@ static int mpc512x_psc_spi_transfer_setup(struct spi_device *spi, return 0; } -static void mpc512x_psc_spi_activate_cs(struct spi_device *spi) +static void mpc512x_psc_spi_set_cs(struct spi_device *spi, bool enable) { struct mpc512x_psc_spi_cs *cs = spi->controller_state; struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); @@ -98,6 +98,12 @@ static void mpc512x_psc_spi_activate_cs(struct spi_device *spi) int speed; u16 bclkdiv; + if (!enable) { + if (mps->cs_control && gpio_is_valid(spi->cs_gpio)) + mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); + return; + } + sicr = in_be32(psc_addr(mps, sicr)); /* Set clock phase and polarity */ @@ -132,15 +138,6 @@ static void mpc512x_psc_spi_activate_cs(struct spi_device *spi) mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0); } -static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi) -{ - struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master); - - if (mps->cs_control && gpio_is_valid(spi->cs_gpio)) - mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); - -} - /* extract and scale size field in txsz or rxsz */ #define MPC512x_PSC_FIFO_SZ(sz) ((sz & 0x7ff) << 2); @@ -290,40 +287,28 @@ static int mpc512x_psc_spi_msg_xfer(struct spi_master *master, struct spi_message *m) { struct spi_device *spi; - unsigned cs_change; int status; struct spi_transfer *t; spi = m->spi; - cs_change = 1; status = 0; list_for_each_entry(t, &m->transfers, transfer_list) { status = mpc512x_psc_spi_transfer_setup(spi, t); if (status < 0) break; - if (cs_change) - mpc512x_psc_spi_activate_cs(spi); - cs_change = t->cs_change; - status = mpc512x_psc_spi_transfer_rxtx(spi, t); if (status) break; m->actual_length += t->len; spi_transfer_delay_exec(t); - - if (cs_change) - mpc512x_psc_spi_deactivate_cs(spi); } m->status = status; if (m->complete) m->complete(m->context); - if (status || !cs_change) - mpc512x_psc_spi_deactivate_cs(spi); - mpc512x_psc_spi_transfer_setup(spi, NULL); spi_finalize_current_message(master); @@ -513,6 +498,7 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->prepare_transfer_hardware = mpc512x_psc_spi_prep_xfer_hw; master->transfer_one_message = mpc512x_psc_spi_msg_xfer; master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw; + master->set_cs = mpc512x_psc_spi_set_cs; master->cleanup = mpc512x_psc_spi_cleanup; master->dev.of_node = dev->of_node; From patchwork Wed Jul 29 21:48:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 247258 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1854803ilg; Wed, 29 Jul 2020 14:51:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0o5L0e5o72d0Hw7UxAegVlJE8oJV+AAvZZuyXttSs5OsE9S3l9xucJt988pCz6qj95Zo9 X-Received: by 2002:a17:906:3685:: with SMTP id a5mr363941ejc.298.1596059464422; Wed, 29 Jul 2020 14:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596059464; cv=none; d=google.com; s=arc-20160816; b=UP8qKWnrYveVBB9kA3tl37ij3IUV678yczpbCgGnzNbm89gNxQ8i1Ic+ew7j7pwp77 nH3dyLEjjCq+1WYDgvtfAxPpCUZT0E25Z+xMLiomdkWI/2YtVt9x6mmpgzgCW4b2/M7s +rTKTtunX/KGii1l+d8rBW321U7+hp5CnSypzGPRhbqAxNamzCoWVzQG13WLI0dimYYg 7gyVsTm0c2I20LhsLpdUhS2H4NoMYni5vDsJrTupYtQzVsqj/yBdBvFhenH7e9agiOuK 0kIMnlSKV5C3xwiYAkbcNbfAn03w9kMbrBvFo171xpnMqSLiJMYpjw6MVDFynRZJQxRM 7ZQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uhXnQZb72OVE/KwqsuLeJrGhAwOKk910rOtvCQvzHic=; b=tjqSGmpt5k4wZv+yvtaJMZMDtMI1Pqri9UEgjeuq5aasVsU/n7RSalNDjxL6FLdqZ5 uxekMPL84IWYeKrSBN2pA6Hv03TaI7LVmhhXS16iQgymEBqFdE+usP+63rMBIYp1jNP6 klMyuptN2hbnZghKLcKL35p2YwyRZmLBTxdSmG4nTAQO5hnREP136i5kVzbN4lUD15l9 d5id/tM4hgYAM2C704coRLt0kWIrgESzwoyYPK6qNJIid7zy2sHqjy8x2eenLlSbwuj6 m543QtHoBYyxxLr9/nXkjF2TTIX7+NpKiLCAG/s74J7wmYnWfs4frHVzhLzo95mEtWYj qqZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wwuW2GJ5; 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 h22si1757230ejj.363.2020.07.29.14.51.04; Wed, 29 Jul 2020 14:51:04 -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=wwuW2GJ5; 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 S1726628AbgG2VvD (ORCPT + 2 others); Wed, 29 Jul 2020 17:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgG2VvD (ORCPT ); Wed, 29 Jul 2020 17:51:03 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B7EC061794 for ; Wed, 29 Jul 2020 14:51:03 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id r19so26646970ljn.12 for ; Wed, 29 Jul 2020 14:51:02 -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=uhXnQZb72OVE/KwqsuLeJrGhAwOKk910rOtvCQvzHic=; b=wwuW2GJ5EwJebvjdUC1IyZ4tAhKBxGAcjcJhLfBkZALkm8/oVCQwNet64/fJYCZxT8 YnzKUdxY846I/wT9ercq6OwiKDk7N5dHPffCEBCrjQF0libGWs+2V6vIBNA93sPdYnmp BLAcIPf2rjOerZmVvug7LUQCKLUrSDMvteyeiDxplvoc+tN9nOOvgd6Q6jb3fTpxycP9 +qmGHZuVrziEFDtGxsEsTbSNXCOGkptKeqY38SsZvlnkpWR/Jah1SLSAWS1Gr41t+C5f hPtyzblnDDVGAo39828sq9pGwQFXvw+GuVJLVJ5txNVSXe3Bw4GpRt99AdxEb3gMJhXu 3GmA== 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=uhXnQZb72OVE/KwqsuLeJrGhAwOKk910rOtvCQvzHic=; b=H62qFj8enltlfVlUUkco//1sTbKKRG3GKeUZpQypfuuQsil+r72aWL2kTIruz/9ii4 UppniSDUSG9ycX+VrX4aw13TvPrnGG0lZ7Tv2s3UmRMl6IxC0fk6muJhuRcwV1X4fJR2 bO6NBljudzOWdhtUySquzHFVkkRemaeB0WAQ31eY0AV28TCzRXJGXqRLcdjAhybAIznX n7KOLV5fjPiO81BFPF0Yk+DB2zABBMHgVDP9TbygT7H4g+pwxK4j5oDNu55Lg97rt+rb HSy8dhWKR1t03m0cOXr3mX6IcYBQK9F/sVXlAevkxplUh/VWL2RuCykZjMNbSdryJLO7 g2Eg== X-Gm-Message-State: AOAM530NPIcUNUwa3WH/w1KLWtZpZeDi1DWk7jWIYb3q3dk+fdZi63pj DHOnXjNG0DoBtlYAVE/W28I97+yS0PWqGg== X-Received: by 2002:a2e:961a:: with SMTP id v26mr164311ljh.467.1596059461464; Wed, 29 Jul 2020 14:51:01 -0700 (PDT) Received: from localhost.localdomain (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id l26sm721262lfj.22.2020.07.29.14.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2020 14:50:59 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , =?utf-8?q?Uwe_Kleine-K=C3=B6?= =?utf-8?q?nig?= , Anatolij Gustschin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/2] spi: mpc512x-psc: Convert to use GPIO descriptors Date: Wed, 29 Jul 2020 23:48:17 +0200 Message-Id: <20200729214817.478834-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200729214817.478834-1-linus.walleij@linaro.org> References: <20200729214817.478834-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org This driver is already relying on the core to provide valid GPIO numbers in spi->cs_gpio through of_spi_get_gpio_numbers(), so we can switch to letting the core use GPIO descriptors instead. Make sure that the .set_cs() is always called, as some controller set-up is also needed. Cc: Uwe Kleine-König Cc: Anatolij Gustschin Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Linus Walleij --- drivers/spi/spi-mpc512x-psc.c | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) -- 2.26.2 diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 35313a77f977..dd8bba408301 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -23,7 +23,6 @@ #include #include #include -#include #include enum { @@ -99,7 +98,7 @@ static void mpc512x_psc_spi_set_cs(struct spi_device *spi, bool enable) u16 bclkdiv; if (!enable) { - if (mps->cs_control && gpio_is_valid(spi->cs_gpio)) + if (mps->cs_control && spi->cs_gpiod) mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1); return; } @@ -134,7 +133,7 @@ static void mpc512x_psc_spi_set_cs(struct spi_device *spi, bool enable) out_be32(psc_addr(mps, ccr), ccr); mps->bits_per_word = cs->bits_per_word; - if (mps->cs_control && gpio_is_valid(spi->cs_gpio)) + if (mps->cs_control && spi->cs_gpiod) mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0); } @@ -358,18 +357,6 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi) if (!cs) return -ENOMEM; - if (gpio_is_valid(spi->cs_gpio)) { - ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "can't get CS gpio: %d\n", - ret); - kfree(cs); - return ret; - } - gpio_direction_output(spi->cs_gpio, - spi->mode & SPI_CS_HIGH ? 0 : 1); - } - spi->controller_state = cs; } @@ -381,8 +368,6 @@ static int mpc512x_psc_spi_setup(struct spi_device *spi) static void mpc512x_psc_spi_cleanup(struct spi_device *spi) { - if (gpio_is_valid(spi->cs_gpio)) - gpio_free(spi->cs_gpio); kfree(spi->controller_state); } @@ -461,11 +446,6 @@ static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id) return IRQ_NONE; } -static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff) -{ - gpio_set_value(spi->cs_gpio, onoff); -} - static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, u32 size, unsigned int irq) { @@ -485,10 +465,8 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, mps->type = (int)of_device_get_match_data(dev); mps->irq = irq; - if (pdata == NULL) { - mps->cs_control = mpc512x_spi_cs_control; - } else { - mps->cs_control = pdata->cs_control; + if (pdata) { + mps->cs_control = pdata->cs_control;x master->bus_num = pdata->bus_num; master->num_chipselect = pdata->max_chipselect; } @@ -499,6 +477,9 @@ static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr, master->transfer_one_message = mpc512x_psc_spi_msg_xfer; master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw; master->set_cs = mpc512x_psc_spi_set_cs; + /* This makes sure our custom .set_cs() is always called */ + master->flags = SPI_MASTER_GPIO_SS; + master->use_gpio_descriptors = true; master->cleanup = mpc512x_psc_spi_cleanup; master->dev.of_node = dev->of_node;