From patchwork Thu Jun 25 23:12:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 191751 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1264439ilg; Thu, 25 Jun 2020 16:13:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqAQOglr9fTm1oKRwU0qw79arctu1DX54Tspf2V1Az21J3Mt2f0YdRn12J/gMrgjQQP4Ed X-Received: by 2002:a17:906:ae56:: with SMTP id lf22mr118510ejb.59.1593126783949; Thu, 25 Jun 2020 16:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593126783; cv=none; d=google.com; s=arc-20160816; b=NY+Rerf80mQs0YrqoQ40LrQ8PcCe4QqPgPsyHWV+qsLyLhzmMLx7tetpDDNHi4cel9 hdu6V0VyZokojmIFpMHg/kqlnU6KpE/Hk8fkUAPcqrCKjyXOqvWi9s5t9PmKmJYZZVe8 nckxAOFiFNhyWuEH2AikH9jM/v0BdK00Y7p2B6abAmGG5drFB0Ln6RKcaq8j3oQ0FAap RMackA6+1ojsauX9VyRX/f00ktjf2+Vb7ZHtspKJCpM/NOj2C4rC59zOXlYWMDOuLaZq B8rHC3WWlZ6/27rz+opmw/fFsgu3eceVJMH1sE7uJHh+fUd8u1Csha3AejJoi/Bwh0uO 7FNA== 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=8l/4qnt5t8nkFw+DlUPZ4RXWogUlkAdw7ImexBI0ikI=; b=wmrUu23Lva1m3GsdEmrF9XYxD9WZKJhQpT1tjV0SOdMwvXtI0ZB30K0BZGaSY/gq3n zuvkOKs8oSbhl3l5aPupp4MYM5l2dW/d7opKOwVIDNF99mQDpou4Ehi5jVLKTzOa9pct 9jAqg4dISDmt2jqOdEYfd7qR6PtgxAeoo8PE4ro3RnUDDlRIHEmDXiv/MyvogJgV5i6x Wg0lNTKddJUTT/z1XruahF+eYvlTA/Jd7gEUAcGqveRJYCxKkyj18r5nTxcXpLL0vJMz oIEtx8jZerqq+VLxOSbrRfrU9Mw2hAds9gnp2plmkLyGcTViC8sqsapfb2dU/1f07CGd QBMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IBKFFdB1; 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 c5si10048872edy.429.2020.06.25.16.13.03; Thu, 25 Jun 2020 16:13:03 -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=IBKFFdB1; 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 S2403984AbgFYXNC (ORCPT + 2 others); Thu, 25 Jun 2020 19:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407700AbgFYXNB (ORCPT ); Thu, 25 Jun 2020 19:13:01 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1965EC08C5C1 for ; Thu, 25 Jun 2020 16:13:01 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id t9so4133628lfl.5 for ; Thu, 25 Jun 2020 16:13:01 -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=8l/4qnt5t8nkFw+DlUPZ4RXWogUlkAdw7ImexBI0ikI=; b=IBKFFdB1A9rgQj5qLECj4YGrtznXMmNs1xQ2l57LiWgCW4He0mUH6+oAF4jP0OgRKV cLd0AVGMJd/i3FpiNY5jSKTS3E2qteXfPN5/cPGWC+TDVr1oghCZYYs2H++3H9EIB3Kq Hjb1vSJJdXZAq7J5AW/lzSj1ZGKodpdGM0TTWxRuQLk2NoSu9oxd6JQxbpXipfxOX0a0 FmX8am3sTO0/hRFzJ3pT0ipywWTEwihaC+HONP55IwfQU3bkwXoR48hbcpojn4XWbCSI rR3w/KWgs7OZC0maM13ReKfc4bZQNe/R7B+QNs7ioUzNritb3PqCi3NexYQQkHH57qJE 0vkg== 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=8l/4qnt5t8nkFw+DlUPZ4RXWogUlkAdw7ImexBI0ikI=; b=QJSrinumSt86RGMGHfL1rSrSs9sELAZwGA9VIgLABlmS5yf75Hke3tIQISKH3QPbUW Jfbn293g71qzoDgL4r5bjt9iR+/dQQMfv9kUHkAiBYmbWDKqTfhi7SqnPa3Jis3cRmRo rZtZwsM/9/51hD3GvY4g4X3cH/hjdr4pVPbWPEiXRZjRaeR4nJIb3Yzfvl8Vgi+EenOM GO4fRNEGNSXcPejfUiqwOlhGMWkwKq+LNaiBN/loCBicaolwgqUabK7UrKPc/+onWeAJ KI6pJ/p3k6vodNhPDr2ZpKBtEiEI5dzTo+QHZ1ryC3rnF4Nx6sTb3OE3Ho6gTXyVQUOX Ldvg== X-Gm-Message-State: AOAM533AWRM5XdJFPzudLuFsXuy5zdZVc1aDtcMuC7UR1iicyHtUtQaA wuyACl5OnefxYB7amjcozSaMww== X-Received: by 2002:a19:14e:: with SMTP id 75mr208475lfb.7.1593126779559; Thu, 25 Jun 2020 16:12:59 -0700 (PDT) Received: from genomnajs.lan (c-d63ee155.152980-0-69706f6e6c79.bbcust.telenor.se. [85.225.62.214]) by smtp.gmail.com with ESMTPSA id m15sm1973156ljp.45.2020.06.25.16.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 16:12:59 -0700 (PDT) From: Linus Walleij To: Mark Brown , linux-spi@vger.kernel.org Cc: Linus Walleij , Vignesh Raghavendra , David Lechner , Tony Lindgren Subject: [PATCH] spi: omap2-mcspi: Convert to use GPIO descriptors Date: Fri, 26 Jun 2020 01:12:57 +0200 Message-Id: <20200625231257.280615-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The OMAP2 MCSPI has some kind of half-baked GPIO CS support: it includes code like this: if (gpio_is_valid(spi->cs_gpio)) { ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); (...) But it doesn't parse the "cs-gpios" attribute in the device tree to count the number of GPIOs or pick out the GPIO numbers and put these in the SPI master's .cs_gpios property. We complete the implementation of supporting CS GPIOs from the device tree and switch it over to use the SPI core for this. Cc: Vignesh Raghavendra Cc: David Lechner Cc: Tony Lindgren Signed-off-by: Linus Walleij --- drivers/spi/spi-omap2-mcspi.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) -- 2.25.4 Acked-by: Tony Lindgren diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index e9e256718ef4..1c9478e6e5d9 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -27,7 +27,6 @@ #include #include -#include #include @@ -1043,16 +1042,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) spi->controller_state = cs; /* Link this to context save list */ list_add_tail(&cs->node, &ctx->cs); - - if (gpio_is_valid(spi->cs_gpio)) { - ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "failed to request gpio\n"); - return ret; - } - gpio_direction_output(spi->cs_gpio, - !(spi->mode & SPI_CS_HIGH)); - } } ret = pm_runtime_get_sync(mcspi->dev); @@ -1080,9 +1069,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) kfree(cs); } - - if (gpio_is_valid(spi->cs_gpio)) - gpio_free(spi->cs_gpio); } static irqreturn_t omap2_mcspi_irq_handler(int irq, void *data) @@ -1152,7 +1138,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master, omap2_mcspi_set_enable(spi, 0); - if (gpio_is_valid(spi->cs_gpio)) + if (spi->cs_gpiod) omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH); if (par_override || @@ -1241,7 +1227,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master, omap2_mcspi_set_enable(spi, 0); - if (gpio_is_valid(spi->cs_gpio)) + if (spi->cs_gpiod) omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH)); if (mcspi->fifo_depth > 0 && t) @@ -1431,6 +1417,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev) master->dev.of_node = node; master->max_speed_hz = OMAP2_MCSPI_MAX_FREQ; master->min_speed_hz = OMAP2_MCSPI_MAX_FREQ >> 15; + master->use_gpio_descriptors = true; platform_set_drvdata(pdev, master);