From patchwork Wed Jun 5 21:22:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687535 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 9C2A715F40C; Wed, 5 Jun 2024 21:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; cv=none; b=Hj4qljILZKKtmHRnbbbWuianHT9iCc4043orRYT2m8/WOjYf5eV7f5OBogVD496nbmOPtiwzn7ljPABcQxkiUEXOGX8h+JYsZsF212XSlgMxh2626QxeWytDZn1LtWjcJoPJweAXBLjGkM9GA7hi1qsuPbstQLH1qdDXxqw4bGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; c=relaxed/simple; bh=rE0Jun7ASocTkER4Zz1WN9mSwEGnbpw9qhfd63n2Xfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d+CKCLo3Qz5HQWjU7exYB/YCWk7KWNcEK8LMny5kBZFAONJb9F3342I1vbR/kjZcdftPZni89VN1grUHmhyrJG0FKridktHGIJPmoFm4H2LSYSLRZO2g2zEBcJ6Gr7qPasHsvDQGoRrJWdKk8R/fEGOn/SpKEPvBMHiqZ3XOO0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=P7QybuMl; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="P7QybuMl" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L22cw000948; Wed, 5 Jun 2024 21:23:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=IeMzCBPMm0HGqKUzTLcpPoxCLl91x2nvDiQoiHU7cEQ=; b=P7QybuMljh6UMPtriSQazoo4PclHKzxyNCG99ygrUtfKp0QN6D0iARS+EJjphGQD0YLP 7oGzFqBedubL8G+pNnfLBqX8FWGuTAuqGxrK/H9qPB4Pb93xNA//yW0v8qiOnl0RzS2x 2GDPeKdwBJWrCtv4dxe8cVibX9V9F7Lt1+zafKa+jpSefH0NpdX/6n0oVL2O9kwc7krK VVhdmTmmvT5q8d2Rp0p2c3qkgw+o5DlrXsHf6zBKnFOSBdBunVm68F/7rOosiX+sTsdy 4+6+45Pb1elhQdOFf3rjjNFPWsf8CTPAmsn+UO0q7q3Vh3qVSkdSAyiuww5n3hpd3JHr EA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxbg09vf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBWHh000815; Wed, 5 Jun 2024 21:23:17 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:17 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNDeh24052398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:15 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 714F658055; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 292A65806A; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 01/40] fsi: hub: Set master index to link number plus one Date: Wed, 5 Jun 2024 16:22:33 -0500 Message-Id: <20240605212312.349188-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wjCEZMeO7OCYMh8f-tgIBCBMY2ATHwui X-Proofpoint-ORIG-GUID: wjCEZMeO7OCYMh8f-tgIBCBMY2ATHwui X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1011 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Hub master indexing is problematic if a hub is rescanned while the root master is being rescanned. Therefore, request a specific index in the hub driver. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-hub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 6d8b6e8854e56..36da643b32018 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -12,6 +12,7 @@ #include #include "fsi-master.h" +#include "fsi-slave.h" #define FSI_ENGID_HUB_MASTER 0x1c @@ -229,6 +230,7 @@ static int hub_master_probe(struct device *dev) hub->master.dev.release = hub_master_release; hub->master.dev.of_node = of_node_get(dev_of_node(dev)); + hub->master.idx = fsi_dev->slave->link + 1; hub->master.n_links = links; hub->master.read = hub_master_read; hub->master.write = hub_master_write; From patchwork Wed Jun 5 21:22:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687538 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3BEEC15F321; Wed, 5 Jun 2024 21:23:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; cv=none; b=Er9gTMz+PTNEWGgwMs0ncneiTOvAQIz+CcNlu+a0iHNvbc6vUgumSh+a7cdjTy9H9gQM6GNcAuLoKfSgwRv5e7IJwwfZ3kq5dS3t3ra0AtfoI5FyL2OloASnGNPUuweiRWM8lYdG4tqh6iQqqEV5taspMpzC8Cf7D+RXRLH4pz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; c=relaxed/simple; bh=28Gfq7n26fRHxuUeS4aQmeyrgTs1A+//LqHpjvdZ47s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GP63d5EOh1UvkMWQRihXewd4iKeCp5ys4J3EaTmgWOyw7fS1pNrEV4XG0NT//6a/6LyMs0RbP4agcKYlWfODooB3D6ZoV9/EfXt9qiojMk7gpxyPfXjL3LSAPos1J7jYxppmv5l4+QtmEl7lCdbUHN7YjgfSmpiZ9D90N7jHIas= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Yz9z/IBR; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Yz9z/IBR" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KwLb6015829; Wed, 5 Jun 2024 21:23:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=oHKlxwrlNdF8PlHD5y5HFMOj3x1VaBvrVhlzZpRcYr8=; b=Yz9z/IBRDllcpXerN5/VRAIlY9xP1b0ZVHXbqnEMarnAGgmCyUE29ufZVS9R8lGBFTxu Ij6YZMgA8vPxl7WPH7XM7cUvDYpc6YVhPA2s6BVWdtTW0bE626hzBiGZmbhBY/+sSjAL dz23YahZjZ/6GhZY9vV04e8RIOv2fAUhVrmP8ntHCjQn3JGKLKsLwvmJBLKKrtwSS3Oz TStjpSXKj9kMG8zM8CrhEiI7VTlEvlzpsBfGO6vY6bv8As3SHG9TbWHKY0b+yb6ezL/X TZgsM6W8rLCKako5bSEGsjRM0WnjoogldxeDijedgl1jNaaNjDkg+JgNy1ADe041Iplr Kg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygp81u2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KGajT022794; Wed, 5 Jun 2024 21:23:17 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygg6med39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:17 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNDRk20251162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:16 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B947358065; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 794B658063; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 02/40] fsi: Move slave definitions to fsi-slave.h Date: Wed, 5 Jun 2024 16:22:34 -0500 Message-Id: <20240605212312.349188-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fUq12zTZtn0dl8zMyNQpeum3Dq7dC68g X-Proofpoint-ORIG-GUID: fUq12zTZtn0dl8zMyNQpeum3Dq7dC68g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Master drivers may need access to the slave definitions. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 35 ----------------- drivers/fsi/fsi-slave.h | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 35 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 097d5a780264c..7bf0c96fc0172 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -45,41 +45,6 @@ static const int engine_page_size = 0x400; -#define FSI_SLAVE_BASE 0x800 - -/* - * FSI slave engine control register offsets - */ -#define FSI_SMODE 0x0 /* R/W: Mode register */ -#define FSI_SISC 0x8 /* R/W: Interrupt condition */ -#define FSI_SSTAT 0x14 /* R : Slave status */ -#define FSI_SLBUS 0x30 /* W : LBUS Ownership */ -#define FSI_LLMODE 0x100 /* R/W: Link layer mode register */ - -/* - * SMODE fields - */ -#define FSI_SMODE_WSC 0x80000000 /* Warm start done */ -#define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */ -#define FSI_SMODE_SID_SHIFT 24 /* ID shift */ -#define FSI_SMODE_SID_MASK 3 /* ID Mask */ -#define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ -#define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ -#define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ -#define FSI_SMODE_SD_MASK 0xf /* Send delay mask */ -#define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ -#define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ - -/* - * SLBUS fields - */ -#define FSI_SLBUS_FORCE 0x80000000 /* Force LBUS ownership */ - -/* - * LLMODE fields - */ -#define FSI_LLMODE_ASYNC 0x1 - #define FSI_SLAVE_SIZE_23b 0x800000 static DEFINE_IDA(master_ida); diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index 1d63a585829dd..dba65bd4e083f 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -7,6 +7,90 @@ #include #include +#define FSI_SLAVE_BASE 0x800 + +/* + * FSI slave engine control register offsets + */ +#define FSI_SMODE 0x0 /* R/W: Mode register */ +#define FSI_SISC 0x8 /* R : Interrupt condition */ +#define FSI_SCISC 0x8 /* C : Clear interrupt condition */ +#define FSI_SISM 0xc /* R/W: Interrupt mask */ +#define FSI_SISS 0x10 /* R : Interrupt status */ +#define FSI_SSISM 0x10 /* S : Set interrupt mask */ +#define FSI_SCISM 0x14 /* C : Clear interrupt mask */ +#define FSI_SSTAT 0x14 /* R : Slave status */ +#define FSI_SI1S 0x1c /* R : Slave interrupt 1 status */ +#define FSI_SSI1M 0x1c /* S : Set slave interrupt 1 mask */ +#define FSI_SCI1M 0x20 /* C : Clear slave interrupt 1 mask */ +#define FSI_SLBUS 0x30 /* W : LBUS Ownership */ +#define FSI_SRSIC0 0x68 /* C : Clear remote interrupt condition */ +#define FSI_SRSIC4 0x6c /* C : Clear remote interrupt condition */ +#define FSI_SRSIM0 0x70 /* R/W: Remote interrupt mask */ +#define FSI_SRSIM4 0x74 /* R/W: Remote interrupt mask */ +#define FSI_SRSIS0 0x78 /* R : Remote interrupt status */ +#define FSI_SRSIS4 0x7c /* R : Remote interrupt status */ +#define FSI_LLMODE 0x100 /* R/W: Link layer mode register */ + +/* + * SMODE fields + */ +#define FSI_SMODE_WSC 0x80000000 /* Warm start done */ +#define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */ +#define FSI_SMODE_SID_SHIFT 24 /* ID shift */ +#define FSI_SMODE_SID_MASK 3 /* ID Mask */ +#define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ +#define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ +#define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ +#define FSI_SMODE_SD_MASK 0xf /* Send delay mask */ +#define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ +#define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ + +/* + * SISS fields + */ +#define FSI_SISS_CRC_ERROR BIT(31) +#define FSI_SISS_PROTO_ERROR BIT(30) +#define FSI_SISS_LBUS_PARITY_ERROR BIT(29) +#define FSI_SISS_LBUS_PROTO_ERROR BIT(28) +#define FSI_SISS_ACCESS_ERROR BIT(27) +#define FSI_SISS_LBUS_OWNERSHIP_ERROR BIT(26) +#define FSI_SISS_LBUS_OWNERSHIP_CHANGE BIT(25) +#define FSI_SISS_ASYNC_MODE_ERROR BIT(14) +#define FSI_SISS_OPB_ACCESS_ERROR BIT(13) +#define FSI_SISS_OPB_FENCED BIT(12) +#define FSI_SISS_OPB_PARITY_ERROR BIT(11) +#define FSI_SISS_OPB_PROTO_ERROR BIT(10) +#define FSI_SISS_OPB_TIMEOUT BIT(9) +#define FSI_SISS_OPB_ERROR_ACK BIT(8) +#define FSI_SISS_MFSI_MASTER_ERROR BIT(3) +#define FSI_SISS_MFSI_PORT_ERROR BIT(2) +#define FSI_SISS_MFSI_HP BIT(1) +#define FSI_SISS_MFSI_CR_PARITY_ERROR BIT(0) +#define FSI_SISS_ALL 0xfe007f00 + +/* + * SI1S fields + */ +#define FSI_SI1S_SLAVE_BIT 31 +#define FSI_SI1S_SHIFT_BIT 30 +#define FSI_SI1S_SCOM_BIT 29 +#define FSI_SI1S_SCRATCH_BIT 28 +#define FSI_SI1S_I2C_BIT 27 +#define FSI_SI1S_SPI_BIT 26 +#define FSI_SI1S_SBEFIFO_BIT 25 +#define FSI_SI1S_MBOX_BIT 24 + +/* + * SLBUS fields + */ +#define FSI_SLBUS_FORCE 0x80000000 /* Force LBUS ownership */ + +/* + * LLMODE fields + */ +#define FSI_LLMODE_ASYNC 0x1 + struct fsi_master; struct fsi_slave { From patchwork Wed Jun 5 21:22:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687558 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 AC53F16B733; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; cv=none; b=OcPNI0nzVZTqUPAmEVwFz/c3g6wpulPD2iwE64my4LTno++HfYQhC3Ij6eA8/9P2NEPdVunXrmx9UGzC281gLsuIYuNo/Ae2PL5eIZf+UjF9X/LW0m+/FTJAojoS764w0hSvqT8nmL7h6PXWOoAMYptsrv80hCiPNmpH7LNkaZ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; c=relaxed/simple; bh=3+focb3tE1wM1QQff+6oE4BhF/jbM/GCPfmx3/r5S1c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HAozRp/LYezktxJdf3JZEa66KB0KqOHP4WLiHWQs1Dr5FuunRvWpGxmVz8Qze6J6S6R7GRSw1oAFi+E5zgbFWtpyLP+HSHNp3PdPhVEb1/tFDaImO4ey0ckQAGSNIR7kQotVKzfE9JVyk6ZdnX3oVX9EURs15+8wUfUdx0kqsIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=D2TU6lSC; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="D2TU6lSC" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LDHcQ011846; Wed, 5 Jun 2024 21:23:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=0/NaGtMOdV6peMp7cxUe2O305K/Nsm2Su9UXKOlASJE=; b=D2TU6lSCtGY6PQMFSaEsbzVvTpkS/6rk98cFcqt+Jgkq3kuQNUFhoZZ9ak6NACk5Txsl CNMXDz0M53IQzDuLbe/uQ1i/+EqeEKaMD58XgzE4s5fV3eJyHVeAsVa/2igPiWJ87gTH ijndYGyDkLMcgYso6kXDZREe4AvkPzvLIY+Kso4NeutZlPjPHaVWtlJNkBlwMD60qyvr n60kT+ooInZ8IBL9oCq0ikIgEF07WHOGiog1VVa7QFhTVMNVaONV+BhWCdHW7Fqwbdne TKmBXO2H371pAitjrXRzFFN21UOWIZgQ9BoDkBPTNHcdQK+Fr0NZBYmW1r/1xle2kpfZ hQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyr080rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455K0hNn026694; Wed, 5 Jun 2024 21:23:17 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffn6hgq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:17 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNEah54329796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:16 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EA1858043; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFFA35806A; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:13 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 03/40] fsi: Fix slave addressing after break command Date: Wed, 5 Jun 2024 16:22:35 -0500 Message-Id: <20240605212312.349188-4-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ESb3mSMAFGOdcFePo6vRJmD-oYXNuBjs X-Proofpoint-ORIG-GUID: ESb3mSMAFGOdcFePo6vRJmD-oYXNuBjs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 After a break command, the slave ID is set to 0x3, which means the FSI driver should use that ID when communicating with the slave, until SMODE is programmed with the new ID (forced to 0 for 23 bit addressing in the current implementation). This worked previously due to a feature of newer FSI slaves that don't enforce this requirement. Since hub masters cannot address non-zero slave IDs, disable this behavior for slaves off hub masters. Fixes: 2b545cd8e1b2 ("drivers/fsi: Implement slave initialisation") Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 20 ++++++++++---------- drivers/fsi/fsi-master-hub.c | 1 + drivers/fsi/fsi-master.h | 1 + drivers/fsi/fsi-slave.h | 1 + 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 7bf0c96fc0172..e8dbf5e95c234 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -217,7 +217,7 @@ static uint32_t fsi_slave_smode(int id, u8 t_senddly, u8 t_echodly) | fsi_smode_lbcrr(0x8); } -static int fsi_slave_set_smode(struct fsi_slave *slave) +static int fsi_slave_set_smode(struct fsi_slave *slave, uint8_t id) { uint32_t smode; __be32 data; @@ -228,8 +228,7 @@ static int fsi_slave_set_smode(struct fsi_slave *slave) smode = fsi_slave_smode(slave->id, slave->t_send_delay, slave->t_echo_delay); data = cpu_to_be32(smode); - return fsi_master_write(slave->master, slave->link, slave->id, - FSI_SLAVE_BASE + FSI_SMODE, + return fsi_master_write(slave->master, slave->link, id, FSI_SLAVE_BASE + FSI_SMODE, &data, sizeof(data)); } @@ -281,7 +280,7 @@ static int fsi_slave_handle_error(struct fsi_slave *slave, bool write, slave->t_send_delay = send_delay; slave->t_echo_delay = echo_delay; - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, FSI_SMODE_SID_BREAK); if (rc) return rc; @@ -773,7 +772,7 @@ static ssize_t slave_send_echo_store(struct device *dev, slave->t_send_delay = val; slave->t_echo_delay = val; - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, slave->id); if (rc < 0) return rc; if (master->link_config) @@ -945,6 +944,8 @@ EXPORT_SYMBOL_GPL(fsi_free_minor); static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) { + const uint8_t break_id = (master->flags & FSI_MASTER_FLAG_NO_BREAK_SID) ? 0 : + FSI_SMODE_SID_BREAK; uint32_t cfam_id; struct fsi_slave *slave; uint8_t crc; @@ -957,7 +958,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) if (id != 0) return -EINVAL; - rc = fsi_master_read(master, link, id, 0, &data, sizeof(data)); + rc = fsi_master_read(master, link, break_id, 0, &data, sizeof(data)); if (rc) { dev_dbg(&master->dev, "can't read slave %02x:%02x %d\n", link, id, rc); @@ -981,9 +982,8 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) */ if (master->flags & FSI_MASTER_FLAG_SWCLOCK) { llmode = cpu_to_be32(FSI_LLMODE_ASYNC); - rc = fsi_master_write(master, link, id, - FSI_SLAVE_BASE + FSI_LLMODE, - &llmode, sizeof(llmode)); + rc = fsi_master_write(master, link, break_id, FSI_SLAVE_BASE + FSI_LLMODE, &llmode, + sizeof(llmode)); if (rc) dev_warn(&master->dev, "can't set llmode on slave:%02x:%02x %d\n", @@ -1028,7 +1028,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) "can't set slbus on slave:%02x:%02x %d\n", link, id, rc); - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, break_id); if (rc) { dev_warn(&master->dev, "can't set smode on slave:%02x:%02x %d\n", diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 36da643b32018..eea8649fee74d 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -232,6 +232,7 @@ static int hub_master_probe(struct device *dev) hub->master.idx = fsi_dev->slave->link + 1; hub->master.n_links = links; + hub->master.flags = FSI_MASTER_FLAG_NO_BREAK_SID; hub->master.read = hub_master_read; hub->master.write = hub_master_write; hub->master.send_break = hub_master_break; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 967622c1cabf7..a0d7ad0f0f7cc 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -111,6 +111,7 @@ /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 +#define FSI_MASTER_FLAG_NO_BREAK_SID 0x2 /* * Structures and function prototypes diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index dba65bd4e083f..f6cca04131a92 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -39,6 +39,7 @@ #define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */ #define FSI_SMODE_SID_SHIFT 24 /* ID shift */ #define FSI_SMODE_SID_MASK 3 /* ID Mask */ +#define FSI_SMODE_SID_BREAK 3 /* ID after break command */ #define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ #define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ #define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ From patchwork Wed Jun 5 21:22:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687531 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3BE5012E63; Wed, 5 Jun 2024 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622616; cv=none; b=jDiwpO61te53tQClmgJeYkSuRXmur9Okpp9ZwgRJCLkyPuJbJ76uffH3d84L1ShDCd6hj6goVIXdvQrc9ufzkXt4Z49dQGcUldPJdqkE2Pu+z1LQVvRVu9UK4PGY/h+mv3k/byWj3lNOEWE+uiQXDV0q5GVDNThUeVray3wjk7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622616; c=relaxed/simple; bh=c6X5cBeVcHCy2khqupbb2XqaXAyq1jU0VNJD2arVWzs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XaFO1cEUNgKJ1V6eFPfBkkGIVPDw55IDP27haaLTxMQQtcl7jYnblDKZv9am6a20T2DSLuGjqPsaFv8eKItjCUTDqAJb2fUXN7w/PbhlpRgfQ/VT5gCQT6CXNpwxvze/p5s+n3SIWFkteyO+LFHmSIzqSMsly4GqfNUkr17Ujao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=oKOhFWtH; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oKOhFWtH" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBh1p011765; Wed, 5 Jun 2024 21:23:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=c52WiDs0KUXzepuhSz5qr9KqOUKGpDG3JkjIGvE1bYo=; b=oKOhFWtHKvw6MSyp/9rHmBc0XnItfj8TU5sdvxNqtGaNAQRj3576bYwaNS8r980FL85s 3BD157qf8RAQZGxT9z+7iv+2VpbsIwhQ5HBCzUGLpcDIIOKinrIxRo/vXh9aqmAaHQE1 pwSIIJ0qHCaKUTqMqkb7u/n727FYLeWIWSfDNZg5GwyKUAsDDo4f99mVFAhz/oeHzWjj fTD/yxw/asDGcungrNbcGicG6rKQqMcFQOq/WZjymBk9s6rCwS4eyV+UKS/+Y+mgUjkc QYdy0yv2kO6f9kXeJLdfnQwszyLQo7Ptm1kmFYKFKrA154i/HkuPuCbfuqxKFW/uCya1 JA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:19 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JVcN9031129; Wed, 5 Jun 2024 21:23:18 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnsv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNEWG7733802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:17 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7F9B58060; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45BFD58059; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 04/40] fsi: Use a defined value for default echo delay Date: Wed, 5 Jun 2024 16:22:36 -0500 Message-Id: <20240605212312.349188-5-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rpB8W7vUEWK5uwd-GLpsqm9PfjL9BVOj X-Proofpoint-ORIG-GUID: rpB8W7vUEWK5uwd-GLpsqm9PfjL9BVOj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Avoid hardcoding '16' several times. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 6 +++--- drivers/fsi/fsi-slave.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index e8dbf5e95c234..27235583183e5 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1008,8 +1008,8 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) slave->link = link; slave->id = id; slave->size = FSI_SLAVE_SIZE_23b; - slave->t_send_delay = 16; - slave->t_echo_delay = 16; + slave->t_send_delay = FSI_SMODE_SD_DEFAULT; + slave->t_echo_delay = FSI_SMODE_ED_DEFAULT; /* Get chip ID if any */ slave->chip_id = -1; @@ -1160,7 +1160,7 @@ static int fsi_master_break(struct fsi_master *master, int link) if (master->send_break) rc = master->send_break(master, link); if (master->link_config) - master->link_config(master, link, 16, 16); + master->link_config(master, link, FSI_SMODE_SD_DEFAULT, FSI_SMODE_ED_DEFAULT); return rc; } diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index f6cca04131a92..45190b06fa027 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -42,8 +42,10 @@ #define FSI_SMODE_SID_BREAK 3 /* ID after break command */ #define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ #define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ +#define FSI_SMODE_ED_DEFAULT 16 /* Default echo delay */ #define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ #define FSI_SMODE_SD_MASK 0xf /* Send delay mask */ +#define FSI_SMODE_SD_DEFAULT 16 /* Default send delay */ #define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ #define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ From patchwork Wed Jun 5 21:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687541 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 20C6E15FA9C; Wed, 5 Jun 2024 21:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; cv=none; b=lyUOKtCqz+E+8u1C6eooItkX9WR7K8inRhEGtDgT3ADn5bmzRtscO5EWpjgEKrl4x4G4ubVEyfo2OZaTtIWi5Py9BB7Gx0MtoD7IQdFJusixcBqF1hMMDt+/EE8Axq8HBHM/2LGb2yfxnC2FNPt2MgmTvpz+WOYIwy78oX7prDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; c=relaxed/simple; bh=B0CdS5kElvMVR1I4RMssK8hzoJSvEEEupBSIlboCebc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eDtj7n49xYa6zlCAYnVw2jdRPCjscLztl8K230dYBvGMkATV103UIMkQP6hNmu+OWFF3Vc+kvbdz+HzPvsCJA91hOFZeSkygMMEn1BlYwyCSAXMTHXqy6xelt0IgxEmJqxzYMN2RU+YPIAY7tqNsn5TFxUG1uHardBtdK43+0ao= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=p9s/NhgB; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="p9s/NhgB" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LE8uk012465; Wed, 5 Jun 2024 21:23:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=Wgrp9mSZpxfDhxFWWnfZxUxl4xHvgw/nBvDHfI2klKI=; b=p9s/NhgB2Zb0NT+dnQnHnoZhfgHdS2t1vs5jIds80DaIEsotF1tmA+Q7K021rk/76hd5 FUBqGRH4J/UVhK+ErGbFPqbY4SXtMtVkGN8Ti0LkJXfeKkbt/ubAQIvralIJAr1R2ws6 qREvgWx6/E1JaC0rZ2Kbi/SpNC3NwNpsS0idopobUyWPNVcP/5j/9hGMktljbUBEiy/X URI7B9dgbC6PaMHrQBXWCEMIEt8VsUJou1oCN9yKjQW8YKLiLaUcHe0tMgkEiiaxs7Yd pg51EzFT9QkRQLLK1lHf8d6XmTo+ZuzP4BSAPkrgkywvLH2m/5SeHNU+T298WZy0NI0t Aw== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyr080rt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KFxdv022791; Wed, 5 Jun 2024 21:23:17 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygg6med3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:17 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNFgY26215122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:17 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A6DF58059; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFA075805D; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:14 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 05/40] fsi: Calculate local bus clock frequency Date: Wed, 5 Jun 2024 16:22:37 -0500 Message-Id: <20240605212312.349188-6-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Tz4SFMVi367gKr_BaxpCBPbnRW3r8nbS X-Proofpoint-ORIG-GUID: Tz4SFMVi367gKr_BaxpCBPbnRW3r8nbS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Instead of a hardcoded local bus clock divider, calculate the responder local bus frequency from the FSI bus frequency. This will allow FSI engine drivers to set and calculate their bus (I2C, SPI, etc) frequencies. Signed-off-by: Eddie James --- Changes since v2: - Use cfam clock-frequency property instead of hardcoded master local bus divider - Change default local bus clock divider from 8 to 2 drivers/fsi/fsi-core.c | 22 +++++++++++++++++++--- drivers/fsi/fsi-master.h | 1 + drivers/fsi/fsi-slave.h | 2 ++ include/linux/fsi.h | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 27235583183e5..44875f2350b04 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -109,6 +109,12 @@ int fsi_device_peek(struct fsi_device *dev, void *val) return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t)); } +unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev) +{ + return dev->slave->master->clock_frequency / dev->slave->clock_div; +} +EXPORT_SYMBOL_GPL(fsi_device_local_bus_frequency); + static void fsi_device_release(struct device *_device) { struct fsi_device *device = to_fsi_dev(_device); @@ -209,12 +215,12 @@ static inline uint32_t fsi_smode_sid(int x) return (x & FSI_SMODE_SID_MASK) << FSI_SMODE_SID_SHIFT; } -static uint32_t fsi_slave_smode(int id, u8 t_senddly, u8 t_echodly) +static uint32_t fsi_slave_smode(int id, int div, u8 t_senddly, u8 t_echodly) { return FSI_SMODE_WSC | FSI_SMODE_ECRC | fsi_smode_sid(id) | fsi_smode_echodly(t_echodly - 1) | fsi_smode_senddly(t_senddly - 1) - | fsi_smode_lbcrr(0x8); + | fsi_smode_lbcrr(div - 1); } static int fsi_slave_set_smode(struct fsi_slave *slave, uint8_t id) @@ -225,7 +231,8 @@ static int fsi_slave_set_smode(struct fsi_slave *slave, uint8_t id) /* set our smode register with the slave ID field to 0; this enables * extended slave addressing */ - smode = fsi_slave_smode(slave->id, slave->t_send_delay, slave->t_echo_delay); + smode = fsi_slave_smode(slave->id, slave->clock_div, slave->t_send_delay, + slave->t_echo_delay); data = cpu_to_be32(smode); return fsi_master_write(slave->master, slave->link, id, FSI_SLAVE_BASE + FSI_SMODE, @@ -950,6 +957,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) struct fsi_slave *slave; uint8_t crc; __be32 data, llmode, slbus; + u32 clock; int rc; /* Currently, we only support single slaves on a link, and use the @@ -1003,6 +1011,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) slave->dev.of_node = fsi_slave_find_of_node(master, link, id); slave->dev.release = fsi_slave_release; device_initialize(&slave->dev); + slave->clock_div = FSI_SMODE_LBCRR_DEFAULT; slave->cfam_id = cfam_id; slave->master = master; slave->link = link; @@ -1020,6 +1029,10 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) } + if (master->clock_frequency && !device_property_read_u32(&slave->dev, "clock-frequency", + &clock) && clock) + slave->clock_div = DIV_ROUND_UP(master->clock_frequency, clock); + slbus = cpu_to_be32(FSI_SLBUS_FORCE); rc = fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SLBUS, &slbus, sizeof(slbus)); @@ -1289,6 +1302,9 @@ int fsi_master_register(struct fsi_master *master) if (!dev_name(&master->dev)) dev_set_name(&master->dev, "fsi%d", master->idx); + if (master->flags & FSI_MASTER_FLAG_SWCLOCK) + master->clock_frequency = 100000000; // POWER reference clock + master->dev.class = &fsi_master_class; mutex_lock(&master->scan_lock); diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index a0d7ad0f0f7cc..ff23983ea84c8 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -121,6 +121,7 @@ struct fsi_master { struct device dev; + unsigned long clock_frequency; int idx; int n_links; int flags; diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index 45190b06fa027..fabc0b66d5bf3 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -48,6 +48,7 @@ #define FSI_SMODE_SD_DEFAULT 16 /* Default send delay */ #define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ #define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ +#define FSI_SMODE_LBCRR_DEFAULT 2 /* Default clk ratio */ /* * SISS fields @@ -104,6 +105,7 @@ struct fsi_slave { int id; /* FSI address */ int link; /* FSI link# */ u32 cfam_id; + u32 clock_div; int chip_id; uint32_t size; /* size of slave address space */ u8 t_send_delay; diff --git a/include/linux/fsi.h b/include/linux/fsi.h index 3df8c54868df5..e0309bf0ae072 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -24,6 +24,7 @@ extern int fsi_device_read(struct fsi_device *dev, uint32_t addr, extern int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val, size_t size); extern int fsi_device_peek(struct fsi_device *dev, void *val); +extern unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev); struct fsi_device_id { u8 engine_type; From patchwork Wed Jun 5 21:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687532 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 CEC5A15F3ED; Wed, 5 Jun 2024 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622617; cv=none; b=M5ZUeiT20L84p7F4cl4SxXJrtHn8leBWytacdTkCqFbgwl+iX9vVwHMc2zyH6JFJFucSZX9v53o8p19W6nvnC/88kMEvf3tZ6K4bNU4ti94wUaUThgzhsLWcYA8i/yd/GyfhCdpEAkeddRRuWwnzfeE255g81ifNtxYHn7Z3VYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622617; c=relaxed/simple; bh=yUz/ROMGEoe6+SLnrmcPZvLaUjxobW2ydVpNVylcngM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tTzR8/ivrusnSpgfx5H3qWGl/Y5t01lZD+JYftA89nz1SdV7yqrC27KMytzWx6nE9Za+WqZS0eqWqWN3ucSVPzXqvKaoQDudP+5w86yZC0jMmha+3SVbfyOS7JcgAduQWwVS/ooof2Irz3g1WIE/DgJ+QoKprum3aXCvplLQErU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=YVdz2aft; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="YVdz2aft" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KKjTo025753; Wed, 5 Jun 2024 21:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=5eeoXCbaU56E8ifND9k7gRXOpAZyJwysFP2rCDv7kG0=; b=YVdz2aftBMryZIQ7m9AHhESDlRVisCt7tgFSuXcqtwHTHoAQ4ArMfUgh9Y4pmiIwDeRb RvHPspileR7Lfj8h4fpmsxr/gcZCliF/SLS2thk2M+/1mEN1DEwyO3THr9Dl+7dbGuj7 bmmwvRFcJkxBtLhkUQ2LBoD8lyNdrbqtvWoHdUp4BRb2hb8ktE1Cf0xEDGGn1ffA+Stt muuCD90oSIR+e9Pa+gtjy17Sy0wBDZBrE1KJ4Li6+HSWbbcjCAjUJDFcL8m10iKTs+mp 08tUEO8Gn+IY7cc8yuIJzIgjWkTtrc5odfyH5Pt9lk2luHTVETv+4BDkkA1BERPrkd8y Ag== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:19 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JBRYQ031204; Wed, 5 Jun 2024 21:23:18 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNFJV34603530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:17 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50E3E58067; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 11AB658061; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 06/40] fsi: core: Improve master read/write/error traces Date: Wed, 5 Jun 2024 16:22:38 -0500 Message-Id: <20240605212312.349188-7-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _O1ZRDGMxSsC5kg47PdcNM1eU2IYsdJp X-Proofpoint-GUID: _O1ZRDGMxSsC5kg47PdcNM1eU2IYsdJp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=886 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Consolidate the master read and write traces into one trace and change the result trace into an error trace for less spam. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 26 +++++---- include/trace/events/fsi.h | 112 ++++++++++++------------------------- 2 files changed, 51 insertions(+), 87 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 44875f2350b04..b3029f9c05e4a 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1116,14 +1116,15 @@ static int fsi_master_read(struct fsi_master *master, int link, { int rc; - trace_fsi_master_read(master, link, slave_id, addr, size); - rc = fsi_check_access(addr, size); - if (!rc) + if (!rc) { rc = master->read(master, link, slave_id, addr, val, size); - - trace_fsi_master_rw_result(master, link, slave_id, addr, size, - false, val, rc); + if (rc) + trace_fsi_master_error(master->idx, link, slave_id, addr, size, val, rc, + true); + else + trace_fsi_master_xfer(master->idx, link, slave_id, addr, size, val, true); + } return rc; } @@ -1133,14 +1134,15 @@ static int fsi_master_write(struct fsi_master *master, int link, { int rc; - trace_fsi_master_write(master, link, slave_id, addr, size, val); - rc = fsi_check_access(addr, size); - if (!rc) + if (!rc) { rc = master->write(master, link, slave_id, addr, val, size); - - trace_fsi_master_rw_result(master, link, slave_id, addr, size, - true, val, rc); + if (rc) + trace_fsi_master_error(master->idx, link, slave_id, addr, size, val, rc, + false); + else + trace_fsi_master_xfer(master->idx, link, slave_id, addr, size, val, false); + } return rc; } diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index 5ff15126ad9d5..fed8835f438e5 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -8,101 +8,63 @@ #include -TRACE_EVENT(fsi_master_read, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size), - TP_ARGS(master, link, id, addr, size), +TRACE_EVENT(fsi_master_xfer, + TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, + bool read), + TP_ARGS(master_idx, link, id, addr, size, data, read), TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) + __field(int, master_idx) + __field(int, link) + __field(int, id) + __field(uint32_t, addr) + __field(int, size) + __field(uint32_t, data) + __field(bool, read) ), TP_fast_assign( - __entry->master_idx = master->idx; + __entry->master_idx = master_idx; __entry->link = link; __entry->id = id; __entry->addr = addr; - __entry->size = size; - ), - TP_printk("fsi%d:%02d:%02d %08x[%zu]", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size - ) -); - -TRACE_EVENT(fsi_master_write, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size, const void *data), - TP_ARGS(master, link, id, addr, size, data), - TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) - __field(__u32, data) - ), - TP_fast_assign( - __entry->master_idx = master->idx; - __entry->link = link; - __entry->id = id; - __entry->addr = addr; - __entry->size = size; + __entry->size = (int)size; __entry->data = 0; memcpy(&__entry->data, data, size); + __entry->read = read; ), - TP_printk("fsi%d:%02d:%02d %08x[%zu] <= {%*ph}", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size, - (int)__entry->size, &__entry->data - ) + TP_printk("fsi%d:%02d:%02d %s %08x {%*ph}", __entry->master_idx, __entry->link, + __entry->id, __entry->read ? "read" : "write", __entry->addr, __entry->size, + &__entry->data) ); -TRACE_EVENT(fsi_master_rw_result, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size, - bool write, const void *data, int ret), - TP_ARGS(master, link, id, addr, size, write, data, ret), +TRACE_EVENT(fsi_master_error, + TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, + int ret, bool read), + TP_ARGS(master_idx, link, id, addr, size, data, ret, read), TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) - __field(bool, write) - __field(__u32, data) - __field(int, ret) + __field(int, master_idx) + __field(int, link) + __field(int, id) + __field(uint32_t, addr) + __field(int, size) + __field(uint32_t, data) + __field(int, ret) + __field(bool, read) ), TP_fast_assign( - __entry->master_idx = master->idx; + __entry->master_idx = master_idx; __entry->link = link; __entry->id = id; __entry->addr = addr; - __entry->size = size; - __entry->write = write; + __entry->size = (int)size; __entry->data = 0; - __entry->ret = ret; - if (__entry->write || !__entry->ret) + if (!read) memcpy(&__entry->data, data, size); + __entry->ret = ret; + __entry->read = read; ), - TP_printk("fsi%d:%02d:%02d %08x[%zu] %s {%*ph} ret %d", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size, - __entry->write ? "<=" : "=>", - (int)__entry->size, &__entry->data, - __entry->ret - ) + TP_printk("fsi%d:%02d:%02d %s %08x {%*ph} %d", __entry->master_idx, __entry->link, + __entry->id, __entry->read ? "read" : "write", __entry->addr, __entry->size, + &__entry->data, __entry->ret) ); TRACE_EVENT(fsi_master_break, From patchwork Wed Jun 5 21:22:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687536 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 B981715F416; Wed, 5 Jun 2024 21:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; cv=none; b=XTq3cZJlvIIVuaar3j+9OKBbNf+6S7wgWqxfbQk5ybg2MK8ixYyerFCUBGpTiGWwzyBHAK6sbrcBYW5pU7aV7EtBxLKr0QwgfWcEvjM72uTP8NelCPMjoLN4Z+Ho/GaWEJnO6EFhnPRSQAp6OESLPE+cZ3GRBel87JdbKAoCNJk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; c=relaxed/simple; bh=LAd7Fl8eb8f+PoK+Joq8lwmFZ5yAW+ThBAA+WrvtsPw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MtqstvQ/PSGTyZp4OGvwGvELpUnItJF3OvWifOKWs0yHqkYKFCTd091tjTZsStGOZbq/EbeEO1b13UZEguY+STygMgDY5n/hAy9mPsfpuCVjPXctEwXGMlXcDUC5kK87XABoYW/4r3n5StOpbMhAeOP4MQTcoWQDc772YUPtfjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Tv0vp0wd; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Tv0vp0wd" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455Kuo58001530; Wed, 5 Jun 2024 21:23:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=wnARRSgz2Wy63EPYwjGONgg7SPU8BXAI/uH83DK3Sg4=; b=Tv0vp0wd0eqmVE0hkiSd8CmwqcAy0YtaIwAgg8sLVvXb6RRGaFKaZx6J84QCtNJ0PnBQ qc3STfh6ZUf0gySXJkAv0VJiagAxXF8wTKh0seJegU/X6po4rS3MYT6FVwRmbycv0h4w QOKODYHyq4kvKqalE0rCBWPZ16DuMblYNMvu5MWD1EpGPQLfHVOkFOresI9y40Oj1FTW g6vkCRCPkNNnjG+o/pJnNyXP1ZAb6aAm3zgTJVIMy9caMzsr4xGHY6R0u1DJMpRrEbkm KLSdYRGM2igERa7PIZ+xh9J2S+nvKBVTNhI8arlK3viT1r6krcS6rdyFI1FRD1ZoGd+9 oA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjwppgcfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:19 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455L18Jw026513; Wed, 5 Jun 2024 21:23:18 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:18 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNFX435717638 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:17 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96B4358061; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57F505805E; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 07/40] fsi: core: Add slave error trace Date: Wed, 5 Jun 2024 16:22:39 -0500 Message-Id: <20240605212312.349188-8-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cfnKhuf6fK2KVIF9IAq3qiTP39R9ZFOj X-Proofpoint-GUID: cfnKhuf6fK2KVIF9IAq3qiTP39R9ZFOj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=947 malwarescore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Trace out the FSI slave status and interrupt status. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 1 + include/trace/events/fsi.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index b3029f9c05e4a..93bbdcf50a89a 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -185,6 +185,7 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) dev_dbg(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n", be32_to_cpu(stat), be32_to_cpu(irq)); + trace_fsi_slave_error(slave, be32_to_cpu(irq), be32_to_cpu(stat)); /* clear interrupts */ return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC, diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index fed8835f438e5..5509afc98ee8b 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -115,6 +115,25 @@ TRACE_EVENT(fsi_master_unregister, TP_printk("fsi%d (%d links)", __entry->master_idx, __entry->n_links) ); +TRACE_EVENT(fsi_slave_error, + TP_PROTO(const struct fsi_slave *slave, uint32_t sisc, uint32_t sstat), + TP_ARGS(slave, sisc, sstat), + TP_STRUCT__entry( + __field(int, master_idx) + __field(int, link) + __field(uint32_t, sisc) + __field(uint32_t, sstat) + ), + TP_fast_assign( + __entry->master_idx = slave->master->idx; + __entry->link = slave->link; + __entry->sisc = sisc; + __entry->sstat = sstat; + ), + TP_printk("fsi%d:%02d sisc:%08x sstat:%08x", __entry->master_idx, __entry->link, + __entry->sisc, __entry->sstat) +); + TRACE_EVENT(fsi_slave_init, TP_PROTO(const struct fsi_slave *slave), TP_ARGS(slave), From patchwork Wed Jun 5 21:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687545 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 1F00715FA97; Wed, 5 Jun 2024 21:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=t82eKomG+TaUK62czPMrFpnnxwYLQEX4psrI64rb+Ld7mdLrbKItBYEr99jcUZmJQ2Fl5AsDBYqcmeXJ2OTGLSrxut6sgEuflqBAkhNqedaL4aIj/pSu1ggwqCRjZX0RV0WGzXNZbtVe0Uel50NLLkjf0rrvzJW0znkGP53OwzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=4ZjZj3THCOKVgY6viW7Cea0T7GWn/8Z7ggQPNe7qU2s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FniHr3s/Jgq3fSMxO3NV2DDLAmuuPZCJEu67qYQDs5MdaAfhQR95Bm19uLxv9nPaiUFhe0Ep/ymwUskxKOINOnVXTD2EMs4t4vIKsZSUerg6IZHBpRou3Zkk7lB8jRWLKA/MUkj6EwnfBZ+hJ7WYrBrMtGqkTLZYhsJcmlCrvRI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=CAPpPLi4; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="CAPpPLi4" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L22RL000949; Wed, 5 Jun 2024 21:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=35QhAQ7kX9QHCSy8fxK00Ig3Cr+S1lp5g6DIkdhYmNw=; b=CAPpPLi4bVRRGc//GeterL+0O98Y3jyYLFp6r0c6dCG6SdxJfZxHVW+ZemHNDydGjV/M 4j1K7LHAKhuYLktvbmxz7okeFTRSNRYiIlVULjbqGEmVaZwoOgHUzpBSDE0IU/p0WHSw O8J2dfE1+Wh53Hq1AwpiHgWBKMT16+fkwKqP9+O3qBh9bJg5i6CDJ0ajLQmdiK8iu1f0 K14upxagk3g9wEiB4k9OWFEQXQrRyCqXk65UZ57yTBiQXLv4YeZviw2TSEh370MTjCoN IfyRWvwbxZ6tALzfsC3OceELQgqpZCwi6e0LStany7AUMLmoSewZ6HmdrlYabuvKNgIS fw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxbg09vm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IX4mD008479; Wed, 5 Jun 2024 21:23:20 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNHeq26215124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:19 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC0F95805E; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9DC5158068; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 08/40] fsi: core: Reset errors instead of clearing interrupts Date: Wed, 5 Jun 2024 16:22:40 -0500 Message-Id: <20240605212312.349188-9-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4jj5RR4L9-1uNJtIYpjzprPcMIaCAcXq X-Proofpoint-ORIG-GUID: 4jj5RR4L9-1uNJtIYpjzprPcMIaCAcXq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The proper way to clear error conditions is to use the SRES register rather than simple clearing SISC. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 9 +++++---- drivers/fsi/fsi-slave.h | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 93bbdcf50a89a..ce9762d1bd8b0 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -166,7 +166,7 @@ static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp, static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) { struct fsi_master *master = slave->master; - __be32 irq, stat; + __be32 irq, reset, stat; int rc, link; uint8_t id; @@ -187,9 +187,10 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) be32_to_cpu(stat), be32_to_cpu(irq)); trace_fsi_slave_error(slave, be32_to_cpu(irq), be32_to_cpu(stat)); - /* clear interrupts */ - return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC, - &irq, sizeof(irq)); + /* reset errors */ + reset = cpu_to_be32(FSI_SRES_ERRS); + return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SRES, &reset, + sizeof(reset)); } /* Encode slave local bus echo delay */ diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index fabc0b66d5bf3..e9fd4be6f3760 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -24,6 +24,7 @@ #define FSI_SSI1M 0x1c /* S : Set slave interrupt 1 mask */ #define FSI_SCI1M 0x20 /* C : Clear slave interrupt 1 mask */ #define FSI_SLBUS 0x30 /* W : LBUS Ownership */ +#define FSI_SRES 0x34 /* W : Reset */ #define FSI_SRSIC0 0x68 /* C : Clear remote interrupt condition */ #define FSI_SRSIC4 0x6c /* C : Clear remote interrupt condition */ #define FSI_SRSIM0 0x70 /* R/W: Remote interrupt mask */ @@ -90,6 +91,11 @@ */ #define FSI_SLBUS_FORCE 0x80000000 /* Force LBUS ownership */ +/* + * SRES fields + */ +#define FSI_SRES_ERRS 0x40000000 /* Reset FSI slave errors */ + /* * LLMODE fields */ From patchwork Wed Jun 5 21:22:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687537 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 5066715FA73; Wed, 5 Jun 2024 21:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; cv=none; b=eWjwCwyUT+LUHLfWxbMgFFOsbddUZYMGHSk8CceqWrAQXQGP8+yJOdxpGWy5am7aOxPWjqXdL2uDpD4kZfZmmQICfNagrMc+NrXhUjjuMPEVjaA6upQyTUR2ZQSjUqFAl09m3Wgkeo79Brc6iI4j4HxQN0lD3e0ErnyDpBGJorM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; c=relaxed/simple; bh=etJOxAM38wpvm42idu/GhLs1AJz+49tbiRt1itlzSAA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KWZwKpgwZyz5NQetm4F01Te75VRipSLb/zWnbnbxJr7vOkBpgZs48PG5+2z7bSCzIuW/38jZD3abnMwG0gJK0diNFDzCEPh7s29HAK9AHZu0aRavgXIxhtXa5FwiQ/Uz0TbiEAylOzMFyCXhgJO389d5yrmIGd0sZDYkAK+3BXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=f+sxBKF1; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="f+sxBKF1" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LD0vZ012786; Wed, 5 Jun 2024 21:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=XynCFTEpJ9c9tpkSKwQRnpEBPBH5oxaR1GiqTnQE1Qk=; b=f+sxBKF14ZiykpJdr8KVMARIJa96s4ptA+0ASQOvFHQooAy0aZ6P+ISa8Fj1XIyVd1dE QHvKS2lbkvn2ZOOvqC71MRw715xwbtRGyifoMZoYVRgoNbEdWaTei7jxfSUj6BEDVhYq UFEshQS8MI2m3C2h1Z13oH7kyOO9F8BG/KZD55jkrgIVb4fDLrUPVHj3MAP8hC4zKNda 57GTfIrlKbMhee/VyQ3NUJNuPUOTjyrQ8tdrd2UyZsJT12Drl2xWr4eo/mPB6qPWQOiR xqmy5CXTe08owp3Z8ATkt13K6kHpih+CvSe27H1/dubxzaEplUN0g8j61vDi5+8Hqx8R wA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00re-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JUEw5031114; Wed, 5 Jun 2024 21:23:19 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:19 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNGaQ19923530 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:18 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B7B358069; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E2BCE58066; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:15 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 09/40] fsi: aspeed: Add AST2700 support Date: Wed, 5 Jun 2024 16:22:41 -0500 Message-Id: <20240605212312.349188-10-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: CMwTXUnHhq8T8B3lnqOzXQTyIJaOrBdC X-Proofpoint-ORIG-GUID: CMwTXUnHhq8T8B3lnqOzXQTyIJaOrBdC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 AST2700 requires a few bits set differently in the OPB retry counter register, so add some match data and set the register accordingly. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index f0a19cd451a07..3d15e867237df 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -18,6 +18,10 @@ #include "fsi-master.h" +struct fsi_master_aspeed_data { + u32 opb_retry_counter; +}; + struct fsi_master_aspeed { struct fsi_master master; struct mutex lock; /* protect HW access */ @@ -81,6 +85,13 @@ static const u32 fsi_base = 0xa0000000; #define XFER_HALFWORD (BIT(0)) #define XFER_BYTE (0) +/* OPB_RETRY_COUNTER */ +#define OPB_RC_FSI_OPB BIT(19) /* Access FSI space over OPB, not AHB (AST27xx+) */ +#define OPB_RC_CTRL_OPB BIT(18) /* Access controller over OPB, not AHB (AST27xx+) */ +#define OPB_RC_XFER_ACK_EN BIT(16) /* Enable OPBx xfer ack bit without mask */ +#define OPB_RC_COUNT GENMASK(15, 0) /* Number of retries */ +#define OPB_RC_DEFAULT 0x10 + #define CREATE_TRACE_POINTS #include @@ -536,6 +547,8 @@ static int tacoma_cabled_fsi_fixup(struct device *dev) static int fsi_master_aspeed_probe(struct platform_device *pdev) { + const struct fsi_master_aspeed_data *md = of_device_get_match_data(&pdev->dev); + u32 opb_retry_counter = md ? md->opb_retry_counter : OPB_RC_DEFAULT; struct fsi_master_aspeed *aspeed; int rc, links, reg; __be32 raw; @@ -579,8 +592,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN, aspeed->base + OPB_IRQ_MASK); - /* TODO: determine an appropriate value */ - writel(0x10, aspeed->base + OPB_RETRY_COUNTER); + writel(opb_retry_counter, aspeed->base + OPB_RETRY_COUNTER); writel(ctrl_base, aspeed->base + OPB_CTRL_BASE); writel(fsi_base, aspeed->base + OPB_FSI_BASE); @@ -656,8 +668,23 @@ static int fsi_master_aspeed_remove(struct platform_device *pdev) return 0; } +static const struct fsi_master_aspeed_data fsi_master_ast2600_data = { + .opb_retry_counter = OPB_RC_DEFAULT, +}; + +static const struct fsi_master_aspeed_data fsi_master_ast2700_data = { + .opb_retry_counter = OPB_RC_FSI_OPB | OPB_RC_CTRL_OPB | OPB_RC_DEFAULT, +}; + static const struct of_device_id fsi_master_aspeed_match[] = { - { .compatible = "aspeed,ast2600-fsi-master" }, + { + .compatible = "aspeed,ast2600-fsi-master", + .data = &fsi_master_ast2600_data, + }, + { + .compatible = "aspeed,ast2700-fsi-master", + .data = &fsi_master_ast2700_data, + }, { }, }; MODULE_DEVICE_TABLE(of, fsi_master_aspeed_match); From patchwork Wed Jun 5 21:22:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687533 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 3BEA11586D7; Wed, 5 Jun 2024 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622617; cv=none; b=DiK5HqZfyooA6JDu9soLOl8DOx/or1BUEjtD2Di++cUB3TvY5TitTDVI41KA85ZGa19UcEugbAWLBWRM5MD6wNObVJUHHEc6jznVDJ2ibjUBe/m7t1073WVygKJSoPV6LLtY8DY4Yd3NLueXBLvt6L/RH/LESW+AOc5ead7maBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622617; c=relaxed/simple; bh=++qxSg8ePVCHBlUfgcxd7PUReZScqf/xPWbBoudBCnE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hymLRFu3pYBiEGWFzDpF2WBnMfecgaJ3bgGJGh2vJgBWoRlqryqnsXl+BZfJDe4XrHHs9fgwlGK1/sCzqG6jsI2TsDAyX5zhBfMpcKx/t5FeUUQX5Fjcs5pCOQHrkiWaTnW+08QZH+n6zTMs7og/nXhTF4lqh4ZfbFrRcg6K1Nc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=lY3oaZv6; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lY3oaZv6" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L0OGr020141; Wed, 5 Jun 2024 21:23:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=Y98dRxrLBHldvjnywSLtVO9jA7MBr6bUSzYUwxA+r8w=; b=lY3oaZv6PK4mfWkBx4bhr+mES/YcHQQDHq8kb/sGTmkrwDhSDcmO7pgPr/fCPYtoKaf7 B4V8XYuPtTiTLLwDJ3MKh8HIQ6NjZkz5ToQzRaoV/9JB6cpPzZV9rvRQEZcdPA/dTqwI +QKw5ZBaH/eSH/FjUxT8Ef02nWIGdmd8l6AK02KYB8juRS2NTmL8Sx3VroKPaWjgP18N cYHgSob1SRvD+aMmn7EAZbbdm55P9wi/d7AQUK1zlHrPHUuxMGdoxfJ0vXK7egMRUuMT +JRugMFzwRUVpXpMLSXOPekXPUpavIMOLsgeWlPnMn+J2Cq7jgwpup+dgfeC/wggOczL EA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyhyr1mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455L18Jx026513; Wed, 5 Jun 2024 21:23:19 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366ee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:19 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNGTJ18547272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:18 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F23258055; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3239F5806A; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 10/40] fsi: core: Add slave spinlock Date: Wed, 5 Jun 2024 16:22:42 -0500 Message-Id: <20240605212312.349188-11-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: -f-zZ_WIngontr3AXPh0CWSnvzJnDmob X-Proofpoint-GUID: -f-zZ_WIngontr3AXPh0CWSnvzJnDmob X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 FSI slave operations were not locked, meaning that during slave error recovery operations, other slave accesses may take place, resulting in incorrect recovery and additional errors. Make the slave access and error recovery atomic with a spinlock. Don't use a mutex for future interrupt handling support. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 7 +++++++ drivers/fsi/fsi-slave.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index ce9762d1bd8b0..660f89b743235 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -304,6 +304,7 @@ static int fsi_slave_handle_error(struct fsi_slave *slave, bool write, int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, void *val, size_t size) { + unsigned long flags; uint8_t id = slave->id; int rc, err_rc, i; @@ -311,6 +312,7 @@ int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, if (rc) return rc; + spin_lock_irqsave(&slave->lock, flags); for (i = 0; i < slave_retries; i++) { rc = fsi_master_read(slave->master, slave->link, id, addr, val, size); @@ -321,6 +323,7 @@ int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, if (err_rc) break; } + spin_unlock_irqrestore(&slave->lock, flags); return rc; } @@ -329,6 +332,7 @@ EXPORT_SYMBOL_GPL(fsi_slave_read); int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, const void *val, size_t size) { + unsigned long flags; uint8_t id = slave->id; int rc, err_rc, i; @@ -336,6 +340,7 @@ int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, if (rc) return rc; + spin_lock_irqsave(&slave->lock, flags); for (i = 0; i < slave_retries; i++) { rc = fsi_master_write(slave->master, slave->link, id, addr, val, size); @@ -346,6 +351,7 @@ int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, if (err_rc) break; } + spin_unlock_irqrestore(&slave->lock, flags); return rc; } @@ -1007,6 +1013,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) if (!slave) return -ENOMEM; + spin_lock_init(&slave->lock); dev_set_name(&slave->dev, "slave@%02x:%02x", link, id); slave->dev.type = &cfam_type; slave->dev.parent = &master->dev; diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index e9fd4be6f3760..0468ec1c60db2 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -6,6 +6,7 @@ #include #include +#include #define FSI_SLAVE_BASE 0x800 @@ -107,6 +108,7 @@ struct fsi_slave { struct device dev; struct fsi_master *master; struct cdev cdev; + spinlock_t lock; /* atomic access and error recovery */ int cdev_idx; int id; /* FSI address */ int link; /* FSI link# */ From patchwork Wed Jun 5 21:22:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687565 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 0F2D316FF22; Wed, 5 Jun 2024 21:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=qUWESTge3Us3+Apqs7SI05lb+Y9LpuohaZSdVXLXPTkeQsJiCrOCGAxOyCwCArzrw3uPI+K+t4pM4NuOJdSJ0IpCsBJKXIlJhEMQHZZPY1R2hlyM1BpxwxB4WkIYSV/gkC/wixJkZUUt5aPKcmq4bv+WKJdUuDJ1GtEOBRK+sfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=XNrRONtL68Pz4zCpeEiE+IkzuNnZ7Cayb/AUOF/wCFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JrG7yRCAwMldLhICMlaZZ0Ojs0nSoWuuk9DQejQFJjfCSLE8a/YwFNuamDK1mn5zGQYmUZxXayhMFAnXrfl6B7YJe6mUECMQJXcD/6cAZAuQROezxqwNYjRqzDwF3nHohVgOymjKfP9RE8vchtyQSLs/XgYQboy92fFkua8bD/A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ioyAb1w0; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ioyAb1w0" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L225X000941; Wed, 5 Jun 2024 21:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=cejzBxtcEByI+xMESV4H8QqE4nNOLYSRaK7OFmvEFBE=; b=ioyAb1w0585qU6CaHMcgcicOMtHeMUvRmJDSfhWxR5cwxKvFkB4CIBxDOB+MPhaBwdMh UpnrB7rGC1utOLVe/oqGQaCVVtMPf5amf29IuAuJBfwUEmD4mTLYaq9u8kZcbh/mZBTH PFRWzgU+Jv9m4Z6Fd6KF7cB9aaoeNjq5v2WhiYaheg3pE76wGDf6r4OfBaRIeu7pdVyM nBKbDH1w3s/5nanjTR3VRNM56KLPYu3iL/Ka/OWCD4pfCGJYEc8Ory30/a+h75ICPX5F 3ycmYsW48iWjqJaROatnQDCBTzeyh+SDUrWcq1t1SCKUSh7lWD8hIkYcuqJ3hyC1Appd Ug== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxbg09vp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KMO2f022835; Wed, 5 Jun 2024 21:23:21 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygg6med3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNIfs57934222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:20 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B204A5806F; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75F925806D; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 11/40] fsi: core: Allow cfam device type aliases Date: Wed, 5 Jun 2024 16:22:43 -0500 Message-Id: <20240605212312.349188-12-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: L36lbHd8U_-4VPslOZbKWIRElqd6FP7j X-Proofpoint-ORIG-GUID: L36lbHd8U_-4VPslOZbKWIRElqd6FP7j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Other FSI devices can uses aliases for the device numbering, so modify the function to get a new minor to allow the cfam type to use aliases too. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 660f89b743235..36e31eafad3d0 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -884,12 +884,37 @@ static int fsi_adjust_index(int index) #endif } -static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, - dev_t *out_dev, int *out_index) +static const char *const fsi_dev_type_names[] = { + "cfam", + "sbefifo", + "scom", + "occ", +}; + +static int __fsi_get_new_minor(struct fsi_slave *slave, struct device_node *np, + enum fsi_dev_type type, dev_t *out_dev, int *out_index) { int cid = slave->chip_id; int id; + if (np && type < 4) { + int aid = of_alias_get_id(np, fsi_dev_type_names[type]); + + if (aid >= 0) { + /* Use the same scheme as the legacy numbers. */ + id = (aid << 2) | type; + id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); + if (id >= 0) { + *out_index = aid; + *out_dev = fsi_base_dev + id; + return 0; + } + + if (id != -ENOSPC) + return id; + } + } + /* Check if we qualify for legacy numbering */ if (cid >= 0 && cid < 16 && type < 4) { /* @@ -918,36 +943,10 @@ static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, return 0; } -static const char *const fsi_dev_type_names[] = { - "cfam", - "sbefifo", - "scom", - "occ", -}; - int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type, dev_t *out_dev, int *out_index) { - if (fdev->dev.of_node) { - int aid = of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]); - - if (aid >= 0) { - /* Use the same scheme as the legacy numbers. */ - int id = (aid << 2) | type; - - id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); - if (id >= 0) { - *out_index = aid; - *out_dev = fsi_base_dev + id; - return 0; - } - - if (id != -ENOSPC) - return id; - } - } - - return __fsi_get_new_minor(fdev->slave, type, out_dev, out_index); + return __fsi_get_new_minor(fdev->slave, fdev->dev.of_node, type, out_dev, out_index); } EXPORT_SYMBOL_GPL(fsi_get_new_minor); @@ -1059,7 +1058,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) } /* Allocate a minor in the FSI space */ - rc = __fsi_get_new_minor(slave, fsi_dev_cfam, &slave->dev.devt, + rc = __fsi_get_new_minor(slave, slave->dev.of_node, fsi_dev_cfam, &slave->dev.devt, &slave->cdev_idx); if (rc) goto err_free; From patchwork Wed Jun 5 21:22:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687548 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 6484015FCF6; Wed, 5 Jun 2024 21:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=YWBcOt4PTNmLszyqT3AY0jzyfnAa/i1kWrx77aWxNc9KMG9JXGPMlbx4uOzFfuc/cO1Sv9mJ3nhZiKuWfZto2NGaK4mLiP4JPY+YgYvgYc1d0I6i2uebWxddupY6+cstr0Mmd/eenX1vXWWko61Bq0CGo6b0h2re+2O0eq9y5lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=f8q9vx2B5SUfjiuAeR1Uuu6CMXySLm3yv7m2N9Gt5ZA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ijwVNIunZBaBOXJclXkhjca2tTZKJ3ZiqW4A1ScycENx5dnyyrvAE22f0FgmnrLaBWVj1Lt4gn4qribenCk6PHGdLH2CA2zbZM5LcJ/gzKpNzZ0BdPzngQfh3ssIWQHL23LtsA9qxFmQGjlZaNsVq/Gs7E/gL8sBL5lj2Dc+MQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=gI1XwB8p; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="gI1XwB8p" Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KuMff009067; Wed, 5 Jun 2024 21:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=7LvYEOFTpxw+bjzxPj1usx5i+DdKwa2ycgUgMyTmWhY=; b=gI1XwB8pTsYzA8fITNQyBzOEpN9Y/LmIxemqVn/J2x9pZFGtw8+qd5HdjsE8V8bYySr2 W1D7P9c0luRrTCpqDQZh3LqRGDRBv4dWRMPKVKQ1LtWrSMb6WSrT8hZgvPntpnNtVKID YMk3Bk/AclIkY20ymRb8Xg6IPxra+UrVARBqQEu8FduKPs+6/KtnWmYF0k8+S9zXsmAl OtuzemkDUD9EdqRAoyax+DlM92w5bvKdw0xI8cJg0kKoa4yoahfb0yOayUp0J7lYK+Wu /ScjJCz3s2cM7GNRn9Ux9C+msRkZ3HFAN1D8NpocmNbktotXI+hGr5SoqSSZrD/RVtjn lg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjy09g4he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JBRYR031204; Wed, 5 Jun 2024 21:23:20 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNHXt33620728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:19 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 075DC58043; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B872458070; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 12/40] fsi: core: Add common regmap master functions Date: Wed, 5 Jun 2024 16:22:44 -0500 Message-Id: <20240605212312.349188-13-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 4-s4gD5FjfYbI2LNwsCgFK1MW1cN_xGU X-Proofpoint-GUID: 4-s4gD5FjfYbI2LNwsCgFK1MW1cN_xGU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 For hardware FSI masters (Aspeed and hub at the moment), the initialization, link enable, and error recovery procedures are common. Add a regmap pointer to the master structure so that master drivers can let the common code handle these procedures. Signed-off-by: Eddie James --- Changes since v2: - Zero the regmap_config structure in the common FSI initialization function drivers/fsi/Kconfig | 2 + drivers/fsi/fsi-core.c | 162 ++++++++++++++++++++++++++++++++++++- drivers/fsi/fsi-master.h | 16 ++++ include/trace/events/fsi.h | 17 ++++ 4 files changed, 195 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 79a31593618a6..a6760870538d3 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -7,6 +7,7 @@ menuconfig FSI tristate "FSI support" depends on OF select CRC4 + select REGMAP help FSI - the FRU Support Interface - is a simple bus for low-level access to POWER-based hardware. @@ -37,6 +38,7 @@ config FSI_MASTER_GPIO config FSI_MASTER_HUB tristate "FSI hub master" + select REGMAP_FSI help This option enables a FSI hub master driver. Hub is a type of FSI master that is connected to the upstream master via a slave. Hubs diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 36e31eafad3d0..bfb147de90efc 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1155,18 +1156,50 @@ static int fsi_master_write(struct fsi_master *master, int link, return rc; } +int fsi_master_link_enable(struct fsi_master *master, int link, bool enable) +{ + u32 msiep = 0x80000000 >> (4 * (link % 8)); + u32 menp = 0x80000000 >> (link % 32); + int enable_idx = 4 * (link / 32); + int irq_idx = 4 * (link / 8); + int rc; + + if (enable) { + rc = regmap_write(master->map, FSI_MSENP0 + enable_idx, menp); + if (rc) + return rc; + + mdelay(FSI_LINK_ENABLE_SETUP_TIME); + + rc = regmap_write(master->map, FSI_MSSIEP0 + irq_idx, msiep); + } else { + rc = regmap_write(master->map, FSI_MCSIEP0 + irq_idx, msiep); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MCENP0 + enable_idx, menp); + } + + return rc; +} +EXPORT_SYMBOL_GPL(fsi_master_link_enable); + static int fsi_master_link_disable(struct fsi_master *master, int link) { if (master->link_enable) return master->link_enable(master, link, false); + else if (master->map) + return fsi_master_link_enable(master, link, false); return 0; } -static int fsi_master_link_enable(struct fsi_master *master, int link) +static int _fsi_master_link_enable(struct fsi_master *master, int link) { if (master->link_enable) return master->link_enable(master, link, true); + else if (master->map) + return fsi_master_link_enable(master, link, true); return 0; } @@ -1194,7 +1227,7 @@ static int fsi_master_scan(struct fsi_master *master) trace_fsi_master_scan(master, true); for (link = 0; link < master->n_links; link++) { - rc = fsi_master_link_enable(master, link); + rc = _fsi_master_link_enable(master, link); if (rc) { dev_dbg(&master->dev, "enable link %d failed: %d\n", link, rc); @@ -1291,6 +1324,131 @@ static struct class fsi_master_class = { .dev_groups = master_groups, }; +void fsi_master_error(struct fsi_master *master, int link) +{ + u32 bits = FSI_MMODE_EIP | FSI_MMODE_RELA; + bool mmode = master->mmode & bits; + + if (trace_fsi_master_error_regs_enabled()) { + unsigned int mesrb = 0xffffffff; + unsigned int mstap = 0xffffffff; + + regmap_read(master->map, FSI_MESRB0, &mesrb); + regmap_read(master->map, FSI_MSTAP0 + (link * 4), &mstap); + + trace_fsi_master_error_regs(master->idx, mesrb, mstap); + } + + if (mmode) + regmap_write(master->map, FSI_MMODE, master->mmode & ~bits); + + regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); + + if (mmode) + regmap_write(master->map, FSI_MMODE, master->mmode); +} +EXPORT_SYMBOL_GPL(fsi_master_error); + +static inline u32 fsi_mmode_crs0(u32 x) +{ + return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; +} + +static inline u32 fsi_mmode_crs1(u32 x) +{ + return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; +} + +int fsi_master_init(struct fsi_master *master, unsigned long parent_clock_frequency) +{ + unsigned int mlevp; + unsigned int maeb; + int div = 1; + int rc; + + if (parent_clock_frequency) { + u32 clock_frequency; + + if (device_property_read_u32(&master->dev, "clock-frequency", &clock_frequency) || + !clock_frequency) + clock_frequency = parent_clock_frequency; + + div = DIV_ROUND_UP(parent_clock_frequency, clock_frequency); + master->clock_frequency = parent_clock_frequency / div; + } + + rc = regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER | + FSI_MRESP_RST_ALL_LINK | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MECTRL, FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); + if (rc) + return rc; + + master->mmode = FSI_MMODE_ECRC | FSI_MMODE_EPC | fsi_mmode_crs0(div) | + fsi_mmode_crs1(div) | FSI_MMODE_P8_TO_LSB; + rc = regmap_write(master->map, FSI_MMODE, master->mmode); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MDLYR, 0xffff0000); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MSENP0, 0xffffffff); + if (rc) + return rc; + + mdelay(FSI_LINK_ENABLE_SETUP_TIME); + + rc = regmap_write(master->map, FSI_MCENP0, 0xffffffff); + if (rc) + return rc; + + rc = regmap_read(master->map, FSI_MAEB, &maeb); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER | + FSI_MRESP_RST_ALL_LINK); + if (rc) + return rc; + + rc = regmap_read(master->map, FSI_MLEVP0, &mlevp); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESB0, FSI_MRESB_RST_GEN); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESB0, FSI_MRESB_RST_ERR); + if (rc) + return rc; + + if (master->flags & FSI_MASTER_FLAG_INTERRUPT) + master->mmode |= FSI_MMODE_EIP; + if (master->flags & FSI_MASTER_FLAG_RELA) + master->mmode |= FSI_MMODE_RELA; + return regmap_write(master->map, FSI_MMODE, master->mmode); +} +EXPORT_SYMBOL_GPL(fsi_master_init); + +void fsi_master_regmap_config(struct regmap_config *config) +{ + memset(config, 0, sizeof(*config)); + + config->reg_bits = 32; + config->val_bits = 32; + config->disable_locking = true; // master driver will lock + config->fast_io = true; + config->cache_type = REGCACHE_NONE; + config->val_format_endian = REGMAP_ENDIAN_NATIVE; + config->can_sleep = false; +} +EXPORT_SYMBOL_GPL(fsi_master_regmap_config); + int fsi_master_register(struct fsi_master *master) { int rc; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index ff23983ea84c8..8ea2f69ec4922 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -27,6 +27,9 @@ #define FSI_MLEVP0 0x18 /* R: plug detect */ #define FSI_MSENP0 0x18 /* S: Set enable */ #define FSI_MCENP0 0x20 /* C: Clear enable */ +#define FSI_MSIEP0 0x30 /* R/W: interrupt enable */ +#define FSI_MSSIEP0 0x50 /* S: Set interrupt enable */ +#define FSI_MCSIEP0 0x70 /* C: Clear interrupt enable */ #define FSI_MAEB 0x70 /* R: Error address */ #define FSI_MVER 0x74 /* R: master version/type */ #define FSI_MSTAP0 0xd0 /* R: Port status */ @@ -108,10 +111,16 @@ /* Misc */ #define FSI_CRC_SIZE 4 +#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 #define FSI_MASTER_FLAG_NO_BREAK_SID 0x2 +#define FSI_MASTER_FLAG_INTERRUPT 0x4 +#define FSI_MASTER_FLAG_RELA 0x8 + +struct regmap; +struct regmap_config; /* * Structures and function prototypes @@ -121,6 +130,8 @@ struct fsi_master { struct device dev; + struct regmap *map; + u32 mmode; unsigned long clock_frequency; int idx; int n_links; @@ -140,6 +151,11 @@ struct fsi_master { #define to_fsi_master(d) container_of(d, struct fsi_master, dev) +void fsi_master_error(struct fsi_master *master, int link); +int fsi_master_init(struct fsi_master *master, unsigned long parent_clock_frequency); +int fsi_master_link_enable(struct fsi_master *master, int link, bool enable); +void fsi_master_regmap_config(struct regmap_config *config); + /** * fsi_master registration & lifetime: the fsi_master_register() and * fsi_master_unregister() functions will take ownership of the master, and diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index 5509afc98ee8b..da977d59e163e 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -67,6 +67,23 @@ TRACE_EVENT(fsi_master_error, &__entry->data, __entry->ret) ); +TRACE_EVENT(fsi_master_error_regs, + TP_PROTO(int master_idx, uint32_t mesrb, uint32_t mstap), + TP_ARGS(master_idx, mesrb, mstap), + TP_STRUCT__entry( + __field(int, master_idx) + __field(uint32_t, mesrb) + __field(uint32_t, mstap) + ), + TP_fast_assign( + __entry->master_idx = master_idx; + __entry->mesrb = mesrb; + __entry->mstap = mstap; + ), + TP_printk("fsi%d mesrb:%08x mstap:%08x", __entry->master_idx, __entry->mesrb, + __entry->mstap) +); + TRACE_EVENT(fsi_master_break, TP_PROTO(const struct fsi_master *master, int link), TP_ARGS(master, link), From patchwork Wed Jun 5 21:22:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687542 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 9D26A160781; Wed, 5 Jun 2024 21:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; cv=none; b=gWRSCOZF97eJdfnQAwrCaKRlqX3UlHPWk5rfOpY++vatMLWWO9UdPSlYmCc2xlPTh49qoomG6wFy48lXfJ0r5OdZ7YOlRLkXOOGR9AStiY1XpXKjTqF3L1E/+pBHFVUO1p21t/4jY0U3aw4Pwuz3EOtxBNSvX7Y8Y5CuqkjZqms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; c=relaxed/simple; bh=Kk1vf7vDZQFiMZVz0TxazBsIlWzRpEvr/ZTsMqk20vw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XiTI67HiupdFB40QkMDEKbcVci6auC4F8l1EIqzC7JCHHlJzJiK7eODR96oAfU2J/zPmrjCTBPuEhPp+kVVGjBLSHfrFZqqFNWGJsUsEu0LJtTjxhk8tzQ/a5adRsIHj6A/A9C7meXBmxwDSIoM8V+A9T2l+xuxoXAX6GbKdCaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qXx91+W4; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qXx91+W4" Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBnB6014237; Wed, 5 Jun 2024 21:23:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=EXGcZynFVVUbk26l2/hfQQpZCKfn9AC1kWN4XMBRoBg=; b=qXx91+W4/Ke0dRAquRVBMsPjy8RP6asSGCQxjt2Mk98xRpKP5IfTnVdQ+o6uncMYdaov nIebfy5qd3bI6KyDnYMRbWMXuDs6VVxQGyxJpxEgX+fn+SjRWobP03zvGYX4JrVZcOYt 13J1uiBymonSNFB/q7KoorkjPjOAp30iLPrZiSdcX0DCUF8MdNDPcrXZE8ML4evkmQkd 0HSWuP3PxzPhqk154MkaeDk6ZvLnUpJ/0cE49fdZrSK9MpDZfHVBXb9x6EYaVWcWr1zD LzYEFa/Y2MRYk+3G0uDlciuI3Xi9P17TmxDQCdGjocTcXNeL4hmKwlI1IJvmLH4N10ZP Xw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjy57r2y2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455I6vQ6000795; Wed, 5 Jun 2024 21:23:20 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wrs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:20 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNHPN61079970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:19 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49DBA58060; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DBC55805F; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 13/40] fsi: core: Disable relative addressing during scan Date: Wed, 5 Jun 2024 16:22:45 -0500 Message-Id: <20240605212312.349188-14-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 6oMHMTQCwYpeabzPdTHqOe14r_iQpm8r X-Proofpoint-ORIG-GUID: 6oMHMTQCwYpeabzPdTHqOe14r_iQpm8r X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=813 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Relative addressing is not allowed during slave ID initialization, so turn it off during the FSI scan procedure. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index bfb147de90efc..8b402149acbe9 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1223,8 +1223,20 @@ static int fsi_master_break(struct fsi_master *master, int link) static int fsi_master_scan(struct fsi_master *master) { + bool set_mmode = false; int link, rc; + /* relative addressing is not allowed during slave ID initialization */ + if (master->map && (master->flags & FSI_MASTER_FLAG_RELA)) { + u32 mmode = master->mmode & ~FSI_MMODE_RELA; + + rc = regmap_write(master->map, FSI_MMODE, mmode); + if (rc) + return rc; + + set_mmode = true; + } + trace_fsi_master_scan(master, true); for (link = 0; link < master->n_links; link++) { rc = _fsi_master_link_enable(master, link); @@ -1246,6 +1258,12 @@ static int fsi_master_scan(struct fsi_master *master) fsi_master_link_disable(master, link); } + if (set_mmode) { + rc = regmap_write(master->map, FSI_MMODE, master->mmode); + if (rc) + return rc; + } + return 0; } From patchwork Wed Jun 5 21:22:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687534 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 74E2715F3FF; Wed, 5 Jun 2024 21:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; cv=none; b=gpfvT0jBh9VhAmjequNzCvCQ9VR/WYljj5aFa4lcjVtTEE09ncIQjQwux2q0E2aLrK5mdjjQe1ldvc5KVppzg1ZFR8c8JsldUK+zfjuI1XNZ0yAjPsDHwoyDo/tis77uFOAlJkHUN7wq42MNxg/MdYEl1mQJIuieGgZzEJFaaXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622618; c=relaxed/simple; bh=SJUTkBqyyZTlwDRg7ldRmAZztx4EwiyDcC6kI4kRcwc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nGOmXlQBQ/b/0x5lZ+358MTLSkQZaclibOzQLNf0y5bl6g40/xW9Y4jYpbAG/XsQO6Bt7BvHcpmw8PY3pUeP4044qpn5WCmjDiomkdPqqDAKgSpavh5DcOtLMqVO5+J3T3wts7/PNFB6OHq5ExWO6BcIgybJHoJt/PNh2e1Bh08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=hXUhAGMK; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hXUhAGMK" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L0VDJ020583; Wed, 5 Jun 2024 21:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=IS0irjXh2U091zKbKR7d+9rVvpukYBODxtV/+wXMALY=; b=hXUhAGMKEm00byhlnN0F2jBp+2w6KChNiERs8h5fwjUP4LnFJt1wRJ+cpJbZZsAXJo6+ QFgzg/qzmlzcrTwCt2yqqsXd9D/xtWH5l9rsDSamcHlXML3VB8LyO1HG58LY8QYZeC2o hxoNGpylv9l1rwnKfujDgZghTjz0fJi71i5iSxm0u5ufNwH7g49QWs+Ls78viYQMYyrr eSknqPZWFDR+HFi3ux0znkUFriW6+DwMOzjSwtMzRZa60RSbGd8LSg7yGiUbmhPZOkCN QVoQxw2NB01NKWKzBM0K6+ewja6JcGYi7NEFR4reGzHigQQZ6c0X0EvZl42Y6iw+mLwp oQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyhyr1mn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:22 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JVcND031129; Wed, 5 Jun 2024 21:23:21 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppntg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNH6A60883398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:19 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C27F058059; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50A915806B; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 14/40] fsi: hub: Use common initialization and link enable Date: Wed, 5 Jun 2024 16:22:46 -0500 Message-Id: <20240605212312.349188-15-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: aed_HAX7kPUDtVtMm45WxMVTt_-_BYov X-Proofpoint-GUID: aed_HAX7kPUDtVtMm45WxMVTt_-_BYov X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=911 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Set up an FSI regmap for the hub master to use the new common master initialization and link enable procedures. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-hub.c | 142 ++++++----------------------------- 1 file changed, 23 insertions(+), 119 deletions(-) diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index eea8649fee74d..91ad6b7728fa2 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "fsi-master.h" @@ -16,8 +17,6 @@ #define FSI_ENGID_HUB_MASTER 0x1c -#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ - /* * FSI hub master support * @@ -78,134 +77,33 @@ static int hub_master_break(struct fsi_master *master, int link) return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd)); } -static int hub_master_link_enable(struct fsi_master *master, int link, - bool enable) -{ - struct fsi_master_hub *hub = to_fsi_master_hub(master); - int idx, bit; - __be32 reg; - int rc; - - idx = link / 32; - bit = link % 32; - - reg = cpu_to_be32(0x80000000 >> bit); - - if (!enable) - return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx), - ®, 4); - - rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), ®, 4); - if (rc) - return rc; - - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - return 0; -} - static void hub_master_release(struct device *dev) { struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev)); + regmap_exit(hub->master.map); kfree(hub); } -/* mmode encoders */ -static inline u32 fsi_mmode_crs0(u32 x) -{ - return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; -} - -static inline u32 fsi_mmode_crs1(u32 x) -{ - return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; -} - -static int hub_master_init(struct fsi_master_hub *hub) -{ - struct fsi_device *dev = hub->upstream; - __be32 reg; - int rc; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Initialize the MFSI (hub master) engine */ - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); - rc = fsi_device_write(dev, FSI_MECTRL, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MMODE_EIP | FSI_MMODE_ECRC | FSI_MMODE_EPC - | fsi_mmode_crs0(1) | fsi_mmode_crs1(1) - | FSI_MMODE_P8_TO_LSB); - rc = fsi_device_write(dev, FSI_MMODE, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(0xffff0000); - rc = fsi_device_write(dev, FSI_MDLYR, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(~0); - rc = fsi_device_write(dev, FSI_MSENP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Leave enabled long enough for master logic to set up */ - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - rc = fsi_device_write(dev, FSI_MCENP0, ®, sizeof(reg)); - if (rc) - return rc; - - rc = fsi_device_read(dev, FSI_MAEB, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - rc = fsi_device_read(dev, FSI_MLEVP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Reset the master bridge */ - reg = cpu_to_be32(FSI_MRESB_RST_GEN); - rc = fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MRESB_RST_ERR); - return fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); -} - static int hub_master_probe(struct device *dev) { + struct regmap_config hub_master_regmap_config; struct fsi_device *fsi_dev = to_fsi_dev(dev); struct fsi_master_hub *hub; + struct regmap *map; uint32_t reg, links; - __be32 __reg; int rc; - rc = fsi_device_read(fsi_dev, FSI_MVER, &__reg, sizeof(__reg)); + fsi_master_regmap_config(&hub_master_regmap_config); + hub_master_regmap_config.reg_base = fsi_dev->addr; + map = regmap_init_fsi(fsi_dev, &hub_master_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + + rc = regmap_read(map, FSI_MVER, ®); if (rc) - return rc; + goto err_regmap; - reg = be32_to_cpu(__reg); links = (reg >> 8) & 0xff; dev_dbg(dev, "hub version %08x (%d links)\n", reg, links); @@ -213,7 +111,7 @@ static int hub_master_probe(struct device *dev) FSI_HUB_LINK_SIZE * links); if (rc) { dev_err(dev, "can't claim slave address range for links"); - return rc; + goto err_regmap; } hub = kzalloc(sizeof(*hub), GFP_KERNEL); @@ -229,22 +127,24 @@ static int hub_master_probe(struct device *dev) hub->master.dev.parent = dev; hub->master.dev.release = hub_master_release; hub->master.dev.of_node = of_node_get(dev_of_node(dev)); + hub->master.map = map; hub->master.idx = fsi_dev->slave->link + 1; hub->master.n_links = links; - hub->master.flags = FSI_MASTER_FLAG_NO_BREAK_SID; + hub->master.flags = FSI_MASTER_FLAG_NO_BREAK_SID | FSI_MASTER_FLAG_INTERRUPT; hub->master.read = hub_master_read; hub->master.write = hub_master_write; hub->master.send_break = hub_master_break; - hub->master.link_enable = hub_master_link_enable; dev_set_drvdata(dev, hub); - hub_master_init(hub); + rc = fsi_master_init(&hub->master, fsi_dev->slave->master->clock_frequency); + if (rc) + goto err_free; rc = fsi_master_register(&hub->master); if (rc) - goto err_release; + goto err_free; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -256,9 +156,13 @@ static int hub_master_probe(struct device *dev) get_device(&hub->master.dev); return 0; +err_free: + kfree(hub); err_release: fsi_slave_release_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, FSI_HUB_LINK_SIZE * links); +err_regmap: + regmap_exit(map); return rc; } From patchwork Wed Jun 5 21:22:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687552 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 93A88163A80; Wed, 5 Jun 2024 21:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; cv=none; b=gUNIc3eMHabF4hk44Cz5FJ7Ol4yO4lquAcTHRliK3FJOeQnN6kJXxoHMVN/GumctnZBa5P2dX3ckLJHHAlIdrNt4BdlfrMR/0Ewc/R4WCvq5NW9wKDwo236kXXcwqkhid0r/kIjSnjTIG5R4GYIKierDkOSwHnsGJLQ2mliQa3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; c=relaxed/simple; bh=AhnSzDLDOWLJZ6wOtscN8EKiHKe2AkmW1DojbzM9uJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lcER1j61whJSYOMnQa2kMG2v4fS0iiORnMY+W28IQvHrW/Uzl2mRPbigw2FynqVkv9s8371J9JBhiWnd8diZpQ++IKglNqbMw2pp7SfOorjjv1cUnM9kMDFjJeyjhAebz359eAVBRMECjjtku6v6z0/Ld4zuAH/B+d3Uzzz0q1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Btpihl/N; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Btpihl/N" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LD6W4013583; Wed, 5 Jun 2024 21:23:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=i2C43nvKw0UyLSXoCA7myzkhI4FP4JjR32/Jp3Q/4S8=; b=Btpihl/NvYPKRC/Sx9j0ltMMv+2LkMaXHW2CNOX+DGSpiuwX8AvVg5UD+ywKjNenXw6g 8Ajagcol0ZGROx92fD7SB1RiTEIk9tD0OKyGGeMly7g6P7uerStxbwevCfYwEEpCpZ6n kR1yxXOEl3KnYZyQiJonM9b+BZgJZEhG7Bwitaf+6vR9t4qd9xLcoaQq1inUaKRJiJx3 ClfaVNe653M90IlXOw1omxsU1ahyDPzHaKkiad5QFw8bKSG08VGSEdvQ9UzqVnbHn26/ vVjss1aZWxSKIHxPM/SSO5LENkboy5QwWPIpugYNcv1Lk1MbfvJjoPnqzfPM8Acervv3 GA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00rk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:22 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JVcNE031129; Wed, 5 Jun 2024 21:23:21 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppntm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNIv725101028 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:20 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 194B258061; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C90C35805F; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:17 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 15/40] fsi: aspeed: Use common initialization and link enable Date: Wed, 5 Jun 2024 16:22:47 -0500 Message-Id: <20240605212312.349188-16-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0ICrE9JqL5knykLLl9bEzW0UNobcK2Vk X-Proofpoint-ORIG-GUID: 0ICrE9JqL5knykLLl9bEzW0UNobcK2Vk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=999 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Create a regmap for accessing the master registers over OPB to use the new common master initialization and link enable procedures. Signed-off-by: Eddie James --- Changes since v2: - Add AST2700 direct AHB access of master registers drivers/fsi/fsi-master-aspeed.c | 173 +++++++++++++------------------- 1 file changed, 68 insertions(+), 105 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 3d15e867237df..a67f185bb8814 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -27,6 +27,7 @@ struct fsi_master_aspeed { struct mutex lock; /* protect HW access */ struct device *dev; void __iomem *base; + void __iomem *ctrl; struct clk *clk; struct gpio_desc *cfam_reset_gpio; }; @@ -95,14 +96,6 @@ static const u32 fsi_base = 0xa0000000; #define CREATE_TRACE_POINTS #include -#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ - -/* Run the bus at maximum speed by default */ -#define FSI_DIVISOR_DEFAULT 1 -#define FSI_DIVISOR_CABLED 2 -static u16 aspeed_fsi_divisor = FSI_DIVISOR_DEFAULT; -module_param_named(bus_div,aspeed_fsi_divisor, ushort, 0); - #define OPB_POLL_TIMEOUT 500 static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr, @@ -333,35 +326,6 @@ static int aspeed_master_write(struct fsi_master *master, int link, return ret; } -static int aspeed_master_link_enable(struct fsi_master *master, int link, - bool enable) -{ - struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); - int idx, bit, ret; - __be32 reg; - - idx = link / 32; - bit = link % 32; - - reg = cpu_to_be32(0x80000000 >> bit); - - mutex_lock(&aspeed->lock); - - if (!enable) { - ret = opb_writel(aspeed, ctrl_base + FSI_MCENP0 + (4 * idx), reg); - goto done; - } - - ret = opb_writel(aspeed, ctrl_base + FSI_MSENP0 + (4 * idx), reg); - if (ret) - goto done; - - mdelay(FSI_LINK_ENABLE_SETUP_TIME); -done: - mutex_unlock(&aspeed->lock); - return ret; -} - static int aspeed_master_term(struct fsi_master *master, int link, uint8_t id) { uint32_t addr; @@ -389,72 +353,54 @@ static void aspeed_master_release(struct device *dev) struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(to_fsi_master(dev)); + regmap_exit(aspeed->master.map); kfree(aspeed); } -/* mmode encoders */ -static inline u32 fsi_mmode_crs0(u32 x) +static int regmap_aspeed_opb_read(void *context, unsigned int reg, unsigned int *val) { - return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; -} + __be32 v; + int ret; -static inline u32 fsi_mmode_crs1(u32 x) -{ - return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; + ret = opb_readl(context, ctrl_base + reg, &v); + if (ret) + return ret; + + *val = be32_to_cpu(v); + return 0; } -static int aspeed_master_init(struct fsi_master_aspeed *aspeed) +static int regmap_aspeed_opb_write(void *context, unsigned int reg, unsigned int val) { - __be32 reg; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); - - /* Initialize the MFSI (hub master) engine */ - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); - - reg = cpu_to_be32(FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); - opb_writel(aspeed, ctrl_base + FSI_MECTRL, reg); - - reg = cpu_to_be32(FSI_MMODE_ECRC | FSI_MMODE_EPC | FSI_MMODE_RELA - | fsi_mmode_crs0(aspeed_fsi_divisor) - | fsi_mmode_crs1(aspeed_fsi_divisor) - | FSI_MMODE_P8_TO_LSB); - dev_info(aspeed->dev, "mmode set to %08x (divisor %d)\n", - be32_to_cpu(reg), aspeed_fsi_divisor); - opb_writel(aspeed, ctrl_base + FSI_MMODE, reg); - - reg = cpu_to_be32(0xffff0000); - opb_writel(aspeed, ctrl_base + FSI_MDLYR, reg); - - reg = cpu_to_be32(~0); - opb_writel(aspeed, ctrl_base + FSI_MSENP0, reg); - - /* Leave enabled long enough for master logic to set up */ - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - opb_writel(aspeed, ctrl_base + FSI_MCENP0, reg); - - opb_readl(aspeed, ctrl_base + FSI_MAEB, NULL); + return opb_writel(context, ctrl_base + reg, cpu_to_be32(val)); +} - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); +static const struct regmap_bus regmap_aspeed_opb = { + .reg_write = regmap_aspeed_opb_write, + .reg_read = regmap_aspeed_opb_read, +}; - opb_readl(aspeed, ctrl_base + FSI_MLEVP0, NULL); +static int regmap_ast2700_read(void *context, unsigned int reg, unsigned int *val) +{ + struct fsi_master_aspeed *aspeed = context; - /* Reset the master bridge */ - reg = cpu_to_be32(FSI_MRESB_RST_GEN); - opb_writel(aspeed, ctrl_base + FSI_MRESB0, reg); + *val = readl(aspeed->ctrl + reg); + return 0; +} - reg = cpu_to_be32(FSI_MRESB_RST_ERR); - opb_writel(aspeed, ctrl_base + FSI_MRESB0, reg); +static int regmap_ast2700_write(void *context, unsigned int reg, unsigned int val) +{ + struct fsi_master_aspeed *aspeed = context; + writel(val, aspeed->ctrl + reg); return 0; } +static const struct regmap_bus regmap_ast2700 = { + .reg_write = regmap_ast2700_write, + .reg_read = regmap_ast2700_read, +}; + static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -466,7 +412,7 @@ static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *att usleep_range(900, 1000); gpiod_set_value(aspeed->cfam_reset_gpio, 0); usleep_range(900, 1000); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); + regmap_write(aspeed->master.map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); mutex_unlock(&aspeed->lock); trace_fsi_master_aspeed_cfam_reset(false); @@ -526,14 +472,6 @@ static int tacoma_cabled_fsi_fixup(struct device *dev) /* If the routing GPIO is high we should set the mux to low. */ if (gpio) { - /* - * Cable signal integrity means we should run the bus - * slightly slower. Do not override if a kernel param - * has already overridden. - */ - if (aspeed_fsi_divisor == FSI_DIVISOR_DEFAULT) - aspeed_fsi_divisor = FSI_DIVISOR_CABLED; - gpiod_direction_output(mux_gpio, 0); dev_info(dev, "FSI configured for external cable\n"); } else { @@ -549,9 +487,13 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) { const struct fsi_master_aspeed_data *md = of_device_get_match_data(&pdev->dev); u32 opb_retry_counter = md ? md->opb_retry_counter : OPB_RC_DEFAULT; + const struct regmap_bus *bus = ®map_aspeed_opb; + struct regmap_config aspeed_master_regmap_config; struct fsi_master_aspeed *aspeed; - int rc, links, reg; - __be32 raw; + u32 opb_ctrl_base = ctrl_base; + struct resource *res; + unsigned int reg; + int rc, links; rc = tacoma_cabled_fsi_fixup(&pdev->dev); if (rc) { @@ -571,6 +513,17 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) goto err_free_aspeed; } + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ctrl"); + if (res) { + aspeed->ctrl = devm_ioremap_resource(&pdev->dev, res); + if (!IS_ERR(aspeed->ctrl)) { + /* Access FSI controller over AHB */ + opb_ctrl_base = res->start; + opb_retry_counter &= ~OPB_RC_CTRL_OPB; + bus = ®map_ast2700; + } + } + aspeed->clk = devm_clk_get(aspeed->dev, NULL); if (IS_ERR(aspeed->clk)) { dev_err(aspeed->dev, "couldn't get clock\n"); @@ -594,7 +547,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) writel(opb_retry_counter, aspeed->base + OPB_RETRY_COUNTER); - writel(ctrl_base, aspeed->base + OPB_CTRL_BASE); + writel(opb_ctrl_base, aspeed->base + OPB_CTRL_BASE); writel(fsi_base, aspeed->base + OPB_FSI_BASE); /* Set read data order */ @@ -611,13 +564,19 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) */ writel(0x1, aspeed->base + OPB0_SELECT); - rc = opb_readl(aspeed, ctrl_base + FSI_MVER, &raw); + fsi_master_regmap_config(&aspeed_master_regmap_config); + aspeed->master.map = regmap_init(&pdev->dev, bus, aspeed, &aspeed_master_regmap_config); + if (IS_ERR(aspeed->master.map)) { + rc = PTR_ERR(aspeed->master.map); + goto err_release; + } + + rc = regmap_read(aspeed->master.map, FSI_MVER, ®); if (rc) { dev_err(&pdev->dev, "failed to read hub version\n"); - goto err_release; + goto err_regmap; } - reg = be32_to_cpu(raw); links = (reg >> 8) & 0xff; dev_info(&pdev->dev, "hub version %08x (%d links)\n", reg, links); @@ -626,20 +585,22 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) aspeed->master.dev.of_node = of_node_get(dev_of_node(&pdev->dev)); aspeed->master.n_links = links; + aspeed->master.flags = FSI_MASTER_FLAG_RELA; aspeed->master.read = aspeed_master_read; aspeed->master.write = aspeed_master_write; aspeed->master.send_break = aspeed_master_break; aspeed->master.term = aspeed_master_term; - aspeed->master.link_enable = aspeed_master_link_enable; dev_set_drvdata(&pdev->dev, aspeed); mutex_init(&aspeed->lock); - aspeed_master_init(aspeed); + rc = fsi_master_init(&aspeed->master, clk_get_rate(aspeed->clk)); + if (rc) + goto err_regmap; rc = fsi_master_register(&aspeed->master); if (rc) - goto err_release; + goto err_regmap; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -651,6 +612,8 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) get_device(&aspeed->master.dev); return 0; +err_regmap: + regmap_exit(aspeed->master.map); err_release: clk_disable_unprepare(aspeed->clk); err_free_aspeed: From patchwork Wed Jun 5 21:22:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687540 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 22B1115FA9D; Wed, 5 Jun 2024 21:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622619; cv=none; b=tKRX05HtX9tY+HDo/OJVsCEY/2mHcLiQCsYLclvZ0AYARn+OiQ7gDKNMYhaWaDnEc8KhFM3GTazeNIXz8Af3Or5tIVBsaXQmGIip4MHdrRzIQQucI8yTuFgVnAS6hs5+1z1qfUKJOUsXh5QXhRTx9JUwu1WYjyh0zNIFIcGaCKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622619; c=relaxed/simple; bh=Swf2Z4ryMSe76Fjjb/WLkycWDTYlW+M1urBDzu+MZ0c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kQwlfySYE9paujfV9JEDNhImd+ACN80H+TVv2/jP30P0QZgCnNyGoWIZRbg8wgPlSUMIFdhJJwUU8JS/KWBNaR1JIj+SHFHa5yiBUWYmQleKFXQSV1xcz9o+FY2kOjeQpQ6OhcJON3wQyXbWnhAzdnrmUiqKX4DP3ZZXVbyYclg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=PW3C6R6z; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="PW3C6R6z" Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KGrYe025968; Wed, 5 Jun 2024 21:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=oRnjoXt2wGckRRsoBzamYSAQD+OnLvBQnzT8NTydriU=; b=PW3C6R6zgrYjyuDqRF22k/Rtf7i1l8x9FrRr8eivRVv8yeYP6+TaiIYxhqYW8J0fgvv9 zKxffSOp3JGCiZnpNRXeO6dIQ8ISVaBJvFIAmtulYOz8ZHFD/hM8BSNL5AZc4mbIxIS4 956x+IW3Y0jLFJRk2sPIM2oa4OKde3kCiyM3azpm0z6Mqnu6IY6c8S2AJ5D/Q/7nmze0 VE323Bybb7ALCOVLJPhVdvyJsFcwKjK5fP6rX+p6JKyBSr6mXg8TFjmvl6fVtdvkI6aV 1VyEhgkIcJfw54vCYACX+nRYL7jw6dwyWrdGirGKcC82/hGJ6DD8MAvppQDchvDX7T1w gQ== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxbg09vr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:22 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IHPPd008474; Wed, 5 Jun 2024 21:23:21 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNIO631719802 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:20 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67AAD58068; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 205A95806B; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 16/40] fsi: aspeed: Remove cfam reset sysfs file in error path and remove Date: Wed, 5 Jun 2024 16:22:48 -0500 Message-Id: <20240605212312.349188-17-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fNwpJIwHES13TfJJgCozSElpqmyvA-E1 X-Proofpoint-ORIG-GUID: fNwpJIwHES13TfJJgCozSElpqmyvA-E1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=930 mlxscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 This fixes a duplicate sysfs warning on device re-probe. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index a67f185bb8814..29932037c9866 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -437,6 +437,7 @@ static int setup_cfam_reset(struct fsi_master_aspeed *aspeed) rc = device_create_file(dev, &dev_attr_cfam_reset); if (rc) { + aspeed->cfam_reset_gpio = NULL; devm_gpiod_put(dev, gpio); return rc; } @@ -615,6 +616,9 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) err_regmap: regmap_exit(aspeed->master.map); err_release: + if (aspeed->cfam_reset_gpio) + device_remove_file(aspeed->dev, &dev_attr_cfam_reset); + clk_disable_unprepare(aspeed->clk); err_free_aspeed: kfree(aspeed); @@ -625,6 +629,9 @@ static int fsi_master_aspeed_remove(struct platform_device *pdev) { struct fsi_master_aspeed *aspeed = platform_get_drvdata(pdev); + if (aspeed->cfam_reset_gpio) + device_remove_file(aspeed->dev, &dev_attr_cfam_reset); + fsi_master_unregister(&aspeed->master); clk_disable_unprepare(aspeed->clk); From patchwork Wed Jun 5 21:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687561 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 89B6116ABC8; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; cv=none; b=C1siP1bV2jj5uEzhSBHqTUFbeyJe6vdSFGa9+Tw3SY83WGy/0jxwRAZryN7tdg4xSBQH/mrdiB3YdV27lXYaOmU8K4wx7imNbtBi5QLWHTrUyE+RsFhRJ6jtVbS7w7OPo6WATNmauqYYbBMOBYiWE1K7gGKlVJT4XFQhc2hxotE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; c=relaxed/simple; bh=wl7RxaZ446EFTr7U3MZ8YZvx9qI3UF/DnMsNBZ+TxEg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BE+GrJjmSCR8xgxzywQswqElXUTGlgq79vlmquaApStok490D/Ytnu9choSgWsoFY/ycxsb2Ll/X9hsMSz+WaZGLnupdwEQV22lbJidqXocQT7t1CuatKNX2kIO3vB3xpjCy8USmZELTrjUgopAHtXjOAChhoy1cPaarL+kwQA0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Dv/RDUZ8; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Dv/RDUZ8" Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBvuo014371; Wed, 5 Jun 2024 21:23:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=ZO87ym+vrHlW5NSObf7CjE5XoUUtGZQpDoF/ti0pRyg=; b=Dv/RDUZ8nP1GfKSkC10tP5LUh9CEhVsBR9gJVa2i7HsrqT+C5mgEGrMRkmYxlljI4sHX cAJP1E17McM/KrF9vlM18b5iROcRziO+lLzzmhugYEFDK2ziUDnzTjesCZDQrGaVhQj5 yQ+T2p/5KW10eB+FhvCE6PhJSkB6ZWWX87nMAKI2XSo/vBLwxbQ4xjsASBBiHIJM/Gkl EbGlEtZ1ZzJJ11d69uV4RmsYXJ+EzdMCSYll2yXta70it5HOCSZXusIc9vqGvdaYr7gP fIEG9X2D3+Nl/QCOW/wFX0RtrAMcmPT/VLJP64n17n8cLXf3lGE1pwT99xfVwd2ZhC24 XA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjy57r2y7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JBRYS031204; Wed, 5 Jun 2024 21:23:23 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNK9J44499268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:22 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAF1D58055; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E26358069; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 17/40] fsi: aspeed: Refactor trace functions Date: Wed, 5 Jun 2024 16:22:49 -0500 Message-Id: <20240605212312.349188-18-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: A-oZrEuoCSwLyCqB8ft9uiakyCYSYlj6 X-Proofpoint-ORIG-GUID: A-oZrEuoCSwLyCqB8ft9uiakyCYSYlj6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=888 impostorscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Remove the opb error trace, add a timeout trace, and combine the read/write traces. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 29 +++------ include/trace/events/fsi_master_aspeed.h | 80 ++++++++---------------- 2 files changed, 34 insertions(+), 75 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 29932037c9866..04aa5cb9b6fad 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -122,16 +122,17 @@ static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr, status = readl(base + OPB0_STATUS); - trace_fsi_master_aspeed_opb_write(addr, val, transfer_size, status, reg); - /* Return error when poll timed out */ - if (ret) + if (ret) { + trace_fsi_master_aspeed_timeout(reg, status, false); return ret; + } /* Command failed, master will reset */ if (status & STATUS_ERR_ACK) return -EIO; + trace_fsi_master_aspeed_opb_xfer(addr, transfer_size + 1, val, false); return 0; } @@ -175,13 +176,11 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, result = readl(base + OPB0_FSI_DATA_R); - trace_fsi_master_aspeed_opb_read(addr, transfer_size, result, - readl(base + OPB0_STATUS), - reg); - /* Return error when poll timed out */ - if (ret) + if (ret) { + trace_fsi_master_aspeed_timeout(reg, status, true); return ret; + } /* Command failed, master will reset */ if (status & STATUS_ERR_ACK) @@ -204,6 +203,7 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, } + trace_fsi_master_aspeed_opb_xfer(addr, transfer_size + 1, result, true); return 0; } @@ -226,19 +226,6 @@ static int check_errors(struct fsi_master_aspeed *aspeed, int err) { int ret; - if (trace_fsi_master_aspeed_opb_error_enabled()) { - __be32 mresp0, mstap0, mesrb0; - - opb_readl(aspeed, ctrl_base + FSI_MRESP0, &mresp0); - opb_readl(aspeed, ctrl_base + FSI_MSTAP0, &mstap0); - opb_readl(aspeed, ctrl_base + FSI_MESRB0, &mesrb0); - - trace_fsi_master_aspeed_opb_error( - be32_to_cpu(mresp0), - be32_to_cpu(mstap0), - be32_to_cpu(mesrb0)); - } - if (err == -EIO) { /* Check MAEB (0x70) ? */ diff --git a/include/trace/events/fsi_master_aspeed.h b/include/trace/events/fsi_master_aspeed.h index 0fff873775f19..7eeecbfec7f09 100644 --- a/include/trace/events/fsi_master_aspeed.h +++ b/include/trace/events/fsi_master_aspeed.h @@ -8,69 +8,41 @@ #include -TRACE_EVENT(fsi_master_aspeed_opb_read, - TP_PROTO(uint32_t addr, size_t size, uint32_t result, uint32_t status, uint32_t irq_status), - TP_ARGS(addr, size, result, status, irq_status), +TRACE_EVENT(fsi_master_aspeed_opb_xfer, + TP_PROTO(uint32_t addr, uint32_t size, uint32_t data, bool read), + TP_ARGS(addr, size, data, read), TP_STRUCT__entry( - __field(uint32_t, addr) - __field(size_t, size) - __field(uint32_t, result) - __field(uint32_t, status) - __field(uint32_t, irq_status) - ), + __field(uint32_t, addr) + __field(uint32_t, size) + __field(uint32_t, data) + __field(bool, read) + ), TP_fast_assign( __entry->addr = addr; __entry->size = size; - __entry->result = result; - __entry->status = status; - __entry->irq_status = irq_status; - ), - TP_printk("addr %08x size %zu: result %08x sts: %08x irq_sts: %08x", - __entry->addr, __entry->size, __entry->result, - __entry->status, __entry->irq_status - ) + __entry->data = data; + __entry->read = read; + ), + TP_printk("%s addr %08x size %u data %08x", __entry->read ? "read" : "write", + __entry->addr, __entry->size, __entry->data) ); -TRACE_EVENT(fsi_master_aspeed_opb_write, - TP_PROTO(uint32_t addr, uint32_t val, size_t size, uint32_t status, uint32_t irq_status), - TP_ARGS(addr, val, size, status, irq_status), +TRACE_EVENT(fsi_master_aspeed_timeout, + TP_PROTO(uint32_t irq, uint32_t status, bool read), + TP_ARGS(irq, status, read), TP_STRUCT__entry( - __field(uint32_t, addr) - __field(uint32_t, val) - __field(size_t, size) - __field(uint32_t, status) - __field(uint32_t, irq_status) - ), + __field(uint32_t, irq) + __field(uint32_t, status) + __field(bool, read) + ), TP_fast_assign( - __entry->addr = addr; - __entry->val = val; - __entry->size = size; + __entry->irq = irq; __entry->status = status; - __entry->irq_status = irq_status; - ), - TP_printk("addr %08x val %08x size %zu status: %08x irq_sts: %08x", - __entry->addr, __entry->val, __entry->size, - __entry->status, __entry->irq_status - ) - ); - -TRACE_EVENT(fsi_master_aspeed_opb_error, - TP_PROTO(uint32_t mresp0, uint32_t mstap0, uint32_t mesrb0), - TP_ARGS(mresp0, mstap0, mesrb0), - TP_STRUCT__entry( - __field(uint32_t, mresp0) - __field(uint32_t, mstap0) - __field(uint32_t, mesrb0) - ), - TP_fast_assign( - __entry->mresp0 = mresp0; - __entry->mstap0 = mstap0; - __entry->mesrb0 = mesrb0; - ), - TP_printk("mresp0 %08x mstap0 %08x mesrb0 %08x", - __entry->mresp0, __entry->mstap0, __entry->mesrb0 - ) - ); + __entry->read = read; + ), + TP_printk("%s irq %08x status %08x", __entry->read ? "read" : "write", __entry->irq, + __entry->status) +); TRACE_EVENT(fsi_master_aspeed_cfam_reset, TP_PROTO(bool start), From patchwork Wed Jun 5 21:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687544 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 468EB1607BC; Wed, 5 Jun 2024 21:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=ICiMWuuZgTcdhadqM52wr3q27NcjKUE7BQJRfGUt21yhL+M0epfIUJ4AMBTtYhTAH8YvMAL3vvbWhMwcVd0vSYXnx7d8WW+4FuzetcQgeUvlAFLyVHzaE7US6qjYU8NElZoqyH6DZLTWG8r+D72eSkJihwurrmwEzR0YRvammhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=3CmP8SDqXBiFId98haK+7Undt4Hf31Bd450GNQU9UOg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=peRvBwHsGz/fLYceEACda5bOdPMNzbUS4K8OzKurJBKkWDxtghGW4JAL7h3PhqAzN7vMM6FaHAlr2mFeQawZXBgzKGcqZ2pk8kLD4RdV9dmnUwPinL91Fp5NegtKbJvueYRMnzrkcLM10j5Ult4JVs3jKzlah/W46zo4pS2hALQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=hGDMIDpS; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hGDMIDpS" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L0dbZ020650; Wed, 5 Jun 2024 21:23:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=dqdJlR5MaTztZMJgWYsXAeJqjv1L5VBfiwva68G3Zto=; b=hGDMIDpS0M7aoWUNZgqpIHhh5x/XsCAyhUXPhjmsgVncnwGmPz4xybC5RkwVbQRR3QP9 kiFkMhWYFXpoh7pibMsIACyLTc6Szn3QisF9aWN+6URVsEOCIa1ODVsHpFuIYaODHttN 3IRwKZqRgSQbt3yUee40Vq7UlGKqLw9EB9eQc4U51lp9rM8bfQWl+WgfMg1wqlPiz1vG dho3aTgjQCd2jMA7UkWj4bGiSO8X70GJH4KX3Z9rjFTUViqeOomZ1DE56ANMEmIyf7ie XUzZtKyiD7Lw0/4/4GLWulVBjUlhEJsaHXWogJ6JEy4fQ6Xrc0CIfpvK4/cgVnJWOXd4 qA== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyhyr1mr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IRgLm000829; Wed, 5 Jun 2024 21:23:22 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wsc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:22 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNJew40042804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:21 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED52A58066; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1DA358063; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 18/40] fsi: aspeed: Don't clear all IRQs during OPB transfers Date: Wed, 5 Jun 2024 16:22:50 -0500 Message-Id: <20240605212312.349188-19-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: UiNXHZseH_KlB6lbNa7IxWdp0FQw7QVl X-Proofpoint-GUID: UiNXHZseH_KlB6lbNa7IxWdp0FQw7QVl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 In order to support FSI interrupts, the OPB transfer functions should not clear all the IRQs pending. Instead, just write the OPB ACK bit to the IRQ status register. As commented, this register invisibly masks the interrupt once the interrupt condition is cleared. Fix this by writing 0 before each OPB transfer. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 04aa5cb9b6fad..f840c7c4a56b9 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -47,6 +47,11 @@ static const u32 fsi_base = 0xa0000000; #define OPB_CLK_SYNC 0x3c #define OPB_IRQ_CLEAR 0x40 #define OPB_IRQ_MASK 0x44 +/* + * This register does NOT behave in the expected manner. It is expected that writing 1b would clear + * the corresponding interrupt condition. However it also invisibly masks the interrupt! Writing 0b + * unmasks again. + */ #define OPB_IRQ_STATUS 0x48 #define OPB0_SELECT 0x10 @@ -113,13 +118,14 @@ static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr, writel_relaxed(transfer_size, base + OPB0_XFER_SIZE); writel_relaxed(addr, base + OPB0_FSI_ADDR); writel_relaxed(val, base + OPB0_FSI_DATA_W); - writel_relaxed(0x1, base + OPB_IRQ_CLEAR); + writel_relaxed(0, base + OPB_IRQ_STATUS); writel(0x1, base + OPB_TRIGGER); ret = readl_poll_timeout(base + OPB_IRQ_STATUS, reg, (reg & OPB0_XFER_ACK_EN) != 0, 0, OPB_POLL_TIMEOUT); + writel(OPB0_XFER_ACK_EN, base + OPB_IRQ_STATUS); status = readl(base + OPB0_STATUS); /* Return error when poll timed out */ @@ -165,13 +171,14 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, writel_relaxed(CMD_READ, base + OPB0_RW); writel_relaxed(transfer_size, base + OPB0_XFER_SIZE); writel_relaxed(addr, base + OPB0_FSI_ADDR); - writel_relaxed(0x1, base + OPB_IRQ_CLEAR); + writel_relaxed(0, aspeed->base + OPB_IRQ_STATUS); writel(0x1, base + OPB_TRIGGER); ret = readl_poll_timeout(base + OPB_IRQ_STATUS, reg, (reg & OPB0_XFER_ACK_EN) != 0, 0, OPB_POLL_TIMEOUT); + writel(OPB0_XFER_ACK_EN, base + OPB_IRQ_STATUS); status = readl(base + OPB0_STATUS); result = readl(base + OPB0_FSI_DATA_R); @@ -530,8 +537,6 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) } writel(0x1, aspeed->base + OPB_CLK_SYNC); - writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN, - aspeed->base + OPB_IRQ_MASK); writel(opb_retry_counter, aspeed->base + OPB_RETRY_COUNTER); From patchwork Wed Jun 5 21:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687543 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 0D8511607B2; Wed, 5 Jun 2024 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; cv=none; b=EIfsJ7/TPfa5dvztydHxJb22mreBDokcpC4q+caUCrqymh1N7amrArZ6+1av4CoPhK5zMQwLftqAS/LRWWW//X8TN3Dp4qiVUJuzNjZpXnyeGbhXvMZAwUyfojpXfgXH9+HSRHKhPduS/elSqk6FqMVizCCWM1EcY5XgqwCK7Lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622620; c=relaxed/simple; bh=gcQ2zkmKa+fmA+wA1USWs3UuxyNB+5m2pTe6OU5K/+s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XKxJIIdgtiPPp4lI2NAIoqq4wPFLySAtaQ1C0k98pYirAgFOG2OfsVyz2anNi8T5hnbshWBaOZElbNstAbjBrQv5HgVtC3kICuJvgPzGNx7fWAAvikaTN+dN87qwVT5T1QOWKhhDug5JAcriKPlD7pFO5Qx8UVDHdQ5evJpCxKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=oUef40pX; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oUef40pX" Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KuLSu008989; Wed, 5 Jun 2024 21:23:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=4QzZpzonx2C/GWGQRLgt495aUpGk9FXO31kMVCNBj/A=; b=oUef40pXu2VwbN+gnGv2CX56jn8pFY2xm7G+c8AYpNC0tN1y+hvhkaUQhnHRfBMoHdnt yJ0C+DJfY7bprR+k+LNI0uAAZ18fHhN69kX3Pl3yDGFasYh2xWyZzWTqnh4hH7zSVI7C 0xDEGXGhLSVbp2Hqdm31mblNWE9md8O+mGvakg9LAmJw1l0ZJLHmwxsK6VK4YjZ9oCSG N1pwz4mC3GiUfQfzuwBUtQOqMyFNKQQe/cozNcoFLLVsdHzwKm4h7bMztxMqmEn3JNn+ qRV13Ed8wQNXjY0gJpk5LLSl+6H7RmupKlpjWogMOdQ/8lw2jEYMj37nLKNGWna/M2MB 8w== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjy09g4hn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IKamw000800; Wed, 5 Jun 2024 21:23:23 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNJ3X35914296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:21 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BD6F58043; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3CFE58069; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:18 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 19/40] fsi: aspeed: Only read result register for successful read Date: Wed, 5 Jun 2024 16:22:51 -0500 Message-Id: <20240605212312.349188-20-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: WyZUdmPUEFb-KTk3rBj0-JV6II_TORz0 X-Proofpoint-GUID: WyZUdmPUEFb-KTk3rBj0-JV6II_TORz0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 No reason to read the result in the error path, and remove the null pointer check on the output, as it should never be null. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index f840c7c4a56b9..10ca23cf58c2e 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -181,8 +181,6 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, writel(OPB0_XFER_ACK_EN, base + OPB_IRQ_STATUS); status = readl(base + OPB0_STATUS); - result = readl(base + OPB0_FSI_DATA_R); - /* Return error when poll timed out */ if (ret) { trace_fsi_master_aspeed_timeout(reg, status, true); @@ -193,21 +191,20 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, if (status & STATUS_ERR_ACK) return -EIO; - if (out) { - switch (transfer_size) { - case XFER_BYTE: - *(u8 *)out = result; - break; - case XFER_HALFWORD: - *(u16 *)out = result; - break; - case XFER_FULLWORD: - *(u32 *)out = result; - break; - default: - return -EINVAL; - } + result = readl(base + OPB0_FSI_DATA_R); + switch (transfer_size) { + case XFER_BYTE: + *(u8 *)out = result; + break; + case XFER_HALFWORD: + *(u16 *)out = result; + break; + case XFER_FULLWORD: + *(u32 *)out = result; + break; + default: + return -EINVAL; } trace_fsi_master_aspeed_opb_xfer(addr, transfer_size + 1, result, true); From patchwork Wed Jun 5 21:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687563 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 19BA916C6A7; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; cv=none; b=UII7Unxy5pHXuZdGqMRXMWV59z5PKemRKOrl0tmIX40uuNFLJTNrrazewXqgVBmnQ7e3aWqD37rm8wZ5L+/lQLzMA8LHDDjF9+YsNj8NEI+2QI2Bkwfwwat8kbpaVUgS1VPW5JnAlHIPuK2rmiLd4zVJTyHvNNw7bGrGHyLWAF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; c=relaxed/simple; bh=qaKSN57DFhgzUoIJwygcbsMbYI7rqB3nhHlVwwQrD0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cmS4SrlMnfpf0Cq55JTkxnUKi81ePTKlpZuLL1ELoRANchsHXZKbYxsIFUEgF0xbquDweLrSdsANNnXqoV8aOHvR3x6yYraN79PQl632Jcgd9vGV/lY2yiAL2xKPfitmlK6WZ+Y9Udyi0jAhQyt6/MYhuKHhq4fsTLOsQb4snPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Hnz9qoQf; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Hnz9qoQf" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KujBr001492; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=7144/LG2eNgprd/415eaf17snNBOk8+YXJ4liDEExS4=; b=Hnz9qoQfLlYK1z9pOG3ZjpNsxjMGqKoy5B44PYAjz19geFUXipws6KjO10JMJmM09rkb hG+YYFzhFQrMUEB5Bo2Hfv9oYTIbJifbh4ZPHbd2/00bbUV+FAxadR7GbFzZsO3UM0ZS Tkj+fzNwwLic/bGFn13YPugrKkLPQTsN/CYnlQBW3bmz4ugkq4+c0xH8rKAIfnNoy0y4 5SLM3SA6OqBrQI7fSNK35QL4FVw+cImVNhStIn+lVpn9aF7VvuQm4C0iODqrbVfZj/bJ W6ahSSwr5snqa5g3PJKz0nbNdG0/pE0KIxf+Zb6TuCGhGieandJ+KKx5rXRSFoZGrtAz ig== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjwppgcg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455LKarF026550; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNL6f40042806 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F84358060; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 423615806E; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 20/40] fsi: aspeed: Switch to spinlock Date: Wed, 5 Jun 2024 16:22:52 -0500 Message-Id: <20240605212312.349188-21-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tUwL7hjLp28dY9WByyu26kuCsCiScvUz X-Proofpoint-GUID: tUwL7hjLp28dY9WByyu26kuCsCiScvUz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=988 malwarescore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 In preparation for interrupt support, switch to a spinlock rather than a mutex. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 10ca23cf58c2e..176e596b4391b 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -8,11 +8,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -24,7 +24,7 @@ struct fsi_master_aspeed_data { struct fsi_master_aspeed { struct fsi_master master; - struct mutex lock; /* protect HW access */ + spinlock_t lock; /* protect HW access */ struct device *dev; void __iomem *base; void __iomem *ctrl; @@ -251,6 +251,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, size_t size) { struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); + unsigned long flags; int ret; if (id > 0x3) @@ -259,7 +260,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, addr |= id << 21; addr += link * FSI_HUB_LINK_SIZE; - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); switch (size) { case 1: @@ -278,7 +279,7 @@ static int aspeed_master_read(struct fsi_master *master, int link, ret = check_errors(aspeed, ret); done: - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); return ret; } @@ -286,6 +287,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, uint8_t id, uint32_t addr, const void *val, size_t size) { struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); + unsigned long flags; int ret; if (id > 0x3) @@ -294,7 +296,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, addr |= id << 21; addr += link * FSI_HUB_LINK_SIZE; - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); switch (size) { case 1: @@ -313,7 +315,7 @@ static int aspeed_master_write(struct fsi_master *master, int link, ret = check_errors(aspeed, ret); done: - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); return ret; } @@ -396,15 +398,16 @@ static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *att const char *buf, size_t count) { struct fsi_master_aspeed *aspeed = dev_get_drvdata(dev); + unsigned long flags; trace_fsi_master_aspeed_cfam_reset(true); - mutex_lock(&aspeed->lock); + spin_lock_irqsave(&aspeed->lock, flags); gpiod_set_value(aspeed->cfam_reset_gpio, 1); - usleep_range(900, 1000); + udelay(900); gpiod_set_value(aspeed->cfam_reset_gpio, 0); - usleep_range(900, 1000); + udelay(900); regmap_write(aspeed->master.map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); return count; @@ -498,6 +501,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) return -ENOMEM; aspeed->dev = &pdev->dev; + spin_lock_init(&aspeed->lock); aspeed->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(aspeed->base)) { @@ -583,7 +587,6 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, aspeed); - mutex_init(&aspeed->lock); rc = fsi_master_init(&aspeed->master, clk_get_rate(aspeed->clk)); if (rc) goto err_regmap; From patchwork Wed Jun 5 21:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687555 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 D8E0D161325; Wed, 5 Jun 2024 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622623; cv=none; b=dAN+izQ4iofr682iAPN680ynRJUm5yUryVxVZgbJnhT6PvpDt8ZXhV9pC+nGqAzHvVV07soLiSAVw+7hvtSntD+uAj8Fo0h1K7lFblAYA8ZSb1uUaFkPO5wpaiV1aEwGJnP2FQ55TQdmfXcnhdDecxwNjTNp4fU0txw6lBCcKKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622623; c=relaxed/simple; bh=DVlspCvxuZKZN7sDi6C13Fa0sXjsUMSeTdMdoR/Qvy0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C4FgULtI+RMbdsuu9tVmT6fgqBMkw8eV56hkj/KdMvcYHH2jqIRd/23g3KNeEE4mi94DpLc3x6WC1KyKUprhSPdBIMQDQJMyGpnJuTVIOVAEY1YKcvNkvLG8EC57Dacm+3FI6cKwR9E+pdtl6Lh81uz78WUpSVMD90Ks/m7Sux8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qTIXnIs0; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qTIXnIs0" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L0dbb020650; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=11zpQI9xr19rfXGIBfzj6RLCrXVfSzpcD3mn995Pgkw=; b=qTIXnIs0cIUFNfnUlChghskfK1spVWV80YRnBV/8P4zVtVDHZFRUKlJyvbSUialCpXrk Xk+wqZ+Pe0b5bPsdd1fKM3uuWDK6CsvJHa1DTGX3cPDnK9J+pAq0+6OPtmq2KW3itgiT 94bRU0KezJN8TwEPv2Yv00gX3v1rpdEwUxTM53xKrIgpaCAKzETdGMY2bFBTZB2fhFF3 8AKcTaMQl5hk1EDDA1IY3OExJz9HhBwE3C0hkpgtDrHuGw9VE0X8mSgDeT3YWO4VIHug X60U7vKIzKzZw6dWfhxh0Q/j8oJEO6uKzlSV6RwUOTftkjl0bsmcV0oypvlAUkP0Zy86 qw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyhyr1mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JlkIQ026600; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffn6hj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNLmI40763872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDA095805D; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85FE95806B; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 21/40] fsi: aspeed: Disable relative addressing and IPOLL for cfam reset Date: Wed, 5 Jun 2024 16:22:53 -0500 Message-Id: <20240605212312.349188-22-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cIvVpV4DnW7VlBXI_jFKy5cMb1bRJmM7 X-Proofpoint-GUID: cIvVpV4DnW7VlBXI_jFKy5cMb1bRJmM7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=721 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Need to disable these for the master reset after cfam reset. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 176e596b4391b..c9f6d84e1a372 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -402,11 +402,18 @@ static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *att trace_fsi_master_aspeed_cfam_reset(true); spin_lock_irqsave(&aspeed->lock, flags); + + regmap_write(aspeed->master.map, FSI_MMODE, + aspeed->master.mmode & ~(FSI_MMODE_EIP | FSI_MMODE_RELA)); + gpiod_set_value(aspeed->cfam_reset_gpio, 1); udelay(900); gpiod_set_value(aspeed->cfam_reset_gpio, 0); udelay(900); + regmap_write(aspeed->master.map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); + regmap_write(aspeed->master.map, FSI_MMODE, aspeed->master.mmode); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); From patchwork Wed Jun 5 21:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687568 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 8BC40174EC9; Wed, 5 Jun 2024 21:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=IcRHzmJ/zvLeE+WOUqsfPLbN/IEfzNZ3ViTKBPIYsxhYJgzD4WhEiKmp5IQ/+k2ZF+a5XRrWJmjT7n0ooVH2VuoB/i3zwIWlPGR74391LODqGis2U5AJogDKiT4hhLXQnDvKOZfxeBU7cJSbTmj7J2Luiu7ZsHmh37TiXozBCxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=3+V1BYHv7imAhNsodfDuqzyVlub/3rC7336E+6Ul+HU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g1/boQzdJiOn8meEO61XDSNo3lto0hZXj5oh12LVtxfFq/N5AhaTgNgKKeVTCJdDk0W4n0+XfPrp2c23VKyOgwRaCw4s6uQvkxC9XfwxWzGIFkW7RWCdc8ifyTmu2oDPAnditNuGW0E6pB14fZdsdYLGkh53jMebzjyG+gwhhrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=sNYBpF0y; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="sNYBpF0y" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455K8Rdf009413; Wed, 5 Jun 2024 21:23:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=kxSj0cj+SHG6G3CgN+VDhbwxi4I1ZjlQ60/1SQ/PgFM=; b=sNYBpF0yZJhYUumcRcGzpnM8KTcckFRjdFV9alyg8qURpJSwIfgY5oyN2gubUtRuDlIA 3aTFz+DN07nDx/DCXWg+zN4S1UmriHRX7JmS0MvBLlg2vMwrb5TrAxjrUfg5aA0aiZBp zbvipDJZ2OMD3bPAJjoywSCTUlO3KYrdE5fP4IAsBI9rqo5Q3i0mupLiVfRn0cGVBGHU rxoTd6egTkPNy82w0idL1ykIrhWFuMeuZid6CGSe1JR3SEs9RvIEoE6urHK9GSbpSb3S brBJIE8NbtZDkFVoZI4BdSLL2ufwYfM9elMgl/7B1de3b3MEq2oZ6nOmUVmrAcWeprA1 VA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxse06rk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IZCbw031109; Wed, 5 Jun 2024 21:23:23 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNKaI17367726 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:22 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E59358059; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4B2758065; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:19 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 22/40] fsi: aspeed: Use common master error handler Date: Wed, 5 Jun 2024 16:22:54 -0500 Message-Id: <20240605212312.349188-23-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NEm3V_-JbDh5Z16bQusD7g1wrzAk3zLR X-Proofpoint-GUID: NEm3V_-JbDh5Z16bQusD7g1wrzAk3zLR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 This will do the correct mmode manipulation to do the master reset. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index c9f6d84e1a372..eecd64bc29512 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -226,27 +226,6 @@ static int opb_readb(struct fsi_master_aspeed *aspeed, uint32_t addr, u8 *out) return __opb_read(aspeed, addr, XFER_BYTE, (void *)out); } -static int check_errors(struct fsi_master_aspeed *aspeed, int err) -{ - int ret; - - if (err == -EIO) { - /* Check MAEB (0x70) ? */ - - /* Then clear errors in master */ - ret = opb_writel(aspeed, ctrl_base + FSI_MRESP0, - cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); - if (ret) { - /* TODO: log? return different code? */ - return ret; - } - /* TODO: confirm that 0x70 was okay */ - } - - /* This will pass through timeout errors */ - return err; -} - static int aspeed_master_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, size_t size) { @@ -277,7 +256,8 @@ static int aspeed_master_read(struct fsi_master *master, int link, goto done; } - ret = check_errors(aspeed, ret); + if (ret == -EIO) + fsi_master_error(&aspeed->master, link); done: spin_unlock_irqrestore(&aspeed->lock, flags); return ret; @@ -313,7 +293,8 @@ static int aspeed_master_write(struct fsi_master *master, int link, goto done; } - ret = check_errors(aspeed, ret); + if (ret == -EIO) + fsi_master_error(&aspeed->master, link); done: spin_unlock_irqrestore(&aspeed->lock, flags); return ret; From patchwork Wed Jun 5 21:22:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687557 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 6803A1586D7; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; cv=none; b=qattLc1b2Wv+lryZUBx1YWELJGYkKxUQrQJ/x4zYfWmFx4hjv16LDWW4PmGluBeVQYgrI9rd4ezbqD/+w2/zzgB7Y3rDU1O5LtlkCxDK+LEy/A3Fr9hAuDbz/DMZE2+SvQl63AsvWkJP7PArx/lZmDClV7cM1CWtzOWasEhOyB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; c=relaxed/simple; bh=Da+7g2WRkg7jGuc0nH2HzTkA09fzVTkF+Wt3wcS/lYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pW92soh/cl66LzVD7B+hXHZuw4DmwmFZLLWT+80+gL/ClILbnCsZAdTi0V2FNGvwuLUJzVy7dytav7bBmsv0rbpF5GhNgkaSt/65PTrQKN4WkmymsIO3TuUK3e0GvMLBi8Q/st4XpY9xKN4iqWMVZ3M98/2bsqdrzRPFZQqkUBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ng06+JGx; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ng06+JGx" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KvShv014025; Wed, 5 Jun 2024 21:23:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=WNiOJmiLmJsTND7DuVuE19O0w7Czdt5rWrFBHzegWuE=; b=ng06+JGxn+54pyqbL9zNE7micGEVzpVHIuMDDGQ5VR4IxojWTKfuwwp23X0oANnzixN+ DG+TTvLTybKU9xeXBLWPRQ/R24Nk4Gbs2otCftcFHPMtQav5lKEktN/t9o5KCu3FO3Z/ 7oW+R5AgVSLIU7sTx4JGb7yQImJf0hp9PQnIuDWR1FruUQ1gdFTsvfqk82GhnaghE6Ib BPowBey19fBI2TDjWuiFb4oAjP8hdDIJkKei62Skj1rt1oRIOBTj9h0UqIgoPXDlGODO /nsr3mwfV3yfySesoFv4+pQcTWm8bO8Ndv60H5fNrze905P24VN9OrhOMIe0hTtG8kT7 Qg== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygp81ug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KwRtD026549; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366fb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNKS221758634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:22 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AB7F58061; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25A5758075; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 23/40] fsi: core: Add interrupt support Date: Wed, 5 Jun 2024 16:22:55 -0500 Message-Id: <20240605212312.349188-24-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mv2oWU15DpZQWFChEZ7HZlF2hKia-8YK X-Proofpoint-ORIG-GUID: mv2oWU15DpZQWFChEZ7HZlF2hKia-8YK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Add an irq chip to the FSI master structure to control slave interrupt masking. Add a function to request an IRQ from the FSI device. The FSI master IRQ mapping is based on the FSI device engine type and slave link. Signed-off-by: Eddie James --- Changes since v3: - Remove use of handle_irq_desc Changes since v2: - Remove slave interrupt handler since it's not used yet drivers/fsi/fsi-core.c | 159 +++++++++++++++++++++++++++++++++++++ drivers/fsi/fsi-master.h | 9 +++ drivers/fsi/fsi-slave.h | 1 - include/linux/fsi.h | 2 + include/trace/events/fsi.h | 41 ++++++++++ 5 files changed, 211 insertions(+), 1 deletion(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 8b402149acbe9..58cb6bc6ccc91 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -14,10 +14,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -109,6 +111,67 @@ int fsi_device_peek(struct fsi_device *dev, void *val) return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t)); } +EXPORT_SYMBOL_GPL(fsi_device_peek); + +static int fsi_request_irq(struct fsi_slave *slave, irq_handler_t handler, void *data, + unsigned int engine_irq, struct device *dev) +{ + struct device_node *parent = of_node_get(slave->master->dev.of_node); + struct irq_fwspec fwspec; + unsigned int irq; + + /* + * FSI devices can only report interrupts to their own master, so if the master + * isn't an interrupt controller, don't try and map an irq. + */ + if (!of_get_property(parent, "#interrupt-cells", NULL)) { + of_node_put(parent); + return -EINVAL; + } + + fwspec.fwnode = of_node_to_fwnode(parent); + fwspec.param_count = 1; + fwspec.param[0] = engine_irq + (slave->link * FSI_IRQ_COUNT); + irq = irq_create_fwspec_mapping(&fwspec); + if (!irq) + return -EINVAL; + + return devm_request_irq(dev, irq, handler, 0, dev_name(dev), data); +} + +int fsi_device_request_irq(struct fsi_device *dev, irq_handler_t handler, void *data) +{ + unsigned int engine_irq; + + switch (dev->engine_type) { + case 0x4: // shift + engine_irq = 1; + break; + case 0x5: // scom + engine_irq = 2; + break; + case 0x6: // scratchpad + engine_irq = 3; + break; + case 0x7: // i2cm + engine_irq = 4; + break; + case 0x20: // mbox + engine_irq = 7; + break; + case 0x22: // sbefifo + engine_irq = 6; + break; + case 0x23: // spim + engine_irq = 5; + break; + default: + return -EINVAL; + } + + return fsi_request_irq(dev->slave, handler, data, engine_irq, &dev->dev); +} +EXPORT_SYMBOL_GPL(fsi_device_request_irq); unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev) { @@ -1467,6 +1530,99 @@ void fsi_master_regmap_config(struct regmap_config *config) } EXPORT_SYMBOL_GPL(fsi_master_regmap_config); +int fsi_master_irq(struct fsi_master *master, struct irq_domain *irq_domain, unsigned int link) +{ + unsigned int downstream = irq_find_mapping(irq_domain, (link * FSI_IRQ_COUNT) + 8); + unsigned long size = FSI_SI1S_SLAVE_BIT + 1; + unsigned long bit = FSI_SI1S_MBOX_BIT; + unsigned long srsis0 = 0; + unsigned long srsis4 = 0; + unsigned long si1s; + __be32 reg; + int rc; + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SI1S, ®, sizeof(reg)); + if (rc) + return rc; + + si1s = (unsigned long)be32_to_cpu(reg); + for_each_set_bit_from(bit, &si1s, size) + generic_handle_domain_irq(irq_domain, (link * FSI_IRQ_COUNT) + (31 - bit)); + + if (downstream) { + int i; + + master->remote_interrupt_status = 0; + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIS0, ®, + sizeof(reg)); + if (rc) + return rc; + + srsis0 = (unsigned long)be32_to_cpu(reg); + for (i = 0; i < 4; ++i) { + if (srsis0 & (0xff000000 >> (8 * i))) + master->remote_interrupt_status |= (1 << i); + } + + rc = fsi_master_read(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIS4, ®, + sizeof(reg)); + if (rc) + return rc; + + srsis4 = (unsigned long)be32_to_cpu(reg); + for (i = 0; i < 4; ++i) { + if (srsis4 & (0xff000000 >> (8 * i))) + master->remote_interrupt_status |= (16 << i); + } + + if (master->remote_interrupt_status) { + generic_handle_irq(downstream); + + reg = cpu_to_be32(0xffffffff); + if (master->remote_interrupt_status & 0xf) + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIC0, + ®, sizeof(reg)); + + if (master->remote_interrupt_status & 0xf0) + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SRSIC4, + ®, sizeof(reg)); + } + } + + trace_fsi_master_irq(master, link, si1s, srsis0, srsis4); + return 0; +} +EXPORT_SYMBOL_GPL(fsi_master_irq); + +static void fsi_master_irq_mask(struct irq_data *data) +{ + unsigned int bit = 31 - (data->hwirq % FSI_IRQ_COUNT); + + if (bit >= FSI_SI1S_MBOX_BIT) { + struct fsi_master *master = irq_data_get_irq_chip_data(data); + int link = data->hwirq / FSI_IRQ_COUNT; + __be32 mask = cpu_to_be32(BIT(bit)); + + trace_fsi_master_irq_mask(master, link, data->hwirq % FSI_IRQ_COUNT, true); + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SCI1M, &mask, sizeof(mask)); + } +} + +static void fsi_master_irq_unmask(struct irq_data *data) +{ + unsigned int bit = 31 - (data->hwirq % FSI_IRQ_COUNT); + + if (bit >= FSI_SI1S_MBOX_BIT) { + struct fsi_master *master = irq_data_get_irq_chip_data(data); + int link = data->hwirq / FSI_IRQ_COUNT; + __be32 mask = cpu_to_be32(BIT(bit)); + + trace_fsi_master_irq_mask(master, link, data->hwirq % FSI_IRQ_COUNT, false); + fsi_master_write(master, link, 0, FSI_SLAVE_BASE + FSI_SSI1M, &mask, sizeof(mask)); + } +} + int fsi_master_register(struct fsi_master *master) { int rc; @@ -1491,6 +1647,9 @@ int fsi_master_register(struct fsi_master *master) if (master->flags & FSI_MASTER_FLAG_SWCLOCK) master->clock_frequency = 100000000; // POWER reference clock + master->irq_chip.name = dev_name(&master->dev); + master->irq_chip.irq_mask = fsi_master_irq_mask; + master->irq_chip.irq_unmask = fsi_master_irq_unmask; master->dev.class = &fsi_master_class; mutex_lock(&master->scan_lock); diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 8ea2f69ec4922..2104902091e05 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -10,6 +10,7 @@ #define DRIVERS_FSI_MASTER_H #include +#include #include /* @@ -112,6 +113,7 @@ /* Misc */ #define FSI_CRC_SIZE 4 #define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ +#define FSI_IRQ_COUNT 9 /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 @@ -137,6 +139,7 @@ struct fsi_master { int n_links; int flags; struct mutex scan_lock; + struct irq_chip irq_chip; int (*read)(struct fsi_master *, int link, uint8_t id, uint32_t addr, void *val, size_t size); int (*write)(struct fsi_master *, int link, uint8_t id, @@ -147,6 +150,7 @@ struct fsi_master { bool enable); int (*link_config)(struct fsi_master *, int link, u8 t_send_delay, u8 t_echo_delay); + u8 remote_interrupt_status; }; #define to_fsi_master(d) container_of(d, struct fsi_master, dev) @@ -176,4 +180,9 @@ extern void fsi_master_unregister(struct fsi_master *master); extern int fsi_master_rescan(struct fsi_master *master); +struct irq_domain; + +extern int fsi_master_irq(struct fsi_master *master, struct irq_domain *irq_domain, + unsigned int link); + #endif /* DRIVERS_FSI_MASTER_H */ diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index 0468ec1c60db2..762636e7c8633 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -73,7 +73,6 @@ #define FSI_SISS_MFSI_PORT_ERROR BIT(2) #define FSI_SISS_MFSI_HP BIT(1) #define FSI_SISS_MFSI_CR_PARITY_ERROR BIT(0) -#define FSI_SISS_ALL 0xfe007f00 /* * SI1S fields diff --git a/include/linux/fsi.h b/include/linux/fsi.h index e0309bf0ae072..c249a95b7ff84 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h @@ -8,6 +8,7 @@ #define LINUX_FSI_H #include +#include struct fsi_device { struct device dev; @@ -25,6 +26,7 @@ extern int fsi_device_write(struct fsi_device *dev, uint32_t addr, const void *val, size_t size); extern int fsi_device_peek(struct fsi_device *dev, void *val); extern unsigned long fsi_device_local_bus_frequency(struct fsi_device *dev); +extern int fsi_device_request_irq(struct fsi_device *dev, irq_handler_t handler, void *data); struct fsi_device_id { u8 engine_type; diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index da977d59e163e..c750ae8e1f5b4 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -8,6 +8,47 @@ #include +TRACE_EVENT(fsi_master_irq, + TP_PROTO(const struct fsi_master *master, unsigned int link, uint32_t si1s, + uint32_t srsis0, uint32_t srsis4), + TP_ARGS(master, link, si1s, srsis0, srsis4), + TP_STRUCT__entry( + __field(int, master_idx) + __field(unsigned int, link) + __field(uint32_t, si1s) + __field(uint32_t, srsis0) + __field(uint32_t, srsis4) + ), + TP_fast_assign( + __entry->master_idx = master->idx; + __entry->link = link; + __entry->si1s = si1s; + __entry->srsis0 = srsis0; + __entry->srsis4 = srsis4; + ), + TP_printk("fsi%d:%02d si1s:%08x srsis0:%08x srsis4:%08x", __entry->master_idx, + __entry->link, __entry->si1s, __entry->srsis0, __entry->srsis4) +); + +TRACE_EVENT(fsi_master_irq_mask, + TP_PROTO(const struct fsi_master *master, unsigned int link, unsigned int bit, bool mask), + TP_ARGS(master, link, bit, mask), + TP_STRUCT__entry( + __field(int, master_idx) + __field(unsigned int, link) + __field(unsigned int, bit) + __field(bool, mask) + ), + TP_fast_assign( + __entry->master_idx = master->idx; + __entry->link = link; + __entry->bit = bit; + __entry->mask = mask; + ), + TP_printk("fsi%d:%02d %s bit:%d", __entry->master_idx, __entry->link, + __entry->mask ? "mask" : "unmask", __entry->bit) +); + TRACE_EVENT(fsi_master_xfer, TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, bool read), From patchwork Wed Jun 5 21:22:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687553 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 A7C001649D3; Wed, 5 Jun 2024 21:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; cv=none; b=Bw1cM0OCDQJCjUmVs9dAM4D+RqZ97TnTleZHljGOQJPGOsSit2TCOGg+N/hjjsrntFz8lMi7r70DBMYauQ2ybW6lrW2/fuRxaZf2FxU6n96nar/vrDjs7vQBi6kr3+D6ftzU3L2AJ2IIj9nXGUN7Wt1QGNmZ//XnzN1jRFpa3Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; c=relaxed/simple; bh=87vNvPwlNAGeQ5WqIoHAelTRCQC/Naflh/0oKi3szzY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tb2arbgN9R0cb8Hq2LiBuYYilIim1nrF0UH9g5itLWf1F6IxqMWfdFxrV5AOfYTv4pUgJsbCt0XQNpLxywRgzLlIiA8Gv1oUKhe0dTMKSFXujgPFlMyNnyiFrgnkoA9KlW74/M+7Xmej2VeEDummdLVjMbgwTQkhp2QPdJn82do= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=nIlE4vI8; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nIlE4vI8" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LC7nj011974; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=8PJMQwkXBuHRk4+y67UGNnhw/k8TP4I96ElVzPKL2DE=; b=nIlE4vI8/SfDnpvvPHcGAdea760Vd0k1amKWBVugRkkjlpWGuJ5ZwWR779PQwfn7OcOr ZcJp+ynBWlHXz9VV5gtpABl8M1i5n6v2UgysnYvhEmOZbk6bEiQQGoUpRrzhsZN1Urym KmX8pNk4f91eTSJX8okyfSZM6kzUjBmmmGyexUpid0WRhdQorCeRB/qHDFQijsgy7A3D bPZ3WCfLA5Grl5PPwrff6mQoHNqpI8qbdWf2UGUFEOBRpvmi4hVkH7QgPVt9Nhy8Fd8Z qg74ZtCgrXX87RHIwNrVI3hVDWzctzXFwgtyTQxeTs5RxJYhf8BjuKqWqv/7C5jegbPq 8g== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455J3Ge9031147; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNKwF10355290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B14F758067; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 721665805F; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 24/40] fsi: aspeed: Add interrupt support Date: Wed, 5 Jun 2024 16:22:56 -0500 Message-Id: <20240605212312.349188-25-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: TZy6v-nwDVax87CmXxW2TRfPA3FaSa3S X-Proofpoint-ORIG-GUID: TZy6v-nwDVax87CmXxW2TRfPA3FaSa3S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=883 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Handle slave interrupts and pass them to the FSI core. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 106 ++++++++++++++++++++++- include/trace/events/fsi_master_aspeed.h | 12 +++ 2 files changed, 115 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index eecd64bc29512..34f4c9e00e43d 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -25,11 +27,13 @@ struct fsi_master_aspeed_data { struct fsi_master_aspeed { struct fsi_master master; spinlock_t lock; /* protect HW access */ + struct irq_domain *irq_domain; struct device *dev; void __iomem *base; void __iomem *ctrl; struct clk *clk; struct gpio_desc *cfam_reset_gpio; + u32 irq_mask; }; #define to_fsi_master_aspeed(m) \ @@ -79,6 +83,11 @@ static const u32 fsi_base = 0xa0000000; #define STATUS_TIMEOUT BIT(4) /* OPB_IRQ_MASK */ +#define FSI_MASTER_ERROR_IRQ BIT(28) +#define FSI_PORT_ERROR_IRQ BIT(27) +#define FSI_HOTPLUG_IRQ BIT(26) +#define FSI_REMOTE_SLV_IRQ(l) (BIT(FSI_REMOTE_SLV_IRQ_BIT) << (l)) +#define FSI_REMOTE_SLV_IRQ_BIT 18 #define OPB1_XFER_ACK_EN BIT(17) #define OPB0_XFER_ACK_EN BIT(16) @@ -96,7 +105,7 @@ static const u32 fsi_base = 0xa0000000; #define OPB_RC_CTRL_OPB BIT(18) /* Access controller over OPB, not AHB (AST27xx+) */ #define OPB_RC_XFER_ACK_EN BIT(16) /* Enable OPBx xfer ack bit without mask */ #define OPB_RC_COUNT GENMASK(15, 0) /* Number of retries */ -#define OPB_RC_DEFAULT 0x10 +#define OPB_RC_DEFAULT (OPB_RC_XFER_ACK_EN | 0x10) #define CREATE_TRACE_POINTS #include @@ -322,11 +331,76 @@ static int aspeed_master_break(struct fsi_master *master, int link) return aspeed_master_write(master, link, 0, addr, &cmd, 4); } +static int aspeed_master_link_enable(struct fsi_master *master, int link, bool enable) +{ + struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); + unsigned long flags; + int rc; + + spin_lock_irqsave(&aspeed->lock, flags); + if (enable) { + rc = fsi_master_link_enable(master, link, enable); + if (rc) + goto done; + + aspeed->irq_mask |= FSI_REMOTE_SLV_IRQ(link); + writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK); + } else { + aspeed->irq_mask &= ~FSI_REMOTE_SLV_IRQ(link); + writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK); + + rc = fsi_master_link_enable(master, link, enable); + } + +done: + spin_unlock_irqrestore(&aspeed->lock, flags); + return rc; +} + +static irqreturn_t aspeed_master_irq(int irq, void *data) +{ + struct fsi_master_aspeed *aspeed = data; + unsigned long size = FSI_REMOTE_SLV_IRQ_BIT + aspeed->master.n_links; + unsigned long bit = FSI_REMOTE_SLV_IRQ_BIT; + unsigned long status; + + status = readl(aspeed->base + OPB_IRQ_STATUS); + writel(0, aspeed->base + OPB_IRQ_MASK); + + for_each_set_bit_from(bit, &status, size) + fsi_master_irq(&aspeed->master, aspeed->irq_domain, bit - FSI_REMOTE_SLV_IRQ_BIT); + + writel(status, aspeed->base + OPB_IRQ_STATUS); + writel(0, aspeed->base + OPB_IRQ_STATUS); + writel(aspeed->irq_mask, aspeed->base + OPB_IRQ_MASK); + + trace_fsi_master_aspeed_irq(status); + return IRQ_HANDLED; +} + +static int aspeed_master_irqd_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + struct fsi_master_aspeed *aspeed = domain->host_data; + + irq_set_chip_and_handler(irq, &aspeed->master.irq_chip, handle_simple_irq); + irq_set_chip_data(irq, &aspeed->master); + + return 0; +} + +static const struct irq_domain_ops aspeed_master_irq_domain_ops = { + .map = aspeed_master_irqd_map, +}; + static void aspeed_master_release(struct device *dev) { struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(to_fsi_master(dev)); + if (aspeed->irq_domain) + irq_domain_remove(aspeed->irq_domain); + regmap_exit(aspeed->master.map); kfree(aspeed); } @@ -477,6 +551,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) struct resource *res; unsigned int reg; int rc, links; + int irq; rc = tacoma_cabled_fsi_fixup(&pdev->dev); if (rc) { @@ -567,11 +642,12 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) aspeed->master.dev.of_node = of_node_get(dev_of_node(&pdev->dev)); aspeed->master.n_links = links; - aspeed->master.flags = FSI_MASTER_FLAG_RELA; + aspeed->master.flags = FSI_MASTER_FLAG_INTERRUPT | FSI_MASTER_FLAG_RELA; aspeed->master.read = aspeed_master_read; aspeed->master.write = aspeed_master_write; aspeed->master.send_break = aspeed_master_break; aspeed->master.term = aspeed_master_term; + aspeed->master.link_enable = aspeed_master_link_enable; dev_set_drvdata(&pdev->dev, aspeed); @@ -579,9 +655,30 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) if (rc) goto err_regmap; + irq = platform_get_irq(pdev, 0); + if (irq > 0) { + unsigned int size = links * FSI_IRQ_COUNT; + + aspeed->irq_domain = irq_domain_add_linear(aspeed->dev->of_node, size, + &aspeed_master_irq_domain_ops, aspeed); + if (aspeed->irq_domain) { + rc = devm_request_irq(aspeed->dev, irq, aspeed_master_irq, 0, + dev_name(aspeed->dev), aspeed); + if (rc) { + dev_warn(aspeed->dev, "failed to request irq:%d\n", irq); + irq_domain_remove(aspeed->irq_domain); + aspeed->irq_domain = NULL; + } else { + dev_info(aspeed->dev, "enabling interrupts irq:%d\n", irq); + } + } else { + dev_warn(aspeed->dev, "failed to create irq domain\n"); + } + } + rc = fsi_master_register(&aspeed->master); if (rc) - goto err_regmap; + goto err_irq; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -593,6 +690,9 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) get_device(&aspeed->master.dev); return 0; +err_irq: + if (aspeed->irq_domain) + irq_domain_remove(aspeed->irq_domain); err_regmap: regmap_exit(aspeed->master.map); err_release: diff --git a/include/trace/events/fsi_master_aspeed.h b/include/trace/events/fsi_master_aspeed.h index 7eeecbfec7f09..dba1776334a0e 100644 --- a/include/trace/events/fsi_master_aspeed.h +++ b/include/trace/events/fsi_master_aspeed.h @@ -8,6 +8,18 @@ #include +TRACE_EVENT(fsi_master_aspeed_irq, + TP_PROTO(uint32_t status), + TP_ARGS(status), + TP_STRUCT__entry( + __field(uint32_t, status) + ), + TP_fast_assign( + __entry->status = status; + ), + TP_printk("status %08x", __entry->status) +); + TRACE_EVENT(fsi_master_aspeed_opb_xfer, TP_PROTO(uint32_t addr, uint32_t size, uint32_t data, bool read), TP_ARGS(addr, size, data, read), From patchwork Wed Jun 5 21:22:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687539 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 E974615FA8E; Wed, 5 Jun 2024 21:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622619; cv=none; b=gDYYTUUxPdjLAyR8Y2spW2cvSQwIcs/6nJnsy2SoXCcs7q9kbc+hSVKA1DyIWUx+zKFNO/HkSnD90BzCMMmaSPWAxmSIl2TwZhaLThGXfUVI9gBp8jTaq6XkdRnWnNPooIw+8Mbj/ANo+e135FV3MXtCQ5JZTWUJQNQELcEj4Uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622619; c=relaxed/simple; bh=N3UTzNUtXmjmm7coOvDA22Gt2jL9BDiDsk86bTF/Nc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z48AfReR4gNnsjgFiZQ1Hk3yBadOiu7Hq2DNdA+AJPIa741zoYaa7QjxDCFpLgzxgJVqMwWQ92bPSV7AAmxUpWRVNzK8WRv2MRZisxjRUM9k0nryFttO9ajX91mHaeJrx1MlWJXrH7ijbWawlXgUqQpkv+Le8j9gk3hlue5uVB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=PiTtOAXh; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="PiTtOAXh" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KvLRH013983; Wed, 5 Jun 2024 21:23:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=YOLIj6L0KAZvactSkelHXB6uAYCWUbFIRDQVWm/PliY=; b=PiTtOAXh3BPpIPX69G2uibOakX68i4UV4dUx9roCCl8b/tFxrxGfGcAFBJER4R5Lf4Xp 8UqnERDqNZFNxBqZMkZoMrtkh8cG1c8S27Hsg6nf7dQ6jKW/w1cCWtZYPbyXgtkGTvZI 7phkshjc/7mr5wzpgwpQe1EVaN3CfQIPsG2ABop+2Tu8B05MAT3SGB3+Hkg77/SHPNyG wa1JHmLiE9J3l+t6aZ1hpEcMTIwox3RqnG1WFTdNCsoSSM/HgvKndT5NArfZvslJ8hxG u7YfMq6xHKyk4SBGsHsygF3TY2Rt0AjutNoItR9pcSrjBTeUwU/Ouim/BSa4Aq7aCky4 Cw== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygp81uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455K6b7t022779; Wed, 5 Jun 2024 21:23:23 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygg6med4d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:23 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNLgh22741606 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 028835805F; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B8C9A58068; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 25/40] fsi: hub: Add interrupt support Date: Wed, 5 Jun 2024 16:22:57 -0500 Message-Id: <20240605212312.349188-26-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: B6cp8WvZrLVnF0C6jRplKcNcw8Vs8k6u X-Proofpoint-ORIG-GUID: B6cp8WvZrLVnF0C6jRplKcNcw8Vs8k6u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=782 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The hub master receives it's interrupts from the local slave register space, which is handled in the FSI core. Therefore, just route the remote slave interrupts to the hub link device interrupts. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-hub.c | 119 ++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 91ad6b7728fa2..4dbc542500bbd 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -7,8 +7,10 @@ #include #include +#include #include #include +#include #include #include @@ -35,9 +37,10 @@ */ struct fsi_master_hub { struct fsi_master master; + struct irq_domain *irq_domain; struct fsi_device *upstream; - uint32_t addr, size; /* slave-relative addr of */ - /* master address space */ + uint32_t addr; + uint32_t size; }; #define to_fsi_master_hub(m) container_of(m, struct fsi_master_hub, master) @@ -77,10 +80,81 @@ static int hub_master_break(struct fsi_master *master, int link) return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd)); } +static int hub_master_link_enable(struct fsi_master *master, int link, + bool enable) +{ + struct fsi_master_hub *hub = to_fsi_master_hub(master); + u32 srsim = 0xff000000 >> (8 * (link % 4)); + int slave_idx = 4 * (link / 4); + __be32 srsim_be; + int ret; + + ret = fsi_slave_read(hub->upstream->slave, FSI_SLAVE_BASE + FSI_SRSIM0 + slave_idx, + &srsim_be, sizeof(srsim_be)); + if (ret) + return ret; + + if (enable) { + ret = fsi_master_link_enable(master, link, enable); + if (ret) + return ret; + + srsim |= be32_to_cpu(srsim_be); + srsim_be = cpu_to_be32(srsim); + ret = fsi_slave_write(hub->upstream->slave, + FSI_SLAVE_BASE + FSI_SRSIM0 + slave_idx, &srsim_be, + sizeof(srsim_be)); + } else { + srsim = be32_to_cpu(srsim_be) & ~srsim; + srsim_be = cpu_to_be32(srsim); + ret = fsi_slave_write(hub->upstream->slave, + FSI_SLAVE_BASE + FSI_SRSIM0 + slave_idx, &srsim_be, + sizeof(srsim_be)); + if (ret) + return ret; + + ret = fsi_master_link_enable(master, link, enable); + } + + return ret; +} + +static irqreturn_t hub_master_irq(int irq, void *data) +{ + struct fsi_master_hub *hub = data; + struct fsi_master *parent = hub->upstream->slave->master; + unsigned int link = 0; + + for (; link < FSI_HUB_MASTER_MAX_LINKS; ++link) { + if (parent->remote_interrupt_status & (1 << link)) + fsi_master_irq(&hub->master, hub->irq_domain, link); + } + + return IRQ_HANDLED; +} + +static int hub_master_irqd_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + struct fsi_master_hub *hub = domain->host_data; + + irq_set_chip_and_handler(irq, &hub->master.irq_chip, handle_simple_irq); + irq_set_chip_data(irq, &hub->master); + + return 0; +} + +static const struct irq_domain_ops hub_master_irq_domain_ops = { + .map = hub_master_irqd_map, +}; + static void hub_master_release(struct device *dev) { struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev)); + if (hub->irq_domain) + irq_domain_remove(hub->irq_domain); + regmap_exit(hub->master.map); kfree(hub); } @@ -135,6 +209,7 @@ static int hub_master_probe(struct device *dev) hub->master.read = hub_master_read; hub->master.write = hub_master_write; hub->master.send_break = hub_master_break; + hub->master.link_enable = hub_master_link_enable; dev_set_drvdata(dev, hub); @@ -142,9 +217,44 @@ static int hub_master_probe(struct device *dev) if (rc) goto err_free; + if (of_property_read_bool(dev->of_node, "interrupt-controller")) { + struct device_node *parent = of_irq_find_parent(dev->of_node); + + if (parent) { + struct irq_fwspec fwspec; + unsigned int irq; + + fwspec.fwnode = of_node_to_fwnode(parent); + fwspec.param_count = 1; + fwspec.param[0] = (fsi_dev->slave->link * FSI_IRQ_COUNT) + 8; + irq = irq_create_fwspec_mapping(&fwspec); + if (irq) { + unsigned int size = links * FSI_IRQ_COUNT; + + hub->irq_domain = irq_domain_add_linear(dev->of_node, size, + &hub_master_irq_domain_ops, + hub); + + if (hub->irq_domain) { + rc = devm_request_irq(dev, irq, hub_master_irq, 0, + dev_name(dev), hub); + if (rc) { + dev_warn(dev, "failed to request irq:%u\n", irq); + irq_domain_remove(hub->irq_domain); + hub->irq_domain = NULL; + } else { + dev_info(dev, "enabling interrupts irq:%u\n", irq); + } + } else { + dev_warn(dev, "failed to create irq domain\n"); + } + } + } + } + rc = fsi_master_register(&hub->master); if (rc) - goto err_free; + goto err_irq; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -156,6 +266,9 @@ static int hub_master_probe(struct device *dev) get_device(&hub->master.dev); return 0; +err_irq: + if (hub->irq_domain) + irq_domain_remove(hub->irq_domain); err_free: kfree(hub); err_release: From patchwork Wed Jun 5 21:22:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687547 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 D669316131C; Wed, 5 Jun 2024 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=K00EmK7QJ3voTOqtS8KfcwTzH6tpuVxOSBfflY2SHx9tBbARp0KyG6x98SZE4z3syvMGkHavGBZhGd+J55/uHsl77A6rm/A+ERUZi3G9TabSsMyFXdA3TuSy+bR6J87gXRoOv4uHcOL7MSxsMudQemjIC1G1WSG8ypCWniRKJRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=VhedKvPFFiUAnj/wYMChhGaaPqdpO862oYKVIuAtwT8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oJ6yBVein3ssGW5tQW6blaJI7yACDJaZcwE/cYE/i66rKeRnW4x31gU14tvrtWfXzmk6e47y8Mkt2BgIuu8CVbSwWojO75iwL0AsCPB1eCrWeri5rLWt3Fp2YQCP2lxnhVcMfRVvOUn30503JLp3cU1SrrH49+okUwhNK5ulJ/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=o5ku3jlD; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="o5ku3jlD" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LC7nl011974; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=n2ELCBKlduOnR5wTkTQugicJX8taWF2bAtKMB7UJJcw=; b=o5ku3jlDKGnNpkYTseiN9vGHPln5AmkJc9bNvPHIFr9vVa9sJoN5hWHuUG+B6IB1A//t DQ+tw/tIvHh/uBH/GRgf9Ohk+jpgGhd2uc1gXM9kf+J0b/JEP/skiXNTDu+0PqHVYsw6 57H28QZQbmGjWxBcbkNqqPyBzQorDDNu4XNofJMhBxLUHnRjfiNSBCN1IAOH3WLVzyUh tlY7NHhZQkZ9DgJSMv3oR5BvJKy0FMPmchqp09cTt4qaPbV53er7aF7lsLffEflccJbq MJuDW7M5iXRSnDoaxTxf3n7OoU5yoRfnCRxbVPjO0qD/bbNbgroiBOw8eBE4v80cmyR7 hw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IMrJS008468; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNLdK11797064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 465E158068; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 09EBF5806A; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:20 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 26/40] i2c: fsi: Calculate clock divider from local bus frequency Date: Wed, 5 Jun 2024 16:22:58 -0500 Message-Id: <20240605212312.349188-27-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: qOMgNStxmKtiBcL3iSuT9syNUUV56CE1 X-Proofpoint-ORIG-GUID: qOMgNStxmKtiBcL3iSuT9syNUUV56CE1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=973 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Use the new FSI device local bus clock to calculate the proper i2c clock divder and look up an optional clock-frequency property from device tree. Change the default clock divider to 7 now that the default local bus clock divider has been reduced as well. Signed-off-by: Eddie James --- Changes since v2: - Change minimum clock div to 3 - Use DIV_ROUND_UP instead of re-implementing it - Better logic for checking for clock-frequency property drivers/i2c/busses/i2c-fsi.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 10332693edf0d..2404ace8c56fa 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -27,7 +27,8 @@ #define FSI_ENGID_I2C 0x7 -#define I2C_DEFAULT_CLK_DIV 6 +#define I2C_DEFAULT_CLK_DIV 7 +#define I2C_DEFAULT_CLK_RATE 400000 /* i2c registers */ #define I2C_FSI_FIFO 0x00 @@ -150,6 +151,7 @@ struct fsi_i2c_master { u8 fifo_size; struct list_head ports; struct mutex lock; + u32 clock_div; }; struct fsi_i2c_port { @@ -194,7 +196,7 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) if (rc) return rc; - mode |= FIELD_PREP(I2C_MODE_CLKDIV, I2C_DEFAULT_CLK_DIV); + mode |= FIELD_PREP(I2C_MODE_CLKDIV, i2c->clock_div); rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); if (rc) return rc; @@ -680,6 +682,7 @@ static int fsi_i2c_probe(struct device *dev) struct fsi_i2c_port *port; struct device_node *np; u32 port_no, ports, stat; + u32 lbus; int rc; i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); @@ -689,6 +692,19 @@ static int fsi_i2c_probe(struct device *dev) mutex_init(&i2c->lock); i2c->fsi = to_fsi_dev(dev); INIT_LIST_HEAD(&i2c->ports); + i2c->clock_div = I2C_DEFAULT_CLK_DIV; + + lbus = fsi_device_local_bus_frequency(i2c->fsi); + if (lbus) { + u32 clock; + + if (device_property_read_u32(dev, "clock-frequency", &clock) || !clock) + clock = I2C_DEFAULT_CLK_RATE; + + i2c->clock_div = DIV_ROUND_UP(DIV_ROUND_UP(lbus, clock), 4) - 1; + if (i2c->clock_div <= 2) + i2c->clock_div = 3; + } rc = fsi_i2c_dev_init(i2c); if (rc) From patchwork Wed Jun 5 21:22:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687554 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 83207167299; Wed, 5 Jun 2024 21:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622623; cv=none; b=KDiLiFncSxoR/D0pjZEeapFsxuMMnF9HZMX+RQpGC4YlRCv/64zChTauPhmFw2aFiZD8IaOUtPiRjyhap8xLLgn2uQsUD7zG9tWcUzK/2RwNxuBlMwHUubDnOrLJ2mKZTxDXGtxKTP88BIzsJb9vF3W+QPaL1eRokZZGXVj912U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622623; c=relaxed/simple; bh=V7YtsL0df7QZ2fCW8ovj+jSPEIs0M575sgx8iNcYOWk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PDrlCrJokwTTcaJlqttC/wE1Z7JDpAn90H8nJ4JeCna/3mBpTZPG7zGcWzQ567LHJBthWCugEyAd7B2UbsdFPcF7Qx2coJwcPo5PIuYGlBs3YeE7wHEfzQo9bxPMSdX/9z8kE5ph3uWIijZ5xdhuMhjrBy3QCVwwKLQ0sLciyks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ks+NI1C6; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ks+NI1C6" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LK8d8026571; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=sExpzqDawVL7Dn962NZ99fpWpjztnGoo0REU8wYGdnY=; b=ks+NI1C6uCGlpRYlznESObdhJDiuf59OhDSq8d1a0Rfa0mVJjBQPpAvSmIAQCZi9bu8W f8LHDCN5pwlIpqqlcs5eR9cbU+hswTpcoKoSOKccwRDoFbnRdoAjuD2Yl6CZ52qVbqkj +BBJBVgQ8bZnCxoCUo6FkNphLCFVz34W52zWEF2iPPSMEcj7Mj3LyHtcTrVn4cOENOSo 3mCGmfYkXlx1u0eFBw5ZGi8X3Qc3R50r4Pl4Iy7aLVZqM02sdcRPHIsDel69A2O/ExMd N8bk+TwVfJ48r6d3s4Naz/IVRGqzvI1tbGgbFnFQpW+9J/2RwYiie4SwRFjfVg/2gNHt Lg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455K5KDA026671; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffn6hhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNLFO24183380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:23 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9286558066; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D6BE5806B; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 27/40] i2c: fsi: Improve formatting Date: Wed, 5 Jun 2024 16:22:59 -0500 Message-Id: <20240605212312.349188-28-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: P7eu08QAOub-E0MYTLx5CmgJkYMXnczj X-Proofpoint-GUID: P7eu08QAOub-E0MYTLx5CmgJkYMXnczj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 No functional change. Remove holes in the master structure. Re-order local variables to look pretty. Remove some local variables in favor of using their containing structure. Signed-off-by: Eddie James --- Changes since v2: - Add detail to commit message. drivers/i2c/busses/i2c-fsi.c | 125 +++++++++++++++++------------------ 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 2404ace8c56fa..8fb5b51b74a4d 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -148,10 +148,10 @@ struct fsi_i2c_master { struct fsi_device *fsi; - u8 fifo_size; struct list_head ports; struct mutex lock; u32 clock_div; + u8 fifo_size; }; struct fsi_i2c_port { @@ -165,15 +165,14 @@ struct fsi_i2c_port { static int fsi_i2c_read_reg(struct fsi_device *fsi, unsigned int reg, u32 *data) { - int rc; __be32 data_be; + int rc; rc = fsi_device_read(fsi, reg, &data_be, sizeof(data_be)); if (rc) return rc; *data = be32_to_cpu(data_be); - return 0; } @@ -187,9 +186,11 @@ static int fsi_i2c_write_reg(struct fsi_device *fsi, unsigned int reg, static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) { - int rc; - u32 mode = I2C_MODE_ENHANCED, extended_status, watermark; + u32 mode = I2C_MODE_ENHANCED; + u32 extended_status; u32 interrupt = 0; + u32 watermark; + int rc; /* since we use polling, disable interrupts */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, &interrupt); @@ -215,9 +216,10 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) static int fsi_i2c_set_port(struct fsi_i2c_port *port) { - int rc; struct fsi_device *fsi = port->master->fsi; - u32 mode, dummy = 0; + u32 dummy = 0; + u32 mode; + int rc; rc = fsi_i2c_read_reg(fsi, I2C_FSI_MODE, &mode); if (rc) @@ -238,7 +240,6 @@ static int fsi_i2c_set_port(struct fsi_i2c_port *port) static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, bool stop) { - struct fsi_i2c_master *i2c = port->master; u32 cmd = I2C_CMD_WITH_START | I2C_CMD_WITH_ADDR; port->xfrd = 0; @@ -252,7 +253,7 @@ static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, cmd |= FIELD_PREP(I2C_CMD_ADDR, msg->addr); cmd |= FIELD_PREP(I2C_CMD_LEN, msg->len); - return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); + return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, &cmd); } static int fsi_i2c_get_op_bytes(int op_bytes) @@ -268,18 +269,17 @@ static int fsi_i2c_get_op_bytes(int op_bytes) static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, u8 fifo_count) { + int bytes_to_write = port->master->fifo_size - fifo_count; + int bytes_remaining = msg->len - port->xfrd; int write; int rc; - struct fsi_i2c_master *i2c = port->master; - int bytes_to_write = i2c->fifo_size - fifo_count; - int bytes_remaining = msg->len - port->xfrd; bytes_to_write = min(bytes_to_write, bytes_remaining); while (bytes_to_write) { write = fsi_i2c_get_op_bytes(bytes_to_write); - rc = fsi_device_write(i2c->fsi, I2C_FSI_FIFO, + rc = fsi_device_write(port->master->fsi, I2C_FSI_FIFO, &msg->buf[port->xfrd], write); if (rc) return rc; @@ -294,12 +294,11 @@ static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, u8 fifo_count) { - int read; - int rc; - struct fsi_i2c_master *i2c = port->master; - int bytes_to_read; int xfr_remaining = msg->len - port->xfrd; + int bytes_to_read; u32 dummy; + int read; + int rc; bytes_to_read = min_t(int, fifo_count, xfr_remaining); @@ -307,7 +306,7 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, read = fsi_i2c_get_op_bytes(bytes_to_read); if (xfr_remaining) { - rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, + rc = fsi_device_read(port->master->fsi, I2C_FSI_FIFO, &msg->buf[port->xfrd], read); if (rc) return rc; @@ -316,8 +315,8 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, xfr_remaining -= read; } else { /* no more buffer but data in fifo, need to clear it */ - rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, &dummy, - read); + rc = fsi_device_read(port->master->fsi, I2C_FSI_FIFO, + &dummy, read); if (rc) return rc; } @@ -330,85 +329,80 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_get_scl(struct i2c_adapter *adap) { - u32 stat = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 stat; - fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); + fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); return !!(stat & I2C_STAT_SCL_IN); } static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { - u32 dummy = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 dummy = 0; if (val) - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, &dummy); else - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, &dummy); } static int fsi_i2c_get_sda(struct i2c_adapter *adap) { - u32 stat = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 stat; - fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); + fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); return !!(stat & I2C_STAT_SDA_IN); } static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { - u32 dummy = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 dummy = 0; if (val) - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, &dummy); else - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, &dummy); } static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) { - int rc; - u32 mode; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 mode; + int rc; - rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_MODE, &mode); if (rc) return; mode |= I2C_MODE_DIAG; - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); } static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) { - int rc; - u32 mode; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 mode; + int rc; - rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_MODE, &mode); if (rc) return; mode &= ~I2C_MODE_DIAG; - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); } static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, struct fsi_i2c_port *port) { + u32 dummy = 0; + u32 stat; int rc; - u32 stat, dummy = 0; /* force bus reset, ignore errors */ i2c_recover_bus(&port->adapter); @@ -439,8 +433,9 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) { + u32 dummy = 0; + u32 mode; int rc; - u32 mode, dummy = 0; /* reset engine */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); @@ -476,18 +471,17 @@ static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) { - int rc; - unsigned long start; + struct fsi_i2c_master *i2c = port->master; u32 cmd = I2C_CMD_WITH_STOP; + unsigned long start; u32 stat; - struct fsi_i2c_master *i2c = port->master; - struct fsi_device *fsi = i2c->fsi; + int rc; rc = fsi_i2c_reset_engine(i2c, port->port); if (rc) return rc; - rc = fsi_i2c_read_reg(fsi, I2C_FSI_STAT, &stat); + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); if (rc) return rc; @@ -503,15 +497,14 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return 0; /* write stop command */ - rc = fsi_i2c_write_reg(fsi, I2C_FSI_CMD, &cmd); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); if (rc) return rc; /* wait until we see command complete in the master */ start = jiffies; - do { - rc = fsi_i2c_read_reg(fsi, I2C_FSI_STAT, &status); + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &status); if (rc) return rc; @@ -527,8 +520,8 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) static int fsi_i2c_handle_status(struct fsi_i2c_port *port, struct i2c_msg *msg, u32 status) { - int rc; u8 fifo_count; + int rc; if (status & I2C_STAT_ERR) { rc = fsi_i2c_abort(port, status); @@ -576,9 +569,9 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, unsigned long timeout) { - u32 status = 0; - int rc; unsigned long start = jiffies; + u32 status; + int rc; do { rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, @@ -608,13 +601,13 @@ static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - int i, rc; - unsigned long start_time; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *master = port->master; + unsigned long start_time; struct i2c_msg *msg; + int rc; + int i; - mutex_lock(&master->lock); + mutex_lock(&port->master->lock); rc = fsi_i2c_set_port(port); if (rc) @@ -635,7 +628,7 @@ static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } unlock: - mutex_unlock(&master->lock); + mutex_unlock(&port->master->lock); return rc ? : num; } @@ -681,8 +674,10 @@ static int fsi_i2c_probe(struct device *dev) struct fsi_i2c_master *i2c; struct fsi_i2c_port *port; struct device_node *np; - u32 port_no, ports, stat; + u32 port_no; + u32 ports; u32 lbus; + u32 stat; int rc; i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); @@ -752,14 +747,14 @@ static int fsi_i2c_probe(struct device *dev) } dev_set_drvdata(dev, i2c); - return 0; } static int fsi_i2c_remove(struct device *dev) { struct fsi_i2c_master *i2c = dev_get_drvdata(dev); - struct fsi_i2c_port *port, *tmp; + struct fsi_i2c_port *port; + struct fsi_i2c_port *tmp; list_for_each_entry_safe(port, tmp, &i2c->ports, list) { list_del(&port->list); From patchwork Wed Jun 5 21:23:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687560 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 AAA4016D328; Wed, 5 Jun 2024 21:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; cv=none; b=nsN5O4XeSNL2MWH1rOvj6LVzbykohmMKmwCyYF7foe2IFPZ7lG3RmK+9XTuqIWSpne5b1Y1SSrxx837JDwi9Cox6y8Qo7IbZuR6fOTzooGOB6X6rW/gTArqIkk5cTGN9tUqEAEIO3IlluJyTRSuahhsj9+OzqU7gLDtiNjnaktY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; c=relaxed/simple; bh=taayyPbBzq9s4gsXkzK7pwa6dRU73kwY4qlC+hFgKzI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f9ttbUEzl5fLirsLtA8aUJJt4T8dmaGemnxwYRjuZiuEDx+QhPHquBGotFdAjknVn1H53CbcsLRDXvrYepOWW4mJlWA4jkJ5pRO3aERszRKJMxwaYW5LS5I/cGTSMJfmAgk10MEM4N9Ef4qzsD11XDWlul2LcBJ/54w0as2WqCA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=BE1Xhe3L; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="BE1Xhe3L" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KKjgj025691; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=/RkWhEH9F+VLK6oub9BZ8DLGrII8B8mgaOhr5sMt70k=; b=BE1Xhe3L5HtD3whcjoxJF0Z3ist4hD3UqE1GIXy3b4rkFQmbOwXzbP243pYGGLAWMCbW Dm/cFY82+DP5eLockcahREZGOhin1p+RTppFexXTx2SpR4R62NzuWA2R8pct8bDuQtrp j7iOaGX3xCrnbqTF6ScAMsmXaIh7CLMvkicZvJidbhceNgFfyY9rEQZgzn2BjAMVWkuf rnyUKuN+JLzc6S8JhBv/hhnUgbTVvGvngB7EjbU6BV4s031oqzrVuBZv+Qyog+R7URF+ jgcvOLOQn9xfHHJQrSeSCNprB4mDCfx21AkxO3/qZZ0BPHE13E3+65fD7NoNSc0gaFgA 4Q== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IH3fe000820; Wed, 5 Jun 2024 21:23:24 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:24 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNL1d14418620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D57A458043; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98E265806A; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 28/40] i2c: fsi: Change fsi_i2c_write_reg to accept data instead of a pointer Date: Wed, 5 Jun 2024 16:23:00 -0500 Message-Id: <20240605212312.349188-29-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RQ8-P0mjnnq9GGWzEBj8agSSXFEo1q-Y X-Proofpoint-GUID: RQ8-P0mjnnq9GGWzEBj8agSSXFEo1q-Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=970 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 There's no use passing a pointer here. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 8fb5b51b74a4d..44aa750278100 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -177,9 +177,9 @@ static int fsi_i2c_read_reg(struct fsi_device *fsi, unsigned int reg, } static int fsi_i2c_write_reg(struct fsi_device *fsi, unsigned int reg, - u32 *data) + u32 data) { - __be32 data_be = cpu_to_be32p(data); + __be32 data_be = cpu_to_be32(data); return fsi_device_write(fsi, reg, &data_be, sizeof(data_be)); } @@ -188,17 +188,16 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) { u32 mode = I2C_MODE_ENHANCED; u32 extended_status; - u32 interrupt = 0; u32 watermark; int rc; /* since we use polling, disable interrupts */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, &interrupt); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, 0); if (rc) return rc; mode |= FIELD_PREP(I2C_MODE_CLKDIV, i2c->clock_div); - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, mode); if (rc) return rc; @@ -211,13 +210,12 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) i2c->fifo_size - I2C_FIFO_HI_LVL); watermark |= FIELD_PREP(I2C_WATERMARK_LO, I2C_FIFO_LO_LVL); - return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_WATER_MARK, &watermark); + return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_WATER_MARK, watermark); } static int fsi_i2c_set_port(struct fsi_i2c_port *port) { struct fsi_device *fsi = port->master->fsi; - u32 dummy = 0; u32 mode; int rc; @@ -229,12 +227,12 @@ static int fsi_i2c_set_port(struct fsi_i2c_port *port) return 0; mode = (mode & ~I2C_MODE_PORT) | FIELD_PREP(I2C_MODE_PORT, port->port); - rc = fsi_i2c_write_reg(fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(fsi, I2C_FSI_MODE, mode); if (rc) return rc; /* reset engine when port is changed */ - return fsi_i2c_write_reg(fsi, I2C_FSI_RESET_ERR, &dummy); + return fsi_i2c_write_reg(fsi, I2C_FSI_RESET_ERR, 0); } static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, @@ -253,7 +251,7 @@ static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, cmd |= FIELD_PREP(I2C_CMD_ADDR, msg->addr); cmd |= FIELD_PREP(I2C_CMD_LEN, msg->len); - return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, &cmd); + return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, cmd); } static int fsi_i2c_get_op_bytes(int op_bytes) @@ -340,12 +338,11 @@ static int fsi_i2c_get_scl(struct i2c_adapter *adap) static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { struct fsi_i2c_port *port = adap->algo_data; - u32 dummy = 0; if (val) - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, 0); else - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, 0); } static int fsi_i2c_get_sda(struct i2c_adapter *adap) @@ -361,12 +358,11 @@ static int fsi_i2c_get_sda(struct i2c_adapter *adap) static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { struct fsi_i2c_port *port = adap->algo_data; - u32 dummy = 0; if (val) - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, 0); else - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, 0); } static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) @@ -380,7 +376,7 @@ static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) return; mode |= I2C_MODE_DIAG; - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, mode); } static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) @@ -394,13 +390,12 @@ static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) return; mode &= ~I2C_MODE_DIAG; - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, mode); } static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, struct fsi_i2c_port *port) { - u32 dummy = 0; u32 stat; int rc; @@ -408,7 +403,7 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, i2c_recover_bus(&port->adapter); /* reset errors */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, 0); if (rc) return rc; @@ -423,7 +418,7 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, return 0; /* failed to get command complete; reset engine again */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, 0); if (rc) return rc; @@ -433,12 +428,11 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) { - u32 dummy = 0; u32 mode; int rc; /* reset engine */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, 0); if (rc) return rc; @@ -455,14 +449,13 @@ static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) if (port) { mode &= ~I2C_MODE_PORT; mode |= FIELD_PREP(I2C_MODE_PORT, port); - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, mode); if (rc) return rc; } /* reset busy register; hw workaround */ - dummy = I2C_PORT_BUSY_RESET; - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_PORT_BUSY, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_PORT_BUSY, I2C_PORT_BUSY_RESET); if (rc) return rc; @@ -497,7 +490,7 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return 0; /* write stop command */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, cmd); if (rc) return rc; From patchwork Wed Jun 5 21:23:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687551 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 50E1416192D; Wed, 5 Jun 2024 21:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; cv=none; b=gOki69COySTJxFIFxQBCEkjDir3lqUXITgxip2fgii3TF6J3dQjokLbAzHEt+LLIdYhqjnEU2zYK8qapP95XczOc5AFvASeBJnPl4atngRhQCpeOUPH9hBHhIzHnzKEp+HmQfQYCzd866kR6lgDu8u+KTn+Omwp/lFjToWR1Rgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; c=relaxed/simple; bh=p7IE1f7B3E4HXLYKDsiggW4zvHAZ9T9oqWSSmLtsBtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BfczUL/0S8G57huVg6N1ToyRaOOuu2rdCX5fNiONZ1zIq+VgE1OcXHtDVnFCZ4mXAPJaDDPoNIqA2VbsjpfbDpBIw42oit3HoHrav1Ttyz/BQb7GyAkCAzJpSxtVWz1C91zZdVBOT798EEAV/xglckp0Y0otjvg+NIKa70fAZHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=I5DLkfUE; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="I5DLkfUE" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KvCZp013933; Wed, 5 Jun 2024 21:23:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=6pwGrpGa/9FUM1RJLI4c4OWS/mHbmuo48TsghubX0+s=; b=I5DLkfUE4u5IcJHzxz9ruTvrBKV8DpAPJ0I4VvwEOQFmUjNiFhOVNeLu6EvHSM4PGQse TZaMneqVG+dGNpOQHRur+yw5taBugkeIDRlE98Dlrei/uB6Wp+WOP1ToRtNGVcvTDhXZ wCeHNxcmHQfrEHk28tuh8hkXLntj2isM+mZIAPbyDfVA0dUHqzl6+a0hWwjMyMzfG5QD CR35GxWPK97aaqPjn+UfhXq1K32Ggxf1NXLvO6n8H1xvbo///L6CwXNKg9CoQefWYZho JXnzzg9H4h32hZITahnmFuVyxSIGCewxAuTTpB5ffdZ5cyHya87FlrzsRp4qts9kkMt0 BA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygp81uj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JVcNJ031129; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNMMr63373712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25F5158069; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCCDA58063; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:21 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 29/40] i2c: fsi: Remove list structure of ports Date: Wed, 5 Jun 2024 16:23:01 -0500 Message-Id: <20240605212312.349188-30-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: bZdKl0u6-FzW7c0GBFM5rWEosqz9SKV- X-Proofpoint-ORIG-GUID: bZdKl0u6-FzW7c0GBFM5rWEosqz9SKV- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Maintaining a list of ports is unnecessary since they can be managed with the device resource framework. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 44 +++++++++--------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 44aa750278100..f3b97bf88d0f9 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -148,14 +147,12 @@ struct fsi_i2c_master { struct fsi_device *fsi; - struct list_head ports; struct mutex lock; u32 clock_div; u8 fifo_size; }; struct fsi_i2c_port { - struct list_head list; struct i2c_adapter adapter; struct fsi_i2c_master *master; u16 port; @@ -327,7 +324,7 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_get_scl(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 stat; fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); @@ -337,7 +334,7 @@ static int fsi_i2c_get_scl(struct i2c_adapter *adap) static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); if (val) fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, 0); @@ -347,7 +344,7 @@ static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) static int fsi_i2c_get_sda(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 stat; fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); @@ -357,7 +354,7 @@ static int fsi_i2c_get_sda(struct i2c_adapter *adap) static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); if (val) fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, 0); @@ -367,7 +364,7 @@ static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 mode; int rc; @@ -381,7 +378,7 @@ static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 mode; int rc; @@ -594,7 +591,7 @@ static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); unsigned long start_time; struct i2c_msg *msg; int rc; @@ -679,7 +676,6 @@ static int fsi_i2c_probe(struct device *dev) mutex_init(&i2c->lock); i2c->fsi = to_fsi_dev(dev); - INIT_LIST_HEAD(&i2c->ports); i2c->clock_div = I2C_DEFAULT_CLK_DIV; lbus = fsi_device_local_bus_frequency(i2c->fsi); @@ -705,38 +701,30 @@ static int fsi_i2c_probe(struct device *dev) ports = FIELD_GET(I2C_STAT_MAX_PORT, stat) + 1; dev_dbg(dev, "I2C master has %d ports\n", ports); - for (port_no = 0; port_no < ports; port_no++) { + port = devm_kzalloc(dev, sizeof(*port) * ports, GFP_KERNEL); + for (port_no = 0; port_no < ports; port_no++, port++) { np = fsi_i2c_find_port_of_node(dev->of_node, port_no); if (!of_device_is_available(np)) continue; - port = kzalloc(sizeof(*port), GFP_KERNEL); - if (!port) { - of_node_put(np); - break; - } - port->master = i2c; port->port = port_no; + i2c_set_adapdata(&port->adapter, port); port->adapter.owner = THIS_MODULE; port->adapter.dev.of_node = np; port->adapter.dev.parent = dev; port->adapter.algo = &fsi_i2c_algorithm; port->adapter.bus_recovery_info = &fsi_i2c_bus_recovery_info; - port->adapter.algo_data = port; snprintf(port->adapter.name, sizeof(port->adapter.name), "i2c_bus-%u", port_no); - rc = i2c_add_adapter(&port->adapter); + rc = devm_i2c_add_adapter(dev, &port->adapter); if (rc < 0) { dev_err(dev, "Failed to register adapter: %d\n", rc); - kfree(port); continue; } - - list_add(&port->list, &i2c->ports); } dev_set_drvdata(dev, i2c); @@ -745,16 +733,6 @@ static int fsi_i2c_probe(struct device *dev) static int fsi_i2c_remove(struct device *dev) { - struct fsi_i2c_master *i2c = dev_get_drvdata(dev); - struct fsi_i2c_port *port; - struct fsi_i2c_port *tmp; - - list_for_each_entry_safe(port, tmp, &i2c->ports, list) { - list_del(&port->list); - i2c_del_adapter(&port->adapter); - kfree(port); - } - return 0; } From patchwork Wed Jun 5 21:23:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687546 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 C42C8161308; Wed, 5 Jun 2024 21:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; cv=none; b=amlBFFmX2l/4/wO1HOZGqNYTXIEnVq8eXiGotTXOPLlsKMigqfbbQl/O0zcSigCKnMwoGb471Ht93EwoC4+bwz2g00k955o7omTu1XQ97ZMf2KDuxnHVD0HzAqCNGIqaoTsa9nUbNbA0YOecG0pSJJKsb7yqQQ9CLBrE+DZ4+x8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622621; c=relaxed/simple; bh=Go/Sw2mfEMY8QsnrCy8Zm/3ksaghSmu3WnFOYYCPdrQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X0F0ClN/ObYC5UV1tKxvfHuChL0XfOQd8DV7MsUsV3ipY7zINK4PTPnvOjWZj6Q4JsIJ7fJSZGGuZY/eDduPKL/mOPUyKV8T9pgQLJbp66caZsBrIU6w5u2Vy2wJV7Mgijlzi00fONwnkCtdQ+SfahFjlxQmJlW3B6f2Ec9cbvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=bZIAPUDX; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bZIAPUDX" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KKjXd025682; Wed, 5 Jun 2024 21:23:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=VVh0pOteeIri9qqbCA+sDhPXPbv1rTPqRDlFd5iwUgU=; b=bZIAPUDXFYmgTFtCfDv9tEDVvUj6CmYgYvE/7YWCivsVTzkCYsCopRFTTMaEsvCVoJoe +d6h5Izah7nlyXWIHXtPUwzKrHP5m99aE8RO5oJOmFMR5iaLxPGBLm1xph9MVxVYYNkW ywZ5Fn+uQWEhWtfHJ6/c9p2Db5XLgoQLtTAHWT3c5xyT4joiM6MZiYRgQUxe0CymqjnE NJ6yDlb34unaIJld6jTZrrQsR4qJbuCaTODjEoxHhRcJXQPdJZEawgRu1hIPZ4Wsig+0 3yLBFfYRObbednuK3gEEJMINFhFPKOld5AzoDgxxUXP1pnlVoKgWSaZf6K5v5/nd65ho MA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455LKNJ5008463; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNMRD48103912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A02558055; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C8415806A; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 30/40] i2c: fsi: Define a function to check status error bits Date: Wed, 5 Jun 2024 16:23:02 -0500 Message-Id: <20240605212312.349188-31-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: uIQ3lo8aMA4Sveu7X7k3F3_3kcFfPMRd X-Proofpoint-GUID: uIQ3lo8aMA4Sveu7X7k3F3_3kcFfPMRd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=914 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 This will be used more than once with interrupt support, so split the error bit checks into a function. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index f3b97bf88d0f9..022f1287aa0e3 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -507,6 +507,26 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return -ETIMEDOUT; } +static int fsi_i2c_error_status_to_rc(u32 status) +{ + if (status & I2C_STAT_INV_CMD) + return -EINVAL; + + if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | I2C_STAT_BE_ACCESS)) + return -EPROTO; + + if (status & I2C_STAT_NACK) + return -ENXIO; + + if (status & I2C_STAT_LOST_ARB) + return -EAGAIN; + + if (status & I2C_STAT_STOP_ERR) + return -EBADMSG; + + return -EIO; +} + static int fsi_i2c_handle_status(struct fsi_i2c_port *port, struct i2c_msg *msg, u32 status) { @@ -518,23 +538,7 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, if (rc) return rc; - if (status & I2C_STAT_INV_CMD) - return -EINVAL; - - if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | - I2C_STAT_BE_ACCESS)) - return -EPROTO; - - if (status & I2C_STAT_NACK) - return -ENXIO; - - if (status & I2C_STAT_LOST_ARB) - return -EAGAIN; - - if (status & I2C_STAT_STOP_ERR) - return -EBADMSG; - - return -EIO; + return fsi_i2c_error_status_to_rc(status); } if (status & I2C_STAT_DAT_REQ) { From patchwork Wed Jun 5 21:23:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687549 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 1CF49161338; Wed, 5 Jun 2024 21:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; cv=none; b=Ynv4LqAGMSLsfaYz3p0jKjXkZVUG80X2mh97LRQawVCg53klmFRJ2A/7N8nOCRfthxTP0aYvmHcxxEJ9H5Ufq7nte61yRAgIET5TtBf6OBu3HRAEHla9IugVrLWYyKz00XFFBSwe8otFMdCCjlFzfbZRG+fEHya48nMziYYcSvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; c=relaxed/simple; bh=X1ZPTS2YGQm53cxlgKYe1PLkwaNISkZBsXhdru69tw0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FfrUbYHHg3822nS3bQrQMCnujx2AeUXPYi5YQoVf4frbxMOEOTnS1C9Q/jjsrgTgkwHIdlHgWtqPh47uNC6gRLf/XEjzIFaIVUqFJEACEG3j8tObcmB1U0eiVGNcAB6pJKxG29O0+UKsCT+12uqkg+4Xi2juvX0wmuIZW7rNIiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=LFmwXbUk; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="LFmwXbUk" Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L0M6C020105; Wed, 5 Jun 2024 21:23:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=tzPFGbo6X3zcNdVJFT3Zq8NM38ZKt/TD8N6qjoX5nmY=; b=LFmwXbUkLDUlqMUbh43BLVJmYJwm3u95qeXYHqRRrIyklKO3Q3Dy29ZWBaX/WP1Nx842 6OC/TFd9N0t8dQT0OH3wx5FDB428MgnQEIMk7z1kKuL202EMW7bG/kXmJa3/a3M0UsJe W8M3o8mcUUbk9GjmxVDuPUbXZMFfmYPoChhQqEAfP8cDWEhEHpzElNWkjEkX39YGaXeU BjeTQpPFpblLOFvFJN34xEgL4iH2baUtJWJOznXr50geBvWrq0zv2nJZjRAB17JIxCZz /jMUpUZzInQ+gCkhibXU0/mgx9lcYw9wmyYXdw96PWdmF3Zx1XaqiDIUGpXR4fxMPv4P 0A== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyhyr1n0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455LKarG026550; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366fn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNMSL62390660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE5FB58059; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70E2958063; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 31/40] i2c: fsi: Add boolean for skip stop command on abort Date: Wed, 5 Jun 2024 16:23:03 -0500 Message-Id: <20240605212312.349188-32-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yW79Vq_Nf2d9DiF3iPLrnYOgWUy5xVNM X-Proofpoint-GUID: yW79Vq_Nf2d9DiF3iPLrnYOgWUy5xVNM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 malwarescore=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 In preparation for interrupt support, store whether to skip the final stop command during the abort procedure instead of checking the previously read status register in the abort function. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 022f1287aa0e3..614d830419bb8 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -116,6 +116,9 @@ #define I2C_STAT_ANY_RESP (I2C_STAT_ERR | \ I2C_STAT_DAT_REQ | \ I2C_STAT_CMD_COMP) +#define I2C_STAT_SKIP_STOP (I2C_STAT_PARITY | \ + I2C_STAT_LOST_ARB | \ + I2C_STAT_STOP_ERR) /* extended status register */ #define I2C_ESTAT_FIFO_SZ GENMASK(31, 24) @@ -150,6 +153,7 @@ struct fsi_i2c_master { struct mutex lock; u32 clock_div; u8 fifo_size; + bool skip_stop; }; struct fsi_i2c_port { @@ -459,31 +463,30 @@ static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) return 0; } -static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) +static int fsi_i2c_abort(struct fsi_i2c_port *port) { struct fsi_i2c_master *i2c = port->master; u32 cmd = I2C_CMD_WITH_STOP; unsigned long start; - u32 stat; + u32 status; int rc; rc = fsi_i2c_reset_engine(i2c, port->port); if (rc) return rc; - rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &status); if (rc) return rc; /* if sda is low, peform full bus reset */ - if (!(stat & I2C_STAT_SDA_IN)) { + if (!(status & I2C_STAT_SDA_IN)) { rc = fsi_i2c_reset_bus(i2c, port); if (rc) return rc; } - /* skip final stop command for these errors */ - if (status & (I2C_STAT_PARITY | I2C_STAT_LOST_ARB | I2C_STAT_STOP_ERR)) + if (i2c->skip_stop) return 0; /* write stop command */ @@ -534,7 +537,8 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, int rc; if (status & I2C_STAT_ERR) { - rc = fsi_i2c_abort(port, status); + port->master->skip_stop = status & I2C_STAT_SKIP_STOP; + rc = fsi_i2c_abort(port); if (rc) return rc; From patchwork Wed Jun 5 21:23:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687569 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 E4BB816D9A1; Wed, 5 Jun 2024 21:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=Qjpq5vkGKYgOV7VjGq85N8aUJiHNZjhV/H+Z+iUAMQC2S3/XCyr0R0GQNNecg55L1lG7bx9eJqFDXTQkohROdFtCZ7SFGrFGSuNDCByIQRoObN9kMJOvAaz11EQQnQP3N59I86OJ6Osfv62YxsaGJ+Rb5ogHOWh5y6VuK4CLq/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=Vc/Ctrqo5sSCNIMESKkxnmoeauNn4qTseHw+BxaGLyU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OZ5NX5MKig/C5IomdfPVgep6bZR3T6bWLHsr2uYSP2NWMQYazQGBZ/NpQ7z4COBWCnE6koP7ELSP9flCpqAfycs+VMSXuTKtxjoloKh7QLMI5pXso9p7fLdtIPca6EbPSJlzCMOdk6YgVBfOn8hK1VgAxLran/RqTpOme8Guudg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=XJvYaEoc; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="XJvYaEoc" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LE2FX012448; Wed, 5 Jun 2024 21:23:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=YxdI1uYsH7cLX7wJt08viDpVjHn4EWk+CktSg/LfJFE=; b=XJvYaEocHaQGaa55cMdn+9IX5q6NyuxlNyLCb/edXaKCtvsBbQxYlKURrv/7OqvAOGax BGgruYy6e2gH5PJDX00phKMQpBqM1TJU1fjRXqQLLIklDtgjWsztgsSCZ/UfsYkQw+/i tNopqeLwpLRI/myI/kW4nElVbpw7ZcsyoMyik39PEHIf1uTtG1/SL1paeWgFwj/UPlnN gV4lWjpD9n4eCT8hnLsomp0UaulNESto3qyLor8LebEWjEsfYCzu7Yr79UhxMNeIJWWc +p6aDEswz5f/hImNLLeWM2/NTmx47kxr2e6tKgwUdF/Z+/6UPFchBmcci8uOA5XJwpCF uQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyr080s9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:27 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JlkIS026600; Wed, 5 Jun 2024 21:23:26 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffn6hjc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNNwB23790302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:25 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 062A058061; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5BBD5806A; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 32/40] i2c: fsi: Add interrupt support Date: Wed, 5 Jun 2024 16:23:04 -0500 Message-Id: <20240605212312.349188-33-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Eze2TnuZ5ZbI2cln7BOhaVQHB_SCg28a X-Proofpoint-ORIG-GUID: Eze2TnuZ5ZbI2cln7BOhaVQHB_SCg28a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Optionally support interrupts from the I2C controller so that the driver can wait rather than poll the status register. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 215 ++++++++++++++++++++++++++++++--- include/trace/events/i2c_fsi.h | 45 +++++++ 2 files changed, 245 insertions(+), 15 deletions(-) create mode 100644 include/trace/events/i2c_fsi.h diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 614d830419bb8..f8d9bc178ef5b 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -23,6 +23,7 @@ #include #include #include +#include #define FSI_ENGID_I2C 0x7 @@ -87,6 +88,7 @@ #define I2C_INT_STOP_ERR BIT(7) #define I2C_INT_BUSY BIT(6) #define I2C_INT_IDLE BIT(5) +#define I2C_INT_ANY GENMASK(15, 7) /* status register */ #define I2C_STAT_INV_CMD BIT(31) @@ -148,21 +150,35 @@ /* choose timeout length from legacy driver; it's well tested */ #define I2C_ABORT_TIMEOUT msecs_to_jiffies(100) +struct fsi_i2c_port; + struct fsi_i2c_master { struct fsi_device *fsi; + struct fsi_i2c_port *port; struct mutex lock; + wait_queue_head_t wait; u32 clock_div; u8 fifo_size; + bool interrupts; bool skip_stop; + bool abort; }; struct fsi_i2c_port { struct i2c_adapter adapter; struct fsi_i2c_master *master; + struct i2c_msg *msgs; + int nmsgs; + int rc; + int i; u16 port; u16 xfrd; + bool wake; }; +#define CREATE_TRACE_POINTS +#include + static int fsi_i2c_read_reg(struct fsi_device *fsi, unsigned int reg, u32 *data) { @@ -192,7 +208,7 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) u32 watermark; int rc; - /* since we use polling, disable interrupts */ + /* start with interrupts disabled */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, 0); if (rc) return rc; @@ -236,22 +252,24 @@ static int fsi_i2c_set_port(struct fsi_i2c_port *port) return fsi_i2c_write_reg(fsi, I2C_FSI_RESET_ERR, 0); } -static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, - bool stop) +static int fsi_i2c_start(struct fsi_i2c_port *port) { u32 cmd = I2C_CMD_WITH_START | I2C_CMD_WITH_ADDR; + struct i2c_msg *msg = &port->msgs[port->i]; port->xfrd = 0; if (msg->flags & I2C_M_RD) cmd |= I2C_CMD_READ; - if (stop || msg->flags & I2C_M_STOP) + if ((port->i == (port->nmsgs - 1)) || (msg->flags & I2C_M_STOP)) cmd |= I2C_CMD_WITH_STOP; cmd |= FIELD_PREP(I2C_CMD_ADDR, msg->addr); cmd |= FIELD_PREP(I2C_CMD_LEN, msg->len); + trace_i2c_fsi_start(port, cmd); + return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, cmd); } @@ -489,11 +507,38 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port) if (i2c->skip_stop) return 0; + if (i2c->interrupts) { + i2c->abort = true; + port->wake = false; + + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, I2C_INT_ANY); + if (rc) + return rc; + } + /* write stop command */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, cmd); if (rc) return rc; + if (i2c->interrupts) { + rc = wait_event_interruptible_timeout(i2c->wait, port->wake, I2C_ABORT_TIMEOUT); + if (rc > 0) + return port->rc; + + fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, 0); + + if (!rc) { + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &status); + if (!rc && (status & I2C_STAT_CMD_COMP)) + rc = 0; + else + rc = -ETIMEDOUT; + } + + return rc; + } + /* wait until we see command complete in the master */ start = jiffies; do { @@ -564,8 +609,59 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, return 0; } -static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, - unsigned long timeout) +static int fsi_i2c_wait_irq(struct fsi_i2c_port *port, unsigned long timeout) +{ + int rc; + + port->wake = false; + + rc = fsi_i2c_write_reg(port->master->fsi, I2C_FSI_INT_MASK, I2C_INT_ANY); + if (rc) + return rc; + + rc = wait_event_interruptible_timeout(port->master->wait, port->wake, timeout); + if (rc > 0) { + rc = port->rc; + + if (port->master->abort) { + int rc2 = fsi_i2c_abort(port); + + if (rc2) + return rc2; + } + + return rc; + } + + /* + * The interrupt handler should turn off interrupts once it's done, but in this + * case we timed out or were interrupted, so mask them off here. + */ + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_INT_MASK, 0); + + if (!rc) { + u32 status; + + rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &status); + if (!rc && (status & I2C_STAT_ANY_RESP)) { + rc = fsi_i2c_handle_status(port, &port->msgs[port->i], status); + if (rc < 0) + return rc; + + /* cmd complete and all data xfrd */ + if (rc == port->msgs[port->i].len) + return 0; + + rc = -ETIMEDOUT; + } else { + rc = -ETIMEDOUT; + } + } + + return rc; +} + +static int fsi_i2c_wait_poll(struct fsi_i2c_port *port, unsigned long timeout) { unsigned long start = jiffies; u32 status; @@ -578,12 +674,12 @@ static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, return rc; if (status & I2C_STAT_ANY_RESP) { - rc = fsi_i2c_handle_status(port, msg, status); + rc = fsi_i2c_handle_status(port, &port->msgs[port->i], status); if (rc < 0) return rc; /* cmd complete and all data xfrd */ - if (rc == msg->len) + if (rc == port->msgs[port->i].len) return 0; /* need to xfr more data, but maybe don't need wait */ @@ -601,9 +697,7 @@ static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, { struct fsi_i2c_port *port = i2c_get_adapdata(adap); unsigned long start_time; - struct i2c_msg *msg; int rc; - int i; mutex_lock(&port->master->lock); @@ -611,21 +705,28 @@ static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, if (rc) goto unlock; - for (i = 0; i < num; i++) { - msg = msgs + i; + port->master->port = port; + port->master->abort = false; + port->msgs = msgs; + port->nmsgs = num; + for (port->i = 0; port->i < num; ++port->i) { start_time = jiffies; - rc = fsi_i2c_start(port, msg, i == num - 1); + rc = fsi_i2c_start(port); if (rc) goto unlock; - rc = fsi_i2c_wait(port, msg, - adap->timeout - (jiffies - start_time)); + if (port->master->interrupts) + rc = fsi_i2c_wait_irq(port, adap->timeout - (jiffies - start_time)); + else + rc = fsi_i2c_wait_poll(port, adap->timeout - (jiffies - start_time)); if (rc) goto unlock; } unlock: + port->msgs = NULL; + port->master->port = NULL; mutex_unlock(&port->master->lock); return rc ? : num; } @@ -636,6 +737,85 @@ static u32 fsi_i2c_functionality(struct i2c_adapter *adap) I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA; } +static irqreturn_t fsi_i2c_irq(int irq, void *data) +{ + struct fsi_i2c_master *i2c = data; + struct fsi_i2c_port *port; + struct i2c_msg *msg; + u32 status; + int rc; + + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, 0); + if (rc) + return IRQ_NONE; + + if (!i2c->port) + return IRQ_HANDLED; + + port = i2c->port; + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &status); + if (rc) + goto wake; + + trace_i2c_fsi_irq(port, status); + + if (i2c->abort) { + if (status & I2C_STAT_CMD_COMP) { + port->wake = true; + goto done; + } else { + rc = fsi_i2c_error_status_to_rc(status); + goto wake; + } + } + + if (status & I2C_STAT_ERR) { + i2c->abort = true; + i2c->skip_stop = status & I2C_STAT_SKIP_STOP; + rc = fsi_i2c_error_status_to_rc(status); + goto wake; + } + + if (!port->msgs || port->i >= port->nmsgs) { + rc = -ENODEV; + goto wake; + } + + msg = &port->msgs[port->i]; + if (status & I2C_STAT_DAT_REQ) { + u8 fifo_count = FIELD_GET(I2C_STAT_FIFO_COUNT, status); + + if (msg->flags & I2C_M_RD) + rc = fsi_i2c_read_fifo(port, msg, fifo_count); + else + rc = fsi_i2c_write_fifo(port, msg, fifo_count); + } else if (status & I2C_STAT_CMD_COMP) { + if (port->xfrd < msg->len) { + rc = -ENODATA; + } else { + ++port->i; + if (port->i < port->nmsgs) { + rc = fsi_i2c_start(port); + } else { + port->wake = true; + goto done; + } + } + } + + if (!rc) + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, I2C_INT_ANY); + +wake: + if (rc) + port->wake = true; +done: + port->rc = rc; + if (port->wake) + wake_up_interruptible_all(&i2c->wait); + return IRQ_HANDLED; +} + static struct i2c_bus_recovery_info fsi_i2c_bus_recovery_info = { .recover_bus = i2c_generic_scl_recovery, .get_scl = fsi_i2c_get_scl, @@ -683,6 +863,7 @@ static int fsi_i2c_probe(struct device *dev) return -ENOMEM; mutex_init(&i2c->lock); + init_waitqueue_head(&i2c->wait); i2c->fsi = to_fsi_dev(dev); i2c->clock_div = I2C_DEFAULT_CLK_DIV; @@ -706,6 +887,10 @@ static int fsi_i2c_probe(struct device *dev) if (rc) return rc; + rc = fsi_device_request_irq(i2c->fsi, fsi_i2c_irq, i2c); + if (!rc) + i2c->interrupts = true; + ports = FIELD_GET(I2C_STAT_MAX_PORT, stat) + 1; dev_dbg(dev, "I2C master has %d ports\n", ports); diff --git a/include/trace/events/i2c_fsi.h b/include/trace/events/i2c_fsi.h new file mode 100644 index 0000000000000..ac49ae9be356b --- /dev/null +++ b/include/trace/events/i2c_fsi.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM i2c_fsi + +#if !defined(_TRACE_I2C_FSI_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_I2C_FSI_H + +#include + +TRACE_EVENT(i2c_fsi_irq, + TP_PROTO(const struct fsi_i2c_port *port, uint32_t status), + TP_ARGS(port, status), + TP_STRUCT__entry( + __field(int, bus) + __field(int, msg_idx) + __field(uint32_t, status) + ), + TP_fast_assign( + __entry->bus = port->adapter.nr; + __entry->msg_idx = port->i; + __entry->status = status; + ), + TP_printk("i2c-%d [%d] status:%08x", __entry->bus, __entry->msg_idx, __entry->status) +); + +TRACE_EVENT(i2c_fsi_start, + TP_PROTO(const struct fsi_i2c_port *port, uint32_t command), + TP_ARGS(port, command), + TP_STRUCT__entry( + __field(int, bus) + __field(int, msg_idx) + __field(uint32_t, command) + ), + TP_fast_assign( + __entry->bus = port->adapter.nr; + __entry->msg_idx = port->i; + __entry->command = command; + ), + TP_printk("i2c-%d [%d] command:%08x", __entry->bus, __entry->msg_idx, __entry->command) +); + +#endif + +#include From patchwork Wed Jun 5 21:23:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687571 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 2C17415FA6B; Wed, 5 Jun 2024 21:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622628; cv=none; b=kOIA1cTY26/RpL53QYhyb24NCYvGTBtKsZAgPbpVOaePyQLehlgKUoQjdDp6GaJC1eysSjJnsAWn7qpTiUJFdoFkqiLALmBtzgeyLYlpsThpRzQGelY4Vsrs/4uCEAcCBk8DwcJtYrJKHu61tKgNICmVtUfwwMB4/8FkHrvx/F0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622628; c=relaxed/simple; bh=vOYsMk7mrSYUToVE3TW3d0+j9nsQ/udu6UXMoY2sLm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PSUlgm7ybzZRYG4cDkMBtTJg4aiDFl2lBV39hTNXqzpKo23emsAH7mDeRz39T7/ApAZe5TqY06znxd2UoO2/+Z4CZ81l64Rz0zexkVPpvD8jtVQvg7Y23Vgg12KTQfAiSxh0IHV4u74o6rBvnkHa3gTQ/h6sOKIADXid9/9G/YY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=RQNwCSNv; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="RQNwCSNv" Received: from pps.filterd (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KuTr9001313; Wed, 5 Jun 2024 21:23:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=OPNP/V+K9oIptQxupTBJOpz2/GhP+4OrRNDg7xLMAPk=; b=RQNwCSNvxB1CqwmLDmmNBtg4mUmfnsmENO88KKc62qKBBpKc/7/OwfOEWug0GCC/Ycvg x0UmaVrqstg8cbcHQmubMqFeJyC6XRMETPSk5gOKgIb7xkem0fYsqgAMRC/myH5kx0mO PePN6Tfb/fXWLWmswGB6XO/XYVjHk1I8LbOXBh+wHw8NUFTY2dXjoKJc57xtC+xXNNQY H9pszB0R+L75L7wNUbalVaYxLXNwRfombWPxHpZPOPlTVdFdYHvkNnePXqZc2b7n+aX3 xZw0AqDwPHA9Fbx2r3Pv+Ld4gRdLLWisgP8igDklOyc3oEW7FN7fLdYnRCNlzWln2MtO 0Q== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjwppgcga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:27 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455J6qWw008517; Wed, 5 Jun 2024 21:23:26 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNNI85833456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:25 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AD805805F; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D41858063; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 33/40] fsi: hub master: Reset hub master after errors Date: Wed, 5 Jun 2024 16:23:05 -0500 Message-Id: <20240605212312.349188-34-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yoh__hnd5WgQ9Cne_kRz1iAF7PKEl-m4 X-Proofpoint-GUID: yoh__hnd5WgQ9Cne_kRz1iAF7PKEl-m4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The hub master driver wasn't clearing errors after accessing remote slaves. Perform the standard master reset procedure to clear errors to fully recover. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-hub.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 4dbc542500bbd..1bd53b1e52a91 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -49,24 +49,34 @@ static int hub_master_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, size_t size) { struct fsi_master_hub *hub = to_fsi_master_hub(master); + int rc; if (id != 0) return -EINVAL; addr += hub->addr + (link * FSI_HUB_LINK_SIZE); - return fsi_slave_read(hub->upstream->slave, addr, val, size); + rc = fsi_slave_read(hub->upstream->slave, addr, val, size); + if (rc) + fsi_master_error(master, link); + + return rc; } static int hub_master_write(struct fsi_master *master, int link, uint8_t id, uint32_t addr, const void *val, size_t size) { struct fsi_master_hub *hub = to_fsi_master_hub(master); + int rc; if (id != 0) return -EINVAL; addr += hub->addr + (link * FSI_HUB_LINK_SIZE); - return fsi_slave_write(hub->upstream->slave, addr, val, size); + rc = fsi_slave_write(hub->upstream->slave, addr, val, size); + if (rc) + fsi_master_error(master, link); + + return rc; } static int hub_master_break(struct fsi_master *master, int link) From patchwork Wed Jun 5 21:23:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687564 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 98F3C16EBE6; Wed, 5 Jun 2024 21:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=W4BM2UwiZtpmA4joGrMntU/iIBTxanK9LL3tml7OsP3WGGi80vhrxXjJDhKiNI7Zs09c/iWE2H80/JmvgdY4A2xYOtRyZWjlWO0DiFQfAdgWXa4jKBtKBg8Riw1Esq7BFAsPAAVz5zwk+VzlQPBO/RNL1U32fbg9Emtze1V1i4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=RBqRbxabKv0CGQ2xdwAfaYcS7JbONGnPFvbJnA6bQPc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FZIvgYy7bV0bWEoacln8ttPyH4n/g6Ih5Bj7ISJXR+UY+b6vfrIH/5xFJEKy57bCBxULhdCEYCgE9u1+InE5z6btoE69LawQfvCdV1vYLCm6VxKNdVdH83Cu0wfbLQelo7ipq6wEtJlw6u99quwE4YhRedZ3qKPNVCn4MTeyd8M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=KtRDcV/W; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KtRDcV/W" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455Kvrrs008155; Wed, 5 Jun 2024 21:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=c/6bQez2W1iTAQVDpyKd+LW+AbhpZPBop+2GaDE/jcM=; b=KtRDcV/WU3VWNzAyfeVoOHy0aH0x4gvT9bjUoFBLbYdKy/e3So9avu9OHGNA/TSBjNUb +Ink67GWP5H7uBA65YKT/kecAzX1txlkv+aAfb/2evT7XRocJnGemUGi42Z8W3RRtKoj HCwxcKaZlDP1On/wlOvNiLxDHr8WdDtV0dY0CypRw+5Cy7uc5+o8XR3gPMY8nn6FT9KP Ggn1MMSFggTXGNSFaDFm5Mw1cEtIIiUf3hQf+7lGNyz+RE6EZewriaWeqF7NcIsVjEA3 utDcQDKc4B/mltz+29RmfKox8JPUc7Z9VvFIcPCemHq/A6u90FviXnDMZ+6sY6HvJa4g YA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygn01ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:30 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455J3GeD031147; Wed, 5 Jun 2024 21:23:29 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:28 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNPjm11338460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:27 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90A625806A; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 525DE5806F; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 34/40] fsi: core: Add master register read-only sysfs Date: Wed, 5 Jun 2024 16:23:06 -0500 Message-Id: <20240605212312.349188-35-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3nNZKFv8n3XJP9gSsQwxkWSXPGW9dMXw X-Proofpoint-ORIG-GUID: 3nNZKFv8n3XJP9gSsQwxkWSXPGW9dMXw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The master registers are commonly used for debugging or diagnosis so provide them in sysfs files. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 144 +++++++++++++++++++++++++++++++++++++++ drivers/fsi/fsi-master.h | 6 ++ 2 files changed, 150 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 58cb6bc6ccc91..4d2e14e2a9148 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1392,6 +1392,141 @@ static ssize_t master_break_store(struct device *dev, static DEVICE_ATTR(break, 0200, NULL, master_break_store); +struct fsi_master_attribute { + struct device_attribute attr; + int reg; +}; + +static ssize_t master_reg_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr); + struct fsi_master *master = to_fsi_master(dev); + unsigned int reg; + int rc; + + rc = regmap_read(master->map, fattr->reg, ®); + if (rc) + return rc; + + return sysfs_emit(buf, "%08x\n", reg); +} + +static ssize_t master_reg_1bpp_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr); + struct fsi_master *master = to_fsi_master(dev); + unsigned int count = (master->n_links + 31) / 32; + unsigned int reg; + unsigned int i; + int len = 0; + int rc; + + for (i = 0; i < count; ++i) { + rc = regmap_read(master->map, fattr->reg + (i * 4), ®); + if (rc) + return rc; + + len += sysfs_emit_at(buf, len, "%08x\n", reg); + } + + return len; +} + +static ssize_t master_reg_4bpp_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr); + struct fsi_master *master = to_fsi_master(dev); + unsigned int count = (master->n_links + 7) / 8; + unsigned int reg; + unsigned int i; + int len = 0; + int rc; + + for (i = 0; i < count; ++i) { + rc = regmap_read(master->map, fattr->reg + (i * 4), ®); + if (rc) + return rc; + + len += sysfs_emit_at(buf, len, "%08x\n", reg); + } + + return len; +} + +static ssize_t master_reg_32bpp_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr); + struct fsi_master *master = to_fsi_master(dev); + unsigned int reg; + int len = 0; + int rc; + int i; + + for (i = 0; i < master->n_links; ++i) { + rc = regmap_read(master->map, fattr->reg + (i * 4), ®); + if (rc) + return rc; + + len += sysfs_emit_at(buf, len, "%08x\n", reg); + } + + return len; +} + +#define FSI_MASTER_ATTR(name, reg) \ + struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_show, NULL), reg } +#define FSI_MASTER_ATTR_1BPP(name, reg) \ + struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_1bpp_show, NULL), reg } +#define FSI_MASTER_ATTR_4BPP(name, reg) \ + struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_4bpp_show, NULL), reg } +#define FSI_MASTER_ATTR_32BPP(name, reg) \ + struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_32bpp_show, NULL), reg } + +static FSI_MASTER_ATTR(mmode, FSI_MMODE); +static FSI_MASTER_ATTR(mdlyr, FSI_MDLYR); +static FSI_MASTER_ATTR_1BPP(mcrsp, FSI_MCRSP); +static FSI_MASTER_ATTR_1BPP(menp, FSI_MENP0); +static FSI_MASTER_ATTR_1BPP(mlevp, FSI_MLEVP0); +static FSI_MASTER_ATTR_1BPP(mrefp, FSI_MREFP0); +static FSI_MASTER_ATTR_1BPP(mhpmp, FSI_MHPMP0); +static FSI_MASTER_ATTR_4BPP(msiep, FSI_MSIEP0); +static FSI_MASTER_ATTR_1BPP(maesp, FSI_MAESP0); +static FSI_MASTER_ATTR(maeb, FSI_MAEB); +static FSI_MASTER_ATTR(mver, FSI_MVER); +static FSI_MASTER_ATTR_1BPP(mbsyp, FSI_MBSYP0); +static FSI_MASTER_ATTR_32BPP(mstap, FSI_MSTAP0); +static FSI_MASTER_ATTR(mesrb, FSI_MESRB0); +static FSI_MASTER_ATTR(mscsb, FSI_MSCSB0); +static FSI_MASTER_ATTR(matrb, FSI_MATRB0); +static FSI_MASTER_ATTR(mdtrb, FSI_MDTRB0); +static FSI_MASTER_ATTR(mectrl, FSI_MECTRL); + +static struct attribute *master_mapped_attrs[] = { + &dev_attr_mmode.attr.attr, + &dev_attr_mdlyr.attr.attr, + &dev_attr_mcrsp.attr.attr, + &dev_attr_menp.attr.attr, + &dev_attr_mlevp.attr.attr, + &dev_attr_mrefp.attr.attr, + &dev_attr_mhpmp.attr.attr, + &dev_attr_msiep.attr.attr, + &dev_attr_maesp.attr.attr, + &dev_attr_maeb.attr.attr, + &dev_attr_mver.attr.attr, + &dev_attr_mbsyp.attr.attr, + &dev_attr_mstap.attr.attr, + &dev_attr_mesrb.attr.attr, + &dev_attr_mscsb.attr.attr, + &dev_attr_matrb.attr.attr, + &dev_attr_mdtrb.attr.attr, + &dev_attr_mectrl.attr.attr, + NULL +}; + +static const struct attribute_group master_mapped_group = { + .attrs = master_mapped_attrs, +}; + static struct attribute *master_attrs[] = { &dev_attr_break.attr, &dev_attr_rescan.attr, @@ -1665,6 +1800,12 @@ int fsi_master_register(struct fsi_master *master) } out: mutex_unlock(&master->scan_lock); + + if (!rc && master->map) { + if (!sysfs_create_group(&master->dev.kobj, &master_mapped_group)) + master->groups = true; + } + return rc; } EXPORT_SYMBOL_GPL(fsi_master_register); @@ -1675,6 +1816,9 @@ void fsi_master_unregister(struct fsi_master *master) trace_fsi_master_unregister(master); + if (master->groups) + sysfs_remove_group(&master->dev.kobj, &master_mapped_group); + mutex_lock(&master->scan_lock); fsi_master_unscan(master); master->n_links = 0; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 2104902091e05..1fa101a477899 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -12,6 +12,7 @@ #include #include #include +#include /* * Master registers @@ -27,12 +28,16 @@ #define FSI_MENP0 0x10 /* R/W: enable */ #define FSI_MLEVP0 0x18 /* R: plug detect */ #define FSI_MSENP0 0x18 /* S: Set enable */ +#define FSI_MREFP0 0x20 /* R: Plug reference */ #define FSI_MCENP0 0x20 /* C: Clear enable */ +#define FSI_MHPMP0 0x28 /* R: Plug monitor */ #define FSI_MSIEP0 0x30 /* R/W: interrupt enable */ +#define FSI_MAESP0 0x50 /* R: Any error port */ #define FSI_MSSIEP0 0x50 /* S: Set interrupt enable */ #define FSI_MCSIEP0 0x70 /* C: Clear interrupt enable */ #define FSI_MAEB 0x70 /* R: Error address */ #define FSI_MVER 0x74 /* R: master version/type */ +#define FSI_MBSYP0 0x78 /* R: Port busy */ #define FSI_MSTAP0 0xd0 /* R: Port status */ #define FSI_MRESP0 0xd0 /* W: Port reset */ #define FSI_MESRB0 0x1d0 /* R: Master error status */ @@ -151,6 +156,7 @@ struct fsi_master { int (*link_config)(struct fsi_master *, int link, u8 t_send_delay, u8 t_echo_delay); u8 remote_interrupt_status; + bool groups; }; #define to_fsi_master(d) container_of(d, struct fsi_master, dev) From patchwork Wed Jun 5 21:23:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687559 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 F413115F3ED; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; cv=none; b=cx/FWYLL3tr/iFYRGKe2e3zmm2ZrqwZLoomIbQ/EEVZCrMAtEAE8U3HwU32AD6iKoFNg2Oo0RIwNldNmwqZXwnWRZ3JrmAkEtrDGizfE/xHV7nf8sjPieQrD3kAJ/cFVEEiHz7CA8jS1KnZoyhfaMPYjXuo1IwC/Xd5jghjMknE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622625; c=relaxed/simple; bh=jtBdO608e54Gjo+WJW+8Z7TDVODmLr1O3UYpEi4xKMw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QZZdBr7kTVI/X0nKJR9U1tFqsjcSxcpHWMRJ0LW62log7gnuTZT4NLk8F1Vsy7JdbSEuk1IgClHZsJEcRhgig4ovXx6CJLZ+HcOkEjZRRT1L6oJoaiNq4UxF+gOlsWX+lT9ii5YY5AHxYHuU4kvyi7pW1Pu++gwoeLgozZjxl7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ltBgFluD; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ltBgFluD" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455Kvepc014563; Wed, 5 Jun 2024 21:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=9EQ/udfwV4988NmJ64/g80BYsVL3x5pmmemzkAQ7CyI=; b=ltBgFluDaEC0cDE5S9NYhq/KsRKIS2KT5k/DxlEsPRKpM1WofkyomZTrOTPkyD/iNa4l Rk3Xdr/XM/Jk+alpmJK1X+ICHKMBeXM8kBa/dnCRwNdBL2OktR2/+kWV5GvtxNR7XItT FFBksn1xD31EE++M4MbDKPOqW027RrOl3i2QOkLhWVK0KM13Retev83AnKzgreSftZkp RYDQDe7/mLG24UhtFm8zE7nfMIGupv9+yn5XXukWGplc2XfDJ73TCez2v0anoajHU8x+ FRR5t5u1BrTq8J8hERAbmn1iePj4aufzSDfs0cVtyrtwnDqi9xAxObeX2dZKbK2CzsYT vg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjygp81us-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:30 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IRk5J008458; Wed, 5 Jun 2024 21:23:29 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNPWP61800790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:28 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF7885805E; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 982AD58072; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 35/40] fsi: core: Add slave register read-only sysfs Date: Wed, 5 Jun 2024 16:23:07 -0500 Message-Id: <20240605212312.349188-36-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: n-d35ugdjtO-3IBsEolZXLq35kxzyTg0 X-Proofpoint-ORIG-GUID: n-d35ugdjtO-3IBsEolZXLq35kxzyTg0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The slave registers are commonly used for debugging or diagnosis so provide them in sysfs files. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 144 +++++++++++++++++++++++++++++++++++++--- drivers/fsi/fsi-slave.h | 21 ++++++ 2 files changed, 155 insertions(+), 10 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 4d2e14e2a9148..62a14a7f28498 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -887,22 +887,146 @@ static ssize_t cfam_id_show(struct device *dev, static DEVICE_ATTR_RO(cfam_id); -static struct attribute *cfam_attr[] = { +static ssize_t config_table_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + const unsigned int end = engine_page_size / sizeof(u32); + struct fsi_slave *slave = to_fsi_slave(dev); + __be32 data; + int len = 0; + u32 conf; + int rc; + + for (unsigned int i = 0; i < end; ++i) { + rc = fsi_slave_read(slave, i * sizeof(data), &data, sizeof(data)); + if (rc) + return rc; + + conf = be32_to_cpu(data); + if (crc4(0, conf, 32)) + return -EBADMSG; + + len += sysfs_emit_at(buf, len, "%08x\n", conf); + if (!(conf & FSI_SLAVE_CONF_NEXT_MASK)) + break; + } + + return len; +} + +static DEVICE_ATTR_RO(config_table); + +struct fsi_slave_attribute { + struct device_attribute attr; + int reg; +}; + +static ssize_t slave_reg_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_slave_attribute *fattr = container_of(attr, struct fsi_slave_attribute, attr); + struct fsi_slave *slave = to_fsi_slave(dev); + __be32 data; + int rc; + + rc = fsi_slave_read(slave, FSI_SLAVE_BASE + fattr->reg, &data, sizeof(data)); + if (rc) + return rc; + + return sysfs_emit(buf, "%08x\n", be32_to_cpu(data)); +} + +static ssize_t slave_reg_8bpp_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct fsi_slave_attribute *fattr = container_of(attr, struct fsi_slave_attribute, attr); + struct fsi_slave *slave = to_fsi_slave(dev); + __be32 data; + int len = 0; + int rc; + int i; + + for (i = 0; i < 2; ++i) { + rc = fsi_slave_read(slave, FSI_SLAVE_BASE + fattr->reg + (i * 4), &data, + sizeof(data)); + if (rc) + return rc; + + len += sysfs_emit_at(buf, len, "%08x\n", be32_to_cpu(data)); + } + + return len; +} + +#define FSI_SLAVE_ATTR(name, reg) \ + struct fsi_slave_attribute dev_attr_##name = { __ATTR(name, 0444, slave_reg_show, NULL), reg } +#define FSI_SLAVE_ATTR_8BPP(name, reg) \ + struct fsi_slave_attribute dev_attr_##name = { __ATTR(name, 0444, slave_reg_8bpp_show, NULL), reg } + +static FSI_SLAVE_ATTR(smode, FSI_SMODE); +static FSI_SLAVE_ATTR(sdma, FSI_SDMA); +static FSI_SLAVE_ATTR(sisc, FSI_SISC); +static FSI_SLAVE_ATTR(sism, FSI_SISM); +static FSI_SLAVE_ATTR(siss, FSI_SISS); +static FSI_SLAVE_ATTR(sstat, FSI_SSTAT); +static FSI_SLAVE_ATTR(si1m, FSI_SI1M); +static FSI_SLAVE_ATTR(si1s, FSI_SI1S); +static FSI_SLAVE_ATTR(sic, FSI_SIC); +static FSI_SLAVE_ATTR(si2m, FSI_SI2M); +static FSI_SLAVE_ATTR(si2s, FSI_SI2S); +static FSI_SLAVE_ATTR(scmdt, FSI_SCMDT); +static FSI_SLAVE_ATTR(sdata, FSI_SDATA); +static FSI_SLAVE_ATTR(slastd, FSI_SLASTD); +static FSI_SLAVE_ATTR(smbl, FSI_SMBL); +static FSI_SLAVE_ATTR(soml, FSI_SOML); +static FSI_SLAVE_ATTR(snml, FSI_SNML); +static FSI_SLAVE_ATTR(smbr, FSI_SMBR); +static FSI_SLAVE_ATTR(somr, FSI_SOMR); +static FSI_SLAVE_ATTR(snmr, FSI_SNMR); +static FSI_SLAVE_ATTR_8BPP(scrsic, FSI_ScRSIC0); +static FSI_SLAVE_ATTR_8BPP(scrsim, FSI_ScRSIM0); +static FSI_SLAVE_ATTR_8BPP(scrsis, FSI_ScRSIS0); +static FSI_SLAVE_ATTR_8BPP(srsic, FSI_SRSIC0); +static FSI_SLAVE_ATTR_8BPP(srsim, FSI_SRSIM0); +static FSI_SLAVE_ATTR_8BPP(srsis, FSI_SRSIS0); +static FSI_SLAVE_ATTR(llmode, FSI_LLMODE); +static FSI_SLAVE_ATTR(llstat, FSI_LLSTAT); + +static struct attribute *cfam_attrs[] = { &dev_attr_send_echo_delays.attr, &dev_attr_chip_id.attr, &dev_attr_cfam_id.attr, &dev_attr_send_term.attr, + &dev_attr_config_table.attr, + &dev_attr_smode.attr.attr, + &dev_attr_sdma.attr.attr, + &dev_attr_sisc.attr.attr, + &dev_attr_sism.attr.attr, + &dev_attr_siss.attr.attr, + &dev_attr_sstat.attr.attr, + &dev_attr_si1m.attr.attr, + &dev_attr_si1s.attr.attr, + &dev_attr_sic.attr.attr, + &dev_attr_si2m.attr.attr, + &dev_attr_si2s.attr.attr, + &dev_attr_scmdt.attr.attr, + &dev_attr_sdata.attr.attr, + &dev_attr_slastd.attr.attr, + &dev_attr_smbl.attr.attr, + &dev_attr_soml.attr.attr, + &dev_attr_snml.attr.attr, + &dev_attr_smbr.attr.attr, + &dev_attr_somr.attr.attr, + &dev_attr_snmr.attr.attr, + &dev_attr_scrsic.attr.attr, + &dev_attr_scrsim.attr.attr, + &dev_attr_scrsis.attr.attr, + &dev_attr_srsic.attr.attr, + &dev_attr_srsim.attr.attr, + &dev_attr_srsis.attr.attr, + &dev_attr_llmode.attr.attr, + &dev_attr_llstat.attr.attr, NULL, }; -static const struct attribute_group cfam_attr_group = { - .attrs = cfam_attr, -}; - -static const struct attribute_group *cfam_attr_groups[] = { - &cfam_attr_group, - NULL, -}; +ATTRIBUTE_GROUPS(cfam); static char *cfam_devnode(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) @@ -919,7 +1043,7 @@ static char *cfam_devnode(const struct device *dev, umode_t *mode, static const struct device_type cfam_type = { .name = "cfam", .devnode = cfam_devnode, - .groups = cfam_attr_groups + .groups = cfam_groups }; static char *fsi_cdev_devnode(const struct device *dev, umode_t *mode, diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index 762636e7c8633..ccc394e92a93f 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -14,6 +14,7 @@ * FSI slave engine control register offsets */ #define FSI_SMODE 0x0 /* R/W: Mode register */ +#define FSI_SDMA 0x4 /* R/W: DMA control */ #define FSI_SISC 0x8 /* R : Interrupt condition */ #define FSI_SCISC 0x8 /* C : Clear interrupt condition */ #define FSI_SISM 0xc /* R/W: Interrupt mask */ @@ -21,11 +22,30 @@ #define FSI_SSISM 0x10 /* S : Set interrupt mask */ #define FSI_SCISM 0x14 /* C : Clear interrupt mask */ #define FSI_SSTAT 0x14 /* R : Slave status */ +#define FSI_SI1M 0x18 /* R/W: Interrupt 1 mask */ #define FSI_SI1S 0x1c /* R : Slave interrupt 1 status */ #define FSI_SSI1M 0x1c /* S : Set slave interrupt 1 mask */ +#define FSI_SIC 0x20 /* R : Interrupt 1 condition */ #define FSI_SCI1M 0x20 /* C : Clear slave interrupt 1 mask */ +#define FSI_SI2M 0x24 /* R/W: Interrupt 2 mask */ +#define FSI_SI2S 0x28 /* R : Interrupt 2 status */ +#define FSI_SCMDT 0x2c /* R : Last command trace */ +#define FSI_SDATA 0x30 /* R : Last data trace */ #define FSI_SLBUS 0x30 /* W : LBUS Ownership */ +#define FSI_SLASTD 0x34 /* R : Last data sent */ #define FSI_SRES 0x34 /* W : Reset */ +#define FSI_SMBL 0x38 +#define FSI_SOML 0x3c +#define FSI_SNML 0x40 +#define FSI_SMBR 0x44 +#define FSI_SOMR 0x48 +#define FSI_SNMR 0x4c +#define FSI_ScRSIC0 0x50 +#define FSI_ScRSIC4 0x54 +#define FSI_ScRSIM0 0x58 +#define FSI_ScRSIM4 0x5c +#define FSI_ScRSIS0 0x60 +#define FSI_ScRSIS4 0x64 #define FSI_SRSIC0 0x68 /* C : Clear remote interrupt condition */ #define FSI_SRSIC4 0x6c /* C : Clear remote interrupt condition */ #define FSI_SRSIM0 0x70 /* R/W: Remote interrupt mask */ @@ -33,6 +53,7 @@ #define FSI_SRSIS0 0x78 /* R : Remote interrupt status */ #define FSI_SRSIS4 0x7c /* R : Remote interrupt status */ #define FSI_LLMODE 0x100 /* R/W: Link layer mode register */ +#define FSI_LLSTAT 0x104 /* * SMODE fields From patchwork Wed Jun 5 21:23:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687566 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 2B6B016C6B3; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=pjdPkuKyPIerVRQ6ZOrxfokQrS7/iVWjA4WmifDCQiV7wM8yAnCvh51D+PTePWwmHNupfODB2KbsWkkc2eynGgMPTj7SBaTob4K5/MZrKDGI4c/8823jTo/XA/IcYWox7jBrgxLroNSZAE0PPM6plB1v24SyPSMLxXgKrTq2fHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=R8kfSOGnIrv271rmukmsk0724R5JFYbq2WSrn+gmnEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O4o/dIDChl4qJ6Gru++P1RNjCDqvP3Fhc0BBGPY0KNKfer58zCPS1tYuZVf8/MPQRwFkuN3YU5cGAcsbLfCqcwyuxnpFP5UpvgSBTRnNxuo2uaAgpgXCPwR5MaAy2wFXHAaUry3qUaACrKEdBV7t4Dg5Pv0oWypFmrDyuOcwJEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=qmEeshXr; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="qmEeshXr" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBooK011894; Wed, 5 Jun 2024 21:23:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=ZC7HnfyHXbwd7VWU1F8seLX5ZR6fsIL25JIyeogTRXM=; b=qmEeshXr7URZ2+lbu7EdCLysiHc3JOjmm8AixjQgkFKHOA73kjH5fQ0JW9hHiJ1iaqKD 6hoYxcWS/RRMhF1U+cblXZHNUXo/h2eJ1M9doTPye9DRcXxpy09Y+xEXSjWpoH2O588u GCknrE1kLuoBdRPpfSoa039LJ6DFzoXkrKF+jrEvzFOPu3yuZeGpZXvw7xmL7RNN185R Y9fQltKG/S0M1zaMRizkZlwT2wPiHRVEh+MsK8xrolCZ3s8Cc/Ba/PohqXNWeoj8hNHh VtyahXuU8Gcpj3xfAgkdo95CnfuEVoS2f0DxSYmpGTeoe3A8yp9KRxAxGN/5xEARH7e8 EA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00ry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:28 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455JOb5T026899; Wed, 5 Jun 2024 21:23:27 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygffn6hjk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:27 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNO0l41288270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:26 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3841858066; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6C5558060; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:23 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 36/40] fsi: i2cr: Adjust virtual CFAM ID to match Odyssey chip Date: Wed, 5 Jun 2024 16:23:08 -0500 Message-Id: <20240605212312.349188-37-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DsH2nPR5Oj99-N18TNLN9fOXaMSyNBrS X-Proofpoint-ORIG-GUID: DsH2nPR5Oj99-N18TNLN9fOXaMSyNBrS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=875 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 The CFAM ID for the I2CR should be the same as the Odyssey chip. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-i2cr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fsi/fsi-master-i2cr.c b/drivers/fsi/fsi-master-i2cr.c index 40f1f4d231e52..c032ba7938815 100644 --- a/drivers/fsi/fsi-master-i2cr.c +++ b/drivers/fsi/fsi-master-i2cr.c @@ -22,7 +22,7 @@ #define I2CR_LOG_CMD 0x60008 static const u8 i2cr_cfam[] = { - 0xc0, 0x02, 0x0d, 0xa6, + 0xc0, 0x01, 0x0c, 0x07, 0x80, 0x01, 0x10, 0x02, 0x80, 0x01, 0x10, 0x02, 0x80, 0x01, 0x10, 0x02, From patchwork Wed Jun 5 21:23:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687562 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 5F2AB16C86C; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; cv=none; b=ZeI89Vq0xc3kqtGMQGcd5Jh4mOCBr3EFWlTYcA7roWVVov/umwFm84Ao491MGHM40QqTDgQLv3X2c42BOg1uXZDkGWf5Qb5vA6X7x0QFfdoEM1+A+odJKBQUslSbWSL94qeZ30mtO5l+d1DLEuJFZIyczZg7bNE1d8Ews9UjJ9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622626; c=relaxed/simple; bh=kU908GL/srmIXI7xAwaPMDqc8xqY+P18Q4IHnIBP/W4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lr85eI7W75L7Q25igdN4QoYhQwvOeWRClRLoyrvSZxb1AiTGdHIUGFkWN8yXaU2TWeO7TfFr+abyQwwbbl/1wWqSUgNID7rbqqYGxTgNxOtgmd1OSyt3cZHQfLcD/i1TPxZZGdWleiFg301FEtU9iR5bAXuZdH6oQiDcosdJa50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=KPCEMYYU; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KPCEMYYU" Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KuMLg009075; Wed, 5 Jun 2024 21:23:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=BxMhdEaKT8dV7A/LdNz6MzdJUjUzgPRl+V7XDXpB1LI=; b=KPCEMYYUm+TLLe7S1jz+3KW2OLMmABfIhuw/jJStuad6ofleXlJpYq4YlGZ/FVdO+LYB 0duXeY06eWCcB9gjeCna0Pi54ULsA0gD6adyKWzJYaNTj9iM/N+LGjpEsUqL8isAqIPZ PYj0eDIbR9RwbJSsQVTGy6ydXq15C+VFKnkWQ0Sx7bEDDtCGPJ8Pa2mObzexkyNZsN1i bT4+8Ha/6gpDdlw8IvmSs9av11Dbojsr3cTzpK3Gp3qZ0Db3KtMLcv8qOToQgiqZFkmO zJ0wI8tIF82Ui08RRoEc14eLqfKLYd0O+q1yyaeI+cd6ATlaLEqGGg0UrUTkd45yUH7h Mg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjy09g4hv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455J3GeC031147; Wed, 5 Jun 2024 21:23:27 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:27 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNOfK29098574 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:26 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AE2458060; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3EA085805D; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 37/40] fsi: core: Add different types of CFAM Date: Wed, 5 Jun 2024 16:23:09 -0500 Message-Id: <20240605212312.349188-38-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: oq3YQgc51Bj1t642DBPdkOGSijCMXwYa X-Proofpoint-GUID: oq3YQgc51Bj1t642DBPdkOGSijCMXwYa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 clxscore=1015 spamscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Detect the CFAM type based on the chip id and set up the device type based on the CFAM type. Signed-off-by: Eddie James --- Changes since v3: - Define fsi_get_cfam_type as static drivers/fsi/fsi-core.c | 84 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 62a14a7f28498..bc561d1b2701c 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1028,6 +1028,37 @@ static struct attribute *cfam_attrs[] = { ATTRIBUTE_GROUPS(cfam); +static struct attribute *cfam_s_attrs[] = { + &dev_attr_send_echo_delays.attr, + &dev_attr_chip_id.attr, + &dev_attr_cfam_id.attr, + &dev_attr_send_term.attr, + &dev_attr_config_table.attr, + &dev_attr_smode.attr.attr, + &dev_attr_sdma.attr.attr, + &dev_attr_sisc.attr.attr, + &dev_attr_sism.attr.attr, + &dev_attr_siss.attr.attr, + &dev_attr_sstat.attr.attr, + &dev_attr_si1m.attr.attr, + &dev_attr_si1s.attr.attr, + &dev_attr_sic.attr.attr, + &dev_attr_si2m.attr.attr, + &dev_attr_si2s.attr.attr, + &dev_attr_scmdt.attr.attr, + &dev_attr_sdata.attr.attr, + &dev_attr_slastd.attr.attr, + &dev_attr_smbl.attr.attr, + &dev_attr_soml.attr.attr, + &dev_attr_snml.attr.attr, + &dev_attr_smbr.attr.attr, + &dev_attr_somr.attr.attr, + &dev_attr_snmr.attr.attr, + NULL, +}; + +ATTRIBUTE_GROUPS(cfam_s); + static char *cfam_devnode(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) { @@ -1046,6 +1077,57 @@ static const struct device_type cfam_type = { .groups = cfam_groups }; +static char *cfam_ody_devnode(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) +{ + const struct fsi_slave *slave = to_fsi_slave(dev); + +#ifdef CONFIG_FSI_NEW_DEV_NODE + return kasprintf(GFP_KERNEL, "fsi/ody%d", slave->cdev_idx); +#else + return kasprintf(GFP_KERNEL, "ody%d", slave->cdev_idx); +#endif +} + +static const struct device_type cfam_ody_type = { + .name = "ody", + .devnode = cfam_ody_devnode +}; + +static char *cfam_s_devnode(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) +{ + const struct fsi_slave *slave = to_fsi_slave(dev); + +#ifdef CONFIG_FSI_NEW_DEV_NODE + return kasprintf(GFP_KERNEL, "fsi/cfam-s%d", slave->cdev_idx); +#else + return kasprintf(GFP_KERNEL, "cfam-s%d", slave->cdev_idx); +#endif +} + +static const struct device_type cfam_s_type = { + .name = "cfam-s", + .devnode = cfam_s_devnode, + .groups = cfam_s_groups, +}; + +static const struct device_type *fsi_get_cfam_type(u32 id) +{ + u32 major = (id & 0xf00) >> 8; + u32 minor = (id & 0xf0) >> 4; + + switch (major) { + case 0x9: + return &cfam_s_type; + case 0xc: + if (minor == 0) + return &cfam_ody_type; + fallthrough; + case 0xd: + default: + return &cfam_type; + } +} + static char *fsi_cdev_devnode(const struct device *dev, umode_t *mode, kuid_t *uid, kgid_t *gid) { @@ -1202,7 +1284,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) spin_lock_init(&slave->lock); dev_set_name(&slave->dev, "slave@%02x:%02x", link, id); - slave->dev.type = &cfam_type; + slave->dev.type = fsi_get_cfam_type(cfam_id); slave->dev.parent = &master->dev; slave->dev.of_node = fsi_slave_find_of_node(master, link, id); slave->dev.release = fsi_slave_release; From patchwork Wed Jun 5 21:23:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687567 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 6474D16DECE; Wed, 5 Jun 2024 21:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=D58MBvBMNhDv1/XIsBZdkY5oWU2+tQjHIpFFPqs4JJkCV9QRr7TqxWpsPNOzlIcUyzQuDKmPrPFf00bjGcChssvAz+AjyszhXZ6phAXCGhxDGn2urEd7rehieLltgjSj+0X+eX4m80ghn9QXpvB2R2RSJ+IJy1Txv+NiXg59nmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=zMJ+8CKS5IsMYaQmugxKikdp5cTIBgraD/MHYZfjCLw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZYPxJS8wbgPMppKQ2lwlBAJLoHqzJeGwOzYQCYsdDsTqCKoHxVn5EqcbJvD+t+Ox866oWAd/5ijUpjvJ+Bs16RfUieyeLoJ4ikaMRM4UyJoyhWxG94hDv6R9eZ3grDaNymfJyRQoE3zY3OK2u6Sv1xAU23k915EGGqgjp+03Udw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=h2RoRc5h; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="h2RoRc5h" Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KKjwf025645; Wed, 5 Jun 2024 21:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=HSXJ9y93L2w7WCAUvMAiyKwD8OoKP9OCmQlQEBeTKjo=; b=h2RoRc5hkNiq33dYGtaDUsQNjDVbRXf/FYGirO4oFwkZ/aZMMUJZI9B6c4gJACYclT0G Ydefg8POZqrT0aNB2wCaOXBoQzA9V14TmLiyLec8vJOHNLhbkKEHBdDw67GiKS3RdDfO FQGOvfhYQsgC9fpFt+CVYlQckIGPM24n2bF1al5Y337SPaGZCkD20JKNmqXsBJDLfm9B pJ+5aFXN0McAYK8tpL2ly/XiiQf7i9db9tzRtrz137ECvlfcaRINKnSl62Vcy0DUL4th KY2Iy53h7v5sL/k2w5l/OE7/UM6Oe4J2DKsPgi8snqMdw+XRYOX0yAB1oEtBqofEf7Xl 5g== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjuwr0qc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IKan1000800; Wed, 5 Jun 2024 21:23:28 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygdyu6wt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:28 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNOR459900160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:27 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEB8158055; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8134658069; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 38/40] spi: fsi: Calculate clock divider from local bus frequency Date: Wed, 5 Jun 2024 16:23:10 -0500 Message-Id: <20240605212312.349188-39-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pXJf5SWkcjqXjY5lUhHcF8kD5LZGfCph X-Proofpoint-GUID: pXJf5SWkcjqXjY5lUhHcF8kD5LZGfCph X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=856 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Use the new FSI device local bus clock to calculate the proper SPI clock divider. Signed-off-by: Eddie James Acked-by: Mark Brown --- drivers/spi/spi-fsi.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-fsi.c b/drivers/spi/spi-fsi.c index fc9e33be1e0e7..e762690f1a390 100644 --- a/drivers/spi/spi-fsi.c +++ b/drivers/spi/spi-fsi.c @@ -40,6 +40,7 @@ #define SPI_FSI_CLOCK_CFG_SCK_RECV_DEL GENMASK_ULL(51, 44) #define SPI_FSI_CLOCK_CFG_SCK_NO_DEL BIT_ULL(51) #define SPI_FSI_CLOCK_CFG_SCK_DIV GENMASK_ULL(63, 52) +#define SPI_FSI_CLOCK_CFG_SCK_DIV_MIN 0x4 #define SPI_FSI_MMAP 0x4 #define SPI_FSI_DATA_TX 0x5 #define SPI_FSI_DATA_RX 0x6 @@ -70,6 +71,7 @@ struct fsi2spi { struct fsi_device *fsi; /* FSI2SPI CFAM engine device */ struct mutex lock; /* lock access to the device */ + u32 lbus_freq; }; struct fsi_spi { @@ -359,7 +361,7 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, return 0; } -static int fsi_spi_transfer_init(struct fsi_spi *ctx) +static int fsi_spi_transfer_init(struct fsi_spi *ctx, u32 clock_div) { int loops = 0; int rc; @@ -370,7 +372,7 @@ static int fsi_spi_transfer_init(struct fsi_spi *ctx) u64 status = 0ULL; u64 wanted_clock_cfg = SPI_FSI_CLOCK_CFG_ECC_DISABLE | SPI_FSI_CLOCK_CFG_SCK_NO_DEL | - FIELD_PREP(SPI_FSI_CLOCK_CFG_SCK_DIV, 19); + FIELD_PREP(SPI_FSI_CLOCK_CFG_SCK_DIV, clock_div); end = jiffies + msecs_to_jiffies(SPI_FSI_TIMEOUT_MS); do { @@ -421,6 +423,24 @@ static int fsi_spi_transfer_init(struct fsi_spi *ctx) return rc; } +static u32 fsi_spi_calculate_clock_div(struct fsi2spi *bridge, struct spi_device *dev, + struct spi_transfer *transfer) +{ + u32 div = 19; + + if (bridge->lbus_freq) { + u32 desired_speed_hz = transfer->speed_hz ?: dev->max_speed_hz; + + div = DIV_ROUND_UP(bridge->lbus_freq, desired_speed_hz); + if (div < SPI_FSI_CLOCK_CFG_SCK_DIV_MIN) + div = SPI_FSI_CLOCK_CFG_SCK_DIV_MIN; + + transfer->effective_speed_hz = bridge->lbus_freq / div; + } + + return div; +} + static int fsi_spi_transfer_one_message(struct spi_controller *ctlr, struct spi_message *mesg) { @@ -429,6 +449,7 @@ static int fsi_spi_transfer_one_message(struct spi_controller *ctlr, unsigned int len; struct spi_transfer *transfer; struct fsi_spi *ctx = spi_controller_get_devdata(ctlr); + u32 div; rc = fsi_spi_check_mux(ctx->bridge->fsi, ctx->dev); if (rc) @@ -446,7 +467,8 @@ static int fsi_spi_transfer_one_message(struct spi_controller *ctlr, dev_dbg(ctx->dev, "Start tx of %d bytes.\n", transfer->len); - rc = fsi_spi_transfer_init(ctx); + div = fsi_spi_calculate_clock_div(ctx->bridge, mesg->spi, transfer); + rc = fsi_spi_transfer_init(ctx, div); if (rc < 0) goto error; @@ -533,6 +555,7 @@ static int fsi_spi_probe(struct device *dev) bridge->fsi = fsi; mutex_init(&bridge->lock); + bridge->lbus_freq = fsi_device_local_bus_frequency(fsi); for_each_available_child_of_node(dev->of_node, np) { u32 base; @@ -550,6 +573,10 @@ static int fsi_spi_probe(struct device *dev) ctlr->dev.of_node = np; ctlr->num_chipselect = of_get_available_child_count(np) ?: 1; + if (bridge->lbus_freq) { + ctlr->min_speed_hz = DIV_ROUND_UP(bridge->lbus_freq, 0xfff); + ctlr->max_speed_hz = bridge->lbus_freq / SPI_FSI_CLOCK_CFG_SCK_DIV_MIN; + } ctlr->flags = SPI_CONTROLLER_HALF_DUPLEX; ctlr->max_transfer_size = fsi_spi_max_transfer_size; ctlr->transfer_one_message = fsi_spi_transfer_one_message; From patchwork Wed Jun 5 21:23:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687556 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 5B699169AE9; Wed, 5 Jun 2024 21:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622624; cv=none; b=HRTFkN6adyFeItJBPZ6+gZ1ZP5gYvU25nw3OukOqu9TrrdV2jIcX7r2nO+R9YqEzvTrfoC3QUbwwom6O5ny2uFvDAiBiBSSkweB1CXxsWDc9ATTNv7T4P9voRCBW1HELx+fglK5beGBzF+Jj5gAd896EvyV5tGfgH2S03NfTi7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622624; c=relaxed/simple; bh=jDLtDsIPQ9cZDigPLWvteHkrW9nW7CaI9vdJjdDIbyQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TKIrw9R8cJm6wP47+Rn5kI+QyUMqiuwK2r1ZaD4nrZnqD4L6nGp83sGsRkh46CT63gyvzIDOEmGLnhBg5lIWPykxn20A34kRm9GpLO49QEkIxVGqEi5o7/jHSQWG0Awu/e4o7hEXuVntMX9V54Ou/CKPaO+e23t5Uoa1PteMdj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=NALWO5t6; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="NALWO5t6" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455LBkFI011845; Wed, 5 Jun 2024 21:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=qasIk3RIlDr87q8vk5+/hF6hYt5CYIJF1PO4NtdRHKc=; b=NALWO5t6GwqWu9gJynh6ScYqB74uYALXX2q4J7hbK+2E0ixwkU2MjXCSueNH+iAqHHWS Jsbq5oz5gApjtkxJl4SfQEN9ZwgBcFTzU+HuoWuT52iDFqBSrdV/ZvYSJhxESDc++gLS vQd9YxxOcojRcLPtCqfTovzDCerXB/ZED+Ns0cvX7HpOsG5jQtX6/1MUUrXTdHPlvnCq KVGzK5/nGLrruyM21brKh8udMRuPf3FNuFl88nKHapgKoyvYlkKwZ4WuHFq8Tkr8a7T+ F+oSqn7SSwGbAXwsmxRkDozu6sb8nwv6nspUFMAr8M9gL3C5x8vJ3+rTML79oNCOIAVX 9g== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjyqf00s1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455IRk5G008458; Wed, 5 Jun 2024 21:23:28 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygec0xv72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:28 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNPii26215096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:27 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1871858059; Wed, 5 Jun 2024 21:23:25 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C59E35805D; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:24 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 39/40] ARM: dts: aspeed: P10 and tacoma: Set FSI clock frequency Date: Wed, 5 Jun 2024 16:23:11 -0500 Message-Id: <20240605212312.349188-40-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: idsBmgqBPFjTMenUQ9YqFj1idWgwxJ-z X-Proofpoint-ORIG-GUID: idsBmgqBPFjTMenUQ9YqFj1idWgwxJ-z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxlogscore=758 impostorscore=0 adultscore=0 bulkscore=0 malwarescore=0 clxscore=1015 mlxscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Now that the driver doesn't hardcode the clock divider, set it in the device tree. Signed-off-by: Eddie James --- arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts | 1 + arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts index 213023bc5aec4..96a8f727bc389 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts @@ -193,6 +193,7 @@ &fsim0 { #address-cells = <2>; #size-cells = <0>; + clock-frequency = <100000000>; fsi-routing-gpios = <&gpio0 ASPEED_GPIO(Q, 7) GPIO_ACTIVE_HIGH>; fsi-mux-gpios = <&gpio0 ASPEED_GPIO(B, 0) GPIO_ACTIVE_HIGH>; diff --git a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi index 07ce3b2bc62a3..44e48e39e6e96 100644 --- a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi +++ b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi @@ -8,6 +8,7 @@ &fsim0 { #size-cells = <0>; cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 0) GPIO_ACTIVE_HIGH>; + clock-frequency = <100000000>; cfam@0,0 { reg = <0 0>; From patchwork Wed Jun 5 21:23:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 13687570 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 D64FA17837D; Wed, 5 Jun 2024 21:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622628; cv=none; b=LumNGE+8/HhHoO4CoOsc9NxYPe4Cnf67xDF3kRp6gL/McUggSjbO8tDrQXeQIHCd7ZDVj/5ui6ppS0BDr2IBjq+1RoYAPHjAe+IxoTagWBeG4cxn3pu/WhhQaL06ZvMEP7sT1blIYDPH0gm6feUgKXUzNkv0ntUe7IyhnS8vzk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622628; c=relaxed/simple; bh=M9G0C5XMvwwySAScbo9qEW4QmuRwYiNTlRB1r+pCTRQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=caTTpt6js40DiH9FII3tFXpffQlKmx8vQCXLCYx46JtH707M7g7Je1xVEjVJmbXYbiIlVnUzZ6a49LPlsIseNVmteNA8f71BW849hBmhghSGGlRYVcVwLPHBwcJM8CJblTCEDPSThzK1KgSiQnuctdlO4hZbK6yOJsm/7mNnanw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=XEEDeGR+; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="XEEDeGR+" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455K7DIq006862; Wed, 5 Jun 2024 21:23:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=MU/yVusaZAzYIm5jhrcns6ij25EwWFQhZWpvdpTtNWw=; b=XEEDeGR+ZYYmnLGurKIeipX8pgtDkOyhp1yIlpjqvAMMLwj8C6XEAEowiR3tuJVFXlX0 EVTty9dknzNlwEnRkODi7LhjV/CDuOy3HfOTQXW9Wgub0MmLJSFDWwoxD3arsGMXE4Ct dQ/TcFYmV0zHk+BmryL89HIy7b/jLJuU1lIsm9isxHpd7/TLdGrupPCtlt+Vkyyy4Btx d9U1BnjfqEmJX2HfjoFmCBaCsiBTGJw97CMXczh1c2VSEgdN0DD69U2ePQM6CYkm2BG/ XjcGrraP7d5RRjPItAe+EYO973NTporg2clKxT0rmA41dXGyoKcqzW1qw/WUOsN8YqlH PQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxjmr903-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KwRtG026549; Wed, 5 Jun 2024 21:23:29 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yggp366g3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:29 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNP2X24642218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:27 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C5255805D; Wed, 5 Jun 2024 21:23:25 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ED6058065; Wed, 5 Jun 2024 21:23:25 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:25 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 40/40] ARM: dts: aspeed: P10: Bump SPI max frequencies Date: Wed, 5 Jun 2024 16:23:12 -0500 Message-Id: <20240605212312.349188-41-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Qb4eb5mdv3-HGoqZyiKOPrRsovDjbZAy X-Proofpoint-ORIG-GUID: Qb4eb5mdv3-HGoqZyiKOPrRsovDjbZAy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 clxscore=1015 adultscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=891 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 These parts support 10MHZ. Signed-off-by: Eddie James --- .../dts/aspeed/aspeed-bmc-ibm-everest.dts | 32 +++++++++---------- .../arm/boot/dts/aspeed/ibm-power10-dual.dtsi | 16 +++++----- .../arm/boot/dts/aspeed/ibm-power10-quad.dtsi | 16 +++++----- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ibm-everest.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ibm-everest.dts index 214b2e6a4c6df..1365dc95f1352 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-ibm-everest.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ibm-everest.dts @@ -2797,7 +2797,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -2813,7 +2813,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -2830,7 +2830,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -2847,7 +2847,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; @@ -3170,7 +3170,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3186,7 +3186,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3203,7 +3203,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3220,7 +3220,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; @@ -3543,7 +3543,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3559,7 +3559,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3576,7 +3576,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3593,7 +3593,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; @@ -3916,7 +3916,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3932,7 +3932,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3949,7 +3949,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -3966,7 +3966,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; diff --git a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi index 44e48e39e6e96..e11354bb384c2 100644 --- a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi +++ b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi @@ -94,7 +94,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -110,7 +110,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -127,7 +127,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -144,7 +144,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; @@ -261,7 +261,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -277,7 +277,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -294,7 +294,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -311,7 +311,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; diff --git a/arch/arm/boot/dts/aspeed/ibm-power10-quad.dtsi b/arch/arm/boot/dts/aspeed/ibm-power10-quad.dtsi index 57494c744b5d0..0ffb4ae6423fc 100644 --- a/arch/arm/boot/dts/aspeed/ibm-power10-quad.dtsi +++ b/arch/arm/boot/dts/aspeed/ibm-power10-quad.dtsi @@ -744,7 +744,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -760,7 +760,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -777,7 +777,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -794,7 +794,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; }; @@ -1117,7 +1117,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -1133,7 +1133,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -1150,7 +1150,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; @@ -1167,7 +1167,7 @@ eeprom@0 { compatible = "atmel,at25"; reg = <0>; - spi-max-frequency = <1000000>; + spi-max-frequency = <10000000>; }; }; };