From patchwork Fri Oct 3 16:49:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 5024001 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25781C11AB for ; Fri, 3 Oct 2014 16:50:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34E762017A for ; Fri, 3 Oct 2014 16:50:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43D0A2014A for ; Fri, 3 Oct 2014 16:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753828AbaJCQt2 (ORCPT ); Fri, 3 Oct 2014 12:49:28 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:38890 "EHLO mailhub1.si.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753329AbaJCQt1 (ORCPT ); Fri, 3 Oct 2014 12:49:27 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 650B31C8700; Fri, 3 Oct 2014 18:49:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lwlmD8LDmrGS; Fri, 3 Oct 2014 18:49:25 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 490841C86FD; Fri, 3 Oct 2014 18:49:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5A34DC7396; Fri, 3 Oct 2014 18:49:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id lyYo3U_K0ymW; Fri, 3 Oct 2014 18:49:20 +0200 (CEST) Received: from PO10863.localdomain (unknown [172.25.231.75]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 845D7C7395; Fri, 3 Oct 2014 18:49:18 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 0) id 397871AB276; Fri, 3 Oct 2014 18:49:17 +0200 (CEST) From: Christophe Leroy To: Mark Brown CC: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-spi@vger.kernel.org Subject: [PATCH v2 2/2] spi: fsl-spi: Allow dynamic allocation of CPM1 parameter RAM Message-Id: <20141003164917.397871AB276@localhost.localdomain> Date: Fri, 3 Oct 2014 18:49:17 +0200 (CEST) Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On CPM1, the SPI parameter RAM has a default location. In order to use SPI while using SCC2 with features like QMC or Ethernet, it is necessary to relocate SPI parameter RAM in a free location in the CPM dual port RAM. With this patch, when "fsl,cpm1-spi-reloc" instead of "fsl,cpm1-spi" compatible is set in the device tree, the parameter RAM for SPI is dynamically allocated with cpm_muram_alloc(). Signed-off-by: Christophe Leroy --- Changes from v1 to v2: using OF compatible instead of compile time option drivers/spi/spi-fsl-cpm.c | 3 +++ drivers/spi/spi-fsl-lib.c | 2 ++ include/linux/fsl_devices.h | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c index 0f3a912..048ca5f 100644 --- a/drivers/spi/spi-fsl-cpm.c +++ b/drivers/spi/spi-fsl-cpm.c @@ -261,6 +261,9 @@ static unsigned long fsl_spi_cpm_get_pram(struct mpc8xxx_spi *mspi) if (mspi->flags & SPI_CPM2) { pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 64); out_be16(spi_base, pram_ofs); + } else if (mspi->flags & SPI_CPM1_RELOC) { + pram_ofs = cpm_muram_alloc(SPI_PRAM_SIZE, 32); + out_be16(spi_base, pram_ofs); } else { u16 rpbase = in_be16(spi_base); diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index c3f7802..e9db4c5 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c @@ -227,6 +227,8 @@ int of_mpc8xxx_spi_probe(struct platform_device *ofdev) pdata->flags = SPI_CPM_MODE | SPI_CPM2; else if (of_device_is_compatible(np, "fsl,cpm1-spi")) pdata->flags = SPI_CPM_MODE | SPI_CPM1; + else if (of_device_is_compatible(np, "fsl,cpm1-spi-reloc")) + pdata->flags = SPI_CPM_MODE | SPI_CPM1 | SPI_CPM1_RELOC; return 0; } diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h index a82296a..417ad52 100644 --- a/include/linux/fsl_devices.h +++ b/include/linux/fsl_devices.h @@ -123,6 +123,7 @@ struct fsl_spi_platform_data { #define SPI_CPM1 (1 << 2) /* SPI unit is in CPM1 block */ #define SPI_CPM2 (1 << 3) /* SPI unit is in CPM2 block */ #define SPI_QE (1 << 4) /* SPI unit is in QE block */ +#define SPI_CPM1_RELOC (1 << 5) /* SPI pram has to be relocated */ /* board specific information */ u16 max_chipselect; void (*cs_control)(struct spi_device *spi, bool on);