From: Piyush Malgujar <pmalgujar@marvell.com>
To: <linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<andi.shyti@kernel.org>, <rric@kernel.org>
Cc: <cchavva@marvell.com>, <sgarapati@marvell.com>,
<jannadurai@marvell.com>, Piyush Malgujar <pmalgujar@marvell.com>
Subject: [PATCH v2 4/4] i2c: thunderx: Adding ioclk support
Date: Fri, 28 Jul 2023 05:00:04 -0700 [thread overview]
Message-ID: <20230728120004.19680-5-pmalgujar@marvell.com> (raw)
In-Reply-To: <20230728120004.19680-1-pmalgujar@marvell.com>
Adding support to use ioclk as reference clock if sclk not
present to make it SOC agnostic.
In case, it's not defined in dts/acpi table, use 800MHz as
default clock.
Signed-off-by: Piyush Malgujar <pmalgujar@marvell.com>
---
drivers/i2c/busses/i2c-thunderx-pcidrv.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
index 3dd5a4d798f99e9b5282360cf9d5840042fc8dcc..0f2a4a677762e832c10046a5702b21f6d13ba7c7 100644
--- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c
+++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
@@ -27,7 +27,7 @@
#define PCI_DEVICE_ID_THUNDER_TWSI 0xa012
-#define SYS_FREQ_DEFAULT 700000000
+#define SYS_FREQ_DEFAULT 800000000
#define TWSI_INT_ENA_W1C 0x1028
#define TWSI_INT_ENA_W1S 0x1030
@@ -99,7 +99,8 @@ static void thunder_i2c_clock_enable(struct device *dev, struct octeon_i2c *i2c)
i2c->sys_freq = clk_get_rate(i2c->clk);
} else {
/* ACPI */
- device_property_read_u32(dev, "sclk", &i2c->sys_freq);
+ if (device_property_read_u32(dev, "sclk", &i2c->sys_freq))
+ device_property_read_u32(dev, "ioclk", &i2c->sys_freq);
}
skip:
@@ -181,7 +182,6 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
if (!i2c->twsi_base)
return -EINVAL;
- thunder_i2c_clock_enable(dev, i2c);
ret = device_property_read_u32(dev, "clock-frequency", &i2c->twsi_freq);
if (ret)
i2c->twsi_freq = I2C_MAX_STANDARD_MODE_FREQ;
@@ -195,12 +195,12 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
if (ret < 0)
- goto error;
+ return ret;
ret = devm_request_irq(dev, pci_irq_vector(pdev, 0), octeon_i2c_isr, 0,
DRV_NAME, i2c);
if (ret)
- goto error;
+ return ret;
ret = octeon_i2c_init_lowlevel(i2c);
if (ret)
@@ -212,6 +212,9 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
*/
if (octeon_i2c_is_otx2(pdev) && IS_LS_FREQ(i2c->twsi_freq))
i2c->sys_freq = 100000000;
+ else
+ thunder_i2c_clock_enable(dev, i2c);
+
octeon_i2c_set_clock(i2c);
i2c->adap = thunderx_i2c_ops;
@@ -238,7 +241,8 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
return 0;
error:
- thunder_i2c_clock_disable(dev, i2c->clk);
+ if (!IS_LS_FREQ(i2c->twsi_freq))
+ thunder_i2c_clock_disable(dev, i2c->clk);
return ret;
}
--
2.17.1
next prev parent reply other threads:[~2023-07-28 12:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 12:00 [PATCH v2 0/4] i2c: thunderx: Marvell thunderx i2c changes Piyush Malgujar
2023-07-28 12:00 ` [PATCH v2 1/4] i2c: thunderx: Clock divisor logic changes Piyush Malgujar
2023-07-28 12:00 ` [PATCH v2 2/4] i2c: thunderx: Add support for High speed mode Piyush Malgujar
2023-07-28 12:00 ` [PATCH v2 3/4] i2c: octeon: Handle watchdog timeout Piyush Malgujar
2023-07-28 12:00 ` Piyush Malgujar [this message]
2023-08-05 12:06 ` [PATCH v2 0/4] i2c: thunderx: Marvell thunderx i2c changes Andi Shyti
2023-10-24 20:14 ` Andi Shyti
2023-10-26 12:54 ` Piyush Malgujar
2024-01-04 22:06 ` Andi Shyti
2024-01-05 11:10 ` Robert Richter
2024-02-08 21:05 ` Andi Shyti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230728120004.19680-5-pmalgujar@marvell.com \
--to=pmalgujar@marvell.com \
--cc=andi.shyti@kernel.org \
--cc=cchavva@marvell.com \
--cc=jannadurai@marvell.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rric@kernel.org \
--cc=sgarapati@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox