From patchwork Wed May 27 19:00:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1319 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 20BAD3F1DD for ; Wed, 27 May 2020 21:00:20 +0200 (CEST) Received: by mail-pj1-f70.google.com with SMTP id gw3sf3210289pjb.1 for ; Wed, 27 May 2020 12:00:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1590606018; cv=pass; d=google.com; s=arc-20160816; b=UCWOs2BieleO4UzwpiTWlzKvtpiGN1o3EsuUGoASRiaagX+mrW3Qddytab+QC7HwKY /T3Xig0hY3EwO80tkp7TvkV13WH+cn6dqUJ1XWjVzYKB7tWVQiPbyLqr0DQpykKmJ1Kq 48j7Zg5OBhqGYGj5i4P12AsK1Vankv6E6vVq0zxXdxGJEwcLam+IlJZq2S/t7Ir8O5CQ QVemCUmjnLqrhTVIRc1UtfbDPC1L+V0LO9lTk48fEW2RBDlsejEcMkDeAan7A4WaOGNN uxCN2eyuGo6SSqziqiMqV6Z6W3ZpmBvpJoqPCbK4WqcdmDIzTTFOc5KKtH/iIjOFlDtu Rv6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MFYAKsLOqD23qSLos7FVWmAZpFiPl4KKJ/pIRQRLK38=; b=BTbh/HYvmmcc9P4paoO3RsYG473tAEipn7I20M0yNcV/uU4yZ5bT3Z2pdJQekkQnSF 6tQpTnTFWRjXP+Ds4JCBeTpKR68GGdCHmW6/lwAARI9lYm60gDWlgyuMZnxCgo02MtiG xidknNdAmrwq8rV+vhZms2eJ31PJCWAjYZH8O5soz4Y0qw7C5cKXZrA5d9o5ZPaRsr4f gC8vPPWJGChBVae2x4Cv1aUmiK889d6O7P2OkeelvDxrMd1p/iOUSSTpvN6QSJAoAX69 CRRmSpPotXexl3uw2NpFtzZz0o+z7E//gjR8eHd1+LuLDTjdpMysXLU+YTyAgY2WY74z z8zQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="RAv/Gy/O"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=MFYAKsLOqD23qSLos7FVWmAZpFiPl4KKJ/pIRQRLK38=; b=WWEDSfKwyQu4Vm5Bkm+170BqnP7qY5ZsChlXcsyCSdxEIo7DIdcK/obnc5xk/tUqVh IEp8BHUaqWC3gGD0U7LOPLTg8pSWctrtlNLhXHmKMg9FmqMjUfyhsfktPmSXjDl05n7I IEXY33dd0kDb9eUHpfc5orZ6XsYBPK7Q/3Sso= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=MFYAKsLOqD23qSLos7FVWmAZpFiPl4KKJ/pIRQRLK38=; b=Yx5xXcBXOlIfAPqwAL5vkjylHbMbVjNOLsrXvaxbz1jjbWUXOyEd0zBYLC+f3afGJP yZnF2sRYst+2QN1fn6k/24YwBkYpoRPjnxQMrmzUyrhHvrhS39eT+vpBwJ+T0doAnjyx EEVRUb8XphAjihlwqacODTSFD99SBM0VpSu1H5KzMY3XrRL3WO39kmGi1CaKmS+xw9w5 sByKYXGFea89miDcOz2poYSJhuGLUQB3emy5Dev0TNjz2MYyBcEXbTQmSJXHlDeT9KJv Hss/8NSbUjyu5vefE5fHo8b7YObYFLljooutYnjfoAKZWWfTtYiuIwSyYC9fPcrWpGfz SECA== X-Gm-Message-State: AOAM530xWO/ammjY1C5OfNMCZHuHiTFECHgmai3QCFYkPtC9/1HZ8Hey tyeoWnx/m1EpJoZwRzL37x4J8urL X-Google-Smtp-Source: ABdhPJxZthSXDpQag7tlGonYJ5E/7zVG3/yOcczxc9yUta3wqoUoxbIY4A//1/e6MBbHQT9Pb4tHyg== X-Received: by 2002:a17:90a:1aa3:: with SMTP id p32mr6865672pjp.4.1590606018259; Wed, 27 May 2020 12:00:18 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90b:384c:: with SMTP id nl12ls1840480pjb.2.canary-gmail; Wed, 27 May 2020 12:00:17 -0700 (PDT) X-Received: by 2002:a17:90a:5806:: with SMTP id h6mr6766963pji.66.1590606017590; Wed, 27 May 2020 12:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606017; cv=none; d=google.com; s=arc-20160816; b=mSc6X9GQ4+8d4Xjf1CY9IgP+VVDwaGl2+BKJDBsBwluTE6FBvggCicawhzmSoARiG3 y3vTfHsCuJEAi8H9zhBHGObH7KVpiXxDSkecCQLGYbQbbXth3+5V5ymrjgcGiN+eKRsW GreutXxM3Cs4pCnOw1hDak2lAp/htsf0KP+DvB17/FuTh5fXfqz/16FLbav9W9/XBKMV 4Ioy+9FWCL+yvmJ7+8bxmkPpcsRPqhCiuT+cAab5PyWv355ZTdQCuI1yQFH09+x/Snel R+32A5/6dVAr09uFFoDrhWrBpPrBFkMG75qPd3xCn2RVx+R0b5teC1mLU3p9F2c6Ct/X eNgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=owYMT0rITPfsX0KDpobeLsujLQ6jL1OkibN+Zx9yG5Q=; b=cPGscnJAIt0MTdSOItTwcr2+UlonrGGuIyTjFVore9o+rjg5jQFZwxN8ExcraGc7Y0 z5+vZd2yHtJfHqNVqOTsuP7ZsTcR8HLcmWSw4h/rKcjRwuIWwp4cDIQvhhwXlqkoJdt2 7JmW8Xw2iqxhPT+y5TC3l8rqJsM3aCCY7P/SqfKkBA+q9jP39J1yzVxablhB8KT5nONv opamo3h05TAv2ywn+8F83W5U/uI1ITe3OJTc6tCo5ptlaf7rqRA6GhYSBP+1exGQRIQh mZuoyy4/nmvB8hNbKA/2ZO9C9UDCj6zmxYkq3e/JIsLGqQp4KV+4+rznHTyPVGDPThPj 2w4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="RAv/Gy/O"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g5sor5400199plp.31.2020.05.27.12.00.17 for (Google Transport Security); Wed, 27 May 2020 12:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:70c1:: with SMTP id l1mr7116914plt.178.1590606016834; Wed, 27 May 2020 12:00:16 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:91de:b2d4:ed11:6aeb]) by smtp.gmail.com with ESMTPSA id s123sm2691532pfs.170.2020.05.27.12.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 12:00:16 -0700 (PDT) From: Jagan Teki To: Simon Glass , Tom Rini Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Jagan Teki , Wenyou Yang Subject: [PATCH 2/3] spi: atmel: Remove nondm code Date: Thu, 28 May 2020 00:30:01 +0530 Message-Id: <20200527190002.202913-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200527190002.202913-1-jagan@amarulasolutions.com> References: <20200527190002.202913-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="RAv/Gy/O"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , atmel spi driver now accessible only when DM_SPI enabled. So, remove nondm code. Cc: Wenyou Yang Signed-off-by: Jagan Teki --- drivers/spi/atmel_spi.c | 198 ---------------------------------------- drivers/spi/atmel_spi.h | 11 --- 2 files changed, 209 deletions(-) diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index f076e92a93..b9f684d67e 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -14,210 +14,13 @@ #include #include -#ifdef CONFIG_DM_SPI #include -#endif #if CONFIG_IS_ENABLED(DM_GPIO) #include #endif #include "atmel_spi.h" -#ifndef CONFIG_DM_SPI - -static int spi_has_wdrbt(struct atmel_spi_slave *slave) -{ - unsigned int ver; - - ver = spi_readl(slave, VERSION); - - return (ATMEL_SPI_VERSION_REV(ver) >= 0x210); -} - -struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, - unsigned int max_hz, unsigned int mode) -{ - struct atmel_spi_slave *as; - unsigned int scbr; - u32 csrx; - void *regs; - - if (!spi_cs_is_valid(bus, cs)) - return NULL; - - switch (bus) { - case 0: - regs = (void *)ATMEL_BASE_SPI0; - break; -#ifdef ATMEL_BASE_SPI1 - case 1: - regs = (void *)ATMEL_BASE_SPI1; - break; -#endif -#ifdef ATMEL_BASE_SPI2 - case 2: - regs = (void *)ATMEL_BASE_SPI2; - break; -#endif -#ifdef ATMEL_BASE_SPI3 - case 3: - regs = (void *)ATMEL_BASE_SPI3; - break; -#endif - default: - return NULL; - } - - - scbr = (get_spi_clk_rate(bus) + max_hz - 1) / max_hz; - if (scbr > ATMEL_SPI_CSRx_SCBR_MAX) - /* Too low max SCK rate */ - return NULL; - if (scbr < 1) - scbr = 1; - - csrx = ATMEL_SPI_CSRx_SCBR(scbr); - csrx |= ATMEL_SPI_CSRx_BITS(ATMEL_SPI_BITS_8); - if (!(mode & SPI_CPHA)) - csrx |= ATMEL_SPI_CSRx_NCPHA; - if (mode & SPI_CPOL) - csrx |= ATMEL_SPI_CSRx_CPOL; - - as = spi_alloc_slave(struct atmel_spi_slave, bus, cs); - if (!as) - return NULL; - - as->regs = regs; - as->mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS - | ATMEL_SPI_MR_PCS(~(1 << cs) & 0xf); - if (spi_has_wdrbt(as)) - as->mr |= ATMEL_SPI_MR_WDRBT; - - spi_writel(as, CSR(cs), csrx); - - return &as->slave; -} - -void spi_free_slave(struct spi_slave *slave) -{ - struct atmel_spi_slave *as = to_atmel_spi(slave); - - free(as); -} - -int spi_claim_bus(struct spi_slave *slave) -{ - struct atmel_spi_slave *as = to_atmel_spi(slave); - - /* Enable the SPI hardware */ - spi_writel(as, CR, ATMEL_SPI_CR_SPIEN); - - /* - * Select the slave. This should set SCK to the correct - * initial state, etc. - */ - spi_writel(as, MR, as->mr); - - return 0; -} - -void spi_release_bus(struct spi_slave *slave) -{ - struct atmel_spi_slave *as = to_atmel_spi(slave); - - /* Disable the SPI hardware */ - spi_writel(as, CR, ATMEL_SPI_CR_SPIDIS); -} - -int spi_xfer(struct spi_slave *slave, unsigned int bitlen, - const void *dout, void *din, unsigned long flags) -{ - struct atmel_spi_slave *as = to_atmel_spi(slave); - unsigned int len_tx; - unsigned int len_rx; - unsigned int len; - u32 status; - const u8 *txp = dout; - u8 *rxp = din; - u8 value; - - if (bitlen == 0) - /* Finish any previously submitted transfers */ - goto out; - - /* - * TODO: The controller can do non-multiple-of-8 bit - * transfers, but this driver currently doesn't support it. - * - * It's also not clear how such transfers are supposed to be - * represented as a stream of bytes...this is a limitation of - * the current SPI interface. - */ - if (bitlen % 8) { - /* Errors always terminate an ongoing transfer */ - flags |= SPI_XFER_END; - goto out; - } - - len = bitlen / 8; - - /* - * The controller can do automatic CS control, but it is - * somewhat quirky, and it doesn't really buy us much anyway - * in the context of U-Boot. - */ - if (flags & SPI_XFER_BEGIN) { - spi_cs_activate(slave); - /* - * sometimes the RDR is not empty when we get here, - * in theory that should not happen, but it DOES happen. - * Read it here to be on the safe side. - * That also clears the OVRES flag. Required if the - * following loop exits due to OVRES! - */ - spi_readl(as, RDR); - } - - for (len_tx = 0, len_rx = 0; len_rx < len; ) { - status = spi_readl(as, SR); - - if (status & ATMEL_SPI_SR_OVRES) - return -1; - - if (len_tx < len && (status & ATMEL_SPI_SR_TDRE)) { - if (txp) - value = *txp++; - else - value = 0; - spi_writel(as, TDR, value); - len_tx++; - } - if (status & ATMEL_SPI_SR_RDRF) { - value = spi_readl(as, RDR); - if (rxp) - *rxp++ = value; - len_rx++; - } - } - -out: - if (flags & SPI_XFER_END) { - /* - * Wait until the transfer is completely done before - * we deactivate CS. - */ - do { - status = spi_readl(as, SR); - } while (!(status & ATMEL_SPI_SR_TXEMPTY)); - - spi_cs_deactivate(slave); - } - - return 0; -} - -#else - #define MAX_CS_COUNT 4 struct atmel_spi_platdata { @@ -507,4 +310,3 @@ U_BOOT_DRIVER(atmel_spi) = { .priv_auto_alloc_size = sizeof(struct atmel_spi_priv), .probe = atmel_spi_probe, }; -#endif diff --git a/drivers/spi/atmel_spi.h b/drivers/spi/atmel_spi.h index b602887c29..9663cca5e6 100644 --- a/drivers/spi/atmel_spi.h +++ b/drivers/spi/atmel_spi.h @@ -79,17 +79,6 @@ #define ATMEL_SPI_BITS_15 7 #define ATMEL_SPI_BITS_16 8 -struct atmel_spi_slave { - struct spi_slave slave; - void *regs; - u32 mr; -}; - -static inline struct atmel_spi_slave *to_atmel_spi(struct spi_slave *slave) -{ - return container_of(slave, struct atmel_spi_slave, slave); -} - /* Register access macros */ #define spi_readl(as, reg) \ readl(as->regs + ATMEL_SPI_##reg)