Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp117154lqt; Mon, 18 Mar 2024 03:16:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUM7isfqJYAVbZhs2BGCKa3bJg3GwU9Np2gq8ssMpLyag7eD/XmQyr8f6MHctqsM9FLg06Id3J73UTVIcrYr+ggm9ov5Lz0hiEeC8N1zQ== X-Google-Smtp-Source: AGHT+IFRrscT/YZ+eocSibJKhokEoLWTNMgmlJhSLHqsERDLjfvyg6/h3eIuprx+/J+QcnrCnIfS X-Received: by 2002:a05:6a00:1783:b0:6e6:9a11:ccec with SMTP id s3-20020a056a00178300b006e69a11ccecmr13193706pfg.17.1710756987693; Mon, 18 Mar 2024 03:16:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710756987; cv=pass; d=google.com; s=arc-20160816; b=GtVoDAQuvtLO7Xgzacr8xCrbCdir96nqwCBh3RjLgRlcbg6kn7j9//5YL9XaaR1QIh E+XQBhVZEu+HdEv+L0anShZj+WBAfdU4Q/EixfPrmSCbIavp1h5V+YQ1KKM5q2K9rEIL pXcMiGI7M0JZdCk+1IFv/OnJ0GHsFHuIHDJASJcKptcxZPN29jRSg1i5/gCF7Ko3QZH0 QBxuKIvZCrt9zz9xs814CgUbsZFHi69dUegHQ8ymSIJDqjrxr8vtAUoQ/23r7DC79LVr uvG+hEjhCSk5GZ1jD6kqK4BH9kRNm5Z+kRCgW8iDSoKknEiTXhDL8UqvFbJWg6Izy5Wz GTTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ZUpHZTUUgUjB75T0vabPnF5k8n99pMnNI8fISkn12Io=; fh=gfooMvHLCw/2z3ibo+Ki3M7b/kvDA/5T8rkZjAvLWks=; b=R81zIIjsD3YBiRigFpnkSXqMDRmZEMjRJ5nHReZ1xPImg7hb0Q/uFxWOGi3ggEGngw z3OZxcn2rHRUDdzglJwaO7BQawzXzc7nEPmzGZXsIkd5BEiw45CsfgiKSShYdR6zbUcB AVtfTFHe4FQVw0Y+euverfvdeKTNpVvRmuA8ZKyU/Gb4e+kE26c2siD8fQURDCO3+ssv a/c4owrQ9xQFFCiKAd11UgzR+wz1meJ4hPdpCN9i8lD3vG/wcQGmHy8NRq9yJ/f9spoL iCPBcgdbVGXg5BlZngUtDeTACm5s992xsJ0T2Qv+oC6Fn5jmaB0tnFH2gWUFdRSdIm0S GwBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=F6cjIG4L; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-105977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z10-20020aa79e4a000000b006e67b7375d1si8748409pfq.148.2024.03.18.03.16.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 03:16:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=F6cjIG4L; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-105977-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105977-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 61F67282976 for ; Mon, 18 Mar 2024 10:16:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8B272E63B; Mon, 18 Mar 2024 10:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="F6cjIG4L" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A5BD2E633; Mon, 18 Mar 2024 10:16:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756969; cv=none; b=jJg1Mv7q1DwQdOyIxLrmzgL/YwveoujZ7TUOKFgk3jXnLFxrCe9HnGTnaonG5d+rC4FEFGTON/Q4z0xSmZ35i4xM61HR2fJVhPDK+OMTy7HafhbXjWS97yGP03PxNpRJ4phm1TgfAkq5qhNn/hicwNxwEa2oargsGDrh+WiOB3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710756969; c=relaxed/simple; bh=wdXdeRL5x3UOBKa21ru0LJKOTtloww8Fsce2L+TBuw4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eNN3PwFvf70MnmTMjYVR+NwhdeojGBFNVdLhsAiQiHgOiEuNOZReEHyknlCWrLjVUnHtdCM0pvcOATvEGe20OnpHtAXk7q012PuE10pJYP8bKXJ4Jn+zI2nw9mQYJo7hqBJ/pIykCJDuPH0zU8mXc5D3XGHABV+2mFZgAdvZIj8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=F6cjIG4L; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710756966; bh=wdXdeRL5x3UOBKa21ru0LJKOTtloww8Fsce2L+TBuw4=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=F6cjIG4L2XY8BPDTZdzVLWFg4FUME3aGH2vdFWDlZlRpzmPdHhWx3iypezSs1oCgU as7Q+/lbn01t611RG/+UNFL7P6ryKxX90SxVRrBOo8NLMvN3ULR+UBgLSLT1uVBO3s PbTQPh/QhDLNxKj+y9UotgF1YpnVBM3BBqDo6RZB2JZafeOQZF0mTTU5Z3WNEukIcI HQN03+0Tri4OpkavDA/UoH7pQJJpZZk50q/r94CGPBAI8uB5iTMvlSNlnW2pr3q1TD r7duVIF9h4WeO0PDZznD4hZI4gDOp9zChN5XrJPd1Gu8aICumFoCTA4e3o82wRyX88 79x1a3IIiK6eg== Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 15D6C3781FCD; Mon, 18 Mar 2024 10:16:06 +0000 (UTC) Message-ID: Date: Mon, 18 Mar 2024 11:16:05 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] spi: mt7621: allow GPIO chip select lines Content-Language: en-US To: Justin Swartz , Mark Brown , Matthias Brugger Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <71533474-eb08-438c-b7ec-5f3277c195fc@sirena.org.uk> <20240316010302.20776-1-justin.swartz@risingedge.co.za> From: AngeloGioacchino Del Regno In-Reply-To: <20240316010302.20776-1-justin.swartz@risingedge.co.za> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Il 16/03/24 02:03, Justin Swartz ha scritto: > Extract a magic number, from mt7621_spi_probe(), used to > declare the number of chip select lines (which co-incides > with the native chip select count of 2) to a macro. > > Use the newly defined MT7621_NATIVE_CS_COUNT macro to > instead populate both the spi_controller's max_native_cs > and num_chipselect members. > > Declare that the spi_controller should use_gpio_descriptors > if present in the device properties (such as those declared > in the cs-gpio property of a "ralink,mt7621-spi" compatible > device-tree node) so that the SPI core will recalculcate > num_chipselect to account for the GPIO descriptors that > it should have populated in the cs_gpiod array member. > > Remove the assignment of mt7621_spi_transfer_one_message() > to the spi_controller's transfer_one_message hook. > > Refactor the mt7621_spi_transfer_one_message() logic into > mt7621_spi_prepare_message() and mt7621_spi_transfer_one() > and assign both to the spi_controller's prepare_message > and transfer_one hooks respectively. > > Migrate the call mt7621_spi_transfer_one_message() made to > mt7621_spi_flush() just before chip select deactivation, > to the end of mt7621_spi_write_half_duplex() to ensure > that any pending data is shifted out of MOSI before the SPI > core deactivates the chip select line. > > As chip select activation is now taken care of by the SPI > core, due to the use of the transfer_one hook instead of > transfer_one_message, the calls to mt7621_spi_set_cs() > from mt7621_spi_transfer_one_message() have fallen away. > > And although the SPI core will handle activation for GPIO > chip select lines behind the scenes, it requires a callback > to allow the driver to perform controller-specific > operations to control its native chip select lines. > > Rename mt7621_spi_set_cs() to mt7621_spi_set_native_cs() > and make sure that it takes into account the activation > polarity of the chip select line it's acting upon, as the > passed enable parameter represents the desired line level > and not the desired activation state, and then assign > mt7621_set_cs() to the spi_controller's set_cs hook. > > Signed-off-by: Justin Swartz Reviewed-by: AngeloGioacchino Del Regno