Message ID | 20240215180102.13887-4-fancer.lancer@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp19775dyb; Thu, 15 Feb 2024 10:02:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOGaNLzKA5h8xSzAY3/z6M8IAkKvF52GtUFcEcnyaw3iBrAEsOQSN6/LdLyVLpD1r//pzMqRERzX9OsJ5rLcjb0AC+cQ== X-Google-Smtp-Source: AGHT+IFos+gsdYzQQnzATeysIjhDb63Uh5GWB9soapiALuBsW0uX44OC5KtW693Az1/i6lZzp6Nq X-Received: by 2002:a17:906:360a:b0:a3d:b150:2144 with SMTP id q10-20020a170906360a00b00a3db1502144mr966015ejb.34.1708020157508; Thu, 15 Feb 2024 10:02:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708020157; cv=pass; d=google.com; s=arc-20160816; b=WUXFE9Usmo6znJcuubr8dezhkzGKONBuHPfYfUM70uMVb6meWbRSsVxEs9TQkD1vCi UqtuMuXY4lSvmosf+Th/ES75hbo2zCSr6neDP0ocROBmv7z03vmXMFJpO7b5QpLRaI1i Zg7IpGi+IBbC0OHhjxVhobd7qFWW+bfL7rk0r/2iKMjdGCi3ar/jjXvEKmqJmnHlXLgf ISmid4ONjmgo+cN1tABziHQR8Fgs71cqFe67PSuEAnbGtNgIqKYrZ5OGHDOizKsTW61q cD4Q7FrpclvE+yQ5BoOQyfYY35nmSJBncc9OvYRfGzvVNvzY+EUZcihqXv3uIkaCoqRv f7VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; fh=OC9+bkJQZ7EAZTN/NfNfaqlrEuuc0dEUeVaHir05ixI=; b=ROvC/X10GBEwDRAcy64WQ2AU2V+9oO7W803wsXzd04+MG7QrD+/DvVIIHvX5ZafGYP 8Ao1GgqbMeaw44rPj6kwhSp/D1FAlgkO06lP/lJbwCs+CDeE80vIAVkuZ1/O3oxqxQ5o jIVdzkaqE/TrByn8He2NNAGbNb9pD97l+hBMrOuybzPUQs0QoBkLUd5MmApAG5m5i/Ur bgfJj26h6XL3JazLz2PoPECgWc0UUqZdLzweI0s9nx1vwRhNZjEUNk8ggz7y+e6l050b fDqBGY7kL0qH44h2ZU3x+KGhW649SyOSpAXnvo06rfEKg9gg+dz0jV/Y4y1bXJGjKjmR dfRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AUwvJFXh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kk27-20020a170907767b00b00a3d41bd0afasi845251ejc.907.2024.02.15.10.02.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:02:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AUwvJFXh; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67463-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0D7B11F23387 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 18:02:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F2F413959C; Thu, 15 Feb 2024 18:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AUwvJFXh" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 036B11386DE; Thu, 15 Feb 2024 18:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; cv=none; b=MmUrODagNJzzu9b2WY2whIkx5TleJX/CyPKlQBkqgPMiBmnE5gdBmRH8QBBS9X5DLRC3sW9nxG1D+FaHBecAPb1I/YIdw7Z7ZjukPKcud9OS2MldTZb90LpsLRNquAG7rzxrBijS3emqj+glII0oVQqU1K2TWpxola7GZqKqGes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708020090; c=relaxed/simple; bh=F8Y/aairEGyfuvo2EhCMfvxfxlwtJhutuIxOg1R0p08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VqM56v4FXlQmCjZI/pT2dAkLkiFJ/6xyhTbBX5wjVjCI0/NCFPO39oE8A5yLOmxR4VJEZzZo4aET9t/kPKzmsDNupRDU+I4XDMF/uzstRIteNAXiSoeNF+251BIoIT2t5jwKwQOmKZXh7P2CZRZfJRZigo8/p5aGsYBFtQA/IVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AUwvJFXh; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-511acd26befso1438303e87.1; Thu, 15 Feb 2024 10:01:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708020087; x=1708624887; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; b=AUwvJFXhXiFYN22auaZiEEPHGvIGgZgOazZDxq8BQ25rVG+RHCd/VB9Xtvpsipao/l TdZfuGnhtrtSw7jqIbgS3vN4vvbUe1XXsGhptJTZ+L6wmqgphXi55UCraT7dO92vfz0o jA9sTRn/aH3DCHF0dyhXxwR9XjhYnsKuOXQ8U4hPp7h40JnRAJGk3tZ9G/BTo2/Dy4lY daU15JkDb0VpmVFSWK876Vkm9hDY+JxfjAlwu9knJwycwgWehZ5stUuOg5nBUKVlmEwD UhHrbAVQYh/kbakAtktNO1tToQ4T7aOE0eIjX58UyAJ6wiDe/aI9FkR9NYCkGFyKc7A1 KjUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708020087; x=1708624887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TdhViubu+MQPzCyySbbId4maKldHevwaTkO7BnF3q5g=; b=F521ACCwCW0xuVlQxgnEfnndqEiPvGG2QY6FgS3Ti2nDqaenj8euv93qAnjPpZhJkG f/GtY0H0y26n0411497vzX2SIsQS781xRuIsPTBW5SnNNmtVX7b0i/rW8FMFlrt0AsBz JjPFPuYn4/xLBHMoNNwBd204QwXzVSqt70pEP66eTAwlP82VcRw4lw1TSkzM55/us52N PNfYqUCazGYn757sSHb76oVjjpnpPBsgbAzH9Z9JOIK8IeKZ7EbQs97B+vulE4FWjujg 66fIrUGm8oTgUy4bUHawF7UAV2Mx4TTmwl8fzcDXbpMHJou3hirhBUQZYt5ls7c/Zh3a zdYw== X-Forwarded-Encrypted: i=1; AJvYcCUHaDDN5bV2cq8JIEtuxCQ08INklpsyREOO0+EyTm1O+7CYUbceIQRs362ZdRW/cO6QdjW3DN6go480KKfaUNxiMifXunElc+b8ExLE0DX+B9tpiTje9gKr7Hp45g3OAG8ZXglE+O9j X-Gm-Message-State: AOJu0YxVZKH7rE6sT5M0CGvbwHM4Or5S2r1tYkpGjCN0QUTZIFG6jQwV q6B2QmcjqB1DZbd9edfcXHND7+vDyoU2kqHO4tVtMUN6+SFHYTcw X-Received: by 2002:a19:9152:0:b0:511:4824:6718 with SMTP id y18-20020a199152000000b0051148246718mr1991126lfj.56.1708020086584; Thu, 15 Feb 2024 10:01:26 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x7-20020a19f607000000b005118c6d6a2fsm322769lfe.305.2024.02.15.10.01.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:01:26 -0800 (PST) From: Serge Semin <fancer.lancer@gmail.com> To: Serge Semin <fancer.lancer@gmail.com>, Mark Brown <broonie@kernel.org>, Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Andy Shevchenko <andy@kernel.org>, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] spi: dw: Drop default number of CS setting Date: Thu, 15 Feb 2024 21:00:48 +0300 Message-ID: <20240215180102.13887-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215180102.13887-1-fancer.lancer@gmail.com> References: <20240215180102.13887-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790988944917435150 X-GMAIL-MSGID: 1790988944917435150 |
Series |
spi: dw: Auto-detect number of native CS
|
|
Commit Message
Serge Semin
Feb. 15, 2024, 6 p.m. UTC
DW APB/AHB SSI core now supports the procedure which automatically
determines the number of native CS. Thus there is no longer point in
defaulting to four CS if platform doesn't specify the real number.
Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
---
drivers/spi/spi-dw-mmio.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Comments
On Thu, Feb 15, 2024 at 09:00:48PM +0300, Serge Semin wrote: > DW APB/AHB SSI core now supports the procedure which automatically > determines the number of native CS. Thus there is no longer point in > defaulting to four CS if platform doesn't specify the real number. .. > - num_cs = 4; Simply update the default here? > - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); > - > - dws->num_cs = num_cs;
On Thu, Feb 15, 2024 at 09:32:23PM +0200, Andy Shevchenko wrote: > On Thu, Feb 15, 2024 at 09:00:48PM +0300, Serge Semin wrote: > > DW APB/AHB SSI core now supports the procedure which automatically > > determines the number of native CS. Thus there is no longer point in > > defaulting to four CS if platform doesn't specify the real number. > > ... > > > - num_cs = 4; > > Simply update the default here? > > > - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); Do you suggest to simply: --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -364,8 +364,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) &dws->reg_io_width)) dws->reg_io_width = 4; - num_cs = 4; + num_cs = 0; device_property_read_u32(&pdev->dev, "num-cs", &num_cs); ? My idea was to make the statement looking closer to what is implemented for "reg-io-width" property. An alternative to what you suggest and to my patch can be converting the dw_spi::num_cs type to u32 and pass it to the device_property_read_u32() method directly: --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h u32 max_freq; /* max bus freq supported */ u32 reg_io_width; /* DR I/O width in bytes */ + u32 num_cs; /* supported slave numbers */ u16 bus_num; - u16 num_cs; /* supported slave numbers */ void (*set_cs)(struct spi_device *spi, bool enable); /* Current message transfer state info */ --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -320,7 +320,6 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) struct resource *mem; struct dw_spi *dws; int ret; - int num_cs; dwsmmio = devm_kzalloc(&pdev->dev, sizeof(struct dw_spi_mmio), GFP_KERNEL); @@ -364,8 +363,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) &dws->reg_io_width)) dws->reg_io_width = 4; - num_cs = 4; - - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); + device_property_read_u32(&pdev->dev, "num-cs", &dws->num_cs); - - dws->num_cs = num_cs; init_func = device_get_match_data(&pdev->dev); if (init_func) { What do you think? Would that be better? -Serge(y) > > - > > - dws->num_cs = num_cs; > > -- > With Best Regards, > Andy Shevchenko > > >
On Fri, Feb 16, 2024 at 5:36 PM Serge Semin <fancer.lancer@gmail.com> wrote: > On Thu, Feb 15, 2024 at 09:32:23PM +0200, Andy Shevchenko wrote: > > On Thu, Feb 15, 2024 at 09:00:48PM +0300, Serge Semin wrote: > > > DW APB/AHB SSI core now supports the procedure which automatically > > > determines the number of native CS. Thus there is no longer point in > > > defaulting to four CS if platform doesn't specify the real number. the platform .. > > > - num_cs = 4; > > > > Simply update the default here? > > > > > - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); > > Do you suggest to simply: > > --- a/drivers/spi/spi-dw-mmio.c > +++ b/drivers/spi/spi-dw-mmio.c > @@ -364,8 +364,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) > &dws->reg_io_width)) > dws->reg_io_width = 4; > > - num_cs = 4; > + num_cs = 0; > > device_property_read_u32(&pdev->dev, "num-cs", &num_cs); > > ? Either this or do num_cs = dw_spi_get_num_cs_from_hw(...); What would work better WRT hardware? .. > My idea was to make the statement looking closer to what is > implemented for "reg-io-width" property. An alternative to what you > suggest and to my patch can be converting the dw_spi::num_cs type to > u32 and pass it to the device_property_read_u32() method directly: ..patch... > What do you think? Would that be better? I like the change, but again, are you sure it won't break any setups? If yes, go for this!
On Fri, Feb 16, 2024 at 07:00:28PM +0200, Andy Shevchenko wrote: > On Fri, Feb 16, 2024 at 5:36 PM Serge Semin <fancer.lancer@gmail.com> wrote: > > On Thu, Feb 15, 2024 at 09:32:23PM +0200, Andy Shevchenko wrote: > > > On Thu, Feb 15, 2024 at 09:00:48PM +0300, Serge Semin wrote: > > > > DW APB/AHB SSI core now supports the procedure which automatically > > > > determines the number of native CS. Thus there is no longer point in > > > > defaulting to four CS if platform doesn't specify the real number. > > the platform Ok. Thanks. > > > ... > > > > > - num_cs = 4; > > > > > > Simply update the default here? > > > > > > > - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); > > > > Do you suggest to simply: > > > > --- a/drivers/spi/spi-dw-mmio.c > > +++ b/drivers/spi/spi-dw-mmio.c > > @@ -364,8 +364,9 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) > > &dws->reg_io_width)) > > dws->reg_io_width = 4; > > > > - num_cs = 4; > > + num_cs = 0; > > > > device_property_read_u32(&pdev->dev, "num-cs", &num_cs); > > > > ? > > Either this or do > > num_cs = dw_spi_get_num_cs_from_hw(...); This is supposed to be generically done in dw_spi_add_host()->dw_spi_hw_init() together with some other auto-detections. > > What would work better WRT hardware? I'd stick with defaulting the dws->num_cs to zero here. > > ... > > > My idea was to make the statement looking closer to what is > > implemented for "reg-io-width" property. An alternative to what you > > suggest and to my patch can be converting the dw_spi::num_cs type to > > u32 and pass it to the device_property_read_u32() method directly: > > ...patch... > > > What do you think? Would that be better? > > I like the change, but again, are you sure it won't break any setups? Well, I thought about this for quite some time. Here are the possible options: 1. If "num-cs" property is specified, then nothing is changed. The actual number of native chip-selects will be read from there. 2. If "num-cs" property isn't specified, then the auto-detection procedure will be attempted. Here are some considerations in this regard: 2.1 defaulting to "4" hasn't been correct in the first place because by default the IP-core is synthesized with a single native CS line. So auto-detection would be more portable than guessing with a constant value. 2.2 If some IP-cores have all SER bits writable then we'll just get to detect more than there are actual chip-selects. No regression in this case. 2.3 If some IP-cores don't support the SER bits being simultaneously set then it violates what is described in the HW manuals - broadcasting is supposed to be supported by all DW SSI devices (currently I've got DW APB SSI v3.10a, v3.22a, v3.22b, v4.02a, v4.03a and DW AHB SSI 1.01a databooks confirming that). 2.4 In case of 2.3 at least one chip-select shall be auto-detected unless the SER register doesn't permit an invalid value being written, which is also an undocumented case. 2.5. In case of 2.3 and 2.4 either "num-cs" property or a platform-specific compatible string is supposed to be specified since the device isn't generic DW APB/AHB SSI. But if such device is discovered we'll see what could be done then. So AFAICS the probability to break some setup shall be rather small. > If yes, go for this! Ok. Thanks. -Serge(y) > > -- > With Best Regards, > Andy Shevchenko
diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index cc74cbe03431..eb335fcc8720 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -364,11 +364,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) &dws->reg_io_width)) dws->reg_io_width = 4; - num_cs = 4; - - device_property_read_u32(&pdev->dev, "num-cs", &num_cs); - - dws->num_cs = num_cs; + if (!device_property_read_u32(&pdev->dev, "num-cs", &num_cs)) + dws->num_cs = num_cs; init_func = device_get_match_data(&pdev->dev); if (init_func) {