{"id":2215654,"url":"http://patchwork.ozlabs.org/api/patches/2215654/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260325011852.19079-3-wanghongliang@loongson.cn/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260325011852.19079-3-wanghongliang@loongson.cn>","list_archive_url":null,"date":"2026-03-25T01:18:52","name":"[v1,2/2] i2c: ls2x: Add clock-input and clock-div properties parsing","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"4fa3073d11aeee31b65b4f71df6838887c625bce","submitter":{"id":92622,"url":"http://patchwork.ozlabs.org/api/people/92622/?format=json","name":"Hongliang Wang","email":"wanghongliang@loongson.cn"},"delegate":{"id":149066,"url":"http://patchwork.ozlabs.org/api/users/149066/?format=json","username":"cazzacarna","first_name":"Andi","last_name":"Shyti","email":"andi.shyti@kernel.org"},"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260325011852.19079-3-wanghongliang@loongson.cn/mbox/","series":[{"id":497370,"url":"http://patchwork.ozlabs.org/api/series/497370/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=497370","date":"2026-03-25T01:18:52","name":"i2c: ls2x: Add clock- related properties and parsing","version":1,"mbox":"http://patchwork.ozlabs.org/series/497370/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215654/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215654/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-i2c+bounces-16724-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-i2c@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org;\n envelope-from=linux-i2c+bounces-16724-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=114.242.206.163","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=loongson.cn"],"Received":["from sin.lore.kernel.org (sin.lore.kernel.org\n [IPv6:2600:3c15:e001:75::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgTZt6Dm2z1xy3\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 12:19:18 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 08E243030366\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 01:19:15 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 893E3268690;\n\tWed, 25 Mar 2026 01:19:14 +0000 (UTC)","from mail.loongson.cn (mail.loongson.cn [114.242.206.163])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 616D726CE39;\n\tWed, 25 Mar 2026 01:19:12 +0000 (UTC)","from loongson.cn (unknown [10.20.42.101])\n\tby gateway (Coremail) with SMTP id _____8BxksANOMNpwWkeAA--.27798S3;\n\tWed, 25 Mar 2026 09:19:09 +0800 (CST)","from loongson-pc.loongson.cn (unknown [10.20.42.101])\n\tby front1 (Coremail) with SMTP id qMiowJBxLMIIOMNpi6xcAA--.44576S4;\n\tWed, 25 Mar 2026 09:19:08 +0800 (CST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774401554; cv=none;\n b=b8TFyUUnpuBEvoCpxC4I+dwJ9oyInbKNX7P8HV8k0lWXwefmvgdWTqoVdoBstPuesZww/bVIWBeQE7xzWwAxA6AzazILgLOF4ZHMbkJwx68iim10+/9NFOjzIKbhJSonzopaQ3I+JqWaoosFS1n+HmbVEHT2bK+EHc3oSX4/uWU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774401554; c=relaxed/simple;\n\tbh=Rg/Bc9YdfMuK7caX3Zt/dQAF6/dluLBBw3SnFSIs3lk=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=Qf/awwUeGUvbzWzDhde4S7JTblPSwt4odTMNpwBLMLcasnrqWRitTme09qGAzc9EJrWYgwLVJGVJ0AziLUdR8ht+2sBZAO7woXbfkzUdAT7KDjJ4fgY6RnYbqT8BHuQ+RQnInEHIhaSHOtFlhxmAzuC8AEfu0+9DKXv5Qhcj3Mw=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=loongson.cn;\n spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163","From":"Hongliang Wang <wanghongliang@loongson.cn>","To":"Binbin Zhou <zhoubinbin@loongson.cn>,\n\tAndi Shyti <andi.shyti@kernel.org>,\n\tRob Herring <robh@kernel.org>,\n\tKrzysztof Kozlowski <krzk+dt@kernel.org>,\n\tConor Dooley <conor+dt@kernel.org>,\n\tHongliang Wang <wanghongliang@loongson.cn>","Cc":"linux-i2c@vger.kernel.org,\n\tdevicetree@vger.kernel.org,\n\tloongarch@lists.linux.dev","Subject":"[PATCH v1 2/2] i2c: ls2x: Add clock-input and clock-div properties\n parsing","Date":"Wed, 25 Mar 2026 09:18:52 +0800","Message-Id":"<20260325011852.19079-3-wanghongliang@loongson.cn>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20260325011852.19079-1-wanghongliang@loongson.cn>","References":"<20260325011852.19079-1-wanghongliang@loongson.cn>","Precedence":"bulk","X-Mailing-List":"linux-i2c@vger.kernel.org","List-Id":"<linux-i2c.vger.kernel.org>","List-Subscribe":"<mailto:linux-i2c+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-i2c+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"qMiowJBxLMIIOMNpi6xcAA--.44576S4","X-CM-SenderInfo":"pzdqwxxrqjzxhdqjqz5rrqw2lrqou0/","X-Coremail-Antispam":"1Uk129KBj93XoW7Cw45Zr15Gryktw4UWryDJwc_yoW8Kr1xpF\n\tZ8Kan5Kr1qkF1S9r4vg347Xry5tws5JrZxGr17AwnrWanxXr1kXFy3tasYkFWkXF1xZa95\n\tZ3yqkr4DGF15AwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa\n\tsCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU\n\t0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2\n\tIYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v\n\te4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI\n\t0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_\n\tGr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I\n\t8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AK\n\txVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64\n\tvIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G\n\tjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2I\n\tx0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK\n\t8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I\n\t0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU7MmhUUUUU"},"content":"From: wanghongliang <wanghongliang@loongson.cn>\n\nOn 3A/7A/2K platform, the input clock of i2c controller and\nthe divisor of input clock maybe different, so define the\nclock-input and clock-div properties in i2c controller node\ndescription of dts or acpi. clock-input describes the input\nclock of i2c controller and clock-div describes the clock\ndivisor of the input clock.\n\nThe formulas is\nPrcescale = (clock-input * 10) / (clock-div * t->bus_freq_hz) - 1\n\nThe value of clock-input and clock-div on different platforms are\nlisted below:\n\n1.7A1000/7A2000:\nclock-input = 80MHZ\nclock-div = 50\n\n2.3A5000/3C5000/3A6000/3C6000:\nclock-input = 100MHZ\nclock-div = 40\n\n3.2K0500/2K1000LA/2K2000:\nclock-input = 100MHZ\nclock-div = 40\n\n4.2K3000:\nclock-input = 100MHZ\nclock-div = 55\n\nSigned-off-by: wanghongliang <wanghongliang@loongson.cn>\n---\n drivers/i2c/busses/i2c-ls2x.c | 7 ++++++-\n 1 file changed, 6 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/i2c/busses/i2c-ls2x.c b/drivers/i2c/busses/i2c-ls2x.c\nindex b475dd27b7af..08c242e5fd75 100644\n--- a/drivers/i2c/busses/i2c-ls2x.c\n+++ b/drivers/i2c/busses/i2c-ls2x.c\n@@ -96,6 +96,7 @@ static irqreturn_t ls2x_i2c_isr(int this_irq, void *dev_id)\n static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)\n {\n \tu16 val;\n+\tu32 pclk, div;\n \tstruct i2c_timings *t = &priv->i2c_t;\n \tstruct device *dev = priv->adapter.dev.parent;\n \tu32 acpi_speed = i2c_acpi_find_bus_speed(dev);\n@@ -107,12 +108,16 @@ static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)\n \telse\n \t\tt->bus_freq_hz = LS2X_I2C_FREQ_STD;\n \n+\tif (!device_property_read_u32(dev, \"clock-input\", &pclk) &&\n+\t    !device_property_read_u32(dev, \"clock-div\", &div) && div != 0)\n+\t\tval = (pclk * 10) / (div * t->bus_freq_hz) - 1;\n+\telse\n+\t\tval = LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1;\n \t/*\n \t * According to the chip manual, we can only access the registers as bytes,\n \t * otherwise the high bits will be truncated.\n \t * So set the I2C frequency with a sequential writeb() instead of writew().\n \t */\n-\tval = LS2X_I2C_PCLK_FREQ / (5 * t->bus_freq_hz) - 1;\n \twriteb(FIELD_GET(GENMASK(7, 0), val), priv->base + I2C_LS2X_PRER_LO);\n \twriteb(FIELD_GET(GENMASK(15, 8), val), priv->base + I2C_LS2X_PRER_HI);\n }\n","prefixes":["v1","2/2"]}