{"id":1936119,"url":"http://patchwork.ozlabs.org/api/patches/1936119/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-aspeed/patch/20240516181907.3468796-27-eajames@linux.ibm.com/","project":{"id":57,"url":"http://patchwork.ozlabs.org/api/projects/57/?format=json","name":"Linux ASPEED SoC development","link_name":"linux-aspeed","list_id":"linux-aspeed.lists.ozlabs.org","list_email":"linux-aspeed@lists.ozlabs.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20240516181907.3468796-27-eajames@linux.ibm.com>","list_archive_url":null,"date":"2024-05-16T18:18:53","name":"[v3,26/40] i2c: fsi: Calculate clock divider from local bus frequency","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e8c1b495a2a0f96f05830ec0a2d698a1cd7f06a5","submitter":{"id":74989,"url":"http://patchwork.ozlabs.org/api/people/74989/?format=json","name":"Eddie James","email":"eajames@linux.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-aspeed/patch/20240516181907.3468796-27-eajames@linux.ibm.com/mbox/","series":[{"id":407101,"url":"http://patchwork.ozlabs.org/api/series/407101/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-aspeed/list/?series=407101","date":"2024-05-16T18:18:31","name":"fsi: Add interrupt support","version":3,"mbox":"http://patchwork.ozlabs.org/series/407101/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1936119/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1936119/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-aspeed@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","linux-aspeed@lists.ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=sBJAxE5Z;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=sBJAxE5Z;\n\tdkim-atps=neutral","lists.ozlabs.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com","lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=sBJAxE5Z;\n\tdkim-atps=neutral","lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com\n (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n envelope-from=eajames@linux.ibm.com; receiver=lists.ozlabs.org)"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4VgJL56RWWz1yfq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 May 2024 04:20:29 +1000 (AEST)","from boromir.ozlabs.org (localhost [IPv6:::1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4VgJL54GWGz3fs2\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 17 May 2024 04:20:29 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n [148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4VgJJw0hxTz3fpX;\n\tFri, 17 May 2024 04:19:27 +1000 (AEST)","from pps.filterd (m0356517.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 44GICPfw024570;\n\tThu, 16 May 2024 18:19:19 GMT","from ppma23.wdc07v.mail.ibm.com\n (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y5q79g0bb-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tThu, 16 May 2024 18:19:19 +0000","from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1])\n\tby ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id\n 44GHkRCF006189;\n\tThu, 16 May 2024 18:19:18 GMT","from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4])\n\tby ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3y2mgmud37-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tThu, 16 May 2024 18:19:18 +0000","from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com\n [10.241.53.104])\n\tby smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 44GIJFjv49807692\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tThu, 16 May 2024 18:19:17 GMT","from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 59FA858075;\n\tThu, 16 May 2024 18:19:15 +0000 (GMT)","from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 1B4D658077;\n\tThu, 16 May 2024 18:19:15 +0000 (GMT)","from slate16.aus.stglabs.ibm.com (unknown [9.61.107.19])\n\tby smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP;\n\tThu, 16 May 2024 18:19:15 +0000 (GMT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com;\n h=from : to : cc : subject\n : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding; s=pp1;\n bh=n2ELCBKlduOnR5wTkTQugicJX8taWF2bAtKMB7UJJcw=;\n b=sBJAxE5ZoH6IdcpM1X7hY97NnK7sToMDpUx1x6/cCDi60IPOBRJU3mVdmt4wI+lppWE0\n PLZhSbMCzsxktvtrR2CTzwNkW6Gub0pCFMzz880+iD1j8Sn0lhwNx48SgFgpz27ezyhk\n FVaNeqbPjkhsoxirDtTGXb3PpkywGWHiVZMaz9dJbrHT6tgwR8Ilrq8ieQnC9G+iWZA+\n M/zYy+BvqAFHMPP/WS9gU+SpVKBFL/HELiYMi3v3pJ2QSbO6pVE8WxTxPLLgu6yl4Len\n 3V/7OVHD22NG2MytKVbhwIObh/ZsJvX28x9IeUOdgOGaicRAXvU+zdXVHW06G1uKA9OF 1g==","From":"Eddie James <eajames@linux.ibm.com>","To":"linux-fsi@lists.ozlabs.org","Subject":"[PATCH v3 26/40] i2c: fsi: Calculate clock divider from local bus\n frequency","Date":"Thu, 16 May 2024 13:18:53 -0500","Message-Id":"<20240516181907.3468796-27-eajames@linux.ibm.com>","X-Mailer":"git-send-email 2.39.3","In-Reply-To":"<20240516181907.3468796-1-eajames@linux.ibm.com>","References":"<20240516181907.3468796-1-eajames@linux.ibm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-TM-AS-GCONF":"00","X-Proofpoint-ORIG-GUID":"bPWYMTGIlqxK3UuxeMX-IKBR1b99g0vy","X-Proofpoint-GUID":"bPWYMTGIlqxK3UuxeMX-IKBR1b99g0vy","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26\n definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n lowpriorityscore=0\n malwarescore=0 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=977\n impostorscore=0 spamscore=0 priorityscore=1501 bulkscore=0 clxscore=1015\n mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1\n engine=8.12.0-2405010000 definitions=main-2405160132","X-BeenThere":"linux-aspeed@lists.ozlabs.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux ASPEED SoC development <linux-aspeed.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linux-aspeed>,\n <mailto:linux-aspeed-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linux-aspeed/>","List-Post":"<mailto:linux-aspeed@lists.ozlabs.org>","List-Help":"<mailto:linux-aspeed-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linux-aspeed>,\n <mailto:linux-aspeed-request@lists.ozlabs.org?subject=subscribe>","Cc":"andi.shyti@kernel.org, linux-aspeed@lists.ozlabs.org, jk@ozlabs.org,\n alistair@popple.id.au, linux-kernel@vger.kernel.org,\n linux-spi@vger.kernel.org, broonie@kernel.org, andrew@codeconstruct.com.au,\n linux-i2c@vger.kernel.org","Errors-To":"linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"Linux-aspeed\"\n <linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"},"content":"Use the new FSI device local bus clock to calculate the proper\ni2c clock divder and look up an optional clock-frequency property\nfrom device tree. Change the default clock divider to 7 now that\nthe default local bus clock divider has been reduced as well.\n\nSigned-off-by: Eddie James <eajames@linux.ibm.com>\n---\nChanges since v2:\n - Change minimum clock div to 3\n - Use DIV_ROUND_UP instead of re-implementing it\n - Better logic for checking for clock-frequency property\n\n drivers/i2c/busses/i2c-fsi.c | 20 ++++++++++++++++++--\n 1 file changed, 18 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c\nindex 10332693edf0d..2404ace8c56fa 100644\n--- a/drivers/i2c/busses/i2c-fsi.c\n+++ b/drivers/i2c/busses/i2c-fsi.c\n@@ -27,7 +27,8 @@\n \n #define FSI_ENGID_I2C\t\t0x7\n \n-#define I2C_DEFAULT_CLK_DIV\t6\n+#define I2C_DEFAULT_CLK_DIV\t7\n+#define I2C_DEFAULT_CLK_RATE\t400000\n \n /* i2c registers */\n #define I2C_FSI_FIFO\t\t0x00\n@@ -150,6 +151,7 @@ struct fsi_i2c_master {\n \tu8\t\t\tfifo_size;\n \tstruct list_head\tports;\n \tstruct mutex\t\tlock;\n+\tu32\t\t\tclock_div;\n };\n \n struct fsi_i2c_port {\n@@ -194,7 +196,7 @@ static int fsi_i2c_dev_init(struct fsi_i2c_master *i2c)\n \tif (rc)\n \t\treturn rc;\n \n-\tmode |= FIELD_PREP(I2C_MODE_CLKDIV, I2C_DEFAULT_CLK_DIV);\n+\tmode |= FIELD_PREP(I2C_MODE_CLKDIV, i2c->clock_div);\n \trc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode);\n \tif (rc)\n \t\treturn rc;\n@@ -680,6 +682,7 @@ static int fsi_i2c_probe(struct device *dev)\n \tstruct fsi_i2c_port *port;\n \tstruct device_node *np;\n \tu32 port_no, ports, stat;\n+\tu32 lbus;\n \tint rc;\n \n \ti2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);\n@@ -689,6 +692,19 @@ static int fsi_i2c_probe(struct device *dev)\n \tmutex_init(&i2c->lock);\n \ti2c->fsi = to_fsi_dev(dev);\n \tINIT_LIST_HEAD(&i2c->ports);\n+\ti2c->clock_div = I2C_DEFAULT_CLK_DIV;\n+\n+\tlbus = fsi_device_local_bus_frequency(i2c->fsi);\n+\tif (lbus) {\n+\t\tu32 clock;\n+\n+\t\tif (device_property_read_u32(dev, \"clock-frequency\", &clock) || !clock)\n+\t\t\tclock = I2C_DEFAULT_CLK_RATE;\n+\n+\t\ti2c->clock_div = DIV_ROUND_UP(DIV_ROUND_UP(lbus, clock), 4) - 1;\n+\t\tif (i2c->clock_div <= 2)\n+\t\t\ti2c->clock_div = 3;\n+\t}\n \n \trc = fsi_i2c_dev_init(i2c);\n \tif (rc)\n","prefixes":["v3","26/40"]}