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: 801919 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: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: 801921 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: 801916 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: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: 801914 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: 801918 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: 801920 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: 801904 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: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: 801906 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: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: 801915 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: 801905 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: 801909 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: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: 801908 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: 801910 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: 801917 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: 801913 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: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: 801911 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: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: 801912 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: 801902 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: 801901 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: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: 801907 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: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: 801903 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;