From patchwork Fri Apr 12 09:41:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10897723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 206D517E1 for ; Fri, 12 Apr 2019 09:41:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0190528E18 for ; Fri, 12 Apr 2019 09:41:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9B0E28E71; Fri, 12 Apr 2019 09:41:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B355428E18 for ; Fri, 12 Apr 2019 09:41:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbfDLJlm (ORCPT ); Fri, 12 Apr 2019 05:41:42 -0400 Received: from smtp.domeneshop.no ([194.63.252.55]:43336 "EHLO smtp.domeneshop.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726327AbfDLJll (ORCPT ); Fri, 12 Apr 2019 05:41:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org; s=ds201810; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From; bh=KGZJ3WnM21zM7Ne/S58ozyw6djuLtV+7nKa/hI+MU9c=; b=A+g/Tikuw0O/4G/yu+qoW6GZQ7o5uwBgGP4uEDz5OF5F1wRJel9zLjEWJCAxYug2JIFPiZrO87pV3a7IisxLmxyHQ1FkjVj+jG815qLmCIea9OwWHfw5Mrm17cDwYTSAGCfRvL0nOmm1ZDdD/qS2kPJ/UWK85t+E45Et3c5gt03tMzpJJgKT6OA4daIv+74epvE5O44RhFMLmhzlMci1B9CGTGmWhDc++oZ9b0C8J2gsdsgYr1Hak7oRHzCEdSHAok+W79/HhREZW9++rYteUrbLD5MkV8MeW1besAkDdbK/vpKYPNJds9u87Of3pE7Upatnb2maOQ0LWuA4VryQcg==; Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:49906 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.84_2) (envelope-from ) id 1hEsgl-0007Xy-EJ; Fri, 12 Apr 2019 11:41:39 +0200 From: =?utf-8?q?Noralf_Tr=C3=B8nnes?= To: linux-spi@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: broonie@kernel.org, =?utf-8?q?Noralf_Tr=C3=B8nnes?= Subject: [PATCH 1/2] spi: Add spi_is_bpw_supported() Date: Fri, 12 Apr 2019 11:41:30 +0200 Message-Id: <20190412094131.25616-1-noralf@tronnes.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This let SPI clients check if the controller supports a particular word width. drivers/gpu/drm/tinydrm/mipi-dbi.c will use this to determine if the controller supports 16-bit for RGB565 pixels. If it doesn't it will swap the bytes before transfer on little endian machines. Signed-off-by: Noralf Trønnes --- include/linux/spi/spi.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 662b336aa2e4..b30e3d13a5ac 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -983,6 +983,26 @@ spi_max_transfer_size(struct spi_device *spi) return min(tr_max, msg_max); } +/** + * spi_is_bpw_supported - Check if bits per word is supported + * @spi: SPI device + * @bpw: Bits per word + * + * This function checks to see if the SPI controller supports @bpw. + * + * Returns: + * True if @bpw is supported, false otherwise. + */ +static inline bool spi_is_bpw_supported(struct spi_device *spi, u32 bpw) +{ + u32 bpw_mask = spi->master->bits_per_word_mask; + + if (bpw == 8 || (bpw <= 32 && bpw_mask & SPI_BPW_MASK(bpw))) + return true; + + return false; +} + /*---------------------------------------------------------------------------*/ /* SPI transfer replacement methods which make use of spi_res */