Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2063799imm; Thu, 11 Oct 2018 04:39:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV62I5ifNimHLGsPCY040+imPLiQ4jrHOnKi+kAxx1aIAz0C2lioPaQiRIEj+rMBgIQxkeja+ X-Received: by 2002:a62:1906:: with SMTP id 6-v6mr1236418pfz.9.1539257956114; Thu, 11 Oct 2018 04:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539257956; cv=none; d=google.com; s=arc-20160816; b=R6uVa3LKMj0Mi1QGjeehiW1kVIDUxsCJnqxdPwvx0JucgZTPh8fA1p8bVxdr6ljyb8 Z9YIMkxXZe3RtXpebhF9q+S6UTJwURjRuAOaqi4AxwW5fK6TPnWksFqN5QN64S39Q519 amaB86RI+1fVKzNOBdGKAUDuCX7KJb684fmH3pYRjLFiRINWpWAeO3j5M63xa8M0ldgB v26+N9VYNAvqEmHiJPpfE0nrKWPKi8rWuqCx00R/1BOxZMnT2JfYIAps6lP/2GrqozYu 0hy2zLGybO8Ls5uz3QL2EwgWdCaoOIfaAxmGE8ljFRHFgv7pPZOsukyVKB98ocRKc/pf W9zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=qrT26U14ienmd8ofx66O9VZShPNLz4vCh3UgFdjV4gA=; b=WopEgvqPgwSIMpdvNzVAUipvQ2BypLdSguiWnfIoJ4JmVircENz9PJ+j8dtCh4kATA /0w9HITUgpxuiZFNTyLzavolRSHCGMA+L8CXOVwyhyzYVT1wuTzPcSqyv9I0AwPIECkJ O5w5TAEM29Ou7uYXztmzb0q6xS0l3ZyfpHdtetrlOMPFScKbEUQ68rRgdChVlCFN6PGh dC0KbyYpvLCJKDjbbr1oG2uJvkERgk2HOkPX2zxwktrjA+XM3hGoEjgPRMqF/hERQL7B 5vkGh9YEOGU+ch34x8LOofZ6+1nvlKfMr0Jrctey1pdXgrLep8gjizyPqeKgGxqJKZng uWVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=VyrsWWus; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd2-v6si27053870plb.382.2018.10.11.04.39.01; Thu, 11 Oct 2018 04:39:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=VyrsWWus; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728517AbeJKSrW (ORCPT + 99 others); Thu, 11 Oct 2018 14:47:22 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:48438 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728502AbeJKSrW (ORCPT ); Thu, 11 Oct 2018 14:47:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1539256834; x=1570792834; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=qrT26U14ienmd8ofx66O9VZShPNLz4vCh3UgFdjV4gA=; b=VyrsWWusFeVbTBTEkrVzZThKf8zYDDpxdbBJbYtxzshmarJ4Jv+0Z0WB kMoUiwNEg+U08DOTIHhn5M/ZhUN7ZCzg0MVGWtzFAGZI7zgedxcAOC+aj KcLH6uIVHTYv80s/xy4BwSNtAWCqEfnC84EQy7dKBfzZmxKLSj33L9iaf Y=; X-IronPort-AV: E=Sophos;i="5.54,368,1534809600"; d="scan'208";a="367323644" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-a11fcaa7.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 Oct 2018 11:20:32 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2c-a11fcaa7.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w9BBKRvs104304 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 11 Oct 2018 11:20:31 GMT Received: from EX13D01EUB001.ant.amazon.com (10.43.166.194) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 11 Oct 2018 11:20:30 +0000 Received: from udc4a3e82dbc15a031435.hfa14.amazon.com (10.43.161.25) by EX13D01EUB001.ant.amazon.com (10.43.166.194) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 11 Oct 2018 11:20:24 +0000 From: Talel Shenhar To: , , , , , CC: , , , , David Woodhouse Subject: [PATCH 2/2] dw: spi: add support for Amazon's Alpine spi controller Date: Thu, 11 Oct 2018 14:20:07 +0300 Message-ID: <1539256807-25676-2-git-send-email-talel@amazon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539256807-25676-1-git-send-email-talel@amazon.com> References: <1539209339.1944.23.camel@impinj.com> <1539256807-25676-1-git-send-email-talel@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.25] X-ClientProxiedBy: EX13D08UWC004.ant.amazon.com (10.43.162.90) To EX13D01EUB001.ant.amazon.com (10.43.166.194) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for a new devicetree compatible string called 'amazon,alpine-apb-ssi', which is necessary for the Amazon Alpine spi controller. 'amazon,alpine-dw-apb-ssi' is used in the dw spi driver if specified in the devicetree. Otherwise, fall back to driver default behavior, i.e. original dw IP hw driver behavior. Signed-off-by: Talel Shenhar Signed-off-by: David Woodhouse --- drivers/spi/spi-dw-mmio.c | 9 +++++++++ drivers/spi/spi-dw.c | 6 ++++++ drivers/spi/spi-dw.h | 2 ++ 3 files changed, 17 insertions(+) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index a768461..3ffb6a40 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -126,6 +126,14 @@ static int dw_spi_mscc_jaguar2_init(struct platform_device *pdev, JAGUAR2_IF_SI_OWNER_OFFSET); } +static int dw_spi_alpine_init(struct platform_device *pdev, + struct dw_spi_mmio *dwsmmio) +{ + dwsmmio->dws.cs_override = 1; + + return 0; +} + static int dw_spi_mmio_probe(struct platform_device *pdev) { int (*init_func)(struct platform_device *pdev, @@ -230,6 +238,7 @@ static const struct of_device_id dw_spi_mmio_of_match[] = { { .compatible = "snps,dw-apb-ssi", }, { .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init}, { .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init}, + { .compatible = "amazon,alpine-dw-apb-ssi", .data = dw_spi_alpine_init}, { /* end of table */} }; MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match); diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 3e205ab..b705f2b 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -144,6 +144,8 @@ void dw_spi_set_cs(struct spi_device *spi, bool enable) if (!enable) dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select)); + else if (dws->cs_override) + dw_writel(dws, DW_SPI_SER, 0); } EXPORT_SYMBOL_GPL(dw_spi_set_cs); @@ -463,6 +465,10 @@ static void spi_hw_init(struct device *dev, struct dw_spi *dws) dws->fifo_len = (fifo == 1) ? 0 : fifo; dev_dbg(dev, "Detected FIFO size: %u bytes\n", dws->fifo_len); } + + /* enable HW fixup for explicit CS deselect for Amazon's alpine chip */ + if (dws->cs_override) + dw_writel(dws, DW_SPI_CS_OVERRIDE, 0xF); } int dw_spi_add_host(struct device *dev, struct dw_spi *dws) diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 0168b08..c9c1588 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -32,6 +32,7 @@ #define DW_SPI_IDR 0x58 #define DW_SPI_VERSION 0x5c #define DW_SPI_DR 0x60 +#define DW_SPI_CS_OVERRIDE 0xf4 /* Bit fields in CTRLR0 */ #define SPI_DFS_OFFSET 0 @@ -109,6 +110,7 @@ struct dw_spi { u32 fifo_len; /* depth of the FIFO buffer */ u32 max_freq; /* max bus freq supported */ + int cs_override; u32 reg_io_width; /* DR I/O width in bytes */ u16 bus_num; u16 num_cs; /* supported slave numbers */ -- 2.7.4