From patchwork Sun Jul 22 21:20:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 142512 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5356788ljj; Sun, 22 Jul 2018 14:20:34 -0700 (PDT) X-Google-Smtp-Source: AAOMgpetm163i+1lWpE63AWWhD8GvE4fyOPTNypf0QQwbRSXKPR6CZLlSZ2NqhoPfYi/anNfLE++ X-Received: by 2002:a62:464f:: with SMTP id t76-v6mr10638188pfa.118.1532294434084; Sun, 22 Jul 2018 14:20:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532294434; cv=none; d=google.com; s=arc-20160816; b=YlYqfvvtGhOwwbiyOBhjC2kICw6Faph+xVTAsXTn+Si3/cE5oqmgTSBFTU9x1wcadI 9jXTqn1Uh26YJzcRquLiF5cOt6jxWDw4vLZMMK6Adv0mvh+jFPjPCfR/AbceRmksecQ0 5EVyS668xZUsFHbtmnGw4/HNGHMFa09rm269HoIloZIoaYLs+JTP4DMS4VoqVz2uXSkS /+YhPuDwHKpRl2zbs6gN7JAipBJvb9IjNuWrDocL11WYK3W79CV/9b9ES9t4kCoe5+ak drHUkNB6i65AABjVaXEK97Hu8iIA1RPpD/Tk75D3ea+OSPAaMdJTqZg8Rz87PMXHBwvT FNhQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/eg8jGcdsZbnJeUp72CWiotqjlDjvLaI5aUx60mWM+E=; b=TonLKiXadAnALBoCfd38lutxE5dLdGW9YRmZM+N64ZRTUpydW4KZKqeF03KsEIALGw FKWwTTNpk+BjF+hE944u3/8fVDub/dUvWRLUFWVBJGJ9HGOkZDBEXjDqnHAj/GhRT2G7 dbhaHe+zKdcz/fhPXVpy2CaB/MKtBNkzTGRNSCP+N8DIuT5xMbagWF55CnwXmQzmJnTP EfHi/FUqRkxVrc3IZhRbk0jP1D9xmR0qOQLViMH+dCesTgqRCnK2FT7wJtr/dRhsFLN3 TtIEH0EhYVSxJHmFqy0fjwYQTnCnFG4b1wj4aKIkSFh/GIhULb7SM15Kqx6IvQDOW3I+ cgSA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k23-v6si7074765pgl.633.2018.07.22.14.20.33; Sun, 22 Jul 2018 14:20:34 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387841AbeGVWSZ (ORCPT + 31 others); Sun, 22 Jul 2018 18:18:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:38792 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387772AbeGVWSZ (ORCPT ); Sun, 22 Jul 2018 18:18:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 301FBAFD5; Sun, 22 Jul 2018 21:20:23 +0000 (UTC) From: =?utf-8?q?Andreas_F=C3=A4rber?= To: linux-mips@linux-mips.org Cc: Ralf Baechle , Paul Burton , James Hogan , linux-kernel@vger.kernel.org, Ionela Voinescu , =?utf-8?q?Andreas_F=C3=A4rber?= , Mark Brown , linux-spi@vger.kernel.org Subject: [PATCH 12/15] spi: img-spfi: Use device 0 configuration for all devices Date: Sun, 22 Jul 2018 23:20:07 +0200 Message-Id: <20180722212010.3979-13-afaerber@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180722212010.3979-1-afaerber@suse.de> References: <20180722212010.3979-1-afaerber@suse.de> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ionela Voinescu Given that we control the chip select line externally, we can use only one parameter register (device 0 parameter register) and one set of configuration bits (port configuration bits for device 0) for all devices (all chip select lines). Signed-off-by: Ionela Voinescu Signed-off-by: Andreas Färber --- drivers/spi/spi-img-spfi.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 2.16.4 diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c index 0d73d31a6a2b..231b59c1ab60 100644 --- a/drivers/spi/spi-img-spfi.c +++ b/drivers/spi/spi-img-spfi.c @@ -437,18 +437,23 @@ static int img_spfi_prepare(struct spi_master *master, struct spi_message *msg) struct img_spfi *spfi = spi_master_get_devdata(master); u32 val; + /* + * The chip select line is controlled externally so + * we can use the CS0 configuration for all devices + */ val = spfi_readl(spfi, SPFI_PORT_STATE); + + /* 0 for device selection */ val &= ~(SPFI_PORT_STATE_DEV_SEL_MASK << SPFI_PORT_STATE_DEV_SEL_SHIFT); - val |= msg->spi->chip_select << SPFI_PORT_STATE_DEV_SEL_SHIFT; if (msg->spi->mode & SPI_CPHA) - val |= SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + val |= SPFI_PORT_STATE_CK_PHASE(0); else - val &= ~SPFI_PORT_STATE_CK_PHASE(msg->spi->chip_select); + val &= ~SPFI_PORT_STATE_CK_PHASE(0); if (msg->spi->mode & SPI_CPOL) - val |= SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + val |= SPFI_PORT_STATE_CK_POL(0); else - val &= ~SPFI_PORT_STATE_CK_POL(msg->spi->chip_select); + val &= ~SPFI_PORT_STATE_CK_POL(0); spfi_writel(spfi, val, SPFI_PORT_STATE); return 0; @@ -548,11 +553,15 @@ static void img_spfi_config(struct spi_master *master, struct spi_device *spi, div = DIV_ROUND_UP(clk_get_rate(spfi->spfi_clk), xfer->speed_hz); div = clamp(512 / (1 << get_count_order(div)), 1, 128); - val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(spi->chip_select)); + /* + * The chip select line is controlled externally so + * we can use the CS0 parameters for all devices + */ + val = spfi_readl(spfi, SPFI_DEVICE_PARAMETER(0)); val &= ~(SPFI_DEVICE_PARAMETER_BITCLK_MASK << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT); val |= div << SPFI_DEVICE_PARAMETER_BITCLK_SHIFT; - spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(spi->chip_select)); + spfi_writel(spfi, val, SPFI_DEVICE_PARAMETER(0)); if (!list_is_last(&xfer->transfer_list, &master->cur_msg->transfers) && /*