From patchwork Wed May 27 19:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1320 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A23413F1DD for ; Wed, 27 May 2020 21:00:22 +0200 (CEST) Received: by mail-pf1-f199.google.com with SMTP id 194sf20362719pfb.15 for ; Wed, 27 May 2020 12:00:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1590606021; cv=pass; d=google.com; s=arc-20160816; b=btxrKXr2bAgo/n8t18ESceTMNuNXrGOgqjraVSYZcOjaZmlrzMQ2xXnUcKtNDkFB+c jvlnGjdDtmZZwtIpNd4xrTLySFKIqF8QoC21ZuJDyGgcIEFagfAizekj/20uHFKcWX1j c/ATcjk1FBiPOwVkD6/GYSTRqqIU1MzBGHmhgSqGHWLd82kFgQG3Pl90h5VimjDT3w48 t8BUWKNgUyAV0PMrC23PADifSD5evdsPv6ZJDHW+CwrLAih3Yn6woMw4Ve2t76GXXmTG GZX0nk/T4ee1KkJrlFkW0oW16+1iRYERYyOUvdJ0BvbfVcuMMJTD52ElF9/8CHoldffr pvng== 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=7ByiU5cAXkpnue3r7KmKSsVulHKg4V7l2O0cv9h6iLU=; b=QEWM8SZQ3OYJ5TTw7uWMpqIovp1758MmwUsDMb2daHpa0UdS4YZGaiE4ErR2q1ev5w oKxGSGVeVrCCOKuvDI0OKti/wwbsZB8Oi7MeFHq5imnjPYhgTe9Sh4v0w7y38tEiIhnS SnxCYaDe8GbIXOo6uUzI3AlAG8eWgWJEP+NmugMiw6yHJ36ptHpMjfXtxxopVeo2x6uP 9lS87M91b/FFh7GSu3bijj52fJNEzYOubiIkz+pwNhlm9KFWRcCA6HBUYXsNQRvZGbKV RyvYkzHKMtaYDuqNLT3FRJcVqSFi57v4CDhZEUAtH8Pt3gUTA4tBvkGXg24fKeO4gQVD qRuA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HCvUIZ+1; 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=7ByiU5cAXkpnue3r7KmKSsVulHKg4V7l2O0cv9h6iLU=; b=Os9bo8yc8bxbc3ttmSiWmRbhZmd5lFjY3vSmMvxXx28oajAENI126dA0QtNkHv4BBS IcjgM0k1IVQrfK2HmTCI9dAesX+IcQYnazPMKV4AZABC2+R91WvGAx/K+mVVSRQ6hEjH znAsKL9HK26Ow+wwYc4/UOPthKV1LPwWCzknA= 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=7ByiU5cAXkpnue3r7KmKSsVulHKg4V7l2O0cv9h6iLU=; b=h/bSh67R+hzwjaHFPC6CxBsTdvhYB7kOOMZJ6cjdkwPgwTkFcky+/OmVcn2oaNiUO+ SuVZhxeVbBGBVOnDRwq1Eyp7/KlTljCgezGrx5pElIm+IUv8wVpYz99qVrPrJwLl7qOr IlaXq+hnlbV/scdppB3gKm3DaQqsCmbQLcmXcMnnaPSEMW/CE50Gl0jy5mOJ0PutVuX8 IBzAGXq+DEhzJi4ZQnNqOESGpCCcN+3Jz6kQhQVgKbq4rbjVl/4CYZOPpiI4rHotc5Lg 2zu7bn8VZbmW5gLfsNwn9vzgRFfrqYuLTys9F95U+VSiv2h6EPz5DNcT6kU0qhYc0GUv mipw== X-Gm-Message-State: AOAM533Ajq1C/OmMRqPxFBrXb3hlvRkSuCESSfRjCyyvB0jRHCXsg3yg YWlQtOajy0odvw5VWdxrXl5yxWSp X-Google-Smtp-Source: ABdhPJzPOkk70dIE2CO8YHst1pSsGa6er5DrW1yWMpSMUsCjL7v3DIjrec7fAAT8TjNV0WD3Hjwc7w== X-Received: by 2002:a62:1d4c:: with SMTP id d73mr5215866pfd.226.1590606020681; Wed, 27 May 2020 12:00:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:63d0:: with SMTP id n16ls1854419pgv.6.gmail; Wed, 27 May 2020 12:00:20 -0700 (PDT) X-Received: by 2002:aa7:850f:: with SMTP id v15mr5485111pfn.277.1590606020160; Wed, 27 May 2020 12:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606020; cv=none; d=google.com; s=arc-20160816; b=SS0q1yPbSqYo9ZOIA/pLlzSxrrQYxG8f6f+pC6i6xlK16a95Z1ak0+o/7rlJZRDdbc xIfI2qYJGw3UrMSLyeaR7qOfRAT+n9G7W2kafP2HnTH4ghwtLcP1aorV/wK6/R2fCVpg 8+BBmRvaEysvH0IuOWfzabk3ngzXl66zCPMr80VHwdl/l8XGNhllDBMWGo43eRoYQh2g 2NX1wxzGrD/9Hy+UF9cY4Q1sZxqeD29P2QCBwiFVn40CCkAINFXDHDJAp85/bAueQBDJ Ug95T/+sCxXo1uccAhmJs2w0V0e5fL4xvoUORNt+Tr7tsg7Qvs7t2Sdm8qIt6MtIjJIf lk0w== 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=YRHXB3oXwtgGqc+LT5BqKJqtUS5ILkTPKm2zKGlnF1o=; b=pZ20x7j+nXLKU7ZmGRLOmZmHOuWwA6z3HsYlxjJUWHJXOwkbWsG1P5v8vgaGqbAnu1 st5gB8zwgKQkM3KLyf3gmOOBdfcSqyEDoy7dbgOvhCnsc6FL+9aaYFlqJIfOL5+3sN1q +jGjJCos8jyPUjzavIlqeM8tLmWy42woW3GCOMkZG70vQplMVFjUEFtU8JTGnjtaI41b 014XJbaBfM/k3cnzaLf4YxVm5uPKL6i3zUxvyghKeeNLIaByL64oZTZ4H0gkK6oPITF2 ymx6DUjgl2wxneliR4gxwQpXcvhNmpK9jdueD3KhRByuIoGXR6Msi/xutpqAqXVRuv0G 24zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HCvUIZ+1; 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 g5sor5400478plp.31.2020.05.27.12.00.20 for (Google Transport Security); Wed, 27 May 2020 12:00:20 -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:6ac2:: with SMTP id i2mr7471503plt.18.1590606019810; Wed, 27 May 2020 12:00:19 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 12:00:19 -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 3/3] spi: atmel: Drop atmel_spi.h Date: Thu, 28 May 2020 00:30:02 +0530 Message-Id: <20200527190002.202913-3-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=HCvUIZ+1; 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.h has register offsets, and atmel_spi_slave structure, move it into .c file for better readability and drop atmel_spi.h Cc: Wenyou Yang Signed-off-by: Jagan Teki --- drivers/spi/atmel_spi.c | 88 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-) diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index b9f684d67e..b120664661 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -9,20 +9,102 @@ #include #include #include - #include - #include #include #include #if CONFIG_IS_ENABLED(DM_GPIO) #include #endif +#include -#include "atmel_spi.h" +/* + * Register definitions for the Atmel AT32/AT91 SPI Controller + */ +/* Register offsets */ +#define ATMEL_SPI_CR 0x0000 +#define ATMEL_SPI_MR 0x0004 +#define ATMEL_SPI_RDR 0x0008 +#define ATMEL_SPI_TDR 0x000c +#define ATMEL_SPI_SR 0x0010 +#define ATMEL_SPI_IER 0x0014 +#define ATMEL_SPI_IDR 0x0018 +#define ATMEL_SPI_IMR 0x001c +#define ATMEL_SPI_CSR(x) (0x0030 + 4 * (x)) +#define ATMEL_SPI_VERSION 0x00fc + +/* Bits in CR */ +#define ATMEL_SPI_CR_SPIEN BIT(0) +#define ATMEL_SPI_CR_SPIDIS BIT(1) +#define ATMEL_SPI_CR_SWRST BIT(7) +#define ATMEL_SPI_CR_LASTXFER BIT(24) + +/* Bits in MR */ +#define ATMEL_SPI_MR_MSTR BIT(0) +#define ATMEL_SPI_MR_PS BIT(1) +#define ATMEL_SPI_MR_PCSDEC BIT(2) +#define ATMEL_SPI_MR_FDIV BIT(3) +#define ATMEL_SPI_MR_MODFDIS BIT(4) +#define ATMEL_SPI_MR_WDRBT BIT(5) +#define ATMEL_SPI_MR_LLB BIT(7) +#define ATMEL_SPI_MR_PCS(x) (((x) & 15) << 16) +#define ATMEL_SPI_MR_DLYBCS(x) ((x) << 24) + +/* Bits in RDR */ +#define ATMEL_SPI_RDR_RD(x) (x) +#define ATMEL_SPI_RDR_PCS(x) ((x) << 16) + +/* Bits in TDR */ +#define ATMEL_SPI_TDR_TD(x) (x) +#define ATMEL_SPI_TDR_PCS(x) ((x) << 16) +#define ATMEL_SPI_TDR_LASTXFER BIT(24) + +/* Bits in SR/IER/IDR/IMR */ +#define ATMEL_SPI_SR_RDRF BIT(0) +#define ATMEL_SPI_SR_TDRE BIT(1) +#define ATMEL_SPI_SR_MODF BIT(2) +#define ATMEL_SPI_SR_OVRES BIT(3) +#define ATMEL_SPI_SR_ENDRX BIT(4) +#define ATMEL_SPI_SR_ENDTX BIT(5) +#define ATMEL_SPI_SR_RXBUFF BIT(6) +#define ATMEL_SPI_SR_TXBUFE BIT(7) +#define ATMEL_SPI_SR_NSSR BIT(8) +#define ATMEL_SPI_SR_TXEMPTY BIT(9) +#define ATMEL_SPI_SR_SPIENS BIT(16) + +/* Bits in CSRx */ +#define ATMEL_SPI_CSRx_CPOL BIT(0) +#define ATMEL_SPI_CSRx_NCPHA BIT(1) +#define ATMEL_SPI_CSRx_CSAAT BIT(3) +#define ATMEL_SPI_CSRx_BITS(x) ((x) << 4) +#define ATMEL_SPI_CSRx_SCBR(x) ((x) << 8) +#define ATMEL_SPI_CSRx_SCBR_MAX GENMASK(7, 0) +#define ATMEL_SPI_CSRx_DLYBS(x) ((x) << 16) +#define ATMEL_SPI_CSRx_DLYBCT(x) ((x) << 24) + +/* Bits in VERSION */ +#define ATMEL_SPI_VERSION_REV(x) ((x) & 0xfff) +#define ATMEL_SPI_VERSION_MFN(x) ((x) << 16) + +/* Constants for CSRx:BITS */ +#define ATMEL_SPI_BITS_8 0 +#define ATMEL_SPI_BITS_9 1 +#define ATMEL_SPI_BITS_10 2 +#define ATMEL_SPI_BITS_11 3 +#define ATMEL_SPI_BITS_12 4 +#define ATMEL_SPI_BITS_13 5 +#define ATMEL_SPI_BITS_14 6 +#define ATMEL_SPI_BITS_15 7 +#define ATMEL_SPI_BITS_16 8 #define MAX_CS_COUNT 4 +/* Register access macros */ +#define spi_readl(as, reg) \ + readl(as->regs + ATMEL_SPI_##reg) +#define spi_writel(as, reg, value) \ + writel(value, as->regs + ATMEL_SPI_##reg) + struct atmel_spi_platdata { struct at91_spi *regs; };