From patchwork Mon Feb 26 16:52: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: 206777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2202408dyb; Mon, 26 Feb 2024 08:56:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBSlM54vxbdkLzzlwD/Wn6XVno/+eG9NunvKEuV6HMasvq67nieGma+ILpEjQlYKJv4XpxsdJ05jrxAK9auGFp5Igt4Q== X-Google-Smtp-Source: AGHT+IF9wWnFzFcDWqv/dX3BqpAVcVg5Ps/E6vnA3znhxNdN4ySnDV2WKFD1AbTpSbuy6pHUYP1U X-Received: by 2002:a05:6214:cae:b0:68f:8ddd:aad3 with SMTP id s14-20020a0562140cae00b0068f8dddaad3mr9875269qvs.20.1708966568753; Mon, 26 Feb 2024 08:56:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966568; cv=pass; d=google.com; s=arc-20160816; b=YgJ1i/Au6V0HQ0EXFroK4oF2kZ5a2T/pBiG2rYF0jM+1lXpblfFh4nd39vQtXPR0BS EBw4Qm0dYaPmQ/PCfAjoAymC458xgI3A3735sXRoHr5DJh4GbmXkj5uGNpm0rsCmDYBD fwrhploxwoooh58GXS8UwXDRK1UZseJbKArFhOAPv8g47s7bXwakdnYEdX5X3XGl9+D4 Oso0/PcBW03gPtiA47fBRn8DcSUBqpNT+KEy+S+3BCQIEqOsl971IvTNkiDLRbiVNaYo 2rRDZm2WntXgf3jlxwZv7C3TsBQrAYEDwYcL+fUA9RpXpZjIXmuCOq2UfGZ47HO4t3RH OWeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EzykbgY8VklP3b8xENMmzzAd8qt59mCClFOsxoemn6M=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=VlUxZW7YdS289bASRCFW9o9b3o4boZtLxvwGiqy1tOFif+PExDriF/oKhGjCKK/Cu3 K+6mON9Bpc1Lyt1LtiAaPNAFb7x0ejMF5OoEeSCAIISlORpl9Db6SLzcgwSSDrEYFjyD GAFQtXEqToI7bpsh4GFM6DbQ9DtkHi5bpybtgU2XQvbpYX95ZqqzqbT1sPR1hkXxv9WN K7zFMAbCeXZlotI+sNzxd1uCcT83RGRgog3EHCjGSE1mgv3DkeCiqslCCeAjKwJI2Jit K6eUhnSAvvPW6WE45N/uuD9MByrDo0lc3ZPvpsOizI8EJRpayDEmGZ5/oZT1z0GZcm0F Dy+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JHEsN4xr; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81951-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81951-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r2-20020a056214212200b0068caf39560dsi5820830qvc.429.2024.02.26.08.56.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:56:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81951-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JHEsN4xr; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81951-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81951-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2AF2F1C2A518 for ; Mon, 26 Feb 2024 16:55:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A108812FF92; Mon, 26 Feb 2024 16:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="JHEsN4xr" 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 B2BF812CD9B; Mon, 26 Feb 2024 16:53:41 +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=1708966423; cv=none; b=EwQZn4qcKM/ZVdchjZq8qlpSSrHKm0+cPTx4zqeDBkzT6RWkRlAFAeFcGc4bZK0P/bKh0bok7x9xQ+aQKfOTKooVV63J50txt3zj+qwro1z5zm8atsZXMFSYsGa0ziDuk6vX4WdsCnXybhAzfH4AX309Yq21+ZCWCl5zKc/gb7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966423; c=relaxed/simple; bh=riOdEpyj6YoR7dLCa84jfGwhhYRmIX3Tq7kzf7ULdVA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AE7iUwNHt3R6HtkaQV9wso2ZCJxLCE1W2VQXx8r4/2on+3fMm8wvF2ES+QGKzCuiMNJXsoM3YbIplalHktQzgRs6Gkxj+Lrvn5xiyGVVj1rHkcOAU9tfw1KuaecDermVuGtYJYc9SIoTitY1Co80JPV/uwKuZNzp3d3hYsWmdCg= 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=JHEsN4xr; 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 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 41QF2jao021749; Mon, 26 Feb 2024 16:53:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=EzykbgY8VklP3b8xENMmzzAd8qt59mCClFOsxoemn6M=; b=JHEsN4xra+lXfagUh1b5WyPlME0LtGEQ5XNaWiMOStmiK5g/FLYAjmBZ3GaS9fTdP6lN OiQ6842StqMzcO8OvogVnUGfrB4cwW7nB6RtfExbbdQkcLarPNfJDIqZ6AZXqy2TeiL7 WS2ucQE3a1mEHpkk20AS/Y15j43XMakxSBo7NOzemdKyDvshdaXLzqmUbrc4+QXS79Y6 j1yI6HL023M2OBu2g5dhqr7DdhGlLQwuLgMCq5GxFZOMbSuhd42ET8bAsiJdtv29uIDN z6om8a8BzB7kqVmmHTOD6/8OMKqXLhRyiffwUaecglDaip47/tl8nep2gSgJeOiUpk3s /w== 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 3wgvp6bjtm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53: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 41QGTLCv021808; Mon, 26 Feb 2024 16:53:26 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytkqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:26 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrNWt15401550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:25 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 811735805F; Mon, 26 Feb 2024 16:53:23 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C64E458043; Mon, 26 Feb 2024 16:53:22 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:22 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 01/31] fsi: Move slave definitions to fsi-slave.h Date: Mon, 26 Feb 2024 10:52:51 -0600 Message-Id: <20240226165321.91976-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: kDm3yAE57BGX1UjRduOtHtmyUbHpZp_i X-Proofpoint-GUID: kDm3yAE57BGX1UjRduOtHtmyUbHpZp_i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981328846019497 X-GMAIL-MSGID: 1791981328846019497 Master drivers may need access to the slave definitions. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 35 ----------------- drivers/fsi/fsi-slave.h | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 35 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 097d5a780264..7bf0c96fc017 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -45,41 +45,6 @@ static const int engine_page_size = 0x400; -#define FSI_SLAVE_BASE 0x800 - -/* - * FSI slave engine control register offsets - */ -#define FSI_SMODE 0x0 /* R/W: Mode register */ -#define FSI_SISC 0x8 /* R/W: Interrupt condition */ -#define FSI_SSTAT 0x14 /* R : Slave status */ -#define FSI_SLBUS 0x30 /* W : LBUS Ownership */ -#define FSI_LLMODE 0x100 /* R/W: Link layer mode register */ - -/* - * SMODE fields - */ -#define FSI_SMODE_WSC 0x80000000 /* Warm start done */ -#define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */ -#define FSI_SMODE_SID_SHIFT 24 /* ID shift */ -#define FSI_SMODE_SID_MASK 3 /* ID Mask */ -#define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ -#define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ -#define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ -#define FSI_SMODE_SD_MASK 0xf /* Send delay mask */ -#define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ -#define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ - -/* - * SLBUS fields - */ -#define FSI_SLBUS_FORCE 0x80000000 /* Force LBUS ownership */ - -/* - * LLMODE fields - */ -#define FSI_LLMODE_ASYNC 0x1 - #define FSI_SLAVE_SIZE_23b 0x800000 static DEFINE_IDA(master_ida); diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index 1d63a585829d..dba65bd4e083 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -7,6 +7,90 @@ #include #include +#define FSI_SLAVE_BASE 0x800 + +/* + * FSI slave engine control register offsets + */ +#define FSI_SMODE 0x0 /* R/W: Mode register */ +#define FSI_SISC 0x8 /* R : Interrupt condition */ +#define FSI_SCISC 0x8 /* C : Clear interrupt condition */ +#define FSI_SISM 0xc /* R/W: Interrupt mask */ +#define FSI_SISS 0x10 /* R : Interrupt status */ +#define FSI_SSISM 0x10 /* S : Set interrupt mask */ +#define FSI_SCISM 0x14 /* C : Clear interrupt mask */ +#define FSI_SSTAT 0x14 /* R : Slave status */ +#define FSI_SI1S 0x1c /* R : Slave interrupt 1 status */ +#define FSI_SSI1M 0x1c /* S : Set slave interrupt 1 mask */ +#define FSI_SCI1M 0x20 /* C : Clear slave interrupt 1 mask */ +#define FSI_SLBUS 0x30 /* W : LBUS Ownership */ +#define FSI_SRSIC0 0x68 /* C : Clear remote interrupt condition */ +#define FSI_SRSIC4 0x6c /* C : Clear remote interrupt condition */ +#define FSI_SRSIM0 0x70 /* R/W: Remote interrupt mask */ +#define FSI_SRSIM4 0x74 /* R/W: Remote interrupt mask */ +#define FSI_SRSIS0 0x78 /* R : Remote interrupt status */ +#define FSI_SRSIS4 0x7c /* R : Remote interrupt status */ +#define FSI_LLMODE 0x100 /* R/W: Link layer mode register */ + +/* + * SMODE fields + */ +#define FSI_SMODE_WSC 0x80000000 /* Warm start done */ +#define FSI_SMODE_ECRC 0x20000000 /* Hw CRC check */ +#define FSI_SMODE_SID_SHIFT 24 /* ID shift */ +#define FSI_SMODE_SID_MASK 3 /* ID Mask */ +#define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ +#define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ +#define FSI_SMODE_SD_SHIFT 16 /* Send delay shift */ +#define FSI_SMODE_SD_MASK 0xf /* Send delay mask */ +#define FSI_SMODE_LBCRR_SHIFT 8 /* Clk ratio shift */ +#define FSI_SMODE_LBCRR_MASK 0xf /* Clk ratio mask */ + +/* + * SISS fields + */ +#define FSI_SISS_CRC_ERROR BIT(31) +#define FSI_SISS_PROTO_ERROR BIT(30) +#define FSI_SISS_LBUS_PARITY_ERROR BIT(29) +#define FSI_SISS_LBUS_PROTO_ERROR BIT(28) +#define FSI_SISS_ACCESS_ERROR BIT(27) +#define FSI_SISS_LBUS_OWNERSHIP_ERROR BIT(26) +#define FSI_SISS_LBUS_OWNERSHIP_CHANGE BIT(25) +#define FSI_SISS_ASYNC_MODE_ERROR BIT(14) +#define FSI_SISS_OPB_ACCESS_ERROR BIT(13) +#define FSI_SISS_OPB_FENCED BIT(12) +#define FSI_SISS_OPB_PARITY_ERROR BIT(11) +#define FSI_SISS_OPB_PROTO_ERROR BIT(10) +#define FSI_SISS_OPB_TIMEOUT BIT(9) +#define FSI_SISS_OPB_ERROR_ACK BIT(8) +#define FSI_SISS_MFSI_MASTER_ERROR BIT(3) +#define FSI_SISS_MFSI_PORT_ERROR BIT(2) +#define FSI_SISS_MFSI_HP BIT(1) +#define FSI_SISS_MFSI_CR_PARITY_ERROR BIT(0) +#define FSI_SISS_ALL 0xfe007f00 + +/* + * SI1S fields + */ +#define FSI_SI1S_SLAVE_BIT 31 +#define FSI_SI1S_SHIFT_BIT 30 +#define FSI_SI1S_SCOM_BIT 29 +#define FSI_SI1S_SCRATCH_BIT 28 +#define FSI_SI1S_I2C_BIT 27 +#define FSI_SI1S_SPI_BIT 26 +#define FSI_SI1S_SBEFIFO_BIT 25 +#define FSI_SI1S_MBOX_BIT 24 + +/* + * SLBUS fields + */ +#define FSI_SLBUS_FORCE 0x80000000 /* Force LBUS ownership */ + +/* + * LLMODE fields + */ +#define FSI_LLMODE_ASYNC 0x1 + struct fsi_master; struct fsi_slave { From patchwork Mon Feb 26 16:52: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: 206776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2202290dyb; Mon, 26 Feb 2024 08:55:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX3M05Yuks4HD42DgN3rw6V4jukutkTaQDdLXgIyRQhR3RiEZGzaTQBW3p2xYuKqwlr4ZYJ3pefbdzMI6duHgT7eU4BIA== X-Google-Smtp-Source: AGHT+IE2GECg7/1JyvvdcowWzxHEi1HHnEs6BN9Orwa3M+1WcWkPoWrkPhF6QK28mn0jrAUzA/lB X-Received: by 2002:a0c:de0e:0:b0:68f:2d56:fc11 with SMTP id t14-20020a0cde0e000000b0068f2d56fc11mr8421080qvk.51.1708966556896; Mon, 26 Feb 2024 08:55:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966556; cv=pass; d=google.com; s=arc-20160816; b=W04GMU+2UBpEdOMUKarscDtcKRkR3xUPcaq4L/lBiF+Zx1tet/Z52hAvUW8Ejsj8lj 4FeeTjU9Dr1u1WJmAK5a2FaimF2bpP9FTb5grWnI8jLeVBU7IpIsHGMuprwAIMf7/Jp1 LGta4lZ235LSnJssYKWBIMQ2TDGu/djfiShf+I5TYVReoDPQsOYAvP/WFKA5A30wBxAw Sg9e7PSLwQowZZZQg2rNwOR/mph+Zb8iOlZEsHKKQkz78z+6XewJWSDw/sek/VHT/Cos 4fHRUBl08yraTFe/bklblg/pcJAqNi3tH9VJCvXFDU2D37rcC1G586OKGR1WEJA32vjX T6Tw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=42KZToJ6L2oi/2I8rKEPazeyIcIc7KzaadnBTEbvxS8=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=Y0hY5TmLsgTecVrJ6pOiU/ZA918gOz++UXjlZCD8AY8AbUJ/8HEEMs25vNklKw8eLa od4T+4A3z8QMEkokqFGRBz64K5+RIId+pj0sl10oxwk307w846PyaH/lU3eC3LzdyXiP wRRnF1t57zD1ZjCtUkMiSSqpHa5/VfjNlbJG9vvMNmVw29l7pG/9fLM4A9u3GJlBCUgM klZ/YwLjS8wOot3w3zrENcv7KWMTAIhrvc6WF/os24ZBPl7UDVQYq6GrfQu6pE3zIgNt BRfjUEVtMCU/l+OvpfBk7ahft77ToT/znEqrOatlDmQWhFBdyFWXrz1Cb4bxbLmA2H/2 LlqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=KLFbl+wT; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81950-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g8-20020a0562140ac800b0068f5c7d73absi5677287qvi.161.2024.02.26.08.55.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:55:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=KLFbl+wT; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81950-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DB8DB1C2BAC8 for ; Mon, 26 Feb 2024 16:55:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB7DE12FF61; Mon, 26 Feb 2024 16:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KLFbl+wT" 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 C9BD412D75F; Mon, 26 Feb 2024 16:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966423; cv=none; b=hg3syNll5pS3zWyNtRJ0mzlDYZs+IyvsxlqX6OTuW1/XLNlYI3Q/1hVbA5gWbWuxzrzzka+gpcWph6qQd7piFCykFNoB4WTb0T7oBZlXkVRXzZUia7Sj0ync2ArjYQRszl2d2eKmwy4HItWcgR2ZR6h0niegZoyXJnTru1+FJds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966423; c=relaxed/simple; bh=t+fL4dbYLUcdsIq4ZMykfifG2UxgfeRtAt3E1EOP/A8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pGhpLx+yazkfPKcuKXP8UkZ8pqoOCP3evi55aLJyNW6MKdHWUnL7zDWWjHqNb1VN1x3mXkRg5yMnR+8P7aph/xyJlKyaw+RkpJmiozo5A+ZTyMFOIopYGLY+H1me5aGbpk5CE7Kwe498id7IxCb++2OJElt1ymY6hHrtagmFMfs= 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=KLFbl+wT; 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 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 41QG5i6L026188; Mon, 26 Feb 2024 16:53:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=42KZToJ6L2oi/2I8rKEPazeyIcIc7KzaadnBTEbvxS8=; b=KLFbl+wTK54ENAwFCeRwOQ1RxZTLuq8qXWweplyRNmCEjoqfL8bn7Dh9QxgCqibz53aj f12/wpxdzEgh04OkHnSH/SRtu0ZCso5r+gehN4g24MwqV4a0UP+glA13ojRSoysaYc/B ZfVIwYNj63tpZyPUKAtwkl0qBU8xjyZox5p5gkRp/16B31VTPHKNPJBB9hoP12OM85o4 LELQ7onVfceggxrA/hub/UGLv+Ip7DMKrSjcPnJ1lELyRkf30+rl78RSNyzvPLXsKEaa 6+44vbmh+5NbK8vwNWAQbhqwyfLQIOPb6aq8t9X9S1gYD/f5ba4kVu/lTTTzEhzlIjEd 5w== 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 3wgvsq33cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:28 +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 41QGmIR9021306; Mon, 26 Feb 2024 16:53:27 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfusntedb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:27 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrOxG66650558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:26 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 519AE58063; Mon, 26 Feb 2024 16:53:24 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9762858043; Mon, 26 Feb 2024 16:53:23 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:23 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 02/31] fsi: Improve master indexing Date: Mon, 26 Feb 2024 10:52:52 -0600 Message-Id: <20240226165321.91976-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: xLt1lVa1QntYMwhEZnW-sGBbMaMkQ8Dc X-Proofpoint-ORIG-GUID: xLt1lVa1QntYMwhEZnW-sGBbMaMkQ8Dc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981316279162876 X-GMAIL-MSGID: 1791981316279162876 Master indexing is problematic if a hub is rescanned while the root master is being rescanned. Move the IDA free below the device unregistration, lock the scan mutex in the probe function, and request a specific idx in the hub driver. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 12 +++++------- drivers/fsi/fsi-master-hub.c | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 7bf0c96fc017..1c687eb021a0 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1271,7 +1271,6 @@ static struct class fsi_master_class = { int fsi_master_register(struct fsi_master *master) { int rc; - struct device_node *np; mutex_init(&master->scan_lock); @@ -1295,14 +1294,13 @@ int fsi_master_register(struct fsi_master *master) rc = device_register(&master->dev); if (rc) { ida_free(&master_ida, master->idx); - goto out; - } + } else { + struct device_node *np = dev_of_node(&master->dev); - np = dev_of_node(&master->dev); - if (!of_property_read_bool(np, "no-scan-on-init")) { - fsi_master_scan(master); + if (!of_property_read_bool(np, "no-scan-on-init")) + fsi_master_scan(master); } -out: + mutex_unlock(&master->scan_lock); return rc; } diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 6d8b6e8854e5..36da643b3201 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 Mon Feb 26 16:52: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: 206780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203005dyb; Mon, 26 Feb 2024 08:57:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUYIe0R4Niht/Qy01LMhvdwNItI+LtlHU/WPdU9OL79htR8FPQL9ijpFSVR5zUbGKiV5gtWcfN0rsymGQhrh/KVXpoOmw== X-Google-Smtp-Source: AGHT+IHd+NY3kGkhhgCtivet+y4K8S+pUEzlfB/hKj3+7O1q66xrdBj5DBG1e3hF9FnlnHpFKE5A X-Received: by 2002:a05:6a00:1b43:b0:6e4:e7dc:25a4 with SMTP id o3-20020a056a001b4300b006e4e7dc25a4mr6888564pfv.23.1708966644274; Mon, 26 Feb 2024 08:57:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966644; cv=pass; d=google.com; s=arc-20160816; b=ZDwN2B38aFiDjyGwmFZQt49+tLWJx3UmYVp3GQZcl/rremOiy5/oH18zraYRzn6S+a jhpnj6PKsJvUpYhAJlhZZ639Wv515cBdpd3/ZoXkDhhFjMKDq9dcI7TnLADH4sAe2lun 2hbOkZvk3fTzy9UNRvuAtNY2/KyojAmKx1G+mHyBRc1JIFnbbuCfE2OLm8hpgWRXrKzX DDXN3t+l5VJJEJJ0m234tSGZmbo12uXoqKDn8ftO0VCYWsFi51Bzg9p3rHG8cfVQ/3JG jonq0eY/6h5UpK5B6afqLu/Oszxov0JWQIfpAFhPxoH1gR4dCEfPSgjAnxpLD1J4O7/u 90Sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RLpioKRBvBvjG6X7CZTJJIG/dvzFzjHsdAqj+Tw9e24=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=fLTckBZs4f9Bv+EuIJ7v05oaNZ4D7Ib940/V/D5DiiyCRchvqgIPTbM4BVc9f9eAqP cz6f+0jebK3F2DG+ofZ8dZjoauuwMqY2xUpqLzJRT3hRAD/08m5WZBAfBBSu9ZPNF4C9 +yF6PSAS+OpqI/8MyYZBXBAnp9wLL8W0AVcNfb+AJ/lY2dUROkPFbuM9KWz3L+Ba/0Ge LYs4cktaqcC1kK4Zh0aC8rNWa1N/DIIdx/uhTbxCBCOC1WZ/XUS8osVWzMpVtFY1u+y/ ci38E7Rhvvr3UTIG1gix8ZpzzYwob/vnZxUfo/SLTaDWllYSsNP0V0BVcCK5REuiQrZb BAsw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AfhZeMNN; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81949-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j24-20020aa783d8000000b006e47dc9d922si3976663pfn.138.2024.02.26.08.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=AfhZeMNN; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81949-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E034C289A7C for ; Mon, 26 Feb 2024 16:55:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6725B12FB10; Mon, 26 Feb 2024 16:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="AfhZeMNN" 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 538EE12C7FC; Mon, 26 Feb 2024 16:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966422; cv=none; b=G3GLpHD6+F9FLYSOuLOa5CuUWXfogmdIgZ4LaFbtWGOxPB3BxCGOABfT3sTqljaI1sfkgbRNi5etPwrdno1+fJZ1XhYqO3oaUIw2Gidi37zmjGmOJVmOPDV22qGruXlPfKBm+IBMGs6SDQoywWH9PeYMd8wL56RLJRPuEgD6w3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966422; c=relaxed/simple; bh=gT16x+suHzi4RJDxnpVIxo63PiknxpyG8sAgpETh/No=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C18aW4D5v+etRDMCA+RqxNL7euhKTfLjpjTrjkqrDJ57qJB7WubP9mjSnLGNDLZuuHbDH9LiUZA7oohhLT0ixMpATvJQewtf85EgdM4n+/XcZ4uyonsT+SDAeTnRlFWgULKFEHMneBvscMQW14LnKijTIVsPyHp+f5MWdyOUMFc= 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=AfhZeMNN; 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 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 41QGgXK8003017; Mon, 26 Feb 2024 16:53:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=RLpioKRBvBvjG6X7CZTJJIG/dvzFzjHsdAqj+Tw9e24=; b=AfhZeMNNflhS5TlF0OCbInsUq8fnMnbB5orPGZGIpKBIUZ1e/8jtujywLdDW05JL5vUG PtSrtp3J7ub1IJT80KlLH8cR9v/Z+XSEJYqkQCkU7AzyWPtV7MzBa1VXK8YLUVlmi7aZ ICft/iwRVJ5gyPqL+1gj9L82tsqo40lurcGokFd/Z6m34biM+DcMKufT7jqNXHaGxuqQ lVDSAX1H/g6XtD/HRVqH0NXswot/aAJNn6Hc+inEYh073WVL5GYCM0FzuDHa79ErUMu6 kuHh6YBdaJ4qwZnQ5gjAb5sKX/y719FTfPfl7KVyKy+hTLixfC78fiUUjIcH2AqjlKw4 mw== 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 3wgxd4g9r3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:28 +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 41QFNDw3024154; Mon, 26 Feb 2024 16:53:27 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23er-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:27 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrP6a14222036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:27 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2983B58053; Mon, 26 Feb 2024 16:53:25 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67E0658043; Mon, 26 Feb 2024 16:53:24 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:24 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 03/31] fsi: Use a defined value for default echo delay Date: Mon, 26 Feb 2024 10:52:53 -0600 Message-Id: <20240226165321.91976-4-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: BzkZT1ZBTfjOdMiCTz16bdgXKFfgIfAD X-Proofpoint-ORIG-GUID: BzkZT1ZBTfjOdMiCTz16bdgXKFfgIfAD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981407939741551 X-GMAIL-MSGID: 1791981407939741551 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 1c687eb021a0..8823e8e56dab 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 dba65bd4e083..dca9db0a42e5 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -41,8 +41,10 @@ #define FSI_SMODE_SID_MASK 3 /* ID Mask */ #define FSI_SMODE_ED_SHIFT 20 /* Echo delay shift */ #define FSI_SMODE_ED_MASK 0xf /* Echo delay mask */ +#define FSI_SMODE_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 Mon Feb 26 16:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203257dyb; Mon, 26 Feb 2024 08:57:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCULsWo2YOu15mJw9UV3gB4anDcsPvC1fq3L2rwpeTqBdwOFQh4uH0oAc5sIwz6EanU/wrByCFeBLbL8Fp/9YHE5mnSmUg== X-Google-Smtp-Source: AGHT+IGVN4GDChhndTTq/7syAyNUtTK1wuYPqr5u4ySLbou769UKUwGVndLKDx//KrNnvqhyX7ei X-Received: by 2002:a05:6402:1606:b0:565:ffa5:becd with SMTP id f6-20020a056402160600b00565ffa5becdmr1969499edv.37.1708966676121; Mon, 26 Feb 2024 08:57:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966676; cv=pass; d=google.com; s=arc-20160816; b=1JmVqTnWY1qpiCLt6d1BAMWnRq+1MGUbxwG5ashOHtFfcFzFiq+74itcz88MEVkK8l u2jyjiFE3d2HDGn3uJ4icbTiOqZgcth8vMOaXUafIfp0CDn1T8v3qqBgah1DJeKYAaLK DaY4oBdeHv2qg0hzdrw0vtvOE6WrFkLlxL3K/IobI4AtKERHu2DYqtdaSX1WYXC6af4E /hYQzVuUC3QdfOOacCUJF/k1VrxE95dY1UmdjzpdstKKv4wRPF2/Q9drCEAUqpg+C+OZ xaT9xNfrbrV4LgZzdDuKNIz1hWv4uY7LrVlRuEZKtv9HJFUKwAcHcogDaW8bqoiy7OKt cn0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SZMmT6FmPBWoUrdH2eDLCNYypdqIO9JdHa/iodwva98=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=i/EHgRdN4C4Iq2RvCfdMj3OFWHsf3TkAbhWPIb+BoGSt7nZm4x3EjUs+14idgkRvjR fYwSDzG9A+4yin5mobF9+5BSxAYkaPDXyF5Audl5beZN+Ayt5JyjGDRl9BPPCSWmvngY xG8DkPpbVjYXpOEaBTOE3QkrKObAgm/+Nt55YCQr85Pa/WcFA4PDKP0JZWJER8YurSAi zEDZ3kSZL8dxWJQJweL7nf0ST66oA/X+UNfBGezs1kcuD/YmU9iXSfvMD9SuXuodXZov XVGuzHsTUXJyAO7qaCTRrGS1Pf2i2CXa9XT90VWgdXOxNq32KG1AFVVW8k/RwZzJ7+LU bPgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Eyi+TgaB; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81956-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l12-20020a056402254c00b00565b69d13a3si1898663edb.148.2024.02.26.08.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Eyi+TgaB; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81956-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81956-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C7311F26FD2 for ; Mon, 26 Feb 2024 16:57:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A12A513246F; Mon, 26 Feb 2024 16:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Eyi+TgaB" 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 2020312EBE2; Mon, 26 Feb 2024 16:53: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=1708966425; cv=none; b=hVyexr09J2LAV54onaNrwEYEDcRpv+YahOx+vt6QLHkuiPb8puWR6/voWwpN6MRKrvwZK3TGNgUogJD3dQSNUzI3wYCWF0Ihc8E4WX3DUYMW5dQM2OT49jigG6kjxoGMBWaEiSvOjm5IP0k5Con5SkCqppSOcX9r8nry0B8ZqHo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; c=relaxed/simple; bh=bDDSQ59Hx/k13de0sfVOys3VHSzqY9HF+wtdkABTdf8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o+6JSrSHV82I4hQOS8N0G+n+amr2uhWV/EIAUxmXSyBwkvPzGYrS8f8+2I2lRWV+wC7K8jZZfIK/klmdFhOk6JPXJ7REdMGabs6BR0nfNbI3U6yYbfgZ0KHFxFSoQyp9ZOS2JoVcjoOshNmteYk3tzYCZ5YQj3PqC8PyK9eb3pc= 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=Eyi+TgaB; 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 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 41QFooRK021801; Mon, 26 Feb 2024 16:53:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=SZMmT6FmPBWoUrdH2eDLCNYypdqIO9JdHa/iodwva98=; b=Eyi+TgaBC7uP/GuikkwmdKrAIa9gJzucp7bap4m32HZVS7rQlZ7u6w7T/0DJmrQl7AWX N4A/S9IgjWC3VsSIy3LNsGAPk40QHTUg1OldPzUNRkZLYp2lWS8w+BvLQvmLxPy6IRTR zsP166I6f0QHbtNj7/gOu8G87cRaltXEOThHSnNoWOLrtzalPxDcoAWaHKI1tcI/BcUi MyqMIQkXhSXlcKpL4PPvnFnylNPQZFH+ztpSpJ+76VZZD1cD2frqs6G7+Caz34Cz8dAw cnOCnz+bKdvH4VbJC9Mwbvb11radvvBMUgaQcL9hmvW2b6yL6SG7xZLvlNgSTmQc+hST 5Q== 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 3wgvp6bjw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:30 +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 41QFL5NR012348; Mon, 26 Feb 2024 16:53:28 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:28 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrQqa66519432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:28 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8DF858059; Mon, 26 Feb 2024 16:53:25 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 390E658043; Mon, 26 Feb 2024 16:53:25 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:25 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 04/31] fsi: Expose master-specific local bus clock divider Date: Mon, 26 Feb 2024 10:52:54 -0600 Message-Id: <20240226165321.91976-5-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6tXFYz9SkgrATz-73cPZW7zxHABo1ANL X-Proofpoint-GUID: 6tXFYz9SkgrATz-73cPZW7zxHABo1ANL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981441385149664 X-GMAIL-MSGID: 1791981441385149664 Instead of a hardcoded local bus clock divider, allow master drivers to select their local bus clock divider. Also expose master clock frequencies in the structure. This will allow FSI engine drivers to set and calculate their bus (I2C, SPI, etc) frequencies. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 27 ++++++++++++++++++++------- drivers/fsi/fsi-master-hub.c | 1 + drivers/fsi/fsi-master.h | 2 ++ drivers/fsi/fsi-slave.h | 1 + include/linux/fsi.h | 1 + 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 8823e8e56dab..9610b5948550 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->master->lbus_divider; +} +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,15 +215,15 @@ 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) +static int fsi_slave_set_smode(struct fsi_slave *slave, int lbus_divider) { uint32_t smode; __be32 data; @@ -225,7 +231,8 @@ static int fsi_slave_set_smode(struct fsi_slave *slave) /* 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, lbus_divider, slave->t_send_delay, + slave->t_echo_delay); data = cpu_to_be32(smode); return fsi_master_write(slave->master, slave->link, slave->id, @@ -281,7 +288,7 @@ static int fsi_slave_handle_error(struct fsi_slave *slave, bool write, slave->t_send_delay = send_delay; slave->t_echo_delay = echo_delay; - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, master->lbus_divider); if (rc) return rc; @@ -773,7 +780,7 @@ static ssize_t slave_send_echo_store(struct device *dev, slave->t_send_delay = val; slave->t_echo_delay = val; - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, master->lbus_divider); if (rc < 0) return rc; if (master->link_config) @@ -1028,7 +1035,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) "can't set slbus on slave:%02x:%02x %d\n", link, id, rc); - rc = fsi_slave_set_smode(slave); + rc = fsi_slave_set_smode(slave, master->lbus_divider); if (rc) { dev_warn(&master->dev, "can't set smode on slave:%02x:%02x %d\n", @@ -1288,6 +1295,12 @@ 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 + + if (!master->lbus_divider) + master->lbus_divider = FSI_SMODE_LBCRR_DEFAULT; + master->dev.class = &fsi_master_class; mutex_lock(&master->scan_lock); diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 36da643b3201..111bf7a11458 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -230,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.lbus_divider = 1; hub->master.idx = fsi_dev->slave->link + 1; hub->master.n_links = links; hub->master.read = hub_master_read; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 967622c1cabf..26e636ad9ef6 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -120,6 +120,8 @@ struct fsi_master { struct device dev; + unsigned long clock_frequency; + int lbus_divider; int idx; int n_links; int flags; diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h index dca9db0a42e5..42af2fae0329 100644 --- a/drivers/fsi/fsi-slave.h +++ b/drivers/fsi/fsi-slave.h @@ -47,6 +47,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 8 /* Default clk ratio */ /* * SISS fields diff --git a/include/linux/fsi.h b/include/linux/fsi.h index 3df8c54868df..e0309bf0ae07 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 Mon Feb 26 16:52: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: 206782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203054dyb; Mon, 26 Feb 2024 08:57:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXtzuxKUbLJX0ElcXLtq4cwcXaBjkqwppkl/U/5FWQGgcjlfjy83QDvZwTm/QMQ+laNYWJwuTX9ZNB8BNFt+rq92MDG4w== X-Google-Smtp-Source: AGHT+IFaTM5Utz+W1NNl8I8wcrROV3F8/CBch5RRGll6yla1u4OwHWA1yGk1FAiyGqwEnX28bv9y X-Received: by 2002:a05:620a:5798:b0:787:9213:73a6 with SMTP id wk24-20020a05620a579800b00787921373a6mr7612503qkn.14.1708966650855; Mon, 26 Feb 2024 08:57:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966650; cv=pass; d=google.com; s=arc-20160816; b=G2KFk04rB7LhkTV6lXi6WI8KBN1FmkQ4wZ8iIop8tprtW+kPTMAzpfSmoMlE32BZPA G7wh4rVuPEhIP9jxJghG/a3M0cX5SkfEyDux/22/GKhc7BoKssqdupF0N79tDl2Q4p6L jtp5Q17CDwGTEiGnTt/AtRw1//6lnKvNIwJz20cHaCOPcaYVHlcFrEmVqq42UDS1k18r AHDUnH93zHf+h4kKScHnB3mAGwPbszQ11hKIfE14CtGZNscpFp2ZIhxZBCrnBzQyYlty Pg8fu1eFN66E7fENvoNeRzgaBVCvusK6/3KwkPmkNKklnrxVFEb96I6IZyxG+eB3IraA 1qDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wUxZWtjBlpcd1C3yzncmoKg+sMI8k4edHwJPu5+uZXE=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=lkx9yIF2vdVOx2gFc1tTJRTlCYSnvJafaKCzWTWIKP4Ccv7JiWuY+5gbR6T9PPd6Vc 5FR4YVmN2w8e+IS6nQGaEPVWKNcye7wNhHoqpIs4zqY/OdrBvXq/tMjJtZm615KqpevV vGxpk7uWo1F7Zmjpr5/rqH7+BQtOnHtNbzlqOLyq2KaW88yu57bXhGk555Ba1dnN4TFj mZeY2Zh5oMmL7EslZVy49brkzRavV947F1kelkYadwgUA0aTvPzW34RXfAtWdgw9Bjdn gOwBMZVwgn993YhtkBCPRLz8UJ1PNt/NO8TbDANQ73AL/66zTENSomGebiLmXrWC5W4s Y5UA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=A4NBfdmW; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81955-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 18-20020a05620a04d200b00787ba3f52e7si5285211qks.648.2024.02.26.08.57.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=A4NBfdmW; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81955-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81955-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 90CDF1C275FB for ; Mon, 26 Feb 2024 16:57:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD10712E1E5; Mon, 26 Feb 2024 16:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="A4NBfdmW" 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 037A112EBD3; Mon, 26 Feb 2024 16:53: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=1708966425; cv=none; b=mTgr0NP3yYm+YwNa0sQcsrrN73YJc1DYtLlHhW+Y/NRta76V8sMWgy8fAOeJBRLYvrQO8+bCUfaABrJi8RkswtWrGfkQH2imN3eLbJW7p6aOpIj2wmPYYG3QphDkpRFSi+EZnSKGstxkc6TLYfX8XDcbzptreQCoI1Jt/2mJ5w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; c=relaxed/simple; bh=8D8QTyVR6yty+U+qM3n9DVm64OloOOKGd9a1EBcdczA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kKod70pD4xfNn0CKYQYGxYBrW1QOTpgBMQzSE+ixQvdP80QHAklzq6Oeux+wWaMH8hj7kYO4EK0ZD+hs6lKTM9/QZQ16UIrLJiCJP4m6rq+ZTMdMf9lY2R6ehko/liCxA3m9+pNWpmZxDNvgXIXkoVC+B8kpbj5Z1EbNfrZ9GfE= 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=A4NBfdmW; 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 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41QGSHmj014969; Mon, 26 Feb 2024 16:53:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=wUxZWtjBlpcd1C3yzncmoKg+sMI8k4edHwJPu5+uZXE=; b=A4NBfdmWBP8Gau9jo37+ogCnjTp1KEbKnoXtt4gwCcScM0Wnoh1TBUYKf6zDE5i7dCWD GT5RHR4c0+SA1/70umzyILxBnlehRmv7k/LjUmrXKF8+hNtxGxispvG2lI36cHYbQ8lO nCp48Sa1kAcZ0VWRcKdLLOjC6IVD2wwFsayPyXfBCQmVf4DIdV0AtyCBVtgJXpVBb4mG /oGUhI6dxputW4+H1GAUkVHYSMy/oslNo51O1jZaeVPwU9XnI1jb594KIXKnWtfCsVxh QnqDNySaSak5R8ZzCSmDur0cWiJDiwHA3TupaXpEH3k5FBJ9lWq9rWRBosD0an9wA6ON aA== 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 3wgx6g8n9c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:30 +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 41QG0x4S012312; Mon, 26 Feb 2024 16:53:29 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:29 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrQvW8389610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:29 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C277458061; Mon, 26 Feb 2024 16:53:26 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B02E5805F; Mon, 26 Feb 2024 16:53:26 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:25 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 05/31] ARM: dts: aspeed: p10 and tacoma: Set FSI clock frequency Date: Mon, 26 Feb 2024 10:52:55 -0600 Message-Id: <20240226165321.91976-6-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: W2o1YKkJ9swY8dvkOCrjUxBs0ZnFesCL X-Proofpoint-ORIG-GUID: W2o1YKkJ9swY8dvkOCrjUxBs0ZnFesCL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxlogscore=815 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981414439520638 X-GMAIL-MSGID: 1791981414439520638 Now that the driver doesn't hardcode the clock divider, set it in the device tree. Signed-off-by: Eddie James --- arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts | 1 + arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts index 213023bc5aec..96a8f727bc38 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-opp-tacoma.dts @@ -193,6 +193,7 @@ &fsim0 { #address-cells = <2>; #size-cells = <0>; + clock-frequency = <100000000>; fsi-routing-gpios = <&gpio0 ASPEED_GPIO(Q, 7) GPIO_ACTIVE_HIGH>; fsi-mux-gpios = <&gpio0 ASPEED_GPIO(B, 0) GPIO_ACTIVE_HIGH>; diff --git a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi index 07ce3b2bc62a..44e48e39e6e9 100644 --- a/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi +++ b/arch/arm/boot/dts/aspeed/ibm-power10-dual.dtsi @@ -8,6 +8,7 @@ &fsim0 { #size-cells = <0>; cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 0) GPIO_ACTIVE_HIGH>; + clock-frequency = <100000000>; cfam@0,0 { reg = <0 0>; From patchwork Mon Feb 26 16:52: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: 206812 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2220042dyb; Mon, 26 Feb 2024 09:22:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4srP5rlUSa8mSRRkJJlVGLh2jyTPNAvhXpCvwt2/DH0V0hW+17m6P7k3+8HnQWfL8Frfur5Ot+6r/pFMER3pl4H+x0A== X-Google-Smtp-Source: AGHT+IGLDX3Ki3FmxcJFgK9dcRQgAFgjHIA9hbfGnAbYHfvLzPctFsb/1Bu59AhS6L3AV5q1j7Nu X-Received: by 2002:a05:6a20:c886:b0:19c:7485:4f75 with SMTP id hb6-20020a056a20c88600b0019c74854f75mr12065115pzb.42.1708968165320; Mon, 26 Feb 2024 09:22:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968165; cv=pass; d=google.com; s=arc-20160816; b=r0B35wSL/zZiFDmRBYq9Go/8KxIbogTcZWAKw8cRtPBoOpVfRLwrVFG68RJhm4lqXh WFuEmERxLkDosr0iB7biJbapjK/swqR3ZJ0WUWv9ScyONVH8BlZg6JD7nQocGIuz9S1i /T5pQu6D89MEyeNSk8WVHZgrFdCcO1qao5aJ5I6aqn4OYj9kl17xl+QIvEC6KfzgmiUI rpxAptd/P/OzjanQF9/tS7iyxc1VBCa2CslQ3aqnjswp5gKXgPaF2jE9VzAURSg+I4zR Qmj/QPuqqHaqF8j57feTJ5i7zPbbOrkSpl6E8ouzWlB1oHkJn0CN9ChjWHxxVfyPgqsM wkqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m8S+2xLwMphNFY1D6Sp8VRqoMTm6aplbC8DM8AmNxec=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=pRvc8IZis3h+m3erI7BhKLBhUhQ11nhRV4ErgvE0kzd+TFibyP3Z5RW4YcfIxQzc2X 5EjARncsk7XF38uCsYAj5fGVOuTCoVynmmuOrN3VVB8IjFiyVElvINEmkObH0sIs0XVj oxfKMZFrODzf+IGaVTi0XXoKb0qLfFfwRi56FdhIgmKTDzn51gL7siQAIFUHePQW8tzK GtVQLnDf3RgxvBRBb94/Xw5wM2P7rNSXsMScLrz8glB/jlTvgeVjXIaVTvoB7TM+DCzJ NGfZZ2T9f5Q3zmAKZWD9rjkD1TXw1t6ZmzFztAHDVixg2d8caLh4yDsuotg8CnnZPUAC wYzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hfcSVrKb; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81954-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y192-20020a62cec9000000b006e474d7a7d2si4071942pfg.62.2024.02.26.09.22.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hfcSVrKb; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81954-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81954-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7CE2CB2DB61 for ; Mon, 26 Feb 2024 16:57:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC46313173A; Mon, 26 Feb 2024 16:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hfcSVrKb" 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 8379912E1E5; Mon, 26 Feb 2024 16:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; cv=none; b=gjZXvEWufbIf71xFwxL8uxFIGg6hXbSCE1qroFu0aS+wtPaNfQG5D305ONU0PwkA6TaNe3WBEvY3FbgHRJFdBylCV/CWAsPL8BSac4UfN7Ao+rFss44ON1a+LzC48yHEqjRKbbf8ftmQ5pk/oj9jsqjkJtx30aJjEmmNln7HI6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; c=relaxed/simple; bh=inaKuQeiyTMX0KtjdTI4EyJ9/PXUVO4eL0aHOzMV/Co=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lKjqteiGnYVzDirP8ZZjCqawj/okvVOSd5bYXNbEOJrBl3JGN0d90AhCsha2jbl9AYVEIhyR7VNHlGfJGraGiwW4RUE1TIk1vKD1bJvMFZFl5/b7WUhhsWR6bGrRvaRb5ChrIz1vRe/AmjxSmYM0mFC95XpGR3y5IUrXLG0ixps= 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=hfcSVrKb; 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 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 41QGgXK9003017; Mon, 26 Feb 2024 16:53:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=m8S+2xLwMphNFY1D6Sp8VRqoMTm6aplbC8DM8AmNxec=; b=hfcSVrKb5d/XXm0IKvULClB4yGftAFsimV9rJNoEGwo0jrWKl5CypQigu1PDACBy9Tb7 Go2FdEWq6/4ROhrdHqlbwNF9aUF1hLTw4HfDAkaNJW6z7emJ3N96yMMmWWa82He3JOEK X0qD2Lj6KHhrgotLgqvISfGnlwkkSjDw63lhVQdooh2qVJUIuiZYlOhB2dcN+XCE49Bs 6xv7oLnjbQBANerbsxDVzNJO+deosO9UXDh6gKo6Q2XpG5DbGtj+/PbJDW1q7JQoBbCY drlyeFFgeyqZiJHNLErEz2HU2E/+++f1RlC5rnPd1dQ2KCn8JOEYLZXuQxgW1tbMIp1a Mw== 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 3wgxd4g9sa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:31 +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 41QFUXdZ023777; Mon, 26 Feb 2024 16:53:30 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23f0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:30 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrRko50594534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:30 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 927DA58043; Mon, 26 Feb 2024 16:53:27 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8BF75805F; Mon, 26 Feb 2024 16:53:26 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:26 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 06/31] fsi: core: Improve master read/write/error traces Date: Mon, 26 Feb 2024 10:52:56 -0600 Message-Id: <20240226165321.91976-7-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wYkkACTCDT0BuXCoho42MRpwo3eINX7v X-Proofpoint-ORIG-GUID: wYkkACTCDT0BuXCoho42MRpwo3eINX7v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=949 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983002640252843 X-GMAIL-MSGID: 1791983002640252843 Consolidate the master read and write traces into one trace and change the result trace into an error trace for less spam. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 26 +++++---- include/trace/events/fsi.h | 112 ++++++++++++------------------------- 2 files changed, 51 insertions(+), 87 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 9610b5948550..a989a2007c0f 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1110,14 +1110,15 @@ static int fsi_master_read(struct fsi_master *master, int link, { int rc; - trace_fsi_master_read(master, link, slave_id, addr, size); - rc = fsi_check_access(addr, size); - if (!rc) + if (!rc) { rc = master->read(master, link, slave_id, addr, val, size); - - trace_fsi_master_rw_result(master, link, slave_id, addr, size, - false, val, rc); + if (rc) + trace_fsi_master_error(master->idx, link, slave_id, addr, size, val, rc, + true); + else + trace_fsi_master_xfer(master->idx, link, slave_id, addr, size, val, true); + } return rc; } @@ -1127,14 +1128,15 @@ static int fsi_master_write(struct fsi_master *master, int link, { int rc; - trace_fsi_master_write(master, link, slave_id, addr, size, val); - rc = fsi_check_access(addr, size); - if (!rc) + if (!rc) { rc = master->write(master, link, slave_id, addr, val, size); - - trace_fsi_master_rw_result(master, link, slave_id, addr, size, - true, val, rc); + if (rc) + trace_fsi_master_error(master->idx, link, slave_id, addr, size, val, rc, + false); + else + trace_fsi_master_xfer(master->idx, link, slave_id, addr, size, val, false); + } return rc; } diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index 5ff15126ad9d..fed8835f438e 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -8,101 +8,63 @@ #include -TRACE_EVENT(fsi_master_read, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size), - TP_ARGS(master, link, id, addr, size), +TRACE_EVENT(fsi_master_xfer, + TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, + bool read), + TP_ARGS(master_idx, link, id, addr, size, data, read), TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) + __field(int, master_idx) + __field(int, link) + __field(int, id) + __field(uint32_t, addr) + __field(int, size) + __field(uint32_t, data) + __field(bool, read) ), TP_fast_assign( - __entry->master_idx = master->idx; + __entry->master_idx = master_idx; __entry->link = link; __entry->id = id; __entry->addr = addr; - __entry->size = size; - ), - TP_printk("fsi%d:%02d:%02d %08x[%zu]", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size - ) -); - -TRACE_EVENT(fsi_master_write, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size, const void *data), - TP_ARGS(master, link, id, addr, size, data), - TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) - __field(__u32, data) - ), - TP_fast_assign( - __entry->master_idx = master->idx; - __entry->link = link; - __entry->id = id; - __entry->addr = addr; - __entry->size = size; + __entry->size = (int)size; __entry->data = 0; memcpy(&__entry->data, data, size); + __entry->read = read; ), - TP_printk("fsi%d:%02d:%02d %08x[%zu] <= {%*ph}", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size, - (int)__entry->size, &__entry->data - ) + TP_printk("fsi%d:%02d:%02d %s %08x {%*ph}", __entry->master_idx, __entry->link, + __entry->id, __entry->read ? "read" : "write", __entry->addr, __entry->size, + &__entry->data) ); -TRACE_EVENT(fsi_master_rw_result, - TP_PROTO(const struct fsi_master *master, int link, int id, - uint32_t addr, size_t size, - bool write, const void *data, int ret), - TP_ARGS(master, link, id, addr, size, write, data, ret), +TRACE_EVENT(fsi_master_error, + TP_PROTO(int master_idx, int link, int id, uint32_t addr, size_t size, const void *data, + int ret, bool read), + TP_ARGS(master_idx, link, id, addr, size, data, ret, read), TP_STRUCT__entry( - __field(int, master_idx) - __field(int, link) - __field(int, id) - __field(__u32, addr) - __field(size_t, size) - __field(bool, write) - __field(__u32, data) - __field(int, ret) + __field(int, master_idx) + __field(int, link) + __field(int, id) + __field(uint32_t, addr) + __field(int, size) + __field(uint32_t, data) + __field(int, ret) + __field(bool, read) ), TP_fast_assign( - __entry->master_idx = master->idx; + __entry->master_idx = master_idx; __entry->link = link; __entry->id = id; __entry->addr = addr; - __entry->size = size; - __entry->write = write; + __entry->size = (int)size; __entry->data = 0; - __entry->ret = ret; - if (__entry->write || !__entry->ret) + if (!read) memcpy(&__entry->data, data, size); + __entry->ret = ret; + __entry->read = read; ), - TP_printk("fsi%d:%02d:%02d %08x[%zu] %s {%*ph} ret %d", - __entry->master_idx, - __entry->link, - __entry->id, - __entry->addr, - __entry->size, - __entry->write ? "<=" : "=>", - (int)__entry->size, &__entry->data, - __entry->ret - ) + TP_printk("fsi%d:%02d:%02d %s %08x {%*ph} %d", __entry->master_idx, __entry->link, + __entry->id, __entry->read ? "read" : "write", __entry->addr, __entry->size, + &__entry->data, __entry->ret) ); TRACE_EVENT(fsi_master_break, From patchwork Mon Feb 26 16:52: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: 206778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2202791dyb; Mon, 26 Feb 2024 08:56:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTbZYNRU+5Q5tjyA74fXePW/TYGS9Nfi+b/G1HJcYD2dBWj7EFRLqhPGa3Bz1U8RSWcKxJEOiIiYWwqgCU0UGBlo2YEA== X-Google-Smtp-Source: AGHT+IH1mWj2lmpsIT5GLi3B0cPwTzvdv0NLaIAtNG3aEXxCT10jxDZLoP4dCpzTbSbmEEBJJe6M X-Received: by 2002:a17:906:f84c:b0:a43:9a72:b711 with SMTP id ks12-20020a170906f84c00b00a439a72b711mr58936ejb.26.1708966613828; Mon, 26 Feb 2024 08:56:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966613; cv=pass; d=google.com; s=arc-20160816; b=zzr8YhchEaR3Pu16fxyT8jebdKracvaP6XlpifuVG80Gu3Jf9I5QBjzq3w/+2YePE5 8+i+59AqGcnFkj2bXe9MaOYyQ2lZM/C682Ofqg8J6WW6CspKFSd5V56XLEDqo62oKyTK U3Z532mj001T0Ud6yJCL0U40uXHLcy3sokw3uaxgoXkP1/z4xrI+knIuVP1/x1gZMa0+ U62k5/rNWe4bAUlmQmIZKTzkJSTnqwd06tqOPoAqDuO1c+jf4sok+c2atLBVM2g5CSNe UVOEIPWGadQ1zZHgfPWniOtOJLZAZ4ztvnH6VAeWytLqYLYGNlFIXBS1G130M+lxpgwq bvRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CbVBtI9wWX/Vle86BDnixujDHBg2fVH5tOyNC480SYk=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=qDeyl2JaQ76+4VsLG3WrfN5C0QdEmESmIn4QdWF1TF/QKtBVMdJw9Th/LxHf5Han/7 338/hxIkdLRXfcY4M2/YQhfM7qbx4bz1G4mtCL9M58YF0DhAUEk85RclP4JeCTRtqKAP EzEPDgoHPomyPX72EK5ygUchdm/2CfUE9M93DaWmtHtXVJyqSFoWwaV++C7ko+pOJ+bH rHjsvpVszdXtPHea7GlfdoLhZk9FTSbI5dmcm/+j88MvgT14gQRmHqW3m0MHdlcOQ8Hv fn/fb3C0mYO7mmkQVzlNeNoR58qmQCrw5bTcLbRkvuXIJxlc8zn/HAAOdFjc2tEqQEmk dTPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rnEwNad2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81953-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81953-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f17-20020a170906391100b00a3e5616271bsi2290763eje.8.2024.02.26.08.56.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:56:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81953-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=rnEwNad2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81953-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81953-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C9A1B1F24909 for ; Mon, 26 Feb 2024 16:56:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1DB4130E3A; Mon, 26 Feb 2024 16:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="rnEwNad2" 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 8376112E1E4; Mon, 26 Feb 2024 16:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; cv=none; b=JCKiP9Al3F6q/6IUnjVA6jtghImo04dYja87TGYV09UcPRAbqdBQ5gk99isWDt3KABoSAp/pudZ+W846fxzCrw8HsgQERZiHGgdrHygILYkJtU181BOcEltA3i3mTmpWHJfEHIKrVosBl9AY2vhGuhMnhbqCa+D0t3yiPzgAdKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966425; c=relaxed/simple; bh=F2EI8CjKMR5+W0auTiL1ZfI3q7DIl9lL0XVfiof8NJw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XC4ST3nDtmY6UyK9c+X4LjP/g8IE2epr2C1tF8dBHnVu/VYwgBt1CE8et7cRMYTpHV11NoepAq3GU0JACuo08AoAZCfIwCH+bcnK9tK2/eqH+PwjikQqha8pWWo7dwKNsPZ1gV4xNj+jhVNA3CsQ5b6X4wq7Qdyuy6Lvuo+ndVU= 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=rnEwNad2; 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 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 41QFvKor020290; Mon, 26 Feb 2024 16:53:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CbVBtI9wWX/Vle86BDnixujDHBg2fVH5tOyNC480SYk=; b=rnEwNad2q1ytYuwp4i1lFkEklJ6zGt/JHwFQQSeMn2AhV13IAVVvJqjs6d5RNzYnV7rm 3dG795cv1cxNF3CyOZIbyatKGZ5TJPn/WSkCXd72Kk8LK4SX1SHaFiBMDVf+1NPaLUZl sA/GF95YRpoSyIYIMD+/DMd5i6xwAj+l9u+spKV0kk7oDm3620UQKWhBpPHqjVkJvu8d qapfOzAnN3beS2tC/sYM2bG0ZnDygsYWzeoK6F1I9JISp5vgQmu8R1a9gXqgmU+1H0cQ zvAJsCoc7sz2dbh2E2nkvi4A03cINrLdIvW+4SgZkvSs3QkeAJ6aCA+DzDFG8Jjqs1qJ ZQ== 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 3wgwr21p2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:32 +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 41QGbYFY008808; Mon, 26 Feb 2024 16:53:31 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wftstaray-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:31 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrSGT42467804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:30 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 626595805D; Mon, 26 Feb 2024 16:53:28 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A93A258053; Mon, 26 Feb 2024 16:53:27 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:27 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 07/31] fsi: core: Add slave error trace Date: Mon, 26 Feb 2024 10:52:57 -0600 Message-Id: <20240226165321.91976-8-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: G92xxlVDLy_CfAvpbOtXZ6YdNreWMvrh X-Proofpoint-GUID: G92xxlVDLy_CfAvpbOtXZ6YdNreWMvrh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981376130332898 X-GMAIL-MSGID: 1791981376130332898 Trace out the FSI slave status and interrupt status. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 1 + include/trace/events/fsi.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index a989a2007c0f..e6ed2d0773b6 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -185,6 +185,7 @@ static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) dev_dbg(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n", be32_to_cpu(stat), be32_to_cpu(irq)); + trace_fsi_slave_error(slave, be32_to_cpu(irq), be32_to_cpu(stat)); /* clear interrupts */ return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC, diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index fed8835f438e..5509afc98ee8 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -115,6 +115,25 @@ TRACE_EVENT(fsi_master_unregister, TP_printk("fsi%d (%d links)", __entry->master_idx, __entry->n_links) ); +TRACE_EVENT(fsi_slave_error, + TP_PROTO(const struct fsi_slave *slave, uint32_t sisc, uint32_t sstat), + TP_ARGS(slave, sisc, sstat), + TP_STRUCT__entry( + __field(int, master_idx) + __field(int, link) + __field(uint32_t, sisc) + __field(uint32_t, sstat) + ), + TP_fast_assign( + __entry->master_idx = slave->master->idx; + __entry->link = slave->link; + __entry->sisc = sisc; + __entry->sstat = sstat; + ), + TP_printk("fsi%d:%02d sisc:%08x sstat:%08x", __entry->master_idx, __entry->link, + __entry->sisc, __entry->sstat) +); + TRACE_EVENT(fsi_slave_init, TP_PROTO(const struct fsi_slave *slave), TP_ARGS(slave), From patchwork Mon Feb 26 16:52: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: 206781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203020dyb; Mon, 26 Feb 2024 08:57:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWaUnDgySi9VssTMx+st5KvOMroOuuQd2476wz8Pt3MNIXq0hOiNkm6RBWFNCgL3paJo7yL5lhj+Rb75CgrUwSQIj2ztA== X-Google-Smtp-Source: AGHT+IGLwPCRZgjRrJD2HtT9KvaE/CIRTnrF4y6Ck1Cl497XHyTJgzIZXhsSubOXCIZm/mkKXgFI X-Received: by 2002:a05:622a:1b9f:b0:42e:58c6:bc9e with SMTP id bp31-20020a05622a1b9f00b0042e58c6bc9emr8722036qtb.60.1708966645779; Mon, 26 Feb 2024 08:57:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966645; cv=pass; d=google.com; s=arc-20160816; b=xwx1UfLRFuIoBZkhHu+wf21yx/3bnl94bJ24rDlgCEjqTjdsRgSSdn/Pvasi4s21Ai C15/EWgPnM/gk+q5rgUZl7WrDhgRAb/QdytT3zc9hU/+dzs8AwNazcSYMBX7CMd96UOg ej9jbnYmwfaewGhJHCz4xwiChsgr78sXWTmNm2nys0apftoG67YWldMnap8rp6HklsFD 8FARpbCzf+HNKGfLn6Wi8+jGudnGDhIN+g7u7yNHo36cvy3578YaM9nfSHXd06UMRdOI RQkdwruZVLf5hFNRUfGWvRx/o4GVT5BZqjOS66y/f1uQT0zGakygkpFYJLGm3/3dtRzM RkFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=C+pRu+K3OrSWU2t4zv85kwDoRmh4FsLurjQWkBINbDU=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=r4MIG1z/NtQF4cYohm/aCiHfAyTxGNP2FBQiXQGIleN0Tr26xITsxyd8jOGuY7kWvL ENjuG1UX2/ryNQtbesvQFUYRmO5gqeYarOc1d/4xFHEf8kxdTHokkZWyN2E88iJufPGZ 12T8/axBsOIbcuI81tuQfy9S92xA6yMPPbwQnGL4EtbaD2XQgtrSAIEOL2lG6vxBSX76 kFzTD2PM1ic+unT6JG/cz2EWEMBNU04CYrEezJQEfI/vb10ouQZo/HbQ9ZbCA4qcKmDc vNOseiQP1hx8dsQxQ2MFqk5s84qU4G5x2P7VtM4Z423Z3lFJsurF7VJA82EnS1F1MN+F e0nQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BYC6Dak5; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81958-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s7-20020ac85cc7000000b0042e918650a6si861884qta.84.2024.02.26.08.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81958-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BYC6Dak5; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81958-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8B50D1C23193 for ; Mon, 26 Feb 2024 16:57:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B03DD131E2F; Mon, 26 Feb 2024 16:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="BYC6Dak5" 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 302BE12F36D; Mon, 26 Feb 2024 16:53:45 +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=1708966426; cv=none; b=e+Kk1I23NQQKVbuoFtKhBBQHEtJMVIXZp/zSSdJ2Sm9kUYBqOu+1RjNZUWF+4jg1NT5nRl4bAuVtnWKqmS5O3AY+rhHeTzAaleQfgKi12g0v1vRGJqoMIEvFMT2Ros8wVXvpLDOli52cDuGDFvb3vAN72EC26HsXc/JzXkgjcqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966426; c=relaxed/simple; bh=E9DUSZacmzJzG+m5rC6gn1HLC7/p/P7CDzyfAfbiWSw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IyrAlsLHhc33juFEnOkinsIpMwradb53yqA1+1NvO9t8RQlgM7halVUJfVvUSIGQ6x5DFkCWG0IKWUyW300g/Rllos/wgjC/Q7+73MPjnyxd1Xllgq2rrMKyAgxGBP9t08sGUjfhpJA6sRMaG3mpwJU6kjxQj4Ed40fFjl1ma90= 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=BYC6Dak5; 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 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 41QGTbIC025113; Mon, 26 Feb 2024 16:53:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=C+pRu+K3OrSWU2t4zv85kwDoRmh4FsLurjQWkBINbDU=; b=BYC6Dak57p54aIjkrX7HzLtPuHE9P1qN+oTIAFB2wPfuGBeeC53hZ1VwZp5NSA3hNV5m Mh96Z94QT8IsiUHC3HCtgK4f9/MqJNI3/v30CD8WfHvIghjT4+GUYMLGFyoFf3fCfy5s 9mRUA4Pv++7HhJS3lx6OdPaGR8LRhCjfLuKPRkPyiDBuojvRhi/bNRNnNzR4K+PnfZNU eIuWRvulBnxen4ypLj/ZFMXlATAK2Z5E2QTqJQCU5CU/qXJ0W2c9EP6SH4dNTMI2RFCd jhjd5+Aw/0vedS3fIE/ytQRWKx7Gs5dgiml3qYf0Hl0d0Ed8H0qGpcGyOquYKq+rm6a7 KA== 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 3wgwr21p39-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:33 +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 41QFAIRw024127; Mon, 26 Feb 2024 16:53:32 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23f4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:32 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrTmU2753176 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:31 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BDA858059; Mon, 26 Feb 2024 16:53:29 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 78EE658053; Mon, 26 Feb 2024 16:53:28 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:28 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 08/31] dt-bindings: fsi: Add AST2700 compatible Date: Mon, 26 Feb 2024 10:52:58 -0600 Message-Id: <20240226165321.91976-9-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: OQWHMRcYdZ6ItXPMThOEgRPKc-sx-VhL X-Proofpoint-GUID: OQWHMRcYdZ6ItXPMThOEgRPKc-sx-VhL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=901 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981409770754365 X-GMAIL-MSGID: 1791981409770754365 Document the 2700 FSI master compatible string. Signed-off-by: Eddie James Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt b/Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt index 9853fefff5d8..5bfe10abbaa5 100644 --- a/Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt +++ b/Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt @@ -5,7 +5,7 @@ The AST2600 contains two identical FSI masters. They share a clock and have a separate interrupt line and output pins. Required properties: - - compatible: "aspeed,ast2600-fsi-master" + - compatible: "aspeed,ast2600-fsi-master" or "aspeed,ast2700-fsi-master" - reg: base address and length - clocks: phandle and clock number - interrupts: platform dependent interrupt description From patchwork Mon Feb 26 16:52:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203157dyb; Mon, 26 Feb 2024 08:57:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0s+HG1FNBLOTHxMK9p4YhaL3cQjH2WPsjjH0VDzmVuXtEocOx9dwziW/z3qJ0BFjaaqxyTB4xnF5xjCCrQnP+bMAl3w== X-Google-Smtp-Source: AGHT+IGgXc9+K1wtsHiIO2ht/GpTH1+/q0pVVCsP7WftBxUH6XB2OrBEPQ0vq2U1vqSFd1cuLXVo X-Received: by 2002:a05:6402:379:b0:566:2495:c489 with SMTP id s25-20020a056402037900b005662495c489mr478583edw.27.1708966666094; Mon, 26 Feb 2024 08:57:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966666; cv=pass; d=google.com; s=arc-20160816; b=F2Hhay36dOAKp07/FmU8rgl7Jz3R9+cNHv95ZUbWQTTB9ssdNDNIY7AbgiqmWZ/yri olE4naJmuCNS/EBNXwCgBf6mar0jRCWBKppXZITbWTF8SGpZS/F7iBse1684RxlWT/1Q ES3JVxdgfHixHrVg2VXbCiq4iSkh7G2rljtYzInhv8vhra2Ih2Wzz7SxGQOPr+V0h6kp OajFRes8FHVmaf87GU6llx8Cemq1NlZH5mZ6dlrSW2jBNst372UExywdPhSnqCpyepFq uWdvgWJ/oO3QBKUW5sT/iAH+F6T8s/FOjad4NO7MRgLs7f6ohX1f6rlhvvpgmGMGHEjH RNGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gaRn11yQSzCtGgfOHG0WfDL4IGGOB1/y2J4JPHKXeY0=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=IJEdhq2i4YeYNjPuuFuxPqysUUmbDQIdzge6Z8tmYH+F0zSdzqySBgW/Drx/BaUqZm tt7PzEHo1V2PTv+8tSQbHqyiSmF5Ns6ufHPTbhw17KtAwILOPNt4R3HJUxBVXaE9UDYf iQbRvQhcnVbh4tZOasZYi4rsYfGsPtO37kBmkxvzKqsbNQQw4nNLEATXTrz7QH/PnVkt Oe6luNdYdSZq0qfhlwplWPgDjV+rV3RW5qlcysQZQPuySOqFEnjbwNYGvfae0Tq3Lp2H Eb8TzcbVuzipTBPD0gWz6tbvOIbVECdZm5mw5uN9s+VmjbgTjFfrnFLSTUaykmqL/q3w jqyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Mq5wI1Oj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u12-20020aa7d88c000000b005660178b46bsi798852edq.239.2024.02.26.08.57.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Mq5wI1Oj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81957-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF2A31F26EFC for ; Mon, 26 Feb 2024 16:57:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64D34131E55; Mon, 26 Feb 2024 16:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Mq5wI1Oj" 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 97D0D12EBFA; Mon, 26 Feb 2024 16:53: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=1708966426; cv=none; b=TIvV0xCvwRKi13dolm/UuhA1yvGtYHRQbSFVWCct716Xwc/UmjG49HOSjrI4MTPDDEiuyfHgdojXOrQg5l6OoADIsUKpf+f04eBju8Z3P6zb+3/V3lGbyqf1d+E8UgRv4CgjFP7DCXPvKyX0uN4JCTwQGKjXD7gJsBRgIaqTq2A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966426; c=relaxed/simple; bh=NGXJUu33Lr1l9NXaZa1510h0VGdsd6eNUEVT355jTIo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BUb47Qiq78MQe7DQ57gNk4LKXo2PF6kLmVVvW78c3zELjuFvcRMjUh3mpYL/ExjNEFctdV4E3WMhqkM6RTS3j5Vyf4SuleyS80uHx0/DQxxEAJixq+RFLYfihZF/6VO/UIB9oPcN0cSJEMsILoItFo25DNu2QH7smdGDTmYqj8A= 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=Mq5wI1Oj; 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 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 41QG5cQ1025170; Mon, 26 Feb 2024 16:53:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=gaRn11yQSzCtGgfOHG0WfDL4IGGOB1/y2J4JPHKXeY0=; b=Mq5wI1OjiWAZKmaxpk/moZ3UR6ltjpxkBtDjvC9B6JctRHu6N6ccbik43+U5uuMgq4cR I93if83MPgQh0fdvZjjwcayQN2wWWygs5hmWmio34HtCVgiWI0R3600Hx0pQ52+ri8z7 hv+uLYLSu7Lb+Fkx90ozyz21oZuTxZlv/dBE/ivSRSCqiznLDMpkriQsemywJRtzlHJa rKR0xMntT/hB/e5A1EooFVNJnF72fq9shvNjFmSfo4xpw9Fy9JWAA//8LKPSGhu+KH/q wF7WvKI84xGnUMXWNtqTW1mdtvCC2uEcw/KcF1I12cfG0gfySGOpa8NN3lzyXTp2hJre Gw== 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 3wgvsq33fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:33 +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 41QG5FVG008798; Mon, 26 Feb 2024 16:53:32 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wftstarb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:32 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrUr020775424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:32 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AC675806A; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51DAE58053; Mon, 26 Feb 2024 16:53:29 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:29 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 09/31] fsi: aspeed: Add AST2700 support Date: Mon, 26 Feb 2024 10:52:59 -0600 Message-Id: <20240226165321.91976-10-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JIO00IJkeUysRHl0uQhFXf0gZiyzFVlX X-Proofpoint-ORIG-GUID: JIO00IJkeUysRHl0uQhFXf0gZiyzFVlX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981430650749403 X-GMAIL-MSGID: 1791981430650749403 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 | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index f0a19cd451a0..d6e923b8f501 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 */ @@ -60,6 +64,8 @@ static const u32 fsi_base = 0xa0000000; #define OPB1_READ_ORDER2 0x60 #define OPB_RETRY_COUNTER 0x64 +#define OPB_RETRY_COUNTER_AST2600 0x00000010 +#define OPB_RETRY_COUNTER_AST2700 0x000c0010 /* OPBn_STATUS */ #define STATUS_HALFWORD_ACK BIT(0) @@ -536,6 +542,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_RETRY_COUNTER_AST2600; struct fsi_master_aspeed *aspeed; int rc, links, reg; __be32 raw; @@ -579,8 +587,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 +663,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_RETRY_COUNTER_AST2600, +}; + +static const struct fsi_master_aspeed_data fsi_master_ast2700_data = { + .opb_retry_counter = OPB_RETRY_COUNTER_AST2700, +}; + 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 Mon Feb 26 16:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203216dyb; Mon, 26 Feb 2024 08:57:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZvywc+GYjGVkIuL9AJTBecs1UoejTNtJfKs8I1YA+GSktNrauVTB5zls/rZ4QiO0dGU79W+XAXCczcmnw3kwf66Odjw== X-Google-Smtp-Source: AGHT+IFb7+kafVRkCLynKNttaEaU1J8bJvjhSLW+O8nhyPof8HMAc/7FLnv877m3FD0E1NnDpPLv X-Received: by 2002:a05:6512:6c3:b0:512:f5ad:ccac with SMTP id u3-20020a05651206c300b00512f5adccacmr4346345lff.2.1708966672931; Mon, 26 Feb 2024 08:57:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966672; cv=pass; d=google.com; s=arc-20160816; b=gySkcWuVZZNXmmUGD6bwQ7j5mqxjpzrjpfk0O6dlm5ih7V7QK6G1H+WNVfqCAQpr/k MzfdL/NvwPJmuEGtKlPX0I9SOTCMRIn+aTCpHqDgXNHK52aqzT78nI6ImwhIug9Wrz8V hQ5KPAegjt35/vSEmTJCnZHFag1AOE1SSTuuoHnY2CP3ouDhhTQzRqs59EN12jPK4QX9 3/lTlmzuf1S4t17lnFiyoEkmidBhooqZxIAv02NgALyydKYSNXLGGGywTT+V5lAkvNoa hLwkLzblQVVpBnUlawlHWOHU3qogGVy7KKImYtknncp5meJfeuGL+iHraNq1+61pvGNy 9aUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bcqBdP1smZ142CVdipR5CsJhhC56BJDRe32BgoHDJb0=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=k72pC9e8l4uszv86NXmwlWGksKGfDTRvuM0cLfUKeUT/fm4rQOdVkWB5oEHDdp8s6f 4SPQHXhhumpEOVph/UlrjQjVIhFL/g43AZEYKPE3yP95iXQx4cQN6YFFl71vI95oACpl M9cp0NbT7s6sRvMYjKX7Dhemr1UDBX6Z9N/J+foypOx4+qWd79baKaLP9J5NwFuYENbh aFmV8sB0d8C6fZT7yfImBCSTJYcXRtolNy/uaPx6SmXVHfxlH7qz9Mn9lpI9LBzE0h+D LusF1OImKPNwedT4Mw0/Gr1qBZhV7tjSvO1eIUopMk8B2XKufMjXzrt5yGNaQ/ktlfGS Q8fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=EzAdIi1N; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81960-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w24-20020a50d798000000b005640f00f50bsi2165509edi.415.2024.02.26.08.57.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=EzAdIi1N; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81960-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5D37E1F27183 for ; Mon, 26 Feb 2024 16:57:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FDD8132465; Mon, 26 Feb 2024 16:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="EzAdIi1N" 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 DF1B912F59D; Mon, 26 Feb 2024 16:53:45 +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=1708966427; cv=none; b=AS1x/0NxrRh6Lm5qjdJwLQUR2N/mJsISc1zW+iiB2t+fKYIjE+L9YW3heTfkRxJPRGFYxX+egVLZjZBZB5oj1IKHL47U4jSwtiw4aQyffCw7zHwEdc6prFrbTf59f4Iw3TxYmrFM+YcJKiVh2RIr+1eUP0wbZtv08ImKxOnpRVY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966427; c=relaxed/simple; bh=rnrW55EMd5WY1H/Lf4PHZ/r+oG7ZBsAslE1xLX4eUiA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sSQNMxEavyzGWpnU3PYlW8OtTxgpVSLyYQWE7nqAkIWOlpVYvXdkk3L34+mZGP5lnalAfkYM9LUxG1/ZqKZqEwAP14XMtGe8F9/ROQz7HS8Y8x7ghNdByIS682CGXPFm782NWafHC1CeP7hR2h7pWe0w6WesAoj9mpf3NxJCqIY= 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=EzAdIi1N; 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 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 41QGAPmv032560; Mon, 26 Feb 2024 16:53:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=bcqBdP1smZ142CVdipR5CsJhhC56BJDRe32BgoHDJb0=; b=EzAdIi1NVXnE+z0nk7YalKHCEtL5d6Sjdwps9boCVbfwfE83eLVEBl0SkYVBgvbtwvzy LnY+59v5HQ1LAFYHTYZoRhniCeg46YfMBA1/5dchRu8DFu93heQjK8co5LLjz5X5HH6X niEE9vDS+pGqIvyFO0CcATJe3ToyclhBntTCjftpkQuzSuTpgDijT/lg1ZwCoHi/xDmp q+uelnaz0Ni/3kgdxwvecyZLUIbf2lnThFVaFF3wbjaA+eR02SCxGFO56TSINmPYlGgR jkspPGaPZd3vx5Mulyg7pib3TBacbGgNkYPkDH/z/uPCgE+rNQLggJNQ6qYgS0TIKeAU Gw== 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 3wgw0k353b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:34 +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 41QFTGIc024151; Mon, 26 Feb 2024 16:53:33 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23f9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:33 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrUAx19858038 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:33 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE0DE58043; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 213B658053; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 10/31] fsi: core: Add slave spinlock Date: Mon, 26 Feb 2024 10:53:00 -0600 Message-Id: <20240226165321.91976-11-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: BOQEUV3VespclJ82cBk5wG0RIE0_MtFr X-Proofpoint-ORIG-GUID: BOQEUV3VespclJ82cBk5wG0RIE0_MtFr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981438471959142 X-GMAIL-MSGID: 1791981438471959142 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 e6ed2d0773b6..eb15e5f5a2ee 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; } @@ -1005,6 +1011,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 42af2fae0329..6f8fb97023fb 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 @@ -100,6 +101,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 Mon Feb 26 16:53: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: 206784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203167dyb; Mon, 26 Feb 2024 08:57:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnc8odKbh5bjkvywCpkCW+dFzTbmRq56zKeGjg7j16IEMvnfbdryqoG66QqL8UowQ5/87EMpOkhl8/mrlo2a5O6wc1Qg== X-Google-Smtp-Source: AGHT+IFJ0fBT9IB5/R5kYPLYRUzygUSCUmZ6BJ91q/gfwqkp0nN5rJeimf/lRgpgaSv/En4o7A/q X-Received: by 2002:a05:6870:e30a:b0:21f:d443:890f with SMTP id z10-20020a056870e30a00b0021fd443890fmr7121524oad.59.1708966667114; Mon, 26 Feb 2024 08:57:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966667; cv=pass; d=google.com; s=arc-20160816; b=MythlOVYglda9RYS4GYrzH9DW/wyqlwlmkFvrQE0krAJ494ahx6cw6Y5YFy16lFWOQ ZZeqcsMSPQnA/hCguaPOKBdubZlDK2pyqOl69UQ0xH2nukE0h7Gr7jgnGycoo6qyQm2s storEMuNY0SdHuIpNiTxmn0crcDsfyLs1SG5vuFeIopoidq4Cf9nkU/Hfbm9UgB0vNfe 0/351M9gPQ2Nn4KP3Y43nqhppYadR3NZ/2YUoigqhC3oMqlBGCaiDfFe4W5t2TWiWjfC bHYASje+F2Ys8hm874Um0N4eVUATEddZamkss3qn+0YnX6UDTgLyxcJ+2japtSS5+7gA dduQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rmoDiCu3fC7Vm+wfRrhY6aDgTDEoQqVvLgZuCXucm4A=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=Gwy2NOG1n0hk2FDhYJMCaIjt7b1eQy8nzOXH2dwCZ4yWro1LCWcWyx2oJAnRI5H+LV ssK63ELkBybmtHhIn4Ka1Guvz1CJgmqQuPxZ1zlBSJhh2Wfs2Wgkkvhl/oxJkadT+ml9 h0EIIJPWSUwzDCWXA8sr0qr1/xu4gujn+YJVsjHpSsZQ/Ty8vMuaVDDHSEcGHbEbH+C/ Lu7fMh5RhRhmGz3lX2NHSbTfXJhZpv3D7WRtzJbCWi2XTRstFAnCi/kTSTlpzZA/hYh7 eQPECA47nu4cvMOvZwwK6aP/gzTqKsrX5KrJOqroS6fPXOqGLokkkkiVDffCkQYVPn2R Kh/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=p0YF905S; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81959-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81959-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z12-20020ae9e60c000000b00787b5b259a7si5302681qkf.472.2024.02.26.08.57.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81959-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=p0YF905S; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81959-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81959-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DE4D61C290E8 for ; Mon, 26 Feb 2024 16:57:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77EF9132460; Mon, 26 Feb 2024 16:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="p0YF905S" 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 B0DF712F596; Mon, 26 Feb 2024 16:53:45 +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=1708966427; cv=none; b=SWL4JKzFAT/KE8/bXjYnKwStJHgHidZ36Jgi0RN9eQP818XJbH7BLHm/m5JtGwa4KrZnFoLFSRvVv/fOfgpns+05UDYHEPfKXEzwCQ+IKIYde1ybMinJi0j+NJiCbqowvxl404bXD2cyHOEIjn2K2IPlTWF8oeF7aAmduWKGUXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966427; c=relaxed/simple; bh=dag58QHRP1fnYaS6R8SJNNOzUfUDraUYmqyTTX6oECc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WEU41TA+iwjxztHI5eb1PsYunRMH/tqSZot8DJB0Ksy6SnIGbBDp5sD1bFZKMYnCZidHmL3pBpwHUAkUZZorgKwTLEPMjkcAlI6SdoMKMbLZ/H6DF3OSiJjtrkUVfog7I4bVwOCiseEkFhYnrjjiduiSU/NOJzXFaqUh/iOcijk= 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=p0YF905S; 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 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 41QGgWSj002982; Mon, 26 Feb 2024 16:53:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=rmoDiCu3fC7Vm+wfRrhY6aDgTDEoQqVvLgZuCXucm4A=; b=p0YF905S/AuVXilU6fAKSWE5tClfDmIFKH0QR1ItsvPW0BLP7fZsqC/EGfDPVBEzUj+3 71u0hmv/swejzplAB+4J2VuJRLAxESOaBi4J4dOFvTmpA0mJxmZ9uSm/hwLcO8jmjY1K 76NuHR6t9198D9ZCAb/m+iQHwIXniVtw0ty7/DvrhDRRIudrFRdKU1faPG9XqYVqUn1s rdLZV0kaGotS2uhArjr8kvSMx/tIBRBqhUlCqMGNZhRqIjqiq1caGrZ54pUNLx6HubmF Gi4fvjN9Gvz0fDhVK8KSccRgA4VJSv49+OvZVi6qHt1BKFEpHVetUJa0Vuyu2NnqNZeA Sg== 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 3wgxd4g9ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:35 +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 41QFJsHA008178; Mon, 26 Feb 2024 16:53:34 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9m2a0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:34 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrVVc36831748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:33 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B83D5805D; Mon, 26 Feb 2024 16:53:31 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E38F458053; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:30 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 11/31] fsi: core: Allow cfam device type aliases Date: Mon, 26 Feb 2024 10:53:01 -0600 Message-Id: <20240226165321.91976-12-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: nWDarWJWpsjLqt_it3GQia91Z1aNl05_ X-Proofpoint-ORIG-GUID: nWDarWJWpsjLqt_it3GQia91Z1aNl05_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981431769876078 X-GMAIL-MSGID: 1791981431769876078 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 --- Changes since v1: - Check fsi device type variable before use to ensure we don't go out of bounds on the fsi_dev_type_names array. 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 eb15e5f5a2ee..8ad4feb71c8e 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); @@ -1052,7 +1051,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 Mon Feb 26 16:53:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203919dyb; Mon, 26 Feb 2024 08:59:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUsRHroEHOBZVg+q0k7WF2Qxs5y9pIvi9gF1lDi7gfmpsr+qf8EmHhEj92V+N28He/Jhpb63g9coCXQnhQcRJSrJ2Rdqg== X-Google-Smtp-Source: AGHT+IGEkjXVE7vVt5gHTm/tKq+3/gePMbXuDVRlzvKgw3l5r845e5GCxxjKlO+nDGG/hVoJhxE9 X-Received: by 2002:a05:620a:136c:b0:785:d8a1:dfbd with SMTP id d12-20020a05620a136c00b00785d8a1dfbdmr8666522qkl.68.1708966760538; Mon, 26 Feb 2024 08:59:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966760; cv=pass; d=google.com; s=arc-20160816; b=kg8lVUKdkfKm51Y5rcKRAsPrLL3YBm+gX8pcmFp+Z9RavwcIbn0fLVyh2UTRp0b1ay GuotOVGAKngphIZlyHBjjHQ9UbV99b8bDVpxfLkFnhw04xqwmCIg91dt9gnbLcyFm64u K16/BX41Px1bwnx1OmIIAmkCbFAAezd8DztM85+NmQrf+0Z7xKixfrMKqO4mmklVHW3M skbYyDO1gTDrNwGsKFyrJBZAjajU3wEYrFafZUKaQHZWD2AEJWBJd9LWomoYdCorb4OO Zuu5y5iL4EJ7yLVy4SjlFiSon6YYu9WirSsquQta+j8/ohsrUcC/bCxKKJExPcFqWabq umcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gESFSMVXMnCGLB+x5Tydxw0NsuYitwWEP9s+E56q80k=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=KNh0VZ8+oj75RXBmESrO9H1ypH6Mthm1ZgoL95LTxXvmt83D3rTmBZq9FAKt+dppLB N+GvONDvkO44SFIDbp4lDBbkJ6fgGWs8iOLvTmYyGpgaf+pR1J3DL2kkNgw0WTMt8luM QcDysCMiMNzAeomdip1BiDJiPVgYRybYPKndFHCZyESTo3H4IYF7CUS/6a75rVRwahfl 3hiDu55X6/ywlna68n3DtqSwbkj7NTD4wVuMviKF4wvBHSZDsiernnJedmFm9oT6ughE Tzl76tBhz9OmIaCzoitp5+1fDIZpM88u6gIeWHdNPMGHT0U+C8SaUt/bbsS/XeMBD0jg yMdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YKEbbUlT; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81962-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 18-20020a05620a04d200b00787ba3f52e7si5285211qks.648.2024.02.26.08.59.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:59:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=YKEbbUlT; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81962-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81962-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 467CC1C298D6 for ; Mon, 26 Feb 2024 16:59:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6325C13341A; Mon, 26 Feb 2024 16:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="YKEbbUlT" 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 47604130AF2; Mon, 26 Feb 2024 16:53:48 +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=1708966430; cv=none; b=FxxguhSILN8liKjEaWTqOslfhWmF3OSUPvpHJXZjzgxW4a833RVyCsy7Nj/UjeAlLNYZQkWCSDS8wJWmDEsJXOuqZir/qsDjrcGDdPZDPgmjIMgpr8qPjaIdfshVhksLBo2fTA3Jtrn5VC2BTDSlMlyKsiWXtgpJxIhMb2+SXiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966430; c=relaxed/simple; bh=+At5w04Q60515qFZzjsO4ZZmd/ATuhWy8mO+YskXrEY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oHK7AsZf6CsKD2XzXtQqcdcdjoJ8TFrramaNNQclsZzQxUdN10/c/0oJvbUwv2/hfE6cqWja2/Vkdc7vR46kUccXi2MJyMYKgMgdJXc91VZnBDO6buzhu8RZkeRx1osP+xwmrE5WYuLgtJGyKia8S6mF45eT+ctvvfMHexNNYrU= 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=YKEbbUlT; 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 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 41QGgWcH002957; Mon, 26 Feb 2024 16:53:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=gESFSMVXMnCGLB+x5Tydxw0NsuYitwWEP9s+E56q80k=; b=YKEbbUlTPvdHRK0UZazCNXGQwtQJm8/ZvaODcWslF+fU9O5Rtd2DvlgW9JymLLR2JJ8c t/BCO93N1My6p+e0mYF16+QU8cjZcuMzPh2X5eMZZson7Z7zGGK2k393WkUUcnesPn6A A90tV3OZVgYUpPM9UaByMWRTbnmJWpSfLucAn+KjUCr3iqtXY2guVlS2VeU2TbSkFwig UpTrwrCq/erh74qkQM0YpLgGArPSCkziZezmLp+R0jRb2+wEQ96Qj/0BlDyT8Scs6lUz khfLyj5ZOFzCLCuw5jQUJOyeh3QnFS2l/TJkVUdYl3dbOpMxDy62vBMrPWFba3fGgisX Qw== 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 3wgxd4g9vf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:37 +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 41QGitZS021768; Mon, 26 Feb 2024 16:53:34 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytkr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:34 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrWvV17826356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:34 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 691705805F; Mon, 26 Feb 2024 16:53:32 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B15F458053; Mon, 26 Feb 2024 16:53:31 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:31 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 12/31] fsi: core: Add common regmap master functions Date: Mon, 26 Feb 2024 10:53:02 -0600 Message-Id: <20240226165321.91976-13-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RNlHarXj6Zibsn_uiOUzTuwLHfK3d4vu X-Proofpoint-ORIG-GUID: RNlHarXj6Zibsn_uiOUzTuwLHfK3d4vu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981530335189627 X-GMAIL-MSGID: 1791981530335189627 For hardware FSI masters (Aspeed and hub at the moment), the initialization, link enable, and error recovery procedures are common. Add a regmap pointer to the master structure so that master drivers can let the common code handle these procedures. Signed-off-by: Eddie James --- drivers/fsi/Kconfig | 2 + drivers/fsi/fsi-core.c | 161 ++++++++++++++++++++++++++++++++++++- drivers/fsi/fsi-master.h | 16 ++++ include/trace/events/fsi.h | 17 ++++ 4 files changed, 194 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/Kconfig b/drivers/fsi/Kconfig index 79a31593618a..a6760870538d 100644 --- a/drivers/fsi/Kconfig +++ b/drivers/fsi/Kconfig @@ -7,6 +7,7 @@ menuconfig FSI tristate "FSI support" depends on OF select CRC4 + select REGMAP help FSI - the FRU Support Interface - is a simple bus for low-level access to POWER-based hardware. @@ -37,6 +38,7 @@ config FSI_MASTER_GPIO config FSI_MASTER_HUB tristate "FSI hub master" + select REGMAP_FSI help This option enables a FSI hub master driver. Hub is a type of FSI master that is connected to the upstream master via a slave. Hubs diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 8ad4feb71c8e..ce463ff8ef70 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1148,18 +1149,50 @@ static int fsi_master_write(struct fsi_master *master, int link, return rc; } +int fsi_master_link_enable(struct fsi_master *master, int link, bool enable) +{ + u32 msiep = 0x80000000 >> (4 * (link % 8)); + u32 menp = 0x80000000 >> (link % 32); + int enable_idx = 4 * (link / 32); + int irq_idx = 4 * (link / 8); + int rc; + + if (enable) { + rc = regmap_write(master->map, FSI_MSENP0 + enable_idx, menp); + if (rc) + return rc; + + mdelay(FSI_LINK_ENABLE_SETUP_TIME); + + rc = regmap_write(master->map, FSI_MSSIEP0 + irq_idx, msiep); + } else { + rc = regmap_write(master->map, FSI_MCSIEP0 + irq_idx, msiep); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MCENP0 + enable_idx, menp); + } + + return rc; +} +EXPORT_SYMBOL_GPL(fsi_master_link_enable); + static int fsi_master_link_disable(struct fsi_master *master, int link) { if (master->link_enable) return master->link_enable(master, link, false); + else if (master->map) + return fsi_master_link_enable(master, link, false); return 0; } -static int fsi_master_link_enable(struct fsi_master *master, int link) +static int _fsi_master_link_enable(struct fsi_master *master, int link) { if (master->link_enable) return master->link_enable(master, link, true); + else if (master->map) + return fsi_master_link_enable(master, link, true); return 0; } @@ -1187,7 +1220,7 @@ static int fsi_master_scan(struct fsi_master *master) trace_fsi_master_scan(master, true); for (link = 0; link < master->n_links; link++) { - rc = fsi_master_link_enable(master, link); + rc = _fsi_master_link_enable(master, link); if (rc) { dev_dbg(&master->dev, "enable link %d failed: %d\n", link, rc); @@ -1284,6 +1317,130 @@ static struct class fsi_master_class = { .dev_groups = master_groups, }; +void fsi_master_error(struct fsi_master *master, int link) +{ + u32 bits = FSI_MMODE_EIP | FSI_MMODE_RELA; + bool mmode = master->mmode & bits; + + if (trace_fsi_master_error_regs_enabled()) { + unsigned int mesrb = 0xffffffff; + unsigned int mstap = 0xffffffff; + + regmap_read(master->map, FSI_MESRB0, &mesrb); + regmap_read(master->map, FSI_MSTAP0 + (link * 4), &mstap); + + trace_fsi_master_error_regs(master->idx, mesrb, mstap); + } + + if (mmode) + regmap_write(master->map, FSI_MMODE, master->mmode & ~bits); + + regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER); + + if (mmode) + regmap_write(master->map, FSI_MMODE, master->mmode); +} +EXPORT_SYMBOL_GPL(fsi_master_error); + +static inline u32 fsi_mmode_crs0(u32 x) +{ + return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; +} + +static inline u32 fsi_mmode_crs1(u32 x) +{ + return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; +} + +int fsi_master_init(struct fsi_master *master, unsigned long parent_clock_frequency) +{ + unsigned int mlevp; + unsigned int maeb; + int div = 1; + int rc; + + if (parent_clock_frequency) { + u32 clock_frequency = parent_clock_frequency; + + if (!device_property_read_u32(&master->dev, "clock-frequency", &clock_frequency)) { + if (!clock_frequency) + clock_frequency = parent_clock_frequency; + } + + div = (parent_clock_frequency + (clock_frequency - 1)) / clock_frequency; + master->clock_frequency = parent_clock_frequency / div; + } + + rc = regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER | + FSI_MRESP_RST_ALL_LINK | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MECTRL, FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); + if (rc) + return rc; + + master->mmode = FSI_MMODE_ECRC | FSI_MMODE_EPC | fsi_mmode_crs0(div) | + fsi_mmode_crs1(div) | FSI_MMODE_P8_TO_LSB; + rc = regmap_write(master->map, FSI_MMODE, master->mmode); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MDLYR, 0xffff0000); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MSENP0, 0xffffffff); + if (rc) + return rc; + + mdelay(FSI_LINK_ENABLE_SETUP_TIME); + + rc = regmap_write(master->map, FSI_MCENP0, 0xffffffff); + if (rc) + return rc; + + rc = regmap_read(master->map, FSI_MAEB, &maeb); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESP0, FSI_MRESP_RST_ALL_MASTER | + FSI_MRESP_RST_ALL_LINK); + if (rc) + return rc; + + rc = regmap_read(master->map, FSI_MLEVP0, &mlevp); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESB0, FSI_MRESB_RST_GEN); + if (rc) + return rc; + + rc = regmap_write(master->map, FSI_MRESB0, FSI_MRESB_RST_ERR); + if (rc) + return rc; + + if (master->flags & FSI_MASTER_FLAG_INTERRUPT) + master->mmode |= FSI_MMODE_EIP; + if (master->flags & FSI_MASTER_FLAG_RELA) + master->mmode |= FSI_MMODE_RELA; + return regmap_write(master->map, FSI_MMODE, master->mmode); +} +EXPORT_SYMBOL_GPL(fsi_master_init); + +void fsi_master_regmap_config(struct regmap_config *config) +{ + config->reg_bits = 32; + config->val_bits = 32; + config->disable_locking = true; // master driver will lock + config->fast_io = true; + config->cache_type = REGCACHE_NONE; + config->val_format_endian = REGMAP_ENDIAN_NATIVE; + config->can_sleep = false; +} +EXPORT_SYMBOL_GPL(fsi_master_regmap_config); + int fsi_master_register(struct fsi_master *master) { int rc; diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h index 26e636ad9ef6..f4cecdff3834 100644 --- a/drivers/fsi/fsi-master.h +++ b/drivers/fsi/fsi-master.h @@ -27,6 +27,9 @@ #define FSI_MLEVP0 0x18 /* R: plug detect */ #define FSI_MSENP0 0x18 /* S: Set enable */ #define FSI_MCENP0 0x20 /* C: Clear enable */ +#define FSI_MSIEP0 0x30 /* R/W: interrupt enable */ +#define FSI_MSSIEP0 0x50 /* S: Set interrupt enable */ +#define FSI_MCSIEP0 0x70 /* C: Clear interrupt enable */ #define FSI_MAEB 0x70 /* R: Error address */ #define FSI_MVER 0x74 /* R: master version/type */ #define FSI_MSTAP0 0xd0 /* R: Port status */ @@ -108,9 +111,15 @@ /* Misc */ #define FSI_CRC_SIZE 4 +#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ /* fsi-master definition and flags */ #define FSI_MASTER_FLAG_SWCLOCK 0x1 +#define FSI_MASTER_FLAG_INTERRUPT 0x2 +#define FSI_MASTER_FLAG_RELA 0x4 + +struct regmap; +struct regmap_config; /* * Structures and function prototypes @@ -120,6 +129,8 @@ struct fsi_master { struct device dev; + struct regmap *map; + u32 mmode; unsigned long clock_frequency; int lbus_divider; int idx; @@ -140,6 +151,11 @@ struct fsi_master { #define to_fsi_master(d) container_of(d, struct fsi_master, dev) +void fsi_master_error(struct fsi_master *master, int link); +int fsi_master_init(struct fsi_master *master, unsigned long parent_clock_frequency); +int fsi_master_link_enable(struct fsi_master *master, int link, bool enable); +void fsi_master_regmap_config(struct regmap_config *config); + /** * fsi_master registration & lifetime: the fsi_master_register() and * fsi_master_unregister() functions will take ownership of the master, and diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h index 5509afc98ee8..da977d59e163 100644 --- a/include/trace/events/fsi.h +++ b/include/trace/events/fsi.h @@ -67,6 +67,23 @@ TRACE_EVENT(fsi_master_error, &__entry->data, __entry->ret) ); +TRACE_EVENT(fsi_master_error_regs, + TP_PROTO(int master_idx, uint32_t mesrb, uint32_t mstap), + TP_ARGS(master_idx, mesrb, mstap), + TP_STRUCT__entry( + __field(int, master_idx) + __field(uint32_t, mesrb) + __field(uint32_t, mstap) + ), + TP_fast_assign( + __entry->master_idx = master_idx; + __entry->mesrb = mesrb; + __entry->mstap = mstap; + ), + TP_printk("fsi%d mesrb:%08x mstap:%08x", __entry->master_idx, __entry->mesrb, + __entry->mstap) +); + TRACE_EVENT(fsi_master_break, TP_PROTO(const struct fsi_master *master, int link), TP_ARGS(master, link), From patchwork Mon Feb 26 16:53: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: 206788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203639dyb; Mon, 26 Feb 2024 08:58:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEv7y+Y4+0AzBYOsWCcgicIcf75zFTnxbQjaB67CvgsPTXhCSLpL6N5VdYUv5Hhgteykja1X3PhrUZwRSFzCnw+Wb3Tw== X-Google-Smtp-Source: AGHT+IFMV9PGWypXeD0d1q4cSJtdvv1vMRvJbffXGH2af4bl2nyuG9iHgpqr2t/293mpo153EIK8 X-Received: by 2002:a17:902:c946:b0:1dc:8546:1584 with SMTP id i6-20020a170902c94600b001dc85461584mr8811225pla.0.1708966724684; Mon, 26 Feb 2024 08:58:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966724; cv=pass; d=google.com; s=arc-20160816; b=NQu99jxa5ntiVeXf/fs0g7Ev8WIoOUiMBnY5u9wP7//Q2or1x0+ccRy0QNLLhI0I80 D9NgFvw29JYVZg+kuqfwpLTubtYMWUpQFC3uonY5nMGeDco3jiCOjcSTs22PCG3PHgRJ NaCjchz7Uw1/60a8QDjwg6ULxf17ZAopYRqbV67UWFTnOCvSkHp6oajuU2Wk+2S5VWfI ac9xGIuevmg9FyHchij/y4yPtMzlO2eLroWl/0TmnxtJVscI2VcFLZGUO+VgdqGDLxlc p5LLYInqBHtZ02Rvelu0VaBmlncTjmAJ6n9+cuXXX6/fwTsk55RSLvGl/8tkdEnf2WdJ Hc/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zrnHDAhdPUnbtmjsykKg9BbRlBjR1tZ8tUSGR8/dp0k=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=JyoLl3on59ldqRxLvwPua/ATp1oDSR086vHNpl5vqGgjb3mO9cJFbGcS/IdnngrvrL 8O38+vP+N1jMtLKEscmgEjn08xpf115+UCbIHLua4BRZqKdBWeDwxtbw2njY/bp091jb 8INspgFUWV/J46eJFPWIy8odabe3GhW9m4aqImVUn/lZzicwltSJ/oI7fYIpwZw7xvFX wXFdYdjSSeqlZQsjQc3Tx+74J8J9pVzpyvz2oA1/clYaqz6o0ymMz3hrqvkgzEWJ/OT2 MCCfvc4yaa8WhgpovvHXuZKBonCTKecGS+bvjy4J455314fx8A9K594OMGZhrtInxzLG cVrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=oj3hOWbO; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81961-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m12-20020a170902768c00b001db27f2357esi3884458pll.579.2024.02.26.08.58.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:58:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81961-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=oj3hOWbO; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81961-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4FE10282EC5 for ; Mon, 26 Feb 2024 16:58:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AED13132C2A; Mon, 26 Feb 2024 16:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oj3hOWbO" 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 7635C12FF86; Mon, 26 Feb 2024 16:53:47 +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=1708966429; cv=none; b=aLQ75w/4sjGgCtyS8k/DAfHbG4SpArM0HoUzVNe0qI3bqZWnFtUdtwCxaucQ4LBqWu9cH8jc+ahpPCc3+TWDmDkRoWhIic8RvVd3FiRK86JSIYC0RkM9c846p6TBeTHjFAtrBv/PSoKFZQomnXGxr8apzI6ArwQGX7n+f8ItrGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966429; c=relaxed/simple; bh=3nimcBkyHMSfym8s4tUd4i+bP6FP4+nFWT7XoE1U7e0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A3NfI5atuMWitk27pPqCpDm2lLn2sHSRORVEqzXI7z8kvE5QDkb7kvX4CfLxS9+RPIKKtpHv2G0F4eO0bJ2V0bCnDUnQ/C3c4I/TmUdn3wMp0HTdAPZmYQpr22T6+iRDCOdr2Mf76DLCYFjJFDF4KXhkNr3xmxdSDUAI977NEYQ= 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=oj3hOWbO; 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 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 41QG15OI018815; Mon, 26 Feb 2024 16:53:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=zrnHDAhdPUnbtmjsykKg9BbRlBjR1tZ8tUSGR8/dp0k=; b=oj3hOWbOMbkjNXKXEKIsbberAkFxEqyZbvpLWUj984XbaX91D2eJaNdcFGca8LzdiNiI elwXIe3S0YzHzm/EXz6lhnKW9TUdkqWZnS34QrrRUFIX762llvVBm8vn0WJL+tVj7M+s I27JSd+L7sluSJqLIPxUcfknbTLsacW/mjdUaAhnMD54DFA6x2mKehpnfYHGJoQ6cxPH 5RXuGWz4qXrqvLd1sUPkf4QIIqO3at9lWMHApaMKP84udlqUh6uIcJC8q1LGQvK13Xo4 zPopWx/dw6Q03y/kKUI9iSj3G6kqAdUhnYXYt4rfNMxr+p9dxbDBAvdeExq1gMEmPzgr ag== 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 3wgw0k3559-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:37 +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 41QG2Vib008792; Mon, 26 Feb 2024 16:53:36 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wftstarbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:35 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrXA628115624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:35 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36BAC58066; Mon, 26 Feb 2024 16:53:33 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EBD358053; Mon, 26 Feb 2024 16:53:32 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:32 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 13/31] fsi: hub: Use common initialization and link enable Date: Mon, 26 Feb 2024 10:53:03 -0600 Message-Id: <20240226165321.91976-14-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 9JtxlGHNjdCSQi9QI3kM5SOlEskEtO_T X-Proofpoint-ORIG-GUID: 9JtxlGHNjdCSQi9QI3kM5SOlEskEtO_T X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=838 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981492503390043 X-GMAIL-MSGID: 1791981492503390043 Set up an FSI regmap for the hub master to use the new common master initialization and link enable procedures. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-hub.c | 141 ++++++----------------------------- 1 file changed, 23 insertions(+), 118 deletions(-) diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index 111bf7a11458..92aa07055c56 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "fsi-master.h" @@ -16,8 +17,6 @@ #define FSI_ENGID_HUB_MASTER 0x1c -#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ - /* * FSI hub master support * @@ -78,134 +77,33 @@ static int hub_master_break(struct fsi_master *master, int link) return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd)); } -static int hub_master_link_enable(struct fsi_master *master, int link, - bool enable) -{ - struct fsi_master_hub *hub = to_fsi_master_hub(master); - int idx, bit; - __be32 reg; - int rc; - - idx = link / 32; - bit = link % 32; - - reg = cpu_to_be32(0x80000000 >> bit); - - if (!enable) - return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx), - ®, 4); - - rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), ®, 4); - if (rc) - return rc; - - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - return 0; -} - static void hub_master_release(struct device *dev) { struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev)); + regmap_exit(hub->master.map); kfree(hub); } -/* mmode encoders */ -static inline u32 fsi_mmode_crs0(u32 x) -{ - return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; -} - -static inline u32 fsi_mmode_crs1(u32 x) -{ - return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; -} - -static int hub_master_init(struct fsi_master_hub *hub) -{ - struct fsi_device *dev = hub->upstream; - __be32 reg; - int rc; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Initialize the MFSI (hub master) engine */ - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); - rc = fsi_device_write(dev, FSI_MECTRL, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MMODE_EIP | FSI_MMODE_ECRC | FSI_MMODE_EPC - | fsi_mmode_crs0(1) | fsi_mmode_crs1(1) - | FSI_MMODE_P8_TO_LSB); - rc = fsi_device_write(dev, FSI_MMODE, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(0xffff0000); - rc = fsi_device_write(dev, FSI_MDLYR, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(~0); - rc = fsi_device_write(dev, FSI_MSENP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Leave enabled long enough for master logic to set up */ - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - rc = fsi_device_write(dev, FSI_MCENP0, ®, sizeof(reg)); - if (rc) - return rc; - - rc = fsi_device_read(dev, FSI_MAEB, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK); - rc = fsi_device_write(dev, FSI_MRESP0, ®, sizeof(reg)); - if (rc) - return rc; - - rc = fsi_device_read(dev, FSI_MLEVP0, ®, sizeof(reg)); - if (rc) - return rc; - - /* Reset the master bridge */ - reg = cpu_to_be32(FSI_MRESB_RST_GEN); - rc = fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); - if (rc) - return rc; - - reg = cpu_to_be32(FSI_MRESB_RST_ERR); - return fsi_device_write(dev, FSI_MRESB0, ®, sizeof(reg)); -} - static int hub_master_probe(struct device *dev) { + struct regmap_config hub_master_regmap_config; struct fsi_device *fsi_dev = to_fsi_dev(dev); struct fsi_master_hub *hub; + struct regmap *map; uint32_t reg, links; - __be32 __reg; int rc; - rc = fsi_device_read(fsi_dev, FSI_MVER, &__reg, sizeof(__reg)); + fsi_master_regmap_config(&hub_master_regmap_config); + hub_master_regmap_config.reg_base = fsi_dev->addr; + map = regmap_init_fsi(fsi_dev, &hub_master_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + + rc = regmap_read(map, FSI_MVER, ®); if (rc) - return rc; + goto err_regmap; - reg = be32_to_cpu(__reg); links = (reg >> 8) & 0xff; dev_dbg(dev, "hub version %08x (%d links)\n", reg, links); @@ -213,7 +111,7 @@ static int hub_master_probe(struct device *dev) FSI_HUB_LINK_SIZE * links); if (rc) { dev_err(dev, "can't claim slave address range for links"); - return rc; + goto err_regmap; } hub = kzalloc(sizeof(*hub), GFP_KERNEL); @@ -229,22 +127,25 @@ static int hub_master_probe(struct device *dev) hub->master.dev.parent = dev; hub->master.dev.release = hub_master_release; hub->master.dev.of_node = of_node_get(dev_of_node(dev)); + hub->master.map = map; hub->master.lbus_divider = 1; hub->master.idx = fsi_dev->slave->link + 1; hub->master.n_links = links; + hub->master.flags = FSI_MASTER_FLAG_INTERRUPT; hub->master.read = hub_master_read; hub->master.write = hub_master_write; hub->master.send_break = hub_master_break; - hub->master.link_enable = hub_master_link_enable; dev_set_drvdata(dev, hub); - hub_master_init(hub); + rc = fsi_master_init(&hub->master, fsi_device_local_bus_frequency(fsi_dev)); + if (rc) + goto err_free; rc = fsi_master_register(&hub->master); if (rc) - goto err_release; + goto err_free; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -256,9 +157,13 @@ static int hub_master_probe(struct device *dev) get_device(&hub->master.dev); return 0; +err_free: + kfree(hub); err_release: fsi_slave_release_range(fsi_dev->slave, FSI_HUB_LINK_OFFSET, FSI_HUB_LINK_SIZE * links); +err_regmap: + regmap_exit(map); return rc; } From patchwork Mon Feb 26 16:53: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: 206793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2204402dyb; Mon, 26 Feb 2024 09:00:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJcghitfPu+Ojr2dlla37WTwHAPOGuAmswfnxjENlNpoSO35YEuqCfp+7PW/qsM/B4G289yMhtr/903FABZbL5Xg7pHQ== X-Google-Smtp-Source: AGHT+IHwM3+/VEv3D34XF9qp2+etzS0sN8dIKQe3TUDT+ObuT67ooLSqUb3Q+FCnEGuzJ8YVfYEA X-Received: by 2002:a17:902:c142:b0:1dc:43d:964 with SMTP id 2-20020a170902c14200b001dc043d0964mr6370216plj.48.1708966808442; Mon, 26 Feb 2024 09:00:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966808; cv=pass; d=google.com; s=arc-20160816; b=GcWT7qOkFrbELVAAjm7G+GTIqagR3D8JxtX7RduciStUKZdK5gBSlcRmHSQZjUjUp0 wT3QA0kTrDvUYpBg74OBoliQ9LU3uhru33UYnS8Rf8YImjQsxYBaW7VN4M9Sqaxkb0qi 2UQgqf5ClXqVWwUx8hy+KGnqtJWcJO0lQRRuK2g8v3ja01cMrBTACbp5qLDZnxKqPyeY ntQZ0r+VwY2/OwGeATd91A5S3U2kn1omNCWdX+CTeRlBqcPwEe1uyQSwYVF477t5bQAT zdeIAddOxmLzhcEpew6GQCQJaGMuh0RN83qyf6S40KkXPeKQ/3bWytZgcRv3rpel9W0r pRrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Wt8UWHHJz1+fM4oAB+F4OGgkDBnjm6htdEah2gI4GTI=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=eNIBgdk8/aUDwjLBxXuNj8KTabtJBaINtRbgr6eEu8W78qfnDaC/I6xi+HIFb8MkyE TJ1DgXJdPRyxJswoyygXTWSrqg8titp+mVuMxw/7lhd5dB9qsL3qSnhpdiHsRjfr+QXv 10f++pz1AzELsUpl5uBa1erZ24Lt8f1NytBJ9CwVq1Onaf6MGfh5cPI9izRhGX95K9J0 NS1xA1MimhYnCJUIyj+0TnuxEWVYa80pDusQKr8T/RO4OW9YYO+6PCdwh83tUx/NfXOp R+oWpiOQ0UK1NBIDKjJ+Q6DIAOfvcZgWL+YjL31CQjKeT7caPBwL0ZwcuTadd0gXAW5H 5VJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="SAtcD5/9"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81965-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z4-20020a170903018400b001dc164b20a1si3985933plg.174.2024.02.26.09.00.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="SAtcD5/9"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81965-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81965-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3F886289E87 for ; Mon, 26 Feb 2024 17:00:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B40B7134747; Mon, 26 Feb 2024 16:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="SAtcD5/9" 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 F40F0131E42; Mon, 26 Feb 2024 16:53:50 +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=1708966433; cv=none; b=B1RvX2fw7SG0smc0HRCQaS5p2xoxd7KrHNfE2NPharIz5dG0zmNMTJb/9G6rtp6L7o4eXtuukXbrKAWHRZSpqou1SMiesdMOhkz0aGzEaajI42clpTGHWR+Dy/yFdWTBHhHvLph43H3D42K1hqN0O9ODhSheDGNw3LmRWHV1Ll4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966433; c=relaxed/simple; bh=06noxcBj+0w/9K5t6WqaO8FUweWGJp65GITzL1ijo5s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=skup/f4Dt23t8tW5CqoUSqr0Y1NHSteWMfs7zFHwEPtKBoH38dw5mdlxZLkX5/pI4Vnzcj+7UKP4Q47SItleompeqBq9aCkhQHyX6l3mZNPWLVEwRgDHmB+/7TBSdO8jzbOfFo2YB3dWEJEPyP+4K55n0cbxRZ0e+qLmQXZUhRg= 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=SAtcD5/9; 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 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 41QF2mUE022255; Mon, 26 Feb 2024 16:53:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Wt8UWHHJz1+fM4oAB+F4OGgkDBnjm6htdEah2gI4GTI=; b=SAtcD5/985Nvt1QZ4/I1M1WNWG5DNwozj/OyiaVy21RlZ+yegxXFDUA/51ThRoD1M7aB rjZBuYR+G42gLTC5iUX7g8wPKXqxmyh3l+VYBxeBteKJIwoeyAuWX7qtAhjViDvrxHBX JbiR30URGMLVmKSDB31H9JfxjUo42vz8OThdVcDTgv+F2eegz0dJaJHQorsvDugNnXQi zOVTWvY2M8AgYEfIijFPabm/jdkSDMsTHwDlMAKgUB22E+NkFozO0RS1OUt6wGCfKT/M m8BTMmR9CRtzYTkK15jCcFiuH41yWL5Tn/mGe0L/gCIfSCPSwPdqZkkUq6nteZPJS6kf GA== 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 3wgvp6bk5w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:38 +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 41QFvbiV012371; Mon, 26 Feb 2024 16:53:36 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xwf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:36 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrYH019530298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:36 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E67758043; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D58658053; Mon, 26 Feb 2024 16:53:33 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:33 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 14/31] fsi: aspeed: Use common initialization and link enable Date: Mon, 26 Feb 2024 10:53:04 -0600 Message-Id: <20240226165321.91976-15-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qQyfIO1IPjbs2PUq4nX-k2kfazlcghbO X-Proofpoint-GUID: qQyfIO1IPjbs2PUq4nX-k2kfazlcghbO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981580209426997 X-GMAIL-MSGID: 1791981580209426997 Create a regmap for accessing the master registers over OPB to use the new common master initialization and link enable procedures. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 146 ++++++++------------------------ 1 file changed, 37 insertions(+), 109 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index d6e923b8f501..2258980e4c47 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -90,14 +90,6 @@ static const u32 fsi_base = 0xa0000000; #define CREATE_TRACE_POINTS #include -#define FSI_LINK_ENABLE_SETUP_TIME 10 /* in mS */ - -/* Run the bus at maximum speed by default */ -#define FSI_DIVISOR_DEFAULT 1 -#define FSI_DIVISOR_CABLED 2 -static u16 aspeed_fsi_divisor = FSI_DIVISOR_DEFAULT; -module_param_named(bus_div,aspeed_fsi_divisor, ushort, 0); - #define OPB_POLL_TIMEOUT 500 static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr, @@ -328,35 +320,6 @@ static int aspeed_master_write(struct fsi_master *master, int link, return ret; } -static int aspeed_master_link_enable(struct fsi_master *master, int link, - bool enable) -{ - struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master); - int idx, bit, ret; - __be32 reg; - - idx = link / 32; - bit = link % 32; - - reg = cpu_to_be32(0x80000000 >> bit); - - mutex_lock(&aspeed->lock); - - if (!enable) { - ret = opb_writel(aspeed, ctrl_base + FSI_MCENP0 + (4 * idx), reg); - goto done; - } - - ret = opb_writel(aspeed, ctrl_base + FSI_MSENP0 + (4 * idx), reg); - if (ret) - goto done; - - mdelay(FSI_LINK_ENABLE_SETUP_TIME); -done: - mutex_unlock(&aspeed->lock); - return ret; -} - static int aspeed_master_term(struct fsi_master *master, int link, uint8_t id) { uint32_t addr; @@ -384,72 +347,33 @@ static void aspeed_master_release(struct device *dev) struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(to_fsi_master(dev)); + regmap_exit(aspeed->master.map); kfree(aspeed); } -/* mmode encoders */ -static inline u32 fsi_mmode_crs0(u32 x) +static int regmap_aspeed_opb_read(void *context, unsigned int reg, unsigned int *val) { - return (x & FSI_MMODE_CRS0MASK) << FSI_MMODE_CRS0SHFT; -} + __be32 v; + int ret; -static inline u32 fsi_mmode_crs1(u32 x) -{ - return (x & FSI_MMODE_CRS1MASK) << FSI_MMODE_CRS1SHFT; + ret = opb_readl(context, ctrl_base + reg, &v); + if (ret) + return ret; + + *val = be32_to_cpu(v); + return 0; } -static int aspeed_master_init(struct fsi_master_aspeed *aspeed) +static int regmap_aspeed_opb_write(void *context, unsigned int reg, unsigned int val) { - __be32 reg; - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); - - /* Initialize the MFSI (hub master) engine */ - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK - | FSI_MRESP_RST_MCR | FSI_MRESP_RST_PYE); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); - - reg = cpu_to_be32(FSI_MECTRL_EOAE | FSI_MECTRL_P8_AUTO_TERM); - opb_writel(aspeed, ctrl_base + FSI_MECTRL, reg); - - reg = cpu_to_be32(FSI_MMODE_ECRC | FSI_MMODE_EPC | FSI_MMODE_RELA - | fsi_mmode_crs0(aspeed_fsi_divisor) - | fsi_mmode_crs1(aspeed_fsi_divisor) - | FSI_MMODE_P8_TO_LSB); - dev_info(aspeed->dev, "mmode set to %08x (divisor %d)\n", - be32_to_cpu(reg), aspeed_fsi_divisor); - opb_writel(aspeed, ctrl_base + FSI_MMODE, reg); - - reg = cpu_to_be32(0xffff0000); - opb_writel(aspeed, ctrl_base + FSI_MDLYR, reg); - - reg = cpu_to_be32(~0); - opb_writel(aspeed, ctrl_base + FSI_MSENP0, reg); - - /* Leave enabled long enough for master logic to set up */ - mdelay(FSI_LINK_ENABLE_SETUP_TIME); - - opb_writel(aspeed, ctrl_base + FSI_MCENP0, reg); - - opb_readl(aspeed, ctrl_base + FSI_MAEB, NULL); - - reg = cpu_to_be32(FSI_MRESP_RST_ALL_MASTER | FSI_MRESP_RST_ALL_LINK); - opb_writel(aspeed, ctrl_base + FSI_MRESP0, reg); - - opb_readl(aspeed, ctrl_base + FSI_MLEVP0, NULL); - - /* Reset the master bridge */ - reg = cpu_to_be32(FSI_MRESB_RST_GEN); - opb_writel(aspeed, ctrl_base + FSI_MRESB0, reg); - - reg = cpu_to_be32(FSI_MRESB_RST_ERR); - opb_writel(aspeed, ctrl_base + FSI_MRESB0, reg); - - return 0; + return opb_writel(context, ctrl_base + reg, cpu_to_be32(val)); } +static const struct regmap_bus regmap_aspeed_opb = { + .reg_write = regmap_aspeed_opb_write, + .reg_read = regmap_aspeed_opb_read, +}; + static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -521,14 +445,6 @@ static int tacoma_cabled_fsi_fixup(struct device *dev) /* If the routing GPIO is high we should set the mux to low. */ if (gpio) { - /* - * Cable signal integrity means we should run the bus - * slightly slower. Do not override if a kernel param - * has already overridden. - */ - if (aspeed_fsi_divisor == FSI_DIVISOR_DEFAULT) - aspeed_fsi_divisor = FSI_DIVISOR_CABLED; - gpiod_direction_output(mux_gpio, 0); dev_info(dev, "FSI configured for external cable\n"); } else { @@ -544,9 +460,10 @@ 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_RETRY_COUNTER_AST2600; + struct regmap_config aspeed_master_regmap_config; struct fsi_master_aspeed *aspeed; - int rc, links, reg; - __be32 raw; + unsigned int reg; + int rc, links; rc = tacoma_cabled_fsi_fixup(&pdev->dev); if (rc) { @@ -606,13 +523,20 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) */ writel(0x1, aspeed->base + OPB0_SELECT); - rc = opb_readl(aspeed, ctrl_base + FSI_MVER, &raw); + fsi_master_regmap_config(&aspeed_master_regmap_config); + aspeed->master.map = regmap_init(&pdev->dev, ®map_aspeed_opb, aspeed, + &aspeed_master_regmap_config); + if (IS_ERR(aspeed->master.map)) { + rc = PTR_ERR(aspeed->master.map); + goto err_release; + } + + rc = regmap_read(aspeed->master.map, FSI_MVER, ®); if (rc) { dev_err(&pdev->dev, "failed to read hub version\n"); - goto err_release; + goto err_regmap; } - reg = be32_to_cpu(raw); links = (reg >> 8) & 0xff; dev_info(&pdev->dev, "hub version %08x (%d links)\n", reg, links); @@ -621,20 +545,22 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) aspeed->master.dev.of_node = of_node_get(dev_of_node(&pdev->dev)); aspeed->master.n_links = links; + aspeed->master.flags = FSI_MASTER_FLAG_RELA; aspeed->master.read = aspeed_master_read; aspeed->master.write = aspeed_master_write; aspeed->master.send_break = aspeed_master_break; aspeed->master.term = aspeed_master_term; - aspeed->master.link_enable = aspeed_master_link_enable; dev_set_drvdata(&pdev->dev, aspeed); mutex_init(&aspeed->lock); - aspeed_master_init(aspeed); + rc = fsi_master_init(&aspeed->master, clk_get_rate(aspeed->clk)); + if (rc) + goto err_regmap; rc = fsi_master_register(&aspeed->master); if (rc) - goto err_release; + goto err_regmap; /* At this point, fsi_master_register performs the device_initialize(), * and holds the sole reference on master.dev. This means the device @@ -646,6 +572,8 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) get_device(&aspeed->master.dev); return 0; +err_regmap: + regmap_exit(aspeed->master.map); err_release: clk_disable_unprepare(aspeed->clk); err_free_aspeed: From patchwork Mon Feb 26 16:53: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: 206787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2203633dyb; Mon, 26 Feb 2024 08:58:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUbliKiq6/xU7+Kx53DwSGy1pitb5DfidsM8kM5flPCAXCfZym7h9X7UaCMn/qINkbqLVjbqmztmeWlJVDjjv1yj424/w== X-Google-Smtp-Source: AGHT+IGEkuhBQuoWyh3YON0eWQ6eW9paQw56zBDTB7Q8i6SCYdOMf8zYE893nRoeVhd7JJPBBLuu X-Received: by 2002:a17:906:fb07:b0:a43:4876:983b with SMTP id lz7-20020a170906fb0700b00a434876983bmr2415277ejb.57.1708966723965; Mon, 26 Feb 2024 08:58:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966723; cv=pass; d=google.com; s=arc-20160816; b=tQGA4MCWGrEKQZrLxUpfHee42atUyQWjlc70zDkOCiCpDdn8ETHpJB6KSc0PDIBp2r RohYGdZlvhB+X7EYuBlGe9AEYhFZWnZcxmL9UPnZ8iLC+ef3ItJMwsNfIjgJ3pu/D6Et qmHFyXKyYxcHzBFSarrHS4PXzC7diwUX2sQ9cOCIbbwa0Yv2u21mq76Q6t3TKQ94HwtC ZljGGX4cRvlQs7qiuoH7jgaEPncFlEzfzljH42fpalg6KLwwflUsKtAvUVco9ro5p4qs PpUUUr2pf8MAiXnK+3qfYXzaeor3oTKMinCIFTfxocPRqUwfzqmv9DliZcUDDal+jrUB Ui/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BoYmg2I4Q0k+a3TaU4ABCYR9yHgcAHY+742VsQ7xQZc=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=XJuOEOLKUzgPs23pzg1GBf6HNxfQARvIPxyS+XATVpRAKnLm0OEVo1pN3Xt8y5ln0j /OwB2rfA5NfU628kwmMAz0sWC938EKDb/riAP/szFrFUJoTaj/rFVozU0MD8iU6hpRzg V/YX1Ed2J6GVz4coNkylLPfavGSoXB7+oLEwzzBPS9q90w5p4m5w0vHBpSIgljvYkjkq PzbnC3krJQtPQ8D3onjFZrkQn6WElsubIVuNfVLa2PcuwRYOiy3PYK20k9MOzQhXCfME zN3SHKbohKpCxtJpLfSDoLhOPeE0nKRi+JgptBf4bUV+tZGxMmi2XgGj6MskQhvzBmDY Xphg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LPNqYiu8; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81963-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b23-20020a170906039700b00a3f18f596fesi2274251eja.616.2024.02.26.08.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=LPNqYiu8; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81963-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81963-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8E0061F28A08 for ; Mon, 26 Feb 2024 16:58:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4E96132C3A; Mon, 26 Feb 2024 16:53:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="LPNqYiu8" 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 02CD6130E3E; Mon, 26 Feb 2024 16:53:48 +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=1708966430; cv=none; b=Q0H3xSJJ8wevd5z7zLijLW8+TcgvsqxL7wFta4NdKVRs1MaLetYzSRNbBwm7hufztCjQqgfN+Le+g6DAOOrOH6UYHeIdT0hOpJqr+Fl2fNvYxyMCZRwj3wQ1FZYhzKlE0hRz1GfkmUYKzKkJBNsvC7Zag46/lbRuoYJdTz82WgI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966430; c=relaxed/simple; bh=8Ct3J2NJkURDInEhDXz003U01AuCHf4/0dNy3zQDeEk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VYT+oprFzQdvSQ1n3QsN1kF8bW7A5uCdfU4NgAZOghXiKd8eDuwNQRUcsnbXdsFFDh9hViT7jn8QdY9z7CsbGFsi310qatkgeiKsCGjcyAebPLOEDiYb2XTpuwGZfHel2Z8pEixFXXYPP5UxJS1W7fNlRl4IEU2QMscZgKwNSug= 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=LPNqYiu8; 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 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 41QFvHZi020191; Mon, 26 Feb 2024 16:53:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BoYmg2I4Q0k+a3TaU4ABCYR9yHgcAHY+742VsQ7xQZc=; b=LPNqYiu8v4vuui8NJwg1Oiq+gOvhZSQmjXBgkNalfpldQtFPs7hYoSQeHSbFMS/NdQJ3 GawrqV5KkWj+7bipTPTHHLM+7WuiHgSopQjT7xuQ6nc67OF1NYYvfAeHdMP3Pig6wRNA pbA23mOkszsG2YRf9T3wWe5pTPmBizWzfDdF93668wdtPYOafp0T6hD9JWAaV8QMiK0R MXwAMBX5a4PXAcRzPlZBrk5d9nTXLRkan8SZ2I4W0UHEC6Msv8aa0LvQosTLeOysTue9 Td3gzG3rxUO7tm5OJTomxrTwJur7uelxEzZi2uYa/CYOqE8wQx9sR2W7JFyaPAUeol21 aA== 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 3wgwr21p72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:38 +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 41QGf4Dh021363; Mon, 26 Feb 2024 16:53:37 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfusnteds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:37 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrYmo12321382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:37 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB04158063; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 244FA58053; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 15/31] fsi: aspeed: Remove cfam reset sysfs file in error path and remove Date: Mon, 26 Feb 2024 10:53:05 -0600 Message-Id: <20240226165321.91976-16-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: pHmNCRKo91aVONu_gTw0RVuVuL7Q233i X-Proofpoint-GUID: pHmNCRKo91aVONu_gTw0RVuVuL7Q233i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=968 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981491515968306 X-GMAIL-MSGID: 1791981491515968306 This fixes a duplicate sysfs warning on device re-probe. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 2258980e4c47..c36e7e49e965 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -410,6 +410,7 @@ static int setup_cfam_reset(struct fsi_master_aspeed *aspeed) rc = device_create_file(dev, &dev_attr_cfam_reset); if (rc) { + aspeed->cfam_reset_gpio = NULL; devm_gpiod_put(dev, gpio); return rc; } @@ -575,6 +576,9 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) err_regmap: regmap_exit(aspeed->master.map); err_release: + if (aspeed->cfam_reset_gpio) + device_remove_file(aspeed->dev, &dev_attr_cfam_reset); + clk_disable_unprepare(aspeed->clk); err_free_aspeed: kfree(aspeed); @@ -585,6 +589,9 @@ static int fsi_master_aspeed_remove(struct platform_device *pdev) { struct fsi_master_aspeed *aspeed = platform_get_drvdata(pdev); + if (aspeed->cfam_reset_gpio) + device_remove_file(aspeed->dev, &dev_attr_cfam_reset); + fsi_master_unregister(&aspeed->master); clk_disable_unprepare(aspeed->clk); From patchwork Mon Feb 26 16:53:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2204396dyb; Mon, 26 Feb 2024 09:00:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVdvCkBbyi30AV2bj7vRh/ZorvKz38ummKJdFnxI6lHobV0NdSaBmB2rSb70ClA6b97WJebJF/+VImdOsAfpUp89KcDOw== X-Google-Smtp-Source: AGHT+IG4fkFxVuoscYa+gDFAXMWDK0mYR2GYGLZmolXK0M/meH2reOhQ1QrNfuR38oYZ8guPGYUH X-Received: by 2002:a0c:cc14:0:b0:68f:280f:14d0 with SMTP id r20-20020a0ccc14000000b0068f280f14d0mr7822277qvk.38.1708966808231; Mon, 26 Feb 2024 09:00:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966808; cv=pass; d=google.com; s=arc-20160816; b=X5nLFlkpn1Ar1pSGv+0b3uIl+AoLMzZHkM52h+C3PJj67ALWbylf+9LA05ZXOTBXoM 3QzEP/1diCAKmYlir4hR61C04Fg5boGzN4FX1Xa5la2kMuwXdnxEc30mXThOMV+FrhQg GcXo5RmloAE0i/DpSyXQrzQjR47wWLOwTpDTbigFCakKt42t14AQeAY5YkMJsq797vAi FP6KZ+50SPOeRIHF6iHsFwBPrVEAszCc4gBkezjgcQxWzXf4j2wi58ZFEk+8crGqKpSo jhDtSt6IKj9Ykk+c/eprsDoDPD4VDgRdALQSgC3alacVsB6G3czbjykrAFiw3wp9avM+ 7oeA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zvpqrz1IR95x4v/nVIcA1R/mLkFs7xansTMd+3MOVyo=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=Im4DQK+WweKmj0eKTn4UK77iVWCseEfVE0c3KRPh/LVOpcbxOBPdnJ6xNJDKkBFKxU LAF2yLeyoyrpCQJIhnLYhZ75ShhswDTkQ9wy6Q0gyzUFpJ5nLgTUvS3TRVrrt9fkWHxY ibKX9ZBgPgsKYpI+pmmzlc5YARWovHygdeIr0SUlZAZ7qttpzgzoUEyPKkez7DKIpKy+ 8V+QGDmmhY/0IsWHCrVhJ+o92b2On3swrL8uQcMluScZBVOUok82XccJx1Cw4F+Vr4SM xbxBVqpUf/1kwViUgzsSJug3l85+phwMTfUKVWfoZMcSRXruRkSZM6rqWk0A/t/GvV8U vrvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BBYFP0uq; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81966-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 9-20020ad45b89000000b0068f8941fc09si5240721qvp.523.2024.02.26.09.00.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BBYFP0uq; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81966-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81966-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0AC951C2BAE8 for ; Mon, 26 Feb 2024 17:00:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3FE013473C; Mon, 26 Feb 2024 16:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="BBYFP0uq" 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 A5957132471; Mon, 26 Feb 2024 16:53:51 +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=1708966433; cv=none; b=qk3R3mZzkTDsU0hLryxN26VqXUUBzl3uJJUnXP2gFkLxUUcjFD2moR5XcGEPHawTcvWQsepIdO24YQkVPrshqmZbVcnHvxccred+hPKPFLSdd2G0l89xJ/9gkApyBi62aL5OcHLVIHYAVqARVNo+UkMSiuYCgGBYh9e7rHbsZD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966433; c=relaxed/simple; bh=rehO7cLR4fQpk+ZuJ/GB/Ev81SeAWJhsriBJhdeCXCk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T85OgJ4yIXKU08TWnR4jWgAaDJabzrO002B+R4uVsd3mTQmLlvDMN4TpC0WP48gpw6Uj+lkppv+FqFZl5LwnZ+stmleW6g4ftnC2vmrz/wIo9Tmj3ZhiRxs7fQ+gqwypDypk2O8lIAxsRQ7BGoz6a02eBhsVr7O4hX9IQ1vVV14= 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=BBYFP0uq; 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 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 41QGgVR9002939; Mon, 26 Feb 2024 16:53:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=zvpqrz1IR95x4v/nVIcA1R/mLkFs7xansTMd+3MOVyo=; b=BBYFP0uqNUf5uQepQkGiI+FNz5PpzJHDoDMDJSj2E14GjuG07Rhx2XincBcxVLqlKR6Z 9rJOe2mLc9FZp+ym1Btm9wGnMMkZ7mTdVjs/0cX+pBHOhJ2oQ5GWNWpYuO3Tmz9luFe4 uXg8ZpCaTIdNMltMydhvZofn90lvJvEYcwfIEs30qJpOFQGSZ4fzc4Fq6FFvRLSTwfWT qI9J3tahP/2Z+NNYPDviGT+SujbEi9mM5xJN1IzHEX5XQupRFADpu7SwbIkN7Ti/j4hX Yarf3tV4HvEblNf+4TrrNEAAaX0WWgzKWOmMvSRoPQXHh4UsNwOClfoFPMZJ1kTiUsyX 1w== 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 3wgxd4g9xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:40 +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 41QFLKEe008164; Mon, 26 Feb 2024 16:53:38 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9m2a0r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:38 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrZO249676706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:38 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9AC558059; Mon, 26 Feb 2024 16:53:35 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0DC858053; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:34 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 16/31] fsi: aspeed: Refactor trace functions Date: Mon, 26 Feb 2024 10:53:06 -0600 Message-Id: <20240226165321.91976-17-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JXCh92xZ_8bmT7NItvxgaCBoSUewsLWc X-Proofpoint-ORIG-GUID: JXCh92xZ_8bmT7NItvxgaCBoSUewsLWc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=943 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981580237890298 X-GMAIL-MSGID: 1791981580237890298 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 c36e7e49e965..1a91f3acdfcc 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -116,16 +116,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; } @@ -169,13 +170,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) @@ -198,6 +197,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; } @@ -220,19 +220,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 0fff873775f1..7eeecbfec7f0 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 Mon Feb 26 16:53: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: 206791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2204253dyb; Mon, 26 Feb 2024 08:59:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXXHzn6G8klIQkIJANq3hEW3VsY/ZYUoV5eZlZyyXJTXtTt782M4Iy3hYeWfg9iMXrU5TX5x7iMSgr7818xIAnn1CPL9A== X-Google-Smtp-Source: AGHT+IHeKnmRJszRG2I956ps6P4un019QYzhcPmYz72rs2Ng6ySZgKvTO8jbL1zoNltpk1t/NhTI X-Received: by 2002:a05:622a:1882:b0:42e:8d0d:cc14 with SMTP id v2-20020a05622a188200b0042e8d0dcc14mr1950454qtc.29.1708966797347; Mon, 26 Feb 2024 08:59:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966797; cv=pass; d=google.com; s=arc-20160816; b=x69RNtC6Iwk0wLeSc0b+sOS4vIC/oy8KWSxhkuSm+L5OnTTvbPJOsc9tzdHeEwtZEP ZAreOU2KJlwsX9sVknaSQ1ZHp8rF33fS4jopHUx6yMwCrAUIc6s72dIjhOIQP/eJRXPQ cC18kyzNXKNf19kS3IJdC0n6Bill54Jm9oOqh3QO4qc5+kgR88Ksnd8XxcGX2GG1vTLG FTcvr7OsekhzwqDxb3pWXda3AcB8s+hLbh35MqRtbmDD25B3iegbfgEMrBmYXWKxCURb +XCrurPHsMPZmgW7CjQE0CRQN3w3ur0nQb7m6EhMf1u97YkU4u2zw3GVgynUbY/P3Z22 n6QQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bofokn5J04e0ZdqBwK6c6SN9GTgFjHTcEiDFXEpuQNw=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=cVNHEC8ViGAeY8GwKRAZne/z4m6HYDPrVPkhxcyFKptR47pcR79IAQ9n21JZluBR+z 37Dxcwel2eIrA7c9VY5rIHUrEmSuc/b9t+jCnUR8ixj8jMP+SXtHEiqHe+C8pWZgiskz ZgRMURJHm+agKLVMNfkaxr7H0fJC86vsY8FK+XX5HXC2EUD6gyxf+067r5xXhdfa1/vj wdaim8VDJSrLkFCLX9qcpTvfEe3dBV7X8V9R4iyzrE39hu3neKY9Tk/ELmPxkFdbcuSh smkbLmG1WJ1ZCT+q+2HTsPXLXPl577j/TelT76OzbgkzuFQpmn+BUvEbPU3lMqrC/3Yw z3yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZE2R0uCj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81967-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c6-20020ac86606000000b0042de3de4c45si5300603qtp.502.2024.02.26.08.59.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:59:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZE2R0uCj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81967-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81967-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1A0FD1C2B26E for ; Mon, 26 Feb 2024 16:59:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C361134727; Mon, 26 Feb 2024 16:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ZE2R0uCj" 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 D817D13247F; Mon, 26 Feb 2024 16:53:51 +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=1708966433; cv=none; b=glL41t9WLrdlT1HpwuVxSZjujRq6GK6BGiJ5zAsOPzqc/GZIcQJYhEyS1/ngPUC8mi0MUy+Lw4oU7PWgiSx/62ICkaJQjXdb/hPi0M8QahRaPhVyFPeDcEjO5ZLPUGiN5mLHpn5/LkbTkgdq6Lb6JlwS/oforQ5brSJfMJUv/Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966433; c=relaxed/simple; bh=N4MM9bu5cZzne7RyOcOdfSZDBM36xNIIHvybGlB7Shs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P1Lyb4IQeLOysZmrnw+h1eHlcU8f9zHN5oiyAgwlnaulNrZBp1e1sTBg3lgxHH+yMQR8blxlKy42woENQcugqQB7HKT1z3yuXFSk5RAR0th5kC6MatrhZL4ag0uPMN3LNhv04u3ciJDoiMEttcfWzf4dV1aBZbt0Hh1Kcbhkl+U= 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=ZE2R0uCj; 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 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 41QG12QL018641; Mon, 26 Feb 2024 16:53:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=bofokn5J04e0ZdqBwK6c6SN9GTgFjHTcEiDFXEpuQNw=; b=ZE2R0uCjBWYbSJgXuxm4J0cQgi8W6Gw/sJiQKTkq/wKhykDBoaR22TGuFA176AwhmLPQ h/XtrxauD7qOTMWEUHXKK1wKbVDGQUM/QV/oQvvTe951PVHkIMK04McU0/xU2h1xowzi a1rfEebzxh5Va65hreWyMUTo5IvarutdSiCTyqkrnzOW4rwGhlBWJvt74Kqc/buMA5CE cZsGIIOtwKevXlg86va83XRc+v9Nxz/DgSTWFhID1kIhdbZlk5X8LSwPUHxTfMoAXW+u qo9eU10jO2jGb74loQ4E5LbFoVPG3QNjRI/c4GvLSCZUT5YqQIV8enEqt+47mw5NZsAG SQ== 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 3wgw0k3572-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:40 +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 41QFTLMl024122; Mon, 26 Feb 2024 16:53:39 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23fs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:39 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrab410486322 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:38 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 796A358043; Mon, 26 Feb 2024 16:53:36 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0A6A58053; Mon, 26 Feb 2024 16:53:35 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:35 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 17/31] fsi: aspeed: Don't clear all IRQs during OPB transfers Date: Mon, 26 Feb 2024 10:53:07 -0600 Message-Id: <20240226165321.91976-18-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fSFqiIdq4BF-TxVEQGCiL5QSwmKDinTZ X-Proofpoint-ORIG-GUID: fSFqiIdq4BF-TxVEQGCiL5QSwmKDinTZ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981568489019150 X-GMAIL-MSGID: 1791981568489019150 In order to support FSI interrupts, the OPB transfer functions should not clear all the IRQs pending. Instead, just write the OPB ACK bit to the IRQ status register. As commented, this register invisibly masks the interrupt once the interrupt condition is cleared. Fix this by writing 0 before each OPB transfer. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 1a91f3acdfcc..64a5407a15ec 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -46,6 +46,11 @@ static const u32 fsi_base = 0xa0000000; #define OPB_CLK_SYNC 0x3c #define OPB_IRQ_CLEAR 0x40 #define OPB_IRQ_MASK 0x44 +/* + * This register does NOT behave in the expected manner. It is expected that writing 1b would clear + * the corresponding interrupt condition. However it also invisibly masks the interrupt! Writing 0b + * unmasks again. + */ #define OPB_IRQ_STATUS 0x48 #define OPB0_SELECT 0x10 @@ -64,8 +69,8 @@ static const u32 fsi_base = 0xa0000000; #define OPB1_READ_ORDER2 0x60 #define OPB_RETRY_COUNTER 0x64 -#define OPB_RETRY_COUNTER_AST2600 0x00000010 -#define OPB_RETRY_COUNTER_AST2700 0x000c0010 +#define OPB_RETRY_COUNTER_AST2600 0x00010010 +#define OPB_RETRY_COUNTER_AST2700 0x000d0010 /* OPBn_STATUS */ #define STATUS_HALFWORD_ACK BIT(0) @@ -107,13 +112,14 @@ static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr, writel_relaxed(transfer_size, base + OPB0_XFER_SIZE); writel_relaxed(addr, base + OPB0_FSI_ADDR); writel_relaxed(val, base + OPB0_FSI_DATA_W); - writel_relaxed(0x1, base + OPB_IRQ_CLEAR); + writel_relaxed(0, base + OPB_IRQ_STATUS); writel(0x1, base + OPB_TRIGGER); ret = readl_poll_timeout(base + OPB_IRQ_STATUS, reg, (reg & OPB0_XFER_ACK_EN) != 0, 0, OPB_POLL_TIMEOUT); + writel(OPB0_XFER_ACK_EN, base + OPB_IRQ_STATUS); status = readl(base + OPB0_STATUS); /* Return error when poll timed out */ @@ -159,13 +165,14 @@ static int __opb_read(struct fsi_master_aspeed *aspeed, uint32_t addr, writel_relaxed(CMD_READ, base + OPB0_RW); writel_relaxed(transfer_size, base + OPB0_XFER_SIZE); writel_relaxed(addr, base + OPB0_FSI_ADDR); - writel_relaxed(0x1, base + OPB_IRQ_CLEAR); + writel_relaxed(0, aspeed->base + OPB_IRQ_STATUS); writel(0x1, base + OPB_TRIGGER); ret = readl_poll_timeout(base + OPB_IRQ_STATUS, reg, (reg & OPB0_XFER_ACK_EN) != 0, 0, OPB_POLL_TIMEOUT); + writel(OPB0_XFER_ACK_EN, base + OPB_IRQ_STATUS); status = readl(base + OPB0_STATUS); result = readl(base + OPB0_FSI_DATA_R); @@ -489,8 +496,6 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) } writel(0x1, aspeed->base + OPB_CLK_SYNC); - writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN, - aspeed->base + OPB_IRQ_MASK); writel(opb_retry_counter, aspeed->base + OPB_RETRY_COUNTER); From patchwork Mon Feb 26 16:53:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2204166dyb; Mon, 26 Feb 2024 08:59:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU7ZavbX2CearQqnbHpst5ednZP05teYJy5oK9UUjKEOYCZUiCdag/KJydDi8XHgQGHC8IKqM1Z6divGcgIIxYggeqa4A== X-Google-Smtp-Source: AGHT+IFzxIbN8B6+h296d2y9K+vhUPFxIDr1ALINVuIsPfnZbENODDZuqJ04fcBjnf9YQ9UDyqAO X-Received: by 2002:a05:6a20:9e4b:b0:1a1:863:e787 with SMTP id mt11-20020a056a209e4b00b001a10863e787mr1455090pzb.31.1708966790561; Mon, 26 Feb 2024 08:59:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966790; cv=pass; d=google.com; s=arc-20160816; b=GumafOJGn2uhV3HuuNYWat1o/s4hccr7sIsPUY+6xvJLpD73n7D8HqVyS903tbWdeQ mLZZ0N7NFALWGAc1d/qy3GJld7/Xbj195HBi3qn7XAKfiLFmdfZPCnXwM2uytDscWbTr H8C+LWsaUza2R3dGLhuxcWbYLh8PoG5h4Uv7PeG4ykufipRYi+5uNSoXQiL52KoGVG1R 64UfSwRoxrW5h0kTyTjwv3bpfvUaknIZB8O+MVK/4iv3xsimUPO3E8aX6H1nThVb+XSC ngn5NHrHYyem67pOTgMTYUPmzXyRbdKC9NsvnRNUNQJ4d9on3j+lJvz7KH0CRnvAfTu3 2elA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sgsnboEv26LhiTyNfYfFAh+jxPvF4LGnhtlgk/oYHyI=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=lMB0df06eeeBgetSO4RCQ6L1HKmg4OGoGUJOigjPmoqKhNaKY8oQOixPUjpwDB3Te5 BDPBvaCEbL/6gYsBP6/34CEXDsJxskk+5a7E91jKUHVrS+tONFXxEptBUn8yAniBF+Vn //DIi1WDBzZfdiMHX/ubP18SRKN4AOGttYQsvSWCszzijCEy9RIRbEWPmCBDDfGDvreF Bff3pIBsej+k++QNekNUrVTS90d2qKXESBL+x+tgrHiBPwGaS60HPxTnigO9DZiGf2Yo s8wmLvPMGd8Q16oLLFTfjhnlqP1UBH222h9xMrgNP+v5W4ohJUttl2GqRBEPFlJX4g+M jzkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=cYb1qWsZ; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81968-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j24-20020aa783d8000000b006e47dc9d922si3976663pfn.138.2024.02.26.08.59.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 08:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=cYb1qWsZ; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81968-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81968-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 62F6D289B91 for ; Mon, 26 Feb 2024 16:59:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 226821339B3; Mon, 26 Feb 2024 16:53:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="cYb1qWsZ" 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 469DB132499; Mon, 26 Feb 2024 16:53:52 +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=1708966434; cv=none; b=S97PmseE4nLZRbhzIFrR39rxgSsp1vwn9yi1ZNivTIQXZbFkamsRZq6/YkAHRqKFeuEhgAcqotFkP3843QibdB6qFel6xh7rGWSF7L4OaZFFnzz4RYDz7s0T8pEDB2RWwm5NQVLlrz77MKb1HGpimnnAbPLG8luB8t253bJqKw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966434; c=relaxed/simple; bh=J/YFPtGFuZwFnq9P5eEqxyt+AdQR6C4+3VLiCYKWnjA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sb8O4MKB8Hs2Uq39t0pJwmfnulVRlUSJxtzJmUr6H4JPYejwAXbYCv063R1aEBAk7Fwk8O/YecMZKwGNJztbA5RfAkooNVfGmDmcLXBo9MigWTC/xtOWjB7FjA4Zj57TIX5+YrecpbZMaPjYcqx/QyT6MB18KK38p43wyKn3RUg= 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=cYb1qWsZ; 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 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 41QG5gqA025499; Mon, 26 Feb 2024 16:53:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=sgsnboEv26LhiTyNfYfFAh+jxPvF4LGnhtlgk/oYHyI=; b=cYb1qWsZ07bBxo0kiS5a5pHsMIL744bRhq3uT6bkr6DFpl/5FaZ4qEPpbkDVa0xzBoMz F3LSH4Xf+5ixxbD0fiUg3zf38AyaYcH1U6BIyVQC2M1iGimSQ+G4PAmXjjYusCKA71u6 p+XY3iVkUGGLJZFs/N9wEkQ/L37XnkdrGJhQxbFpMzRwtCZ1YLpz1SJ2yM+2WN5/hqSX mISAFg1m5Hcv247Y4eGb5WI8n2UmU0DnV3SF4ExOy6yZlj9YNueodoh2beDAYPT3Q3Lo 85ru5L5n1g4Jl4LERyxepaFFEIwEFRyWOhpi5KkOid/Ru9ldTiAurj1+3wPS2T1C0rKp gA== 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 3wgvsq33n7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:41 +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 41QFGmdb008142; Mon, 26 Feb 2024 16:53:40 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9m2a0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:40 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrbnX7799336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:39 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48B7F58065; Mon, 26 Feb 2024 16:53:37 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F64958053; Mon, 26 Feb 2024 16:53:36 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:36 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 18/31] fsi: aspeed: Only read result register for successful read Date: Mon, 26 Feb 2024 10:53:08 -0600 Message-Id: <20240226165321.91976-19-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kmunfQXPC4eEI1gQTSNhWBZ1_cIwpHdP X-Proofpoint-ORIG-GUID: kmunfQXPC4eEI1gQTSNhWBZ1_cIwpHdP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981561329884477 X-GMAIL-MSGID: 1791981561329884477 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 64a5407a15ec..83f84ee6d6f4 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -175,8 +175,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); @@ -187,21 +185,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 Mon Feb 26 16:53:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2205153dyb; Mon, 26 Feb 2024 09:00:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXf05vBWmYvOpjEi3QuaSM/GESK+nslE+Y8sYy1mw9RVfNthPtmxI9gu6JTyIFYsUuCpDP+6RUAfMDvYiKOSS2NIa6Ouw== X-Google-Smtp-Source: AGHT+IGRvOuLbtbimkB+nyKvb8J8RLtGNpSPQHE9VnS4nTEVCuhDQ2S0aDSUCMRv4boPQP7KZhNn X-Received: by 2002:a50:e71a:0:b0:564:dd69:341e with SMTP id a26-20020a50e71a000000b00564dd69341emr4928872edn.22.1708966859689; Mon, 26 Feb 2024 09:00:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966859; cv=pass; d=google.com; s=arc-20160816; b=kTJFmLCnzuey2xp0Fb5+9lmz43Uw+USlaMTunSDmCaK/DotkraTf07KaMI0F5xwXE3 xZU6Js9LOMtycRhM6HbelFPXprmwvPUuoVVqDHfNJ9x2R4rPs1DMTZzcSiAI4FsVxOBV IuDJ/G2NzJ44l6YxYkwPOP79TlrQAUvfhlnQJgWe4Rb8WFtod+idcECYqb4QTcnzQNn2 5sJypnmH5m2n2CWvKe2ErijG6l0AgewQTKu4iDCub/34csaqQ3hrA5Z3GNdfMSrxVZmj q6AfK9E7B5F/Ek7ms08jEQUC2mT4mvCM96qqioTvlHHf+o5Nb3A3zXqL1Ez96OgETvDL EC1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ETtwT8LcMCJW+mcR7ZD5Qq2B6I2ZwqYbef+CZ36s+uQ=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=Y3XSd8Hd/QRRs+8pWol4ry7kpwOiE2DmfPEf4QYPJiUfrO6tTiuxKDm/qBSHToJlQ0 AIum3UZ7YXxNh7Pgo24ockjpIxDcfq4NELtWcjysXi3uU3MRF49COELLyLGROcY4Fy7M TpDiLSTKF+i+aid3+xSA2ZKp8/Q79gkuct0m7KyhEsgWYPtHW7Y3UkLVnDnQLtyxbSsA 2Zu0uF5ggSyki/WiJbqd1/EGXh+DkKnKY490keY/EqfXhDwmaVgoDHE5AGfUDPLNVytW qp0uPm5gOTux/oNq9FegsSqsFYwQ7MFB+cKuLFSaDdosSdKQYF/y1/fFbAbIxxUH6wEe IAUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NVAAt5yw; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81969-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m4-20020a056402430400b00565a8de3833si2163366edc.204.2024.02.26.09.00.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NVAAt5yw; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81969-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81969-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 231F91F29B8D for ; Mon, 26 Feb 2024 17:00:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40BEE1353F6; Mon, 26 Feb 2024 16:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="NVAAt5yw" 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 C125E1332BA; Mon, 26 Feb 2024 16:53:54 +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=1708966436; cv=none; b=Z3D14rYkFJ5E/IbN2z2YEKwctZuteLCHC7w6N8zB6O9l7tzRwUTozqkf/rP2OpD+h35axX3iHkrz3J/P4MlVz/1u7gcwDQh6i1hY8YdjxqTyuBGYONkPUj/J8kqdMIkZEiaAQ4i+sLHRpGOGwbHzMvc9H1xWDO5nAEG9CHHgTMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966436; c=relaxed/simple; bh=vMXLZdWtNXhO12KyFpb6gqzuEGpjA+RzS5g5kNb3j6c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f/ZING6gbEB5MyxMLpe2a8adZW0ex3Zp55U48K+6dmvTbSuX66kNEAnH1EtgbSYfF8uX2jxzF3m/ks6y7vpnJJdy5AXO63DAoR/4PDCiQl4wirYM94xt3v0LI27uBClERQAvt+l2Lga2nMJBIG0XsdeNR15vXKZqWoU4U2LeShc= 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=NVAAt5yw; 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 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41QGSLjd015212; Mon, 26 Feb 2024 16:53:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ETtwT8LcMCJW+mcR7ZD5Qq2B6I2ZwqYbef+CZ36s+uQ=; b=NVAAt5ywdwvAyOYNqMPY6aGN/noDrEnpdCZFCpAXaYL84bc9Y2lv3v1lNEe+wXEzbpEn 8B2dKkyCVOuAhptk92F9ADNkNPjykU4TrEam41IomdG5HMLG5DfOOD/sQ68iQ92MLzq1 uvLf5faWJ06P5/XrdtXqA4mXMr5n4ni8xqLcM4TmlE+5kvPq2FOXYaNO16SwBjkJ3hjq 06rssfKkcp0oo1AieCCt/OomzxJU3nY4h4BqJdUzHtrE/RvUMKWHycuS6b3tOezXsBJ/ 60FNZ/PlpED8i0PEqh4KbdExhnqQfsr1/O2Hh7fttPznnDntbCBwuJB+fXm4xRHD9ziw Mw== 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 3wgx6g8npm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:42 +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 41QGBYAg012324; Mon, 26 Feb 2024 16:53:40 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xwv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:40 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrcLc18350716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:40 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 178485805F; Mon, 26 Feb 2024 16:53:38 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E74658053; Mon, 26 Feb 2024 16:53:37 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:37 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 19/31] fsi: aspeed: Switch to spinlock Date: Mon, 26 Feb 2024 10:53:09 -0600 Message-Id: <20240226165321.91976-20-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Pv_sDwOsAvV0ykjEgHo9l94QyNTknLd6 X-Proofpoint-ORIG-GUID: Pv_sDwOsAvV0ykjEgHo9l94QyNTknLd6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981633868021874 X-GMAIL-MSGID: 1791981633868021874 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 83f84ee6d6f4..1cb5bf6c05d2 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; struct clk *clk; @@ -245,6 +245,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) @@ -253,7 +254,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: @@ -272,7 +273,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; } @@ -280,6 +281,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) @@ -288,7 +290,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: @@ -307,7 +309,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; } @@ -369,15 +371,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); opb_writel(aspeed, ctrl_base + FSI_MRESP0, cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); - mutex_unlock(&aspeed->lock); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); return count; @@ -468,6 +471,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)) { @@ -543,7 +547,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 Mon Feb 26 16:53: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: 206795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2205367dyb; Mon, 26 Feb 2024 09:01:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWf1ZOZGFSVmUmnccvofyleivXjnAIgOm4inL3141SUHRJU7e3dJXNCf7AIvI6ANG0AHQYyzLu8sGXUgN3f8SJ5friFnA== X-Google-Smtp-Source: AGHT+IHdlnX54BrW7PwYkRrxJ1MV3wogcAOmF09dSt8Fs2rhay8tDgFY9AI3tUQAWC+oj3YsrO0b X-Received: by 2002:a17:906:36cd:b0:a3e:f79e:ce56 with SMTP id b13-20020a17090636cd00b00a3ef79ece56mr4712606ejc.45.1708966876493; Mon, 26 Feb 2024 09:01:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966876; cv=pass; d=google.com; s=arc-20160816; b=Q2yNR+nVSaVS3/AgdGIzW07KAHeVc99yYkkTDVq9sXaFRsaNcQHx1cuRRehiM2b3JU u5KTNHha/AmRMm2aNP9pXUnduOsv3YIA9/gKYGtYlrbbxc5cGmPpCaw2sHHN6u/nt3Xn eebqG1IUM6iUHXQqr+spG166YwuE7y2U1R97cvkVB6ftOIzWLRs7P5uBM7Sz5ROU4FD1 klwMGvBEOJ6P2tl4mPVu9Sp22Z6/xV1wWtFv0cBv6u+jRZ74Wq/ICqmLeJe793UNYuZf kbpIYThmOSAa8RrnLRyslf8qyogWq9V7mxDZvs9vSR2wD51LR3Ih80Irj1M6E1ewy67K uBbQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5LerAFfyndDwaim6ezZwBkxBwQM30xrAj4RWbdAGWGI=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=Tt+hpDelUSbI3Y7+m+BWkLQOA6wzFL/jy0S7zCITWmhkVKsDEYd/+C01JgzYkeTcdN Lvp/JXnHYsKSGM5eCUR1B/TNHssNOKr1zokC/39q8WJl3DCuR1boeodYaB+zMuCFfITp SUOll8tSmYBPfyHd1vORGlx/FxrbDaT/3DzZQugxMWwjc+VwcgiGeen1stY61iDiFGyM gk0z8GQHAZmCtHWpd51H8mhEne5afBtziu+5TRkEVnyKZch928KVsu3H6uACNN4ks5W3 L+GaBgjEqLqrJgCiK0XCwPDLvLPy3+c3JCmQkQhVesFQtxfjWe+sLyUbZS6vHDLZYY1M CMCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lCnn4JOb; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81971-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b23-20020a170906039700b00a3f18f596fesi2274251eja.616.2024.02.26.09.01.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:01:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81971-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lCnn4JOb; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81971-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 177D61F2A829 for ; Mon, 26 Feb 2024 17:01:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F25F3135A45; Mon, 26 Feb 2024 16:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lCnn4JOb" 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 9C7CA13342E; Mon, 26 Feb 2024 16:53:55 +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=1708966437; cv=none; b=rTNZjtNg7jT1h80j/TBXb8biwTZWe+Yyl5vHaw7KHYoxoHZjnrevuojuIKMZa5NkEP0udapEv2qV3kzbPRxzpTFfHWlCOU3jUNtuMaoLxXGNhKc8QTu2EvZ+pdmNZsjbRXF0EQx7Yiq5xGX4pWachvQBHl1NZEm9YF3aT3kbBlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966437; c=relaxed/simple; bh=kx+oOcwZGizk7pnn1u+NW+Z8JFTuM9vEKXNINaOBa4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BwRzmy0sg1UA3q+x3xhNkwnKtXwQ5RppcRk4qa53pQUFxzXPpfFYNdBlVRoHW5hhogTesDjPeGBU2hUw6RUg+JiOFq/y78KZWq8oTb1703/Q3nt6uIigBtd9ygKOSTtO5gSle8eYLXr9OqgwWk9ErdoyIFqNuCbqxGzshVWR+PQ= 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=lCnn4JOb; 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 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 41QGEXD9012349; Mon, 26 Feb 2024 16:53:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=5LerAFfyndDwaim6ezZwBkxBwQM30xrAj4RWbdAGWGI=; b=lCnn4JObgXudDKMdFhIUwt6ueBTgNxd0zerZTR5wRK08NSaVOx1nYc95RDK9BpHLoEE1 koz9Vcj+OCfi4ikdlVvo4ORNFWwII049iyQDEax3H1AjHZVWzER33QMUujXqCfzEm3FA SIDl3zuIos65WGEQh3ayVPo9BcvdD1bIp53P7HbUtYghgqyTZWrIobDFpb1QeV6eLU+U FrunEn89rynW951Mzcb3m9u9LRpd7W1vwAUqgoH+8xX1LU/hfim9saEyfnojzWggrxKX 1vIWLmXuO4agmt995mMvROlMcidpv1TuGEc48JJ0CfeWCu6ZAvcCwyYKMGhHbykdY/oC 5w== 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 3wgvp6bkc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:43 +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 41QGFrrA021762; Mon, 26 Feb 2024 16:53:41 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytkrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:41 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrd5Z17105472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:41 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E53A75806A; Mon, 26 Feb 2024 16:53:38 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DEED58053; Mon, 26 Feb 2024 16:53:38 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:38 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 20/31] fsi: aspeed: Disable relative addressing and IPOLL for cfam reset Date: Mon, 26 Feb 2024 10:53:10 -0600 Message-Id: <20240226165321.91976-21-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: fvJmaLB3_uTR0ayp6d5k-picsIkscZzx X-Proofpoint-GUID: fvJmaLB3_uTR0ayp6d5k-picsIkscZzx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=812 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981651311510717 X-GMAIL-MSGID: 1791981651311510717 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 1cb5bf6c05d2..92b47bc9917a 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -375,11 +375,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); + + opb_writel(aspeed, ctrl_base + FSI_MMODE, + cpu_to_be32(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); + opb_writel(aspeed, ctrl_base + FSI_MRESP0, cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); + opb_writel(aspeed, ctrl_base + FSI_MMODE, cpu_to_be32(aspeed->master.mmode)); + spin_unlock_irqrestore(&aspeed->lock, flags); trace_fsi_master_aspeed_cfam_reset(false); From patchwork Mon Feb 26 16:53:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2221143dyb; Mon, 26 Feb 2024 09:24:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVj7upaRNaqvgNl53tuQX2sCYExYsczm3Du0fwyqyjCCjvk1H+tnoiNKGy/TBLMNn9jnVtJU3Z/p0ypsV4bC2aXTkhxBA== X-Google-Smtp-Source: AGHT+IHTyw2ay3iLZe4mS078fRGmhEV0a5LUkOPeK4cUpIDaIxX8alhTDHPNsmbOoB7JqSoczw0M X-Received: by 2002:a17:902:a3cc:b0:1dc:a5fb:3544 with SMTP id q12-20020a170902a3cc00b001dca5fb3544mr2292696plb.1.1708968292214; Mon, 26 Feb 2024 09:24:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968292; cv=pass; d=google.com; s=arc-20160816; b=0Up/5GqfaDNNbYsCtlkvz9dPEvj7PWUnCU7dVIOPc1JDrPDDHckvp9a5cHBrWejRhJ 2JSwS8zE8kDcSGu9n8OqZrcOWhUfjq+Cx598/IQNSL8EEa1ENwU1409Q4s+M1K4KD8Rc 4AwLHzjvgTfTJcoV8PIR9CVbNsPIxMr4rjESE09eDDef/R+ilpWgLT7bwwsIMmkRmB6q koNEyuLXktgIPBLXkEazI/vWLPR9YMQdlaN+3tegSLdEEFEjZdk0SRZtV/vxNjznGJm+ fHX1uYcDly6zAbAnWc2+Q2ndTwpbdMEZTt6ho0F6rnnG+67zUriLWTjoIdOnf2D0AWCq E2CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YFVgmE6fC8McLNPQMyrQ9AZdJJ8T1N9YLZ9PrKcr1ZY=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=BFTBE5iRjimo6ooxOQK1E5VTv34IS0FxtyAEAd5q3Hbw0iVDc0Wz85A/aEUI7g/+M4 04Nu57JSzxz+B5GNCEljX79XSdsueUiYmUMVqMqR0dUff5JEnWLgpfGnwJbHA08Zu+If UfP0Vhv8fNvrGa5sdveS2+ktreqnBseDbx1VDxoc/qFVxkBG290e3Lc/Nv3uPotkLmoJ AwmAgPfzRvCPsEM0k8ph9Xdweyh/9fkcVmWje1q/8FlVoyowEjgZTqgXXYlG1aH/Owxs wcP7HsAHTLEWailimOmQV7/1cnl+LZTK2LHeJk6P418sKwvp3CHJPEFQloNLZnxddTH9 H5Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=oJ4T4a3v; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81970-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81970-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id p6-20020a170902e74600b001dbfaa6d4absi4103812plf.596.2024.02.26.09.24.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:24:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81970-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=oJ4T4a3v; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81970-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81970-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6CA35B2EED6 for ; Mon, 26 Feb 2024 17:01:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFFC613541D; Mon, 26 Feb 2024 16:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oJ4T4a3v" 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 AB9F5133431; Mon, 26 Feb 2024 16:53:55 +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=1708966437; cv=none; b=FF/ZmkczEWZSZ45lpPLQR0uzIHPtATo+8YusrExrQdiUYpWe+jp80d95sagN0QWV+WnoO7rTsAfubUh5SYgNHifxZ4eKXAH/1SnyHMNO0+56cRfHWqg93JsgwGVQuZx2SDwg9ZWZjTK0CRMxgPBicCOyXl8NFwYoYQRYLwUTER8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966437; c=relaxed/simple; bh=Nitj0lZrrDkxeMQ8i5VV2Bwzuo49UpxkAe+abtxsgAI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CAAmYMivh7FG/chMJY3qV2ZLTQDfqbK89gFEgp+QKxWcVp3jenmF0IXJYgZbfs8zMbD5Tni13xi79790ZidZH/+VpRQxlwvdqflnB1HvJmrpZ1XuLmsGW8RoKM2KktTRKjfvaSVUonC0PCnVxUfGWLQI+Iv6Jxe1sBz+eFFg5Cs= 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=oJ4T4a3v; 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 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 41QGph80021815; Mon, 26 Feb 2024 16:53:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=YFVgmE6fC8McLNPQMyrQ9AZdJJ8T1N9YLZ9PrKcr1ZY=; b=oJ4T4a3v9xMoqBnSCMhKB6aak7W+Ona2rO3E+W6BTGgPa5dUMU0iaVtex3I/H8zJP5mo 9PN/+iKwY0gg0iAlWO8KalmLqZ4+ocvN1TeJLYmKx1BmB6gUnEwRuo1xu1wzn6vYCTqy wzwB898jrACA1Oh7tfUg8jI98K6ycYalQ3vheW2vkqggKYoNd3z5QCQEQ7nzxpkBvmt2 56Rt7cdq97TXgz8j7dKHAZMPhuOubqXMA4E7xFx+tBJV3YKq9EuWMKPyuUztc/oe3Vsw R7JTqbu4ic6OFAw3Ijp2U23qpbMk4ZeemQs9zvd29nyyso3FtuU0ERzTeSSZjtSZ74uP ZQ== 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 3wgvp6bkdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:43 +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 41QGFrrB021762; Mon, 26 Feb 2024 16:53:42 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytkrt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:42 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrdIZ7209920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:42 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3E4358061; Mon, 26 Feb 2024 16:53:39 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07B0458053; Mon, 26 Feb 2024 16:53:39 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:38 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 21/31] fsi: aspeed: Use common master error handler Date: Mon, 26 Feb 2024 10:53:11 -0600 Message-Id: <20240226165321.91976-22-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: NALELMYsCZ3eQc4Sgz_1MA4rnSSIpAy7 X-Proofpoint-GUID: NALELMYsCZ3eQc4Sgz_1MA4rnSSIpAy7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983135880511092 X-GMAIL-MSGID: 1791983135880511092 This will do the correct mmode manipulation to do the master reset. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 92b47bc9917a..ac8835e4d1f8 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -220,27 +220,6 @@ static int opb_readb(struct fsi_master_aspeed *aspeed, uint32_t addr, u8 *out) return __opb_read(aspeed, addr, XFER_BYTE, (void *)out); } -static int check_errors(struct fsi_master_aspeed *aspeed, int err) -{ - int ret; - - if (err == -EIO) { - /* Check MAEB (0x70) ? */ - - /* Then clear errors in master */ - ret = opb_writel(aspeed, ctrl_base + FSI_MRESP0, - cpu_to_be32(FSI_MRESP_RST_ALL_MASTER)); - if (ret) { - /* TODO: log? return different code? */ - return ret; - } - /* TODO: confirm that 0x70 was okay */ - } - - /* This will pass through timeout errors */ - return err; -} - static int aspeed_master_read(struct fsi_master *master, int link, uint8_t id, uint32_t addr, void *val, size_t size) { @@ -271,7 +250,8 @@ static int aspeed_master_read(struct fsi_master *master, int link, goto done; } - ret = check_errors(aspeed, ret); + if (ret == -EIO) + fsi_master_error(&aspeed->master, link); done: spin_unlock_irqrestore(&aspeed->lock, flags); return ret; @@ -307,7 +287,8 @@ static int aspeed_master_write(struct fsi_master *master, int link, goto done; } - ret = check_errors(aspeed, ret); + if (ret == -EIO) + fsi_master_error(&aspeed->master, link); done: spin_unlock_irqrestore(&aspeed->lock, flags); return ret; From patchwork Mon Feb 26 16:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2207212dyb; Mon, 26 Feb 2024 09:03:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWu9PkR8nNTUfqSBzAEWpWZHd+jBYQItDLiXWvgtsy8f8iW9e2eAVk0vlvQmag+pwgLuV6WvEtoHkiNSJsSVj/AyAri9g== X-Google-Smtp-Source: AGHT+IGRgOXIz3jz1efLKTEUApbjvhrTjwyPm8ikQDmtbRtVInOMLtCaIDuR73JumydGht6tcVvQ X-Received: by 2002:a17:907:6087:b0:a3f:d2a8:a5c4 with SMTP id ht7-20020a170907608700b00a3fd2a8a5c4mr5989661ejc.35.1708966997920; Mon, 26 Feb 2024 09:03:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966997; cv=pass; d=google.com; s=arc-20160816; b=eFQ0nMK6xiEwGMhPhrSPDAlDTUqipkUiTf0n9zTE2plCImyUuMjeQrQ6AVAfVYA2W5 OuE+2xrv6kHp1eiwZNx9ID1tATXMsa/BOPFkJJSAMSjj31ptx8ugu1hFpb6VEuJW1ikV oGQzbWIt+VAKnAwelOY+Iq7K4LbeIzuR+GVr0rntR2mM0kh72mMiWUbyc4vq6D/DejM8 d9Kl2S7a6igceaS8O1WOT0BKjfX1QuQqrnSMeRTOqus9sa0cO/c+p/3yavZOcc3THErZ Ms1m6NoUEqYr8W+Et7hOYoDDMinEXmtn1i6gncpqxBSTXSNlrSW6EtoQu3/b7Pjm4FDq 8xCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WxfAGywu2AttZSoe43SdDUfwB1vRf0idG419kD0lB08=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=HOSp74hwjx51qBthUihdjWdtxtnfpsTB/T7FOQ3OZd7Tvr+wUYqN8RmibjSSMThdpi xYgLbvQwitN/PT+k51l1aWXzvT8mRdWBSWi4psdE1IA9iTAbUGMX0SqPVreSkE6SzzSc Ncwp3YR7noWAMYghz4kBZ4xVAV7nqmH4Z2a3LJFYQ1AmcgORbD3Q43I0uvfG+pmAD2tE MKsCmkcFTLXXvwi2vHly9Sa+whvAtIDDD8yBBX6Vtl9ZXOyoWuaf33DXe0PFesKDFJfk UJALouFet85i9cvpakwQWVkUZIT22Nwiim5EPpr04ZZdSjs2F3G5gMojUMxNw6qm1xuQ RAUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=SHEUlOjw; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81974-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81974-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dt17-20020a170907729100b00a3e7ce7d717si2374991ejc.875.2024.02.26.09.03.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:03:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81974-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=SHEUlOjw; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81974-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81974-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 362301F29088 for ; Mon, 26 Feb 2024 17:03:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC317137C4C; Mon, 26 Feb 2024 16:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="SHEUlOjw" 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 E32FF134757; Mon, 26 Feb 2024 16:53:57 +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=1708966439; cv=none; b=nFE0/C4sfoisSVG16nMp9ZEIOPKXRVf81MzAJb4E2nwz9AtKJHebUKdPqb3cpvD6bp4tc2oBKKXNaeDK9+zOl/vPjXNdskT0ZLfhS8mkvwgKRmiPjIXHV/ue4Yby06JvFq18eW7V5bh6gBs8aWZ4/tiXgKM94nGOlNjNeNO8Rl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966439; c=relaxed/simple; bh=Oy/PecaJQqqYYGdXapk1iSlOMlrVMCJsXMFhQNMPBBk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E3OuIz4HWmm73i7MNZmAZR44fu/NfmISOupY7xgiMquHPO6lwgapiBoLNrSs0Z5hJnd0GjqvlD2uwqYD6Zr44ycbOA2ZCnO0/0FJrKoyenFILaf/ze0ljxhsZrg6HWywCYmfyOuQg1f93Vf1AFdQXef5ezrPqzNqt+DQPV/2NTc= 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=SHEUlOjw; 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 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 41QF2mUJ022255; Mon, 26 Feb 2024 16:53:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WxfAGywu2AttZSoe43SdDUfwB1vRf0idG419kD0lB08=; b=SHEUlOjwtx+Fgw3c4vNCdRsMFHGvAHwYBPQrh5Y+f6saP6NsR4vsR5FvumPZL5hXNRWW XnrAuw5oQAfzxG2Xna2VikRECNDSdWjTyrIsojSM1EH3cK36bLzfKAqrYiWmThtGjt6E uaE/OeHb6r55QU5azB/q7HOg5yqxLSsZvEsLnkxRr5/lK8uBJK7K/oHXl3KGLZQ4Mndd bYeFI9/iznIKGchqVQ+c9TgtliSvAt0zHQUTlKp+zRULbZTAyA57/qreqvz0NtpIFqvK 1N+Jn7Dk/0ZD34S9inarFq9ScA+MLIkYnPCD2WtPC9DOG1zTizhO9MTXSsKl2nS5K7eP Bg== 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 3wgvp6bkea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:44 +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 41QGPaeD021759; Mon, 26 Feb 2024 16:53:43 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytkrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:43 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGreSJ34931044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:42 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 80DD058067; Mon, 26 Feb 2024 16:53:40 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9F1B58053; Mon, 26 Feb 2024 16:53:39 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:39 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 22/31] fsi: core: Add interrupt support Date: Mon, 26 Feb 2024 10:53:12 -0600 Message-Id: <20240226165321.91976-23-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: aQ1NP8BJ83p9zEnNmR99-y-L_4CC-GCr X-Proofpoint-GUID: aQ1NP8BJ83p9zEnNmR99-y-L_4CC-GCr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981778746177324 X-GMAIL-MSGID: 1791981778746177324 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 --- drivers/fsi/fsi-core.c | 196 +++++++++++++++++++++++++++++++++++++ drivers/fsi/fsi-master.h | 9 ++ include/linux/fsi.h | 2 + include/trace/events/fsi.h | 60 ++++++++++++ 4 files changed, 267 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index ce463ff8ef70..ff5d9d0c9992 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) { @@ -600,6 +663,9 @@ static const struct bin_attribute fsi_slave_raw_attr = { static void fsi_slave_release(struct device *dev) { struct fsi_slave *slave = to_fsi_slave(dev); + __be32 scism = cpu_to_be32(0xffffffff); + + fsi_slave_write(slave, FSI_SLAVE_BASE + FSI_SCISM, &scism, sizeof(scism)); fsi_free_minor(slave->dev.devt); of_node_put(dev->of_node); @@ -957,6 +1023,27 @@ void fsi_free_minor(dev_t dev) } EXPORT_SYMBOL_GPL(fsi_free_minor); +static irqreturn_t fsi_slave_irq(int irq, void *data) +{ + struct fsi_slave *slave = data; + __be32 reg; + u32 siss; + int rc; + + rc = fsi_slave_read(slave, FSI_SLAVE_BASE + FSI_SISS, ®, sizeof(reg)); + if (rc) + return IRQ_NONE; + + siss = be32_to_cpu(reg); + reg = cpu_to_be32(0xffffffff); + rc = fsi_slave_write(slave, FSI_SLAVE_BASE + FSI_SCISC, ®, sizeof(reg)); + if (rc) + return IRQ_NONE; + + trace_fsi_slave_irq(slave, siss); + return IRQ_HANDLED; +} + static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) { uint32_t cfam_id; @@ -1067,6 +1154,19 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) goto err_free_ida; } + rc = fsi_request_irq(slave, fsi_slave_irq, slave, 0, &slave->dev); + if (!rc) { + __be32 ssism = cpu_to_be32(FSI_SISS_ALL); + + /* clear interrupt conditions before unmasking */ + data = cpu_to_be32(0xffffffff); + fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SCISC, &data, + sizeof(data)); + + fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SSISM, &ssism, + sizeof(ssism)); + } + /* Now that we have the cdev registered with the core, any fatal * failures beyond this point will need to clean up through * cdev_device_del(). Fortunately though, nothing past here is fatal. @@ -1441,6 +1541,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) +{ + struct irq_desc *downstream = irq_resolve_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) { + handle_irq_desc(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; @@ -1467,6 +1660,9 @@ int fsi_master_register(struct fsi_master *master) if (!master->lbus_divider) master->lbus_divider = FSI_SMODE_LBCRR_DEFAULT; + 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 f4cecdff3834..b718eeba3f43 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/include/linux/fsi.h b/include/linux/fsi.h index e0309bf0ae07..c249a95b7ff8 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 da977d59e163..0e4d717ee0ad 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), @@ -206,6 +247,25 @@ TRACE_EVENT(fsi_slave_invalid_cfam, ) ); +TRACE_EVENT(fsi_slave_irq, + TP_PROTO(const struct fsi_slave *slave, uint32_t siss), + TP_ARGS(slave, siss), + TP_STRUCT__entry( + __field(int, master_idx) + __field(int, link) + __field(int, id) + __field(uint32_t, siss) + ), + TP_fast_assign( + __entry->master_idx = slave->master->idx; + __entry->link = slave->link; + __entry->id = slave->id; + __entry->siss = siss; + ), + TP_printk("fsi%d:%02d:%02d siss:%08x", __entry->master_idx, __entry->link, __entry->id, + __entry->siss) +); + TRACE_EVENT(fsi_dev_init, TP_PROTO(const struct fsi_device *dev), TP_ARGS(dev), From patchwork Mon Feb 26 16:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2206472dyb; Mon, 26 Feb 2024 09:02:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcqeklo90YgFJjSQL07FE9stj01KC4cuhnhskeGCyFuAc3sgft5k1K/FUnk4nb+sq4nK6YZMXoz++aiQHWMa89fZtHtw== X-Google-Smtp-Source: AGHT+IEu6FRWDBeyJ+5/ZYZuwKI9JrtB48NuCz3Byn5NRP7/Y2f3qPkrel4GCKegEpn9t1kpTH7e X-Received: by 2002:a05:6402:643:b0:563:bd95:4ef8 with SMTP id u3-20020a056402064300b00563bd954ef8mr5146086edx.23.1708966950442; Mon, 26 Feb 2024 09:02:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966950; cv=pass; d=google.com; s=arc-20160816; b=t6tSugdgND9NVy9xx8N2sEB4F6TEo67dzo7A79Uvq73O3c31d7SprvZbRe0xpNWz73 6INE1jUYYVYH8zFAL1o9/iSd2Old+ZHTZC66MZb+wuQ4+HqerdOmXqxe7BQGB8O+xjX/ I40Fu9JvIAx7fp0CX8zhG8LbziAdIW2IWHHNeF/o4IbO/Z4S491gSZDCvnYDfZv3rF3U 4qfXAo0RFOafHIFjBJG0lAo16LjSv2Z08tK9ES86cSROTICevDTX5ozAj+YeicWf9vu9 ez+0biX5vR7PyLLRaNPpGIorlaV6zzyi/KcMcqhrYHyzYa2sH/L2f5efG+jYbhmmTkvQ Gr/w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=acDsFEaV89yyM3MMGJ1GuBnRej8Gzzefq6bvVEMTi8I=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=dikQqpY8u8nQz8Awkz5+EN4gW4gCo1MMCnAOyo5swAytJo8rmxCbDnpfm9s7FbGic9 d/oi/JCsq4EXvfoAaozCrwD+aoNK7V9N5CvVQN9+qSnoy9/ppaTHwCqQnlW+A0gZIYRI dMZK49UqeuEq+E6uAlSJURNSiW56Gd7e37SUsahfUtBFO85n3XOG/NGtv2kmbKdsnj7t eAakntNt/5RolLLC9BsROJEow1AWKeQ0iWCB3vKlVwX7MkUQ+LBazOgBfneXL+02hZAd lbqlVbavivLaTuUUuZs77FS4us4zATk+9aDPS0IPadLnu/rx59LPdusTYSEPOMZ8Bg72 WIOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j6wYmBKC; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z14-20020a05640240ce00b00565b0344691si1987436edb.229.2024.02.26.09.02.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=j6wYmBKC; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81973-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81973-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B5C881F25192 for ; Mon, 26 Feb 2024 17:02:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 141C5136999; Mon, 26 Feb 2024 16:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="j6wYmBKC" 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 88EA212CD9E; Mon, 26 Feb 2024 16:53:57 +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=1708966439; cv=none; b=IX8CxL8PfhbyyczIJOvmBC7cgNuddFsAdSgPzuncCK+UTmd5dTrH/vKLjwQzPH41qGC1iaGgyqP3qjhithrJPZZqL8o/7ExLAuAuXl0R6/ET/eE8JNPv4AplckOC9X9hJxRRajYFvljp3Txz4zMEaIuKi8TYwXW+5aEb6yetijI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966439; c=relaxed/simple; bh=IrBE4fcRHBBIKINnpShMKbyQ6uSukeQFgVtSxmIFIdM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mX5MJBh6rxho1L0cO3+debQF1UM7BunfILi6j+fvDuH2oK+MNb6FuwBB7FgRi5UQh1pmtFflWukVs2iss50zvJDVDOnST75s0iGlalF6a0/8hL4jgHCAmTK2gco/qzkrWio/0LYU/v5BgGlVGyPgmSuH/0eoVW/z9ftn8Bhiz84= 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=j6wYmBKC; 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 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 41QGgVRB002939; Mon, 26 Feb 2024 16:53:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=acDsFEaV89yyM3MMGJ1GuBnRej8Gzzefq6bvVEMTi8I=; b=j6wYmBKCcxuN23Mx4TERjdtdmQ4zf0jBduMXSd6/jhLsixTPosVChjdPWgrAq80ckvNe tjjPmvzPzIb2PyOyWew3TmYT8V+geHZda1cOLOjQxG6jppObbfNr6ZBvxxGGphwwMBLa LNPQg8kRiQEW5beKVbp0VmPKdcIK//lQ0LHp33xlnsizjIikOYN62Zbnf7dFBm8mEyMj DBaVrfDGnuDtvCTMNnvnFdDutUfVa2DmAaOw4PaXVZ3koKtg5oUTYEKLS82PCCDUuDwR wmsEhmmLIkOTTtTaUPctQKyT436EuAvM7U2qCys+NrVS/3wx/Rj08NxVcGexwr9I/LdU 5Q== 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 3wgxd4ga1n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:45 +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 41QGf4Dm021363; Mon, 26 Feb 2024 16:53:43 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfusnteea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:43 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrf0a54198560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:43 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EEED5805D; Mon, 26 Feb 2024 16:53:41 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96A5A58053; Mon, 26 Feb 2024 16:53:40 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:40 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 23/31] fsi: aspeed: Add interrupt support Date: Mon, 26 Feb 2024 10:53:13 -0600 Message-Id: <20240226165321.91976-24-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DIEjtBN6oY4qetOWzXZmO1XIvxM4aQh6 X-Proofpoint-ORIG-GUID: DIEjtBN6oY4qetOWzXZmO1XIvxM4aQh6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=871 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981729483438481 X-GMAIL-MSGID: 1791981729483438481 Handle slave interrupts and pass them to the FSI core. Signed-off-by: Eddie James --- drivers/fsi/fsi-master-aspeed.c | 104 ++++++++++++++++++++++- include/trace/events/fsi_master_aspeed.h | 12 +++ 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index ac8835e4d1f8..ce16ea65f65d 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,10 +27,12 @@ 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; struct clk *clk; struct gpio_desc *cfam_reset_gpio; + u32 irq_mask; }; #define to_fsi_master_aspeed(m) \ @@ -80,6 +84,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) @@ -316,11 +325,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); } @@ -447,6 +521,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) struct fsi_master_aspeed *aspeed; unsigned int reg; int rc, links; + int irq; rc = tacoma_cabled_fsi_fixup(&pdev->dev); if (rc) { @@ -527,11 +602,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); @@ -539,9 +615,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 @@ -553,6 +650,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 7eeecbfec7f0..dba1776334a0 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 Mon Feb 26 16:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2207047dyb; Mon, 26 Feb 2024 09:03:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWUnR0vt6FSuwOheiBVR0mmiOqBsDS+SUvVIw7yqQrFbTiB83OtKLo46+2c9ijZ89x7HOXYmRH70rBFqNT2CS/cVP9h9g== X-Google-Smtp-Source: AGHT+IEqKYdp9rY4hmMTw5mBDSH1dNdNHexHZV6wJe7p7tYEUyg2zxKQb8dlfdlzkyVID4EZrKwK X-Received: by 2002:a05:6830:6b8e:b0:6e4:971a:9249 with SMTP id dd14-20020a0568306b8e00b006e4971a9249mr6024642otb.9.1708966985354; Mon, 26 Feb 2024 09:03:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966985; cv=pass; d=google.com; s=arc-20160816; b=ufeEc4sqFVHUy+GMA35fIshnNgnd8/DAwgf7PTVRMCYGQwzX8IdGPYYCH1tO8/YcsI tjGFzYp6iXMc5/gXLN9LWlZkBR1IQ7CyJ6G32LO0nXdstRLsiP9JGCRmdjlpnoblQvEZ 2Zbs1jb0h2SKA+PWWK4cKQxAcxefkaFzr4DIOqm1yfzBYsLFrpKDSUWbzsAqhTXKuvNL 6GFs8DlkRp1p6J8nJMDuponw5ObwSy7CXo7kR7t8Za/eT7CrB28YIhlfw2EzmKW3QlBw nQCcvipYxX3616xdHGFUJFEkFu5trkbuL2lindsijIoHSdIbdtBb+7Pantttu5rVolOC adzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=G2U9RCikIAWX79HQyTXxI0GoS+WAxRjBt+QZS9Zg4lY=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=nrsCHIXpoVD3i3Fzua2zwmBHjXh2rmDnbBdcOzrUTf/IHi0NqilqAsbxBZO4HFfoO9 3yv/tQlKSFlg2QkTmihFzzeH+nl4I5RIPJ2vun/x/SUK0ofKoX/3tjUe+DTNee17gRmC eZ7d+3SQJv8RKT5OgRnN78WE4I3fjuf1419rTGBkU+aQTETViK742kfgJVKp2J5b9zo6 F4PiktggqEap9RObOVWFckV4mKyQtVhlc61Y4z6r0Db4uAUhoc0ULVfyqCxgcNzz2sDq a+VFLpjjX2Ho2f/SNcrWERpel5dcEHb+adJATRS6W3gM9py0wT32jBcpqoB1etXXur4J ioKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=so1hCob2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81972-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81972-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f15-20020a81414f000000b00607be9027a4si1813818ywk.471.2024.02.26.09.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:03:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81972-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=so1hCob2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81972-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81972-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DC02A1C2C5CC for ; Mon, 26 Feb 2024 17:02:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32B5F135A48; Mon, 26 Feb 2024 16:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="so1hCob2" 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 4942B133415; Mon, 26 Feb 2024 16:53:57 +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=1708966438; cv=none; b=tCQkwJYUF5a/ibpnD5GrkcjqN7zP4NhI7ewZZnsov4zCPoWnmsXUAJWwEJM9NQx7TfHPh9ds01SnClFZ9QMEMLmCet3PeFv6WtMzMN/h1ra/Ptq8T29jQiWfZ7YEnWG4mOqwm6NbPoL1PnwzNUilEViTko2G2wkNlnLzRcBA0eM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966438; c=relaxed/simple; bh=QVu20tcW/pErFdegM6TNMtLP095kS72bKybdH0MbwEw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a1TvMI3cDVLwpXgHP447TM1tgOu4BRKEEnw05y/dsgrGmwJ+kwAjxBk8T9hz2x5YnqqbXnIuCFZEfAdsIsLHKLCSdo00J5r1kD310py7jrzUrISA9exyuqqi68yu5AzmKvYl+dFnp5JH5pH7/32kTBp3P59k2O4UNDpP1V1o1zo= 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=so1hCob2; 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 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 41QG5fEn025327; Mon, 26 Feb 2024 16:53:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=G2U9RCikIAWX79HQyTXxI0GoS+WAxRjBt+QZS9Zg4lY=; b=so1hCob2lrdmA0BS7W4tdMtd5JwUuNqjuR7Cn3E44ZpDMfkuXMiXF/W8pYiZr9kDnoK4 i1E7ayVpS6BsTILqSD6YieJU0RsnRIN30DGHUVDm9oShV2xCbX8ttxa39xLGNK87Iw6l ZEysi2T7iqkQk7mNWS80jvvmrOgq5/OQjrXJlo0sR2dgX9iJQKaxfwpc0NHyiLW9VCB6 OnGTOXPZT/p0BPnLJWrV6dpHYnNHjKdWCjR+4ePQwSEhJsZzQ+fbAbWIDizEtfRNWqxT m4jZA2FDRgBxAGrKg8bGiOxmOgPffwyqmzLyQdoQAJgeYsmgf923Oq+ICFEnBtQZ9vnf Ww== 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 3wgvsq33r2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:45 +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 41QFTLMo024122; Mon, 26 Feb 2024 16:53:44 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfw0k23g4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:44 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrgbj18350752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:44 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1DCF158059; Mon, 26 Feb 2024 16:53:42 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6631258053; Mon, 26 Feb 2024 16:53:41 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:41 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 24/31] fsi: hub: Add interrupt support Date: Mon, 26 Feb 2024 10:53:14 -0600 Message-Id: <20240226165321.91976-25-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RWPrxzSiwqdlwKVl5f0uxeQqtEencxJe X-Proofpoint-ORIG-GUID: RWPrxzSiwqdlwKVl5f0uxeQqtEencxJe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 priorityscore=1501 phishscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=777 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981765550939175 X-GMAIL-MSGID: 1791981765550939175 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 92aa07055c56..4c3f77ae1faf 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); } @@ -136,6 +210,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); @@ -143,9 +218,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 @@ -157,6 +267,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 Mon Feb 26 16:53:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2209702dyb; Mon, 26 Feb 2024 09:06:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUp6vp1jS0GfIbtvbhD/+ikaIBQNG2hXVT2Xe9bs8AW9uj4Dy2bX/I/RUNaaXnZ+prx8LVy2Pfeb5I6z14JBaph3J/gPQ== X-Google-Smtp-Source: AGHT+IEwcADD3JLXkF1khViNaUaT6DB46tVvI3rHvoOVckU+Ay2d80TS6EILcLJUsIN1Q6WbpOFF X-Received: by 2002:aa7:8b8b:0:b0:6e4:61af:4c7b with SMTP id r11-20020aa78b8b000000b006e461af4c7bmr6563170pfd.30.1708967176158; Mon, 26 Feb 2024 09:06:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967176; cv=pass; d=google.com; s=arc-20160816; b=FhQhlsP9eG72mihlgEfT6cxpr3sgd0HluTvgn+T7miysi61wKuE4v38LcaBEBgC+pn FSingQuixF3KgxY0ki0qyeM/j1jgdWLaL0jbexFiegSDCMCP/hRto6SHLEj6HKBR1jXy IhAX+jBkYYiMD0xSjbbJCea1lmj/OhYhwW9O35xvYISxjAHNa+BmcDFcXHsRJgWzTioz 102V8Tb6wWu1OEzk44g5tWvFECx6O5IpNY6IvktVAJShD7rEW425R0SCQqX+CA7edSXU fk06ViCNqGSsRIKfbTL4Tx/DATREf5fVv0/COpfeXrYTEgYV5+piHii9coZnNCjRB6Hq HwXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0qbOHG7gDL7BluVHG6aIFuWkCkqtnciMO6tHFzvcS9c=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=GFCTSi+pdLKZPwT2KJCIMaYQSN15eukRq02F+qW9Pe5MD5Ku2SuEbg2jJfE1iBQngl xfZSWIkYqMpMQzpFoboSCZuqwpdfJPAjcAs3jJFZ183AzhZy0/1TP1A7ynC1VXS0suQQ GXKSBzchvH7+g0RjPTfyk7Fksg2FAy3HW6YGIauv8TwYUVDVqWUnvZBx9UKpHgWMhwnO rxXtTl4ZgkWdqyYq3OpfO34d27REfC6lmz2Dd64XhaW3CePOiGE+hLhyiA/Zjk+fpr2Q UNNTBf/SvoACRJfHZAe7D6cAgz++Ik7/76RW4rAAvNbq/UHcocJK/UMZcBKbkozwUG3b 3h7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="OGL/k54Z"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81977-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81977-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f23-20020a63f757000000b005dc430e6e30si3983718pgk.788.2024.02.26.09.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:06:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81977-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="OGL/k54Z"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81977-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81977-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 393A6294BBE for ; Mon, 26 Feb 2024 17:03:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DC14137C45; Mon, 26 Feb 2024 16:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="OGL/k54Z" 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 378E51353E8; Mon, 26 Feb 2024 16:54:00 +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=1708966442; cv=none; b=U9QyCcGsG78eJqUskvlCs7daadkMqwqRhXSwAMu8ODMKvxlyaDtGxMYiMeZiTU3BGzhupft+Ss0RHRMtxeOci2foqLzovEA2wdOp5kwuFFoCMJSw7vofO0Hn/KdkyQBNf12jWzjidnu1/mPO2ChRhRDL9FHTJf5I7DoZfY6Evm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966442; c=relaxed/simple; bh=T+M2Nn1CbVzGiWWZ25GQh8RxyvzQFAsyFI0vKdVAGuc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kc4OIru2uCSzOMkS3qV4XL8pVID6wLT/cSYSSejCG2gmLzteggIGReYUIUYKv2rEZqCN+l/RVtgVDhUjdqp9Y8/46cFHaCyXyU2g+F/ap6Zbvp3wbG73frKth8FV3TiWir0BGYZJjuxbtmvjmsqHLg1xHw17oBRCgLX4yw5Wd5Q= 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=OGL/k54Z; 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 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41QGSDtg014784; Mon, 26 Feb 2024 16:53:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=0qbOHG7gDL7BluVHG6aIFuWkCkqtnciMO6tHFzvcS9c=; b=OGL/k54Za+Oi+Ik9UMAZN1dYIHrAG7YQzCySyQaf5UnXUZCWg6LF40yFVtQm1hZ1JfR3 IuxVtXlXADkOVq2JgkLNnoRf9yg18DKi5x1vuoTWSDOcT0b3qZUxlPAbqxkD4OZU2pE8 GESoxCq5XaCI9PuJj2asZVsYwfwSBttiEh0K+LTbI4YlD8K7cjoEDd3jIuI2JgoV8+f3 fGMp1UZWnn4AnE7cPOnI+F4kbbGG8vvK+JD6gz2YIH8cxuS0yNkuZ+xh/n0REgNEnkLg 4yXL1Vt/eMezBraH0xiqrf88LLaU/hNOcBIVsDeir80fDiDqSfaTB2UUKkL3Pg0RRhrm Lg== 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 3wgx6g8nv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:46 +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 41QFvbid012371; Mon, 26 Feb 2024 16:53:45 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xx9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:45 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrgQt18481720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:45 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFE8B58061; Mon, 26 Feb 2024 16:53:42 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 336E558053; Mon, 26 Feb 2024 16:53:42 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:42 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 25/31] i2c: fsi: Calculate clock divider from local bus frequency Date: Mon, 26 Feb 2024 10:53:15 -0600 Message-Id: <20240226165321.91976-26-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Qx9NO90-TIrXxkEaxq-0tWytwCPDqHVy X-Proofpoint-ORIG-GUID: Qx9NO90-TIrXxkEaxq-0tWytwCPDqHVy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxlogscore=987 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981965597355775 X-GMAIL-MSGID: 1791981965597355775 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 --- drivers/i2c/busses/i2c-fsi.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 10332693edf0..eaecf156ac31 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,20 @@ 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 = I2C_DEFAULT_CLK_RATE; + + if (!device_property_read_u32(dev, "clock-frequency", &clock)) { + if (!clock) + clock = I2C_DEFAULT_CLK_RATE; + } + + // i2c clock rate = local bus clock / (4 * (i2c clock div + 1)) + i2c->clock_div = (((lbus + (clock - 1)) / clock) / 4) - 1; + } rc = fsi_i2c_dev_init(i2c); if (rc) From patchwork Mon Feb 26 16:53:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2222193dyb; Mon, 26 Feb 2024 09:26:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvzPRm1OcP15KR+c37Rsc3KHYDpx5/fAvEXy9bydYDXGx19zI6qnxOk5poCsjwUIIVVZ5z7VrMJiJq2MA45at0um7JiA== X-Google-Smtp-Source: AGHT+IFb99PouK8dRI7JY6tfZnRJxYEg4LoUtkUNBDhYnjXjTTyvDej2iu4tmr5smmXrYf+rEorH X-Received: by 2002:a17:90b:19d1:b0:29a:b1cb:ff10 with SMTP id nm17-20020a17090b19d100b0029ab1cbff10mr3214655pjb.23.1708968409529; Mon, 26 Feb 2024 09:26:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968409; cv=pass; d=google.com; s=arc-20160816; b=qEy68kiBC4T3DnmkfmnRZ8FeXfNupUZzEI18Cl4BbkaDN6JaCBnmI2DaF8NhVJIpdr z+8yRzpvjFNNZwy7DYxw4u5h3q5pJXe5/9sZ8n9OgBabSkwbFCz4orBP7FX6G6L/E5f4 CFbh5henW3caw3q3ipssJTsmXO5Lp9fH9pCWpUyQTlkXqTWVGuAC5ksaUvFnFDyeYS+Z iT1fdyRtxvLbO1z0UL/q0ob8dMBqh6TtInPvRAULUIL/zHKTVXYOxQrHrtDh6A28Phk2 KT+CA+0Md+HNJvjKuBdPXfT0ayfBuNacdzFvwSaqYQRCTLmgpvoT8WfTnK6+TvoWjhWW DdGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=psAc7NhzV/4UUrvAwzBQj4m9xdKePW/86HpHbKqjtW0=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=wM8RIYpSKv91VOt4m6HfxHRKYyis0S9wTTWNxDPyAd2J3lGjptPqMwSGHr9vVIM+7X j7a6UuHFSfz4/6ENUYke7Y/is/vX043xCeFtChUhQlR/bMsQ9T6bp46otGNRey4IdjVs sdeUrHoKyYEPvTF2nLsD06jDRbGWhj+5VuT9XbfO7qtwkjeju85ZZHtlib75a8Gdynq4 YJ+UNy84QkaYUyoezSdK4bfmv3DO0JNcoSZ9+8UWFnK/S6XPw+BGe+rl8q99Zt8yRD+a b7lOOpyUjuEITe+lsij5q6jaVc/5mhtfjKY40dSk+fIUrUkQOBVCUCfHD3208Lv0w/Zd whKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="k7acfr/J"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81979-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h6-20020a17090a604600b002995cc18356si5860596pjm.67.2024.02.26.09.26.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="k7acfr/J"; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81979-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81979-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BA6FCB304F0 for ; Mon, 26 Feb 2024 17:04:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 718081384BE; Mon, 26 Feb 2024 16:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="k7acfr/J" 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 B34741350F0; Mon, 26 Feb 2024 16:53:59 +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=1708966443; cv=none; b=pnz0w3b559wFVukFArhnVmwYzWDrrEC4RFRzptMrfpZGX6TE5zaFniLgMOFQZi1msdq3J4g0FoCKlaDHsMMNvgKABrOi0Y0S6+juANiR6QPpARBalb6NKmAPBZhiFfcHZJiLkNmyOI69JSu5Ic03IhZn2zWMHKIxJBkH6p5V8vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966443; c=relaxed/simple; bh=y7Ir3NHVxuCw/j7v8sOGwdCGBziRK95layLM4Yi7WNM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iZnVPpQwWuRwDSvPWF/IPWTmmHQKzi1uJYo9rgdOPG5Zt3GsFyC8uSVU7B/t9/3fb9bdDSBCPHMr7qP7+L3Wqfb9N/h7RCcha5Zf5lP+W9NzeLYeH+2tC9Pl/ntcEaH2Kf4nsf3P+YznzWFQDG1Hpf1oTYkqlwKZNhVCKWrE3ls= 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=k7acfr/J; 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 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41QGSHn8014969; Mon, 26 Feb 2024 16:53:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=psAc7NhzV/4UUrvAwzBQj4m9xdKePW/86HpHbKqjtW0=; b=k7acfr/J+c7hK44idEgZU0Ut9YXZl63Flafqq+xaZx8LQXOcrre78SeBt5xtMr7v1NDf JR5D6+rgFTeF+frl4SneTYqLvlfy0KQQK+gy5oNGCf0dDErw5cypEgJKwY584O/YCWPV 0nslXt2I3H7dJEU/TgWF7Ndwa9+RVEmMewtkUjBcZrS1yNb7ZrJa3fOzbH+9EIG1RBIr F2V2AdBhac3TUQbXa+Bi+A6Jm4TVTzINvWO4TWGMEWIEjsXUxTDVvV3S963Azr5QiqVW AkPat5pwZ4SqM4SOe6a7igsLnZDILjISGKngPbMEkQKwXNGUB3xsa4q8jTY9XM1OcEVM qQ== 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 3wgx6g8nwa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:47 +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 41QG5FVN008798; Mon, 26 Feb 2024 16:53:46 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wftstarc0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:46 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrhfg17367696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:45 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC99858065; Mon, 26 Feb 2024 16:53:43 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01C5F58053; Mon, 26 Feb 2024 16:53:43 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:42 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 26/31] i2c: fsi: Improve formatting Date: Mon, 26 Feb 2024 10:53:16 -0600 Message-Id: <20240226165321.91976-27-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7cepKPpawhsebnHBPokYLYDvkOm1sJDi X-Proofpoint-ORIG-GUID: 7cepKPpawhsebnHBPokYLYDvkOm1sJDi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxlogscore=964 priorityscore=1501 adultscore=0 phishscore=0 impostorscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983258621456687 X-GMAIL-MSGID: 1791983258621456687 No functional change. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 125 +++++++++++++++++------------------ 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index eaecf156ac31..bc44cad49ef2 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -148,10 +148,10 @@ struct fsi_i2c_master { struct fsi_device *fsi; - u8 fifo_size; struct list_head ports; struct mutex lock; u32 clock_div; + u8 fifo_size; }; struct fsi_i2c_port { @@ -165,15 +165,14 @@ struct fsi_i2c_port { static int fsi_i2c_read_reg(struct fsi_device *fsi, unsigned int reg, u32 *data) { - int rc; __be32 data_be; + int rc; rc = fsi_device_read(fsi, reg, &data_be, sizeof(data_be)); if (rc) return rc; *data = be32_to_cpu(data_be); - return 0; } @@ -187,9 +186,11 @@ static int fsi_i2c_write_reg(struct fsi_device *fsi, unsigned int reg, static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) { - int rc; - u32 mode = I2C_MODE_ENHANCED, extended_status, watermark; + u32 mode = I2C_MODE_ENHANCED; + u32 extended_status; u32 interrupt = 0; + u32 watermark; + int rc; /* since we use polling, disable interrupts */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, &interrupt); @@ -215,9 +216,10 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) static int fsi_i2c_set_port(struct fsi_i2c_port *port) { - int rc; struct fsi_device *fsi = port->master->fsi; - u32 mode, dummy = 0; + u32 dummy = 0; + u32 mode; + int rc; rc = fsi_i2c_read_reg(fsi, I2C_FSI_MODE, &mode); if (rc) @@ -238,7 +240,6 @@ static int fsi_i2c_set_port(struct fsi_i2c_port *port) static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, bool stop) { - struct fsi_i2c_master *i2c = port->master; u32 cmd = I2C_CMD_WITH_START | I2C_CMD_WITH_ADDR; port->xfrd = 0; @@ -252,7 +253,7 @@ static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, cmd |= FIELD_PREP(I2C_CMD_ADDR, msg->addr); cmd |= FIELD_PREP(I2C_CMD_LEN, msg->len); - return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); + return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, &cmd); } static int fsi_i2c_get_op_bytes(int op_bytes) @@ -268,18 +269,17 @@ static int fsi_i2c_get_op_bytes(int op_bytes) static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, u8 fifo_count) { + int bytes_to_write = port->master->fifo_size - fifo_count; + int bytes_remaining = msg->len - port->xfrd; int write; int rc; - struct fsi_i2c_master *i2c = port->master; - int bytes_to_write = i2c->fifo_size - fifo_count; - int bytes_remaining = msg->len - port->xfrd; bytes_to_write = min(bytes_to_write, bytes_remaining); while (bytes_to_write) { write = fsi_i2c_get_op_bytes(bytes_to_write); - rc = fsi_device_write(i2c->fsi, I2C_FSI_FIFO, + rc = fsi_device_write(port->master->fsi, I2C_FSI_FIFO, &msg->buf[port->xfrd], write); if (rc) return rc; @@ -294,12 +294,11 @@ static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, u8 fifo_count) { - int read; - int rc; - struct fsi_i2c_master *i2c = port->master; - int bytes_to_read; int xfr_remaining = msg->len - port->xfrd; + int bytes_to_read; u32 dummy; + int read; + int rc; bytes_to_read = min_t(int, fifo_count, xfr_remaining); @@ -307,7 +306,7 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, read = fsi_i2c_get_op_bytes(bytes_to_read); if (xfr_remaining) { - rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, + rc = fsi_device_read(port->master->fsi, I2C_FSI_FIFO, &msg->buf[port->xfrd], read); if (rc) return rc; @@ -316,8 +315,8 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, xfr_remaining -= read; } else { /* no more buffer but data in fifo, need to clear it */ - rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, &dummy, - read); + rc = fsi_device_read(port->master->fsi, I2C_FSI_FIFO, + &dummy, read); if (rc) return rc; } @@ -330,85 +329,80 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_get_scl(struct i2c_adapter *adap) { - u32 stat = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 stat; - fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); + fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); return !!(stat & I2C_STAT_SCL_IN); } static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { - u32 dummy = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 dummy = 0; if (val) - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, &dummy); else - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, &dummy); } static int fsi_i2c_get_sda(struct i2c_adapter *adap) { - u32 stat = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 stat; - fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); + fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); return !!(stat & I2C_STAT_SDA_IN); } static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { - u32 dummy = 0; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 dummy = 0; if (val) - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, &dummy); else - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, &dummy); } static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) { - int rc; - u32 mode; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 mode; + int rc; - rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_MODE, &mode); if (rc) return; mode |= I2C_MODE_DIAG; - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); } static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) { - int rc; - u32 mode; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *i2c = port->master; + u32 mode; + int rc; - rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_MODE, &mode); if (rc) return; mode &= ~I2C_MODE_DIAG; - fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); } static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, struct fsi_i2c_port *port) { + u32 dummy = 0; + u32 stat; int rc; - u32 stat, dummy = 0; /* force bus reset, ignore errors */ i2c_recover_bus(&port->adapter); @@ -439,8 +433,9 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) { + u32 dummy = 0; + u32 mode; int rc; - u32 mode, dummy = 0; /* reset engine */ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); @@ -476,18 +471,17 @@ static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) { - int rc; - unsigned long start; + struct fsi_i2c_master *i2c = port->master; u32 cmd = I2C_CMD_WITH_STOP; + unsigned long start; u32 stat; - struct fsi_i2c_master *i2c = port->master; - struct fsi_device *fsi = i2c->fsi; + int rc; rc = fsi_i2c_reset_engine(i2c, port->port); if (rc) return rc; - rc = fsi_i2c_read_reg(fsi, I2C_FSI_STAT, &stat); + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &stat); if (rc) return rc; @@ -503,15 +497,14 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return 0; /* write stop command */ - rc = fsi_i2c_write_reg(fsi, I2C_FSI_CMD, &cmd); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); if (rc) return rc; /* wait until we see command complete in the master */ start = jiffies; - do { - rc = fsi_i2c_read_reg(fsi, I2C_FSI_STAT, &status); + rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_STAT, &status); if (rc) return rc; @@ -527,8 +520,8 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) static int fsi_i2c_handle_status(struct fsi_i2c_port *port, struct i2c_msg *msg, u32 status) { - int rc; u8 fifo_count; + int rc; if (status & I2C_STAT_ERR) { rc = fsi_i2c_abort(port, status); @@ -576,9 +569,9 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, unsigned long timeout) { - u32 status = 0; - int rc; unsigned long start = jiffies; + u32 status; + int rc; do { rc = fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, @@ -608,13 +601,13 @@ static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - int i, rc; - unsigned long start_time; struct fsi_i2c_port *port = adap->algo_data; - struct fsi_i2c_master *master = port->master; + unsigned long start_time; struct i2c_msg *msg; + int rc; + int i; - mutex_lock(&master->lock); + mutex_lock(&port->master->lock); rc = fsi_i2c_set_port(port); if (rc) @@ -635,7 +628,7 @@ static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, } unlock: - mutex_unlock(&master->lock); + mutex_unlock(&port->master->lock); return rc ? : num; } @@ -681,8 +674,10 @@ static int fsi_i2c_probe(struct device *dev) struct fsi_i2c_master *i2c; struct fsi_i2c_port *port; struct device_node *np; - u32 port_no, ports, stat; + u32 port_no; + u32 ports; u32 lbus; + u32 stat; int rc; i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); @@ -753,14 +748,14 @@ static int fsi_i2c_probe(struct device *dev) } dev_set_drvdata(dev, i2c); - return 0; } static int fsi_i2c_remove(struct device *dev) { struct fsi_i2c_master *i2c = dev_get_drvdata(dev); - struct fsi_i2c_port *port, *tmp; + struct fsi_i2c_port *port; + struct fsi_i2c_port *tmp; list_for_each_entry_safe(port, tmp, &i2c->ports, list) { list_del(&port->list); From patchwork Mon Feb 26 16:53:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2222784dyb; Mon, 26 Feb 2024 09:27:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuMnmYE7PzapszX9BTLFuS2uYx+ksPpIPdBRP+q+eagYI6rmBK4CdqGuowxu0f0bYq9gNOJQme/NCKO+C2hWXN/en75A== X-Google-Smtp-Source: AGHT+IHK267Vz7UADk+km6qqCA9PhuIl7bltPPbUFHUT0Ul/Yqa/hKuAauiobmieYYQjEZ+7yBua X-Received: by 2002:a05:6870:514f:b0:21f:828:7a7c with SMTP id z15-20020a056870514f00b0021f08287a7cmr10299365oak.6.1708968479744; Mon, 26 Feb 2024 09:27:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968479; cv=pass; d=google.com; s=arc-20160816; b=I6jmNAp31Bklbt0RgxbcKSXxl1YAGbq9iNdnzqr7RFEJM4g3nA04kwbhwJsv7b22iW fRRliO0hoaNA26HkoXrDWPoXfN4XG+6N0dgckpEzkpng4mx61QKJZuDUEVUzKiIn0YXE PRtVUq/MmjPEOaR45o3e2PtFj4ZP6B5y9dJH6EnZTPT81otWbWFmyWc2E6wGGu9t6KNB YJR55DUf2Rtwv1l7PTeRg7Yr0rRRdyd+UpL81e2r0kTQR+IDHd0TiiOgrjw7DpANTAPU 004tUn5859QHpxMxd8tOBMtlrxxAlZEq/8Rt0x9t2OT8vMvzm3bXw4rY/BXWh1K60Z2R AJnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WfBD8Asm+mV0Bam4k6IBKyEciz8onft06t3pHx4oKg8=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=OzwUYHfzghs08YD+ADbTUqz337mNpvgS7wZRPtyeKg0sQZuvmORwBWiufl/ZFSKY/9 nRZM5e54lPR5NvJA3d3wf4DwGuquBPka8y73J/W8OR87eLeqnm7WTjk9m3n2V0dhu8DV jzx59J3OUYAGxJOT9ach6838RaKxbxPWOy2Kl+TMGnxap0bDdYWrjmZrh/c2Y4g79K1d 39tyCqC0drKA07PLJwj2iXPS5S3J6AOeQNpUT01XmAm0iiX5VEowbbCkCsuAgeavU2ss 3TMRqLjVQ4MOeVHcNkVA0ekGuzHil6iH4dpgnp8tWRe+r+iLUmWGzPr9mMqAJbvM+PtL EvSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GMiSKxMk; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81975-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e1-20020a63ee01000000b005dc4f8a376asi4024375pgi.884.2024.02.26.09.27.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:27:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GMiSKxMk; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81975-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 147DAB2FB79 for ; Mon, 26 Feb 2024 17:02:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0B161369B8; Mon, 26 Feb 2024 16:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GMiSKxMk" 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 8C49E134CE1; Mon, 26 Feb 2024 16:53:58 +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=1708966440; cv=none; b=CRV4QFJHNWjJAwFHAwA9C7PgqVLqIKT9yUOFBEbYh4M5xC0y+jNIhKQD2ieF4Y1ViApc9NgcFdRiorRu84i/Qbe7ZtoUZJKiHV98fMissMuFxP89CI0XR2sX9W9wMPU3QnzeFygVSh48pVnr8Covq72InsiVm13XW82g4z+fRV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966440; c=relaxed/simple; bh=dy7BHjNi3sCnkRYeOejehYWb5ftkNMI+oDiVGphW4jc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bnDfAcxAmlcS/qTv1Smi0wr4p/wHDegOYZqUq7J1nlmIgYYevWl+fUaLX4aAGiyvDcE2aHxd1/JQOgVvImYkh+M2HqI2hybIOWEl0pFxzAQK812NhaCxfs8rjEhn0jyAR6MRffqh5CDFITy4m3xcMwpYDUUGD0hRqPVLBC1Tmxo= 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=GMiSKxMk; 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 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 41QG1294018638; Mon, 26 Feb 2024 16:53:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WfBD8Asm+mV0Bam4k6IBKyEciz8onft06t3pHx4oKg8=; b=GMiSKxMkLQWVrH+l/ZzT6Y+xSiUXdOcXrf3lkJ/N7D9cQy+NNl0ZECWmZwop8kS09EGL t5CvC3/QYoE6eAXE/HFHBwMw2j4/OUHyAQZqDMPVZyMvn/ukqgo0hd4DoioRsOTxtNmN jeCdwoyoQLP2DVHvwthQGbFHQNcS2m5IkV4fn6b+mGr5sDQv6C0rN4EmxywI3hu9nKSP JeAZJqI+wmvPTh421lrdaHIwpHg5Pkxn1ZD1G0nuEZPXbNAXG3/9dkYXOLaO7ZaFkw79 /WInfWpHM1GZuv75Xxjb63IZ/gZLgP/rhcsbJ2D+RHTP7P57fMes1iC2/QuBvYtS1Rne ZQ== 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 3wgw0k35c8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:48 +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 41QEosxi008189; Mon, 26 Feb 2024 16:53:47 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9m2a1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:46 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrif935980010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:46 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A48A58067; Mon, 26 Feb 2024 16:53:44 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C25F558069; Mon, 26 Feb 2024 16:53:43 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:43 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 27/31] i2c: fsi: Change fsi_i2c_write_reg to accept data instead of a pointer Date: Mon, 26 Feb 2024 10:53:17 -0600 Message-Id: <20240226165321.91976-28-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sSy-N-pEteeeRnPMcnR_-GvDiuFwaAht X-Proofpoint-ORIG-GUID: sSy-N-pEteeeRnPMcnR_-GvDiuFwaAht X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983332133818197 X-GMAIL-MSGID: 1791983332133818197 There's no use passing a pointer here. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 47 +++++++++++++++--------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index bc44cad49ef2..f237e76d29e6 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -177,9 +177,9 @@ static int fsi_i2c_read_reg(struct fsi_device *fsi, unsigned int reg, } static int fsi_i2c_write_reg(struct fsi_device *fsi, unsigned int reg, - u32 *data) + u32 data) { - __be32 data_be = cpu_to_be32p(data); + __be32 data_be = cpu_to_be32(data); return fsi_device_write(fsi, reg, &data_be, sizeof(data_be)); } @@ -188,17 +188,16 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) { u32 mode = I2C_MODE_ENHANCED; u32 extended_status; - u32 interrupt = 0; u32 watermark; int rc; /* since we use polling, disable interrupts */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, &interrupt); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_INT_MASK, 0); if (rc) return rc; mode |= FIELD_PREP(I2C_MODE_CLKDIV, i2c->clock_div); - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, mode); if (rc) return rc; @@ -211,13 +210,12 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c) i2c->fifo_size - I2C_FIFO_HI_LVL); watermark |= FIELD_PREP(I2C_WATERMARK_LO, I2C_FIFO_LO_LVL); - return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_WATER_MARK, &watermark); + return fsi_i2c_write_reg(i2c->fsi, I2C_FSI_WATER_MARK, watermark); } static int fsi_i2c_set_port(struct fsi_i2c_port *port) { struct fsi_device *fsi = port->master->fsi; - u32 dummy = 0; u32 mode; int rc; @@ -229,12 +227,12 @@ static int fsi_i2c_set_port(struct fsi_i2c_port *port) return 0; mode = (mode & ~I2C_MODE_PORT) | FIELD_PREP(I2C_MODE_PORT, port->port); - rc = fsi_i2c_write_reg(fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(fsi, I2C_FSI_MODE, mode); if (rc) return rc; /* reset engine when port is changed */ - return fsi_i2c_write_reg(fsi, I2C_FSI_RESET_ERR, &dummy); + return fsi_i2c_write_reg(fsi, I2C_FSI_RESET_ERR, 0); } static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, @@ -253,7 +251,7 @@ static int fsi_i2c_start(struct fsi_i2c_port *port, struct i2c_msg *msg, cmd |= FIELD_PREP(I2C_CMD_ADDR, msg->addr); cmd |= FIELD_PREP(I2C_CMD_LEN, msg->len); - return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, &cmd); + return fsi_i2c_write_reg(port->master->fsi, I2C_FSI_CMD, cmd); } static int fsi_i2c_get_op_bytes(int op_bytes) @@ -340,12 +338,11 @@ static int fsi_i2c_get_scl(struct i2c_adapter *adap) static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { struct fsi_i2c_port *port = adap->algo_data; - u32 dummy = 0; if (val) - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, 0); else - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SCL, 0); } static int fsi_i2c_get_sda(struct i2c_adapter *adap) @@ -361,12 +358,11 @@ static int fsi_i2c_get_sda(struct i2c_adapter *adap) static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { struct fsi_i2c_port *port = adap->algo_data; - u32 dummy = 0; if (val) - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, 0); else - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, &dummy); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_RESET_SDA, 0); } static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) @@ -380,7 +376,7 @@ static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) return; mode |= I2C_MODE_DIAG; - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, mode); } static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) @@ -394,13 +390,12 @@ static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) return; mode &= ~I2C_MODE_DIAG; - fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, &mode); + fsi_i2c_write_reg(port->master->fsi, I2C_FSI_MODE, mode); } static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, struct fsi_i2c_port *port) { - u32 dummy = 0; u32 stat; int rc; @@ -408,7 +403,7 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, i2c_recover_bus(&port->adapter); /* reset errors */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, 0); if (rc) return rc; @@ -423,7 +418,7 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, return 0; /* failed to get command complete; reset engine again */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, 0); if (rc) return rc; @@ -433,12 +428,11 @@ static int fsi_i2c_reset_bus(struct fsi_i2c_master *i2c, static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) { - u32 dummy = 0; u32 mode; int rc; /* reset engine */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, 0); if (rc) return rc; @@ -455,14 +449,13 @@ static int fsi_i2c_reset_engine(struct fsi_i2c_master *i2c, u16 port) if (port) { mode &= ~I2C_MODE_PORT; mode |= FIELD_PREP(I2C_MODE_PORT, port); - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, mode); if (rc) return rc; } /* reset busy register; hw workaround */ - dummy = I2C_PORT_BUSY_RESET; - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_PORT_BUSY, &dummy); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_PORT_BUSY, I2C_PORT_BUSY_RESET); if (rc) return rc; @@ -497,7 +490,7 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return 0; /* write stop command */ - rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, &cmd); + rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_CMD, cmd); if (rc) return rc; From patchwork Mon Feb 26 16:53:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2224387dyb; Mon, 26 Feb 2024 09:30:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXu8Eh1RMZqNojRmAdeU773xWhUCyMNtM+ZCO+i1jMWh9tdNI9jiIa78Zex/zgNHV8tmcvIfADbVON4j4QYag3vjZp3JQ== X-Google-Smtp-Source: AGHT+IHgDesM1hjdToiPuqoEIWHZpNJT4u63qWXX/F0XXq2ke56hnve4x5ehSzlyx8R/l/1SshRS X-Received: by 2002:a17:903:246:b0:1d4:4df7:22ab with SMTP id j6-20020a170903024600b001d44df722abmr7600276plh.55.1708968649221; Mon, 26 Feb 2024 09:30:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968649; cv=pass; d=google.com; s=arc-20160816; b=1CLBz3JR85J1dDjgSFI8xK8lomsi3lVbTrXEKlT3brMbzpfvuazWSWcLjZZ5KAO09u lVlS4WoYYrKt9SQN1tD5S1deoq6ZT/wqMCJSK2UDkscEd+RQSQ270n+fdYOCQe+fUAK5 G1K9qmfUqk4cjQ/RG+75Y1+bWelbFWQfBeQkirilx0jZZyoWfQv3FTL4mJn0Ns4irNsy enTy5s4JcUR0SLZ8iH5NbED6CuNSFFr5AdnX/4enjppRsw5OG0nxsye9HH/XwG6OlRe5 iIr63INQnf3FrHaDz7ZxzLJYh2fDrdRHnNsEmiuwhCmH9DyRBZcXY70a9EXgb4b2FX/m P/Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=njZMmA5i9z9+KJhOIDW6auHi8a7ZavWPmGAbuJxdb8I=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=WgSRF72GUJLzf7uKARghBxkxI/i6n8KO+4yfRVxDIOaaPOK5xRal6T9nt0O7Q74n19 a1MPA/CStrTorlY0knaE/7snSzb8u5boH1teTpWOwcDl+FaYm9NxGvPFVOswPZFskOCT mWxRVMoD4r4FVBRpUFvmQFfshhEUvp3n0R5Bn1M9yq3FH4ddLFQc4O2Kpte1I+J2ZDO1 q75N65sXCvofOWfedrod/oF4IsmUVOaYU2kkYSjKH5AMRwCp2WE91rsKEXkBkh+z+YIh Qk/gYWy4+gS2ieRrksLSSe54xdXa/7vVMaw8gDuW3K2qDmWHXlIoOLOpU8a+BCihr9xE QXSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qe30t4RZ; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81981-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81981-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p6-20020a170902ebc600b001dbb13a5b17si4056672plg.117.2024.02.26.09.30.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:30:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81981-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qe30t4RZ; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81981-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81981-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 674EAB3059D for ; Mon, 26 Feb 2024 17:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DEDA1386AC; Mon, 26 Feb 2024 16:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Qe30t4RZ" 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 A0C03136981; Mon, 26 Feb 2024 16:54:03 +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=1708966445; cv=none; b=fLBeijiZz83mERMf29JIib54NXtb6ElE7cFQK726sPkUyucw+GFQPSQ9xxvP3Jvm7AkGtrfL68CFt1diJTGS3N9OrZNNW4anni4PMKnRAg0t/7Du1QvhANhX9PrH4R61z6Ml86qSej8IPXy2s5eHiLusU/Dk8sGIxzwwDxGGwxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966445; c=relaxed/simple; bh=BmpHIcdLad4je9edWwtINpVsWPUVd4TCH6j5XSMsz9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q6GW6X5bkb0WEJ4hoBroUrtLByj2ZpekijsTWzRr9TtCaKYqa0vsiOCoWt0pBavDII1Zp7IudluyqppE+YeBhvrXBjbPucgrrWJwuFaVyL7gmjPa6auYyO/UkIrbi2bVLZPN7UTwSYwVMH/zWDNDqgCOoV2HAkikEc8Fm9Mz/xo= 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=Qe30t4RZ; 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 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 41QF2jEb021800; Mon, 26 Feb 2024 16:53:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=njZMmA5i9z9+KJhOIDW6auHi8a7ZavWPmGAbuJxdb8I=; b=Qe30t4RZTgn7Gbc1D1HLUj0HxljJjxsTLcdURZcEdvtYkkK3z6UBV6b5dqx+ucDbMn0b skdcgocXW5A9JEbAf+Ydelc/GLEqqOoncJSrz3JTntiIWf+XVvidXO1Db6pVIG0sw0dy ThG6v76ZKgAnq9Pssyud34UpGHoTIUEWH7aMH1uTUr4oWzW0UVioHjFqm3X3fqLbtovk /iBwT95QY0KNlryF3Ldk09kIofyed4fN+a6UGWzgehdfGyjjazD1I6ldB95L80dpNV1g o8bj2yfA5iLQnwbqhExk0BTNA9sFbEL8g1tD4DF9wcyVq7OF6C+FgweraKXZWcVBuoJb LQ== 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 3wgvp6bkkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:49 +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 41QFvbie012371; Mon, 26 Feb 2024 16:53:48 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:48 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrjkG29622572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:47 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4861C5805F; Mon, 26 Feb 2024 16:53:45 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90ABA58043; Mon, 26 Feb 2024 16:53:44 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:44 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 28/31] i2c: fsi: Remove list structure of ports Date: Mon, 26 Feb 2024 10:53:18 -0600 Message-Id: <20240226165321.91976-29-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: xZ5uEUdjI1YWTXrYDZb7tgB-4KZxS1SD X-Proofpoint-GUID: xZ5uEUdjI1YWTXrYDZb7tgB-4KZxS1SD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983510000635420 X-GMAIL-MSGID: 1791983510000635420 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 f237e76d29e6..096dc7e2369f 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); @@ -706,38 +702,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); @@ -746,16 +734,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 Mon Feb 26 16:53:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2206918dyb; Mon, 26 Feb 2024 09:02:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoRcfHLLbEPHU52eSm3UNbtr0XkjStCbzCOlaNGImUi9YNjAam8TQVh1mVv086eWttitUK4ThVDcRJI9FDC7ga2ckqPA== X-Google-Smtp-Source: AGHT+IF4FF3BLxnA2r/rsjRF1LTvLGPpj44MPExeQhsFZ+aEKcmii4gU3XDZgQBUlBkoIDFONJUc X-Received: by 2002:ac2:5a5e:0:b0:512:d5ca:eb2f with SMTP id r30-20020ac25a5e000000b00512d5caeb2fmr4231654lfn.52.1708966977266; Mon, 26 Feb 2024 09:02:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708966977; cv=pass; d=google.com; s=arc-20160816; b=FSnTu/67eqDUYqPh+u13UJv8pMKAAHsE8Bd85+s55nXPV+FE4eaoTvfmXEtpK9f95w LGNVjnj3GNrT/tfcOgtYJF48CaPvsJFaklgM+BifphbCbXo3JoNctpxSmpYtEwpsExEo yrM16/PNM6N9wo2dUDeOZkia2dKL9JDEE5q3yXrfM/5lJrMElolq1Znj+nNiLIpSNNyL 9XDy5sumUzKAWYQgqBMtO2NRUtCpQqRzWqHIchaH0PDSHDrWsOtr6QX7/YMGadGlv5MX zEsQf/FBiBdKeNKml9NZoFEDEwAOrVJHlYzZRQMuZDK2yJsEv8ZqElruas9P9SlexncY 3C2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VTP7z+tQ2W8GOsBuCAI+ahfXY5pZN8Q0NRIJ8nxWHJo=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=tDRoXwpsn134bL3J3NtAGNm3WnLIr4IPebGOUEjkmyXyokDGtLVoE8LgFHTvSmXoeW TaVGmQaunFpyb4aDuPr2Tpcv0yo4e8r9jNFzvIN3JUh3+nZoY/wxt6ObAxQi4tNPchgk NzCYKKj5IUn2+a6zAfty/pb5pQtJWfrf2O/XCucsaOdczLJG15xwH94lgGrDeWYYt9vl xoJVtGU7tkCl1mECxQ+TE8XnmqmoOELak+5uOA1+mIBnkp0jMPwwXm1PrLDN8oescmKl U+BZg8hRxZnWmY8fNkJvHBPE9KCY5gRoxcLxBGZrfopeN6FbWleCZloGjjv4zsOV95BD Gndg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=VHd2tQVe; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81976-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p20-20020a50cd94000000b005638f3b35d9si2231391edi.297.2024.02.26.09.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:02:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=VHd2tQVe; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81976-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AF2341F2670C for ; Mon, 26 Feb 2024 17:02:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D713137C28; Mon, 26 Feb 2024 16:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="VHd2tQVe" 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 CB10F1350EE; Mon, 26 Feb 2024 16:53:59 +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=1708966441; cv=none; b=XkUN7flB1r9Ji9rgBNkQjJoYd/ipuXbxCW8kBMJJLsOYi5mMoQi3mbQdwu2/tr75fwf/XmpvwqEOR0ZQmkPO1rFsLgLebzcoRFaXSGCdlNPaZw1c+EiDEsaJYKvGd+ytXQ07bIwOFKxRnrsMu+izgGyIM0WSww268YJsrr9r1SI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966441; c=relaxed/simple; bh=H95OXKDiOnZPDBQirsADlzhMc6VAfrwQDtpLN9WMyRg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MqWkmjdyeKkgw/1ZpDaIKivVGhDCQSMtOAJftp95aWrxdcHHvkC9ssQRXTzuleXpnThFh2veJ+ZXEoZqpCuK4R1h+Cwl1DHQ9RWhiU1YSejHMrn3iZlhCR/2XfNQNEC1EHw6aixw9PoDWEFc69n9esKVdIQUx3t+hqTAzfPAEh4= 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=VHd2tQVe; 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 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 41QGgVRD002939; Mon, 26 Feb 2024 16:53:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=VTP7z+tQ2W8GOsBuCAI+ahfXY5pZN8Q0NRIJ8nxWHJo=; b=VHd2tQVebWFmLxgWk/WRZIckNa2Xel8JPZqWYe9uqWgp9QwvYj6GF9jIQlOZBFHD4If9 qQPe30agy8o1QTw8TK4LNrayP1sE3N05HDh2+fokWdlKWVDVskARnSZQPXM4wQbjz0As lJUj06yxNNm2YLqPN6Fk/sHWgcLjihgF4cNk7aitc83teC4qrGgFDummnnPR0NLb8tpx XtOEz3BztEQoWeegGcl8vawR5V3xT31cW82+5ePueDJUSutC883ryx/w9RieSy3FaFML lPvyhZ8tiGaZM0UoBdP/eQSzDRwOSR/PxOQMZd2MPlA2KSWMTrtCU0f4Q6dLUVkRCr+U 8Q== 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 3wgxd4ga4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:49 +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 41QEbsEA021259; Mon, 26 Feb 2024 16:53:48 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfusnteen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:48 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrk1S63439312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:48 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 187B058053; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F32358043; Mon, 26 Feb 2024 16:53:45 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:45 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 29/31] i2c: fsi: Define a function to check status error bits Date: Mon, 26 Feb 2024 10:53:19 -0600 Message-Id: <20240226165321.91976-30-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: tszOviq8HUQ84u2AJHZSGmB61XkJ3l3f X-Proofpoint-ORIG-GUID: tszOviq8HUQ84u2AJHZSGmB61XkJ3l3f X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 mlxlogscore=967 spamscore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981757158004483 X-GMAIL-MSGID: 1791981757158004483 This will be used more than once with interrupt support, so split the error bit checks into a function. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 096dc7e2369f..5f524fb6f0f8 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -507,6 +507,26 @@ static int fsi_i2c_abort(struct fsi_i2c_port *port, u32 status) return -ETIMEDOUT; } +static int fsi_i2c_error_status_to_rc(u32 status) +{ + if (status & I2C_STAT_INV_CMD) + return -EINVAL; + + if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | I2C_STAT_BE_ACCESS)) + return -EPROTO; + + if (status & I2C_STAT_NACK) + return -ENXIO; + + if (status & I2C_STAT_LOST_ARB) + return -EAGAIN; + + if (status & I2C_STAT_STOP_ERR) + return -EBADMSG; + + return -EIO; +} + static int fsi_i2c_handle_status(struct fsi_i2c_port *port, struct i2c_msg *msg, u32 status) { @@ -518,23 +538,7 @@ static int fsi_i2c_handle_status(struct fsi_i2c_port *port, if (rc) return rc; - if (status & I2C_STAT_INV_CMD) - return -EINVAL; - - if (status & (I2C_STAT_PARITY | I2C_STAT_BE_OVERRUN | - I2C_STAT_BE_ACCESS)) - return -EPROTO; - - if (status & I2C_STAT_NACK) - return -ENXIO; - - if (status & I2C_STAT_LOST_ARB) - return -EAGAIN; - - if (status & I2C_STAT_STOP_ERR) - return -EBADMSG; - - return -EIO; + return fsi_i2c_error_status_to_rc(status); } if (status & I2C_STAT_DAT_REQ) { From patchwork Mon Feb 26 16:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2221834dyb; Mon, 26 Feb 2024 09:26:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWO3NLHzwIAHMsbuUlNvUrOj5KjcYvgUcGiqPwsPg9CsFTs0qLpyz7+oSafiD46xmKeCLxmlZL68spVeSWDVNx9MPxw0Q== X-Google-Smtp-Source: AGHT+IHxXklBUREpaaCJ1IRUXelp6n/i9//QHfh7+2rF0ROnvgKFn7If1V5KnLDPbfuhj6aofkrs X-Received: by 2002:a17:90a:ee8a:b0:299:4d91:c8f6 with SMTP id i10-20020a17090aee8a00b002994d91c8f6mr5259288pjz.35.1708968368834; Mon, 26 Feb 2024 09:26:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708968368; cv=pass; d=google.com; s=arc-20160816; b=XV2fU+A4/VlkBeORE7D9cQRekPu9ccmjwz/Vt6W/kTDIGPjpPvuItWLxK4zAYxkMux rXt31OyDRag6ahi5aIgkvY2JGjHY377Q0H/SeWToXdYzC+ED90yZs23gjtssIpk+Ue0b XqSTFMibQPeNQFjC7FUj+DslRHy6ZtRIDyzgq1FzUz+b4UALmDIJvO10WXwfvZ/vV4g6 u/vhdOpvrwPoo/zlT5/iyAY84JFYi5cBqOaVgpwlmB99r1wyiCZ28HPqW4vzUtNNfR6F O0Tto1I/NzHtg/OPNuTjRKJsYIBlIDYi+FM6sbVNYUiZ019yLBLmVLE7PVHaLe3ApIpq rxRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jHq/vBDBbZBSuhSZdVDjxpYwsAaHsSkR8YTxz+PKabo=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=MKD/dBHM3vp8Y6oUOMubo6DDs7GQmT3N/bXbgQ+TaOyNtlIJyCUvtabY7lvb6aO/0X mBH1kGjjkNP4xclX1EOYiT5RQyCkDgBOlpeav2HkvWAJ25ZSozL38G8R3M94EO4rgFfy wqrTmI3H3Ir+/iMhrqU7KReR7y3aVJzWr6ogD89lUS0S9vvMV0CKVpY+AnNsZEmMJdTB BaIvF/Qc7IbCVu/xklVpEdaiak8X3NoLxUnPE7TRd4lihGCxRL5X2UXkWeLSpMdDrE7p sFA2x4mtUxTCD2uDs7hULp2H2XiDUXbH+Y9sOEemH8jw2NLDGVhGt+nejFKJ4cCZngfp dTxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bNogvbta; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81978-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id mw10-20020a17090b4d0a00b00298e649da8csi4125645pjb.135.2024.02.26.09.26.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=bNogvbta; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81978-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81978-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1D2B6B2B613 for ; Mon, 26 Feb 2024 17:03:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F27A0137C58; Mon, 26 Feb 2024 16:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="bNogvbta" 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 ED15F135A43; Mon, 26 Feb 2024 16:54:00 +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=1708966442; cv=none; b=RpPsoo1lpPJKgoJ9RsAOxfDeY0nKzi6MzMnu4uQhYyM3mEanDN1yFrYIAZuNgoO+Q4nvvh3ftyQy1OMKPX2pQlYpOb24kXcQa95bxcduXbBzOxBfL2UfvxPBip2afqd2KXmEty8mdf65m5xqpQYypSABuXB0L7BirMEYL/axl+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966442; c=relaxed/simple; bh=6ORCo3+k9OdhTzhZOX/OvaI7dLnhbXmu+cXgKL7siCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rH8rSJr4QezWnrffgaKaJ9xD7KGs59WnnW2iCNMv6d/fEBp/pW89WvSTXJaCHy8K0M15K232LvBd4bhxifCYVWxqlC6D+BJ98ltUrGsFwQGDeqB5jzTNAQ53uMOJIrFI+iFfkVtmVgt4oe3lUCBMkMpBgrhuPYRqGdMUP4usISo= 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=bNogvbta; 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 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 41QG12KX018630; Mon, 26 Feb 2024 16:53:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=jHq/vBDBbZBSuhSZdVDjxpYwsAaHsSkR8YTxz+PKabo=; b=bNogvbtaSA5C+ilSm/CEZHEW6K4gJdQQcdVBLJuP1jYpYCU6gsh17yWs7cXC8vw8Rkk1 pRv8EW0IwA8VWfYC/zQgshUNkwUx2sX43OUiDv+mnm5qDwawY7DBjPu1AYfSKlvK+TIO 5TxqtP6gWrlNHpRc4pvQLZxFoqmKnIfs5yVk9HsHU5i7M5Dc88dtDhfkm55tOU/DJ6eq MUOfbC1rAWqfUB0na+0DmolXPxp7dHZ00HljXjEKR17ijRyXv/K7FvP33USJA6yT7vlG YTsPNA3zGfLQ5JfpNbbkASN7XdQAR2iT9+85HnKk8pLHOPLRHCpugp0SLoUaRuum8hJN wQ== 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 3wgw0k35dk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:50 +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 41QGgnTt021728; Mon, 26 Feb 2024 16:53:49 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfu5ytksd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:49 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrkUl21103192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:49 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA5BE58059; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E2025805D; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 30/31] i2c: fsi: Add boolean for skip stop command on abort Date: Mon, 26 Feb 2024 10:53:20 -0600 Message-Id: <20240226165321.91976-31-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: XYAcP_qZUe-CGT6_iSEUR-llXo9h3YtH X-Proofpoint-ORIG-GUID: XYAcP_qZUe-CGT6_iSEUR-llXo9h3YtH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791983216431671003 X-GMAIL-MSGID: 1791983216431671003 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 5f524fb6f0f8..33f4e64cb60b 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 Mon Feb 26 16:53:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 206802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2208079dyb; Mon, 26 Feb 2024 09:04:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBnlLuFhiMMygrSsIivLPEwNQPwZ27eOzFLI860tztjAPl3lMjM8PjZ6n74EO3YTiSCciqhZN6QVdaOYp0txsvz49dKw== X-Google-Smtp-Source: AGHT+IHosh9KDIXYHS2Na8+HJX+o8mTxH0NakVjnUeNYek6BEGbdPWkjct+dwuIeIizvaa4OX9Sk X-Received: by 2002:a81:a085:0:b0:608:cf2d:ee33 with SMTP id x127-20020a81a085000000b00608cf2dee33mr6539767ywg.15.1708967060351; Mon, 26 Feb 2024 09:04:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967060; cv=pass; d=google.com; s=arc-20160816; b=T8taZpAzK0BXV9gvK4EcrfyGpC+zBw3slLZJ1vy50FuqZOckkc+h9M+8Zrxk1/Kzyu fqp/K0CjRLu3Yf1/Jhxd+6CYNCcXpAvDQFRKghi24zW5TclDcc5sICfBhLc/55TtLWyG kuDqRUeSnY1bqxk5QGpXe3AwPL4U+l6arg7Bp9agKft0sfzlsTEFVFJsSnu5hZMoJsuH 5k8W6P3OfhC4eKojjsnAsxHlUAoXuW+dqbJGGXT1ZuPTsaMiH1Z1SKWM6il8rE1QQBdW TzwdMnEtxKPqZJ+DbNi3z486KInSfQHpHqgzeqa+tRgsCw1xuaDe7jIU/tsdGOg31qvk 05mg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GgJ7F+dcd0WCLJ0MXE682Wr0l+kLhInQlwRytq3asIY=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=X9g9qZ3RbuTxLnyHri+5q+YuFl794ZVFChPiJqn/3WNx0i+NSMFQOC676Xct7JP6iz Y9fxrFGjxZ2S3p5TUjQ0DJhI/DAuM8aBoeOdCGoUG0suuYecmccjQ0ppcdkPnpuYjgS6 Os0TNR8C7nPhYIqwb3MUNXp1RguwdkR7xE6cmbGOeQINjioaiwhWcc+WUH0fbP9KwnIc 3bBWN9WHJ/cY2OzkAAZ8c9Wk0Dh3UFutwFKbU89c7FlVg06XMqHtspqpvMI7Mr0pcu31 lbM3pskGRseCXMl0X4WtvS/7pxr+cxKVqt8vNPzEshGhLA4ZN0CWxUxY4DXKYjEZ44Sl c6hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=P54EyeA2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81982-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bx4-20020a05690c080400b00604b41a83bfsi1777736ywb.426.2024.02.26.09.04.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=P54EyeA2; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-81982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81982-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 15D991C21CCE for ; Mon, 26 Feb 2024 17:04:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 133771386BD; Mon, 26 Feb 2024 16:54:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="P54EyeA2" 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 800B712DDAA; Mon, 26 Feb 2024 16:54:04 +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=1708966446; cv=none; b=Mvy98iQnhxAldDpsKVd5EbxKoCPcDWDqxrlVBF6SJI4OVbCpZ/+VOojKPeMD9/Pb+ryr5DhWBM93ApJ6XuCrTori29rhwGsn9tbtL+d6uZkXtksS62aC+u6sG0u9KJFvqJFvw6eRP0Bt4Dzj/QSgvo99l9lVtwViVHOyh6EQLVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966446; c=relaxed/simple; bh=r7i6r1TAnXFKp6Ud7ZNcT3dqvowjChmj4bvNXv7VZl8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hSy0/3HzTvf79WoDNtm/ca5b99/sCewV9K5t4R+XPLvcZ1ZGSzjjrocpWGiuwRdOaG05XrgqHdZ4UwQAamBoiEOkmxFjYTwy2sQBZzx6Onfe90nRb5dQfIweSue6FW5EQ3RQGm/r0t626l0CHFMvu5Eo+enWEW1xu0Ulr0CNftw= 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=P54EyeA2; 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 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 41QG0xI6018527; Mon, 26 Feb 2024 16:53:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=GgJ7F+dcd0WCLJ0MXE682Wr0l+kLhInQlwRytq3asIY=; b=P54EyeA25/B979o2/+ncPKg3R9nWmMUTZFSKyKHQ1id5/Hwb0iHBxz1YHP464z97eU3v 07zpmjDJPO0o3RT8SzKsT6VCqV4DMaWIFU25tfMNsbe4xrfPrxcNHC4JvMKevAqA+eiX VYfS8+F2hsH9MdQQVjTwJvvdmjN1qRJ6E72JzGegSei32JJsg0pkyQY/IHJz6i1G0KJm HoG1lqA6ofUhm3Wr5d3CnfMoXppxnw2A2mTwZKZGvb+Gwc61oKrG8r2FXbjEk/1SmcEU Ul2Z3tcvPZs0hSuksIWRuYtuV89GW/Mywdz1etELosvVryoIn/g1OGRyCKane17x4RYq tw== 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 3wgw0k35e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:53 +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 41QFBCqU008147; Mon, 26 Feb 2024 16:53:50 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3wfv9m2a1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:50 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrlBa16122396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:49 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA70258063; Mon, 26 Feb 2024 16:53:47 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F155E5805D; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:46 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 31/31] i2c: fsi: Add interrupt support Date: Mon, 26 Feb 2024 10:53:21 -0600 Message-Id: <20240226165321.91976-32-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: boY5GV-6Za5peXFbMheOKAlx_RyZhqBD X-Proofpoint-ORIG-GUID: boY5GV-6Za5peXFbMheOKAlx_RyZhqBD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791981844280251631 X-GMAIL-MSGID: 1791981844280251631 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 33f4e64cb60b..096edeaa3312 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; @@ -707,6 +888,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 000000000000..691fb2adf454 --- /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 status: %08x", __entry->bus, __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 command: %08x", __entry->bus, __entry->command) +); + +#endif + +#include