From patchwork Tue Apr 16 15:52:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13632188 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 7834A131726; Tue, 16 Apr 2024 15:53:06 +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=1713282788; cv=none; b=k3k6V0U8mG/xXbOqs3M+TOUq+I6FbOyePxMZH2ODhOTyZryG4TggLP5ZXpV/miKZTVKxz69prseWSyldbcGgrzgL1xQEVHni8m/phUV5JOQ1B+pVwmrJMudecaZ4mol7xaqQVSdcY0WJ2eKwek2zkHMCIFtpqUoW0hdtRzNnbIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282788; c=relaxed/simple; bh=K1UkPr+qwrl0AxN89XM75ZcSZhSG0ZNbLMmfwU7qP70=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u73qIvPgtcum6EXwswR7Bm1xfwfWEX4uz+K/ZVMcrNyw+50vX7VOKWko9bBg4O60CmwNZYvSU0a5vjUcYsWzLo9rx5OXstqqhIUXAPcSq1lRuEqjodtVeLlvMX/E5hfIyIiwjVPy9PyYGqv8/f3O9Y6jB4xF4qDZJgxURjevDdo= 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=E/m0ZLnN; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E/m0ZLnN" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-518a3e0d2e4so2912593e87.0; Tue, 16 Apr 2024 08:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713282785; x=1713887585; 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=YkIadt0nAZR1d0O39/7H5hjsJWBN2vmdJ6bdv/9nuZs=; b=E/m0ZLnNABqKxFA6IrKK9TzkdnKmL5Md9nuSf506ukTSx9ILAzcl5JyMtNNFphNomM FUbtDuMdvMwwtefXEluoVkkulgNvuPAG0mqKCnuWhX+Xh5Btzlo0BQYMgl7O7wxu5o4X kAyEQVIh/XfNZE1estVBDnZ+CU7TQv1t69BcdaorBWe+FaZZoikPf3IFoQvwyd6dD/v+ RV+SMj2X1pSbAi1Dzl5eW7lwuIje8vYdU2JKPypifz08hfoRGZSMQHjHLtORawdD2LPa IAxSZedJIXiVodEmHcDnspywV63faqssuedb8Y4ZNI5SLdFg1qXX+W0ACcG4ex96Lzax PdNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713282785; x=1713887585; 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=YkIadt0nAZR1d0O39/7H5hjsJWBN2vmdJ6bdv/9nuZs=; b=ah+1GrdUMvyDb0q0gnhE7WQ9bKpq3E8ftt10hTMvjecQvdFO8VAPSEx8RcQLGfE+WE 6I9TRjzopLqQ7ShZb3ULhnFo0Ow9LpS89wAE6QnVg6zvvWO9zgPpZJywEACUBhRHDYzp Eqfb2laYPwdVe2bRP9hGJvPgSsBqnoF8i0C7UzebjjQr0KW5ijfFuBLa309StkNcnptt fFQOf+Kim5GP0EmDRg0BzgT8K5OSbXrZc3argDuL94BEI/MRmMq0prppKKI5MbobflIe X1ckD6IYqHeYb2ClZ4f//6OFpTl6hus5g2bRnUFuQbW+QXkWbl/tfMiFj8hDxmRd8vXk bSsA== X-Forwarded-Encrypted: i=1; AJvYcCXmW8RTP9V+ZqMbzw07orhDqG6PwvgRDcF9YotWn+TR+AcK6PfQoJb4AAttHWJmV0TCTRkJmJ0lXfb1u88YE7pfXfF3wWRWwmS9JiUE8sfQApa0Ew6HhZIJxjT+yOF4gooeeSYAusdk X-Gm-Message-State: AOJu0YzOxwc7YCXZQBtwv2hrJO4fDnn2sIbkvnKe61sZOBBgX6uXkyyb Ibj/Cslv5+KZ3JOwBaduuJN5D4Q7+n5sxugmgBW8DeApUfSpWqEK X-Google-Smtp-Source: AGHT+IEmlsKuTvv29AZcjbm2jgINk5kqSdt8EBTvnGKkpTK8/cz3AsyabAHVN49eico5elcIoVkQAg== X-Received: by 2002:ac2:4216:0:b0:519:16cc:aa72 with SMTP id y22-20020ac24216000000b0051916ccaa72mr752455lfh.13.1713282784376; Tue, 16 Apr 2024 08:53:04 -0700 (PDT) Received: from localhost (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id t4-20020a056512068400b00518b3b1b0ddsm979082lfe.259.2024.04.16.08.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:53:03 -0700 (PDT) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v3 1/4] spi: dw: Convert to using BITS_TO_BYTES() macro Date: Tue, 16 Apr 2024 18:52:31 +0300 Message-ID: <20240416155257.22429-2-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416155257.22429-1-fancer.lancer@gmail.com> References: <20240416155257.22429-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since commit dd3e7cba1627 ("ocfs2/dlm: move BITS_TO_BYTES() to bitops.h for wider use") there is a generic helper available to calculate a number of bytes needed to accommodate the specified number of bits. Let's use it instead of the hard-coded DIV_ROUND_UP() macro function. Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko --- drivers/spi/spi-dw-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 0274c9295514..722b5eb1f709 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -421,10 +422,7 @@ static int dw_spi_transfer_one(struct spi_controller *host, int ret; dws->dma_mapped = 0; - dws->n_bytes = - roundup_pow_of_two(DIV_ROUND_UP(transfer->bits_per_word, - BITS_PER_BYTE)); - + dws->n_bytes = roundup_pow_of_two(BITS_TO_BYTES(transfer->bits_per_word)); dws->tx = (void *)transfer->tx_buf; dws->tx_len = transfer->len / dws->n_bytes; dws->rx = transfer->rx_buf; From patchwork Tue Apr 16 15:52:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13632189 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 D96A7131749; Tue, 16 Apr 2024 15:53:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282789; cv=none; b=QO4CfpvYq5XtJO9fwYTv8PqmkCTDLJnbkDUjdwZlRPoVLtq/fkIG1/8RsIEThG8YGF05YBw2p7h4w4Awde/g1oBt4W4JUpdFQs/sFjOsV2uvNSBxszyFrpA2NUanlUc39p9mIDtUUMgMuLQLyY8z0BwiswLwQpRc2bCWMi5favo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282789; c=relaxed/simple; bh=wn6duOFR0By1a9rcZwmatu6QiLy3rmMNGIJzk+ktlD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PyyK2tu9zLg+gC4UuyCgfzfESrpktYRJG+L7vCw18QKnPIccNFwDQQQ4AAaWjtMhwYDbSP6b+mgsFduOkBuyFnfDXwxYtDPsuTGvkK3pk+Uv0UySbwqL99wXmfBOf0uyh6fQAUmI4j5551tu9/EJ/3UfNsl3LkxKQ+pCtLTY3mU= 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=J6UDNPaB; arc=none smtp.client-ip=209.85.167.51 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J6UDNPaB" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-518d98b9620so3179290e87.3; Tue, 16 Apr 2024 08:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713282786; x=1713887586; 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=IXtT3vdT1DlOmZWPolm6flA8JD62wpxOz2LSc4zAwz4=; b=J6UDNPaBmTCFwlqdx5HafhDwVbm2qBEeakPxCXVLbk/4lEhSUYhrl3Y8xsX3VlvRoG sEAwZ5Uw/3c+eIHCAe2g3QlzSnlz4PRrpzwUxGjcrCAbh7KUA+10z9h/shWvihfNOxWp 2iqVgucF4FASOSwI7kXH+JxcBvT6MKpybqqMNzjfCeKeDuYvxwrmuXPcv5jPNS29e3gH Y9kDZvqT912UvVw7ek7XyILnepQ/3JUnq7aNjDWm+fF3kYaZc4y0tqeJJ7cS/t+MGonv U9flfpdfz4yG8MYnAGNno0MLgcdjeTJIPtRb+YOegoZX+bgh5fn/y4DRXYOjXRhZadFQ OHew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713282786; x=1713887586; 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=IXtT3vdT1DlOmZWPolm6flA8JD62wpxOz2LSc4zAwz4=; b=IQeopw8y9dLqPaWZvYvhqltU2UBIpVq0LuYXQLtLH1u5L6dFVmfnsRHhGqsCJ506JN /FTsWmXvmEKh9VHqAMyHQUVVoaPpH9eBxYCC0vQBsoPS5USTu/hBj1XE1rIxm3HiN/EV EmdlVdtdqQudHXy+m8fTooaO2ITn+gjktxgG7iUj2prmcE55BaCFfX1TRZ2Di/sv465Q 8srYvM+GknkGNLxMxWKznDbxAl+qtv84FeCbF+UZs0pY+pr9GrZztlu03D2bxQqGYgws 9yV0oo2y+j/9pRtlFAPCsSRGeQHHEZ16HSqh3/kxN3xBtNJbQs5TwgHQJnRXgKxjrwWO aHvg== X-Forwarded-Encrypted: i=1; AJvYcCX8S9IAd5v25SQblNFGrb4CKT5/+y/qLK4GfRl6YmlCmyLQaUoUiMIB6SFtYQ54xzhrttr22rrckk1YhK6ljW8kl5H0LnQVJuSKg7UILBA7lzxn80bWKZizu2UXg/1fVzw+T+EuQAO/ X-Gm-Message-State: AOJu0YzhhsAoJn+kwd9GwDcKL3jtxgiVQu2a9XQD8bm3hXOfwF7WGFdq UM6+/xzhQq80VZ1Htwj8kFlvcxTcKKwBHtkHTRSnemhn+SJE+FrwoIyzPfeW X-Google-Smtp-Source: AGHT+IEM7mHWopWAZZypWiCNUUUTE9ZOT3mcesQT3O6XqnlpLVsiPpWLOnh0rO743E0ShUM8ZQJY0A== X-Received: by 2002:ac2:51b7:0:b0:516:c099:e785 with SMTP id f23-20020ac251b7000000b00516c099e785mr8253881lfk.20.1713282786032; Tue, 16 Apr 2024 08:53:06 -0700 (PDT) Received: from localhost (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id m13-20020a0565120a8d00b00518bfad5ac6sm898349lfu.108.2024.04.16.08.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:53:05 -0700 (PDT) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v3 2/4] spi: dw: Add a number of native CS auto-detection Date: Tue, 16 Apr 2024 18:52:32 +0300 Message-ID: <20240416155257.22429-3-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416155257.22429-1-fancer.lancer@gmail.com> References: <20240416155257.22429-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Aside with the FIFO depth and DFS field size it's possible to auto-detect a number of native chip-select synthesized in the DW APB/AHB SSI IP-core. It can be done just by writing ones to the SER register. The number of writable flags in the register is limited by the SSI_NUM_SLAVES IP-core synthesize parameter. All the upper flags are read-only and wired to zero. Based on that let's add the number of native CS auto-detection procedure so the low-level platform drivers wouldn't need to manually set it up unless it's required to set a constraint due to platform-specific reasons (for instance, due to a hardware bug). Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko --- drivers/spi/spi-dw-core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 722b5eb1f709..ddfdb903047a 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -834,6 +834,20 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws) DW_SPI_GET_BYTE(dws->ver, 1)); } + /* + * Try to detect the number of native chip-selects if the platform + * driver didn't set it up. There can be up to 16 lines configured. + */ + if (!dws->num_cs) { + u32 ser; + + dw_writel(dws, DW_SPI_SER, 0xffff); + ser = dw_readl(dws, DW_SPI_SER); + dw_writel(dws, DW_SPI_SER, 0); + + dws->num_cs = hweight16(ser); + } + /* * Try to detect the FIFO depth if not set by interface driver, * the depth could be from 2 to 256 from HW spec From patchwork Tue Apr 16 15:52:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13632190 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 BCE0A132484; Tue, 16 Apr 2024 15:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282791; cv=none; b=OV+qZnXH1hIum0pQXnZEvNttw17Dzs9zxRz3j2SfXXa+6euDJr2WgSUoW2mPPyWO37P3as9Y5sJeE/TljZrP7aPCkAtm/rnxn9ags3TXyvkkPEh8KKiDi9Ri940D0W3lhZveNVEWiJ9kSrpprDqd4NXXAfJdFAcvp6P0cGzjFDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282791; c=relaxed/simple; bh=UGWxHmZrSPG8/xRqYnebAtoN4G8LcvIkIQJroY+v/X4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q6xn6vP39jYFBVSpcMPzGU92dKYfZWZIV17MDdU8UGfr67QvycC8YmS83D6t0Z0UD5vyJ7jeBxcpAdYFIp8EQoAxhFSZQrArVG0K1QVTtNgS5TwuFMBiI8WcWgRoz/3R5k24SCQMON4y+GwvI1HTAGa7xRzk924DW57FjomJXKQ= 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=CaQ/mKES; arc=none smtp.client-ip=209.85.167.41 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CaQ/mKES" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-516d487659bso5523391e87.2; Tue, 16 Apr 2024 08:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713282788; x=1713887588; 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=HGFEeAw7g7SRdmEPZBJXDlgsScugDV25Y9+Iq5aXYYE=; b=CaQ/mKESClwIbJHR0NQ0DHvfFEZ1cFIr+V15F1hiNtHGg+ziUCv4PHiZW4fMC54y4Q gueoWdbK6AcgXPOpBdMwnEM3GNePT0vgCv7RKIfVbRjQ4F6ayPWdl7c5/DfT2zwymPm2 9yAFWh3giEEaUcXCETgCZP05J4LgoW1+T/uWmTllx52DDpVC6p8lX+ORkekv2qB+8Fgx EznTDAtV99y0h7k8xmTybp0I/56/4ydooWRZ52uxTWrhSZ8UK+lpuSr1nEo3UxuJiXuS jiw2duBONn7WIYd5xikLhMV2NT81AUbo/p0W2DkmR3uV3hFGzqQHriHrHjgoipjvIrPS rtZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713282788; x=1713887588; 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=HGFEeAw7g7SRdmEPZBJXDlgsScugDV25Y9+Iq5aXYYE=; b=apUOt50MC3f2TnA8MkxDbtDu13bJM8FpWICFKkaTh+TaigJzAbheJBJGTdwnaMY+xR qr+voCJGfXpVSqdIN4EOjsr5tbS5kL+HXWKrrrJUzW7e6rjhWOWydbcyJWRqgPUsYTb/ MCb93djBQ1HFStSekuCSgaxKwN9AAqhmkOxtQSvdy+eB5wv6dvhtlskC+VyDANMGeUmd hLuXzXsoqQVwGBuLi17RtQ8/ze4ZV8T+gKkg71DMXnqNuyh/gqiHigMkWnL7mSEd8cEO ptxrRx0pk5GLf42HeOX57qZ68wd5L6Wl1+fgRCteNzqZQadzWP2q7g4BYzsPzYkDlmRD Q6Cg== X-Forwarded-Encrypted: i=1; AJvYcCU6zkDLJ0Kfaxg+EwywhWbQUjkvt70sg89YUluMIW/SVEbFWQWSPb/p7tOb5GaCfjdYFI2r1xMurbsX7i5cUUrgAmMJQi+L42z0xPTQyOOofjt02647kLonXZfjlJmalAZ6SbxBOxOw X-Gm-Message-State: AOJu0Yxql6oA/WRpHZrjh5Fd9uod+ekBRBfShM5arXY45dud3L912WKK PfFkY53Oh+F2HhHbEx8s2Gtuuxc3/oeq5vtleRF063EbDZQ+OV/J X-Google-Smtp-Source: AGHT+IHmFtrZbedJpSMWdE2mG9MIg7a44E/hkNOlj1XWn6b1agndnR/SwISstCEaUh8i1eubA20Muw== X-Received: by 2002:ac2:5982:0:b0:516:d692:5e0b with SMTP id w2-20020ac25982000000b00516d6925e0bmr7466849lfn.54.1713282787839; Tue, 16 Apr 2024 08:53:07 -0700 (PDT) Received: from localhost (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id j17-20020a05651231d100b00518b5e1f36fsm968504lfe.233.2024.04.16.08.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:53:07 -0700 (PDT) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v3 3/4] spi: dw: Convert dw_spi::num_cs to u32 Date: Tue, 16 Apr 2024 18:52:33 +0300 Message-ID: <20240416155257.22429-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416155257.22429-1-fancer.lancer@gmail.com> References: <20240416155257.22429-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Number of native chip-select lines is either retrieved from the "num-cs" DT-property or auto-detected in the generic DW APB/AHB SSI probe method. In the former case the property is supposed to be of the "u32" size. Convert the field type to being u32 then to be able to drop the temporary variable afterwards. Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko --- Changelog v2: - Just added. --- drivers/spi/spi-dw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h index 6cafeee8ee2a..fc267c6437ae 100644 --- a/drivers/spi/spi-dw.h +++ b/drivers/spi/spi-dw.h @@ -164,8 +164,8 @@ struct dw_spi { u32 max_freq; /* max bus freq supported */ u32 reg_io_width; /* DR I/O width in bytes */ + u32 num_cs; /* chip select lines */ u16 bus_num; - u16 num_cs; /* supported slave numbers */ void (*set_cs)(struct spi_device *spi, bool enable); /* Current message transfer state info */ From patchwork Tue Apr 16 15:52:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13632191 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 47552131726; Tue, 16 Apr 2024 15:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282792; cv=none; b=nT0+Wq8/SmG2mymPeOZ5cTtJJIzYyAtUhtHf72teTTCZISml8CiqiBFWyuHiqBR0Yd3skQy4Rs9lc8vIWbSmhn01zBQ4WBaZjhXlbtGLO8iWIOvgYCfynGEwQYuWuWXu8hD5xYhAO5DfOigcMi9vgczb7W/YBThmLS54UtvX24E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713282792; c=relaxed/simple; bh=0PBo9Of6CNy3BPbkd/tZVfSeHDs2kDzIZaMPAx/MRPk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b6cmQg757Z52b+fh7Mz0zzDB9/Wd71XDcbrM90mb8kFl4IKJDnyR26LfEGASzHqBTimimIIZ0GVpBsizx/SCT3kcwKIXP0JMam41WXvjmL2oOD4//Ix1T/RvEPBh6rVt2J8yW0oXtmLnl4J5ABCFRAWZDgwXP1gSV1D6Fmz8c8Y= 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=O5v0Aq/b; arc=none smtp.client-ip=209.85.167.51 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O5v0Aq/b" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5171a529224so5829582e87.0; Tue, 16 Apr 2024 08:53:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713282789; x=1713887589; 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=dckUSl5z4UaY1zLi6ZaUm7FPVPOD+pWKaRJKmeXicSI=; b=O5v0Aq/bVNou+CMzvMEDBknaRWuQMYccF4g9NJfO6w/rWazblIYnr7CbRLo2Dze+X6 uQoN1ZinO3nxSuQlE65KiqVWGrk+Dzya1uRPWmAja7tbtiiAvLEN0PHRBzqufNbQEesA axUSngsHA+k6jXcJforTpRWjFBaCp0H9h9WtV9x+5VhDfENcSfUtVxD9tRZKFuWLmxhA Yk44VritcmTTNVum0Ewskd9CpjZuUd7GYR95mO6meUNxpMQGFMOh3Ve8YCNTzKyEJLMW y/k1MyI5pCIfGFS5FUVd99+/ZdTVltrWjTGpHMkKL7s+gXspd/l/u52tVgpH78FsU/gP IQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713282789; x=1713887589; 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=dckUSl5z4UaY1zLi6ZaUm7FPVPOD+pWKaRJKmeXicSI=; b=FH1wc8UsKgZ3gHEY/q1UONLkJSAMzClbJExumReWoqxiGLQpT8D5X2lo/g5prnE2BN Tus7fMkwvfBITCI6sJP86a6jvLMr7bClEn/7Lrrdd/jyWn+b2TVq5NDhNnfvCzbl5REf EJcnVtTTTpsIWUE7b+x9nUGRVOoK88ab66GHE769qvjFrw38aBa3opE/bBcvbWxbqBji 6jtv0L4c14uAiagw7pumxUTTAFKuJPRjb+VIAWlBHWTj7+BxFH+gScWXgKsb10mCImiK mqn5HtvxpaylOkGGcpKXqQjfJ6THm4CkpLDJ2Mu2tDCPqnHnsnIuTxzeU4v/NRGWwIvd w6rQ== X-Forwarded-Encrypted: i=1; AJvYcCXutUKrv4tICXol/YAGEIOZl6Gx5QTanK94KKLVv7PryhE4lS2qIW8FrdTtgdnPsxfOrJYEeLGAH5HDj6gsA8It5Rc4/MpN8qEvBczvoIieyQyNX+PbXX3ILM3veDZXkkiXJvPzhUnd X-Gm-Message-State: AOJu0Yw9dfsctglxzs0pFxYpwas5fYRK/4v/N2AntaqXy2IvbA1lxl5w TdxAlgHJNqg/8Z9DbNxuCD4mymH4dv+yLW8czoqXLdYPkhUYkMqw X-Google-Smtp-Source: AGHT+IGVEuCQi+moMpiZAWclRgl+2kiaOhRvkqzJFDhaQQIiLhibEJ33yPFDB7F100uTJ3qRWKZozg== X-Received: by 2002:a05:6512:4889:b0:518:c902:f992 with SMTP id eq9-20020a056512488900b00518c902f992mr4601473lfb.9.1713282789382; Tue, 16 Apr 2024 08:53:09 -0700 (PDT) Received: from localhost (srv1.baikalchip.ru. [87.245.175.227]) by smtp.gmail.com with ESMTPSA id bp41-20020a05651215a900b00516d6924bc6sm793551lfb.175.2024.04.16.08.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:53:09 -0700 (PDT) From: Serge Semin To: Serge Semin , Mark Brown , Andy Shevchenko Cc: Andy Shevchenko , Andy Shevchenko , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND v3 4/4] spi: dw: Drop default number of CS setting Date: Tue, 16 Apr 2024 18:52:34 +0300 Message-ID: <20240416155257.22429-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416155257.22429-1-fancer.lancer@gmail.com> References: <20240416155257.22429-1-fancer.lancer@gmail.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DW APB/AHB SSI core now supports the procedure automatically detecting the number of native chip-select lines. Thus there is no longer point in defaulting to four CS if the platform doesn't specify the real number especially seeing the default number didn't correspond to any original DW APB/AHB databook. Signed-off-by: Serge Semin Reviewed-by: Andy Shevchenko --- Changelog v2: - Drop temporal variable and pass dws_spi::num_cs directly. --- drivers/spi/spi-dw-mmio.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index cc74cbe03431..c56de35eca98 100644 --- 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,11 +363,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; + /* Rely on the auto-detection if no property specified */ + device_property_read_u32(&pdev->dev, "num-cs", &dws->num_cs); init_func = device_get_match_data(&pdev->dev); if (init_func) {