From patchwork Tue Feb 6 11:43:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piyush Malgujar X-Patchwork-Id: 197360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1485906dyb; Tue, 6 Feb 2024 04:01:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9D8vnaIo9eUfE8paumwMT0BP0ttCbtUH49TcfZCBDODPIor1R/nYuUWKxRcWYuIjwzV6h X-Received: by 2002:a05:6808:2116:b0:3bf:d136:62bd with SMTP id r22-20020a056808211600b003bfd13662bdmr2393338oiw.32.1707220880050; Tue, 06 Feb 2024 04:01:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707220880; cv=pass; d=google.com; s=arc-20160816; b=hKWaSWRVEFHXVGB4+gi7QzugS8Uw5izt1u6ERVxNNeDTLKWElTTbnccq62IdO/Od8d +GOYp/Z1lJHLzKxgeMV6ulmdklZCGeU2FP0Wxo+YmwUBz6u53hIaguijYZ9npYhAEhwe M/LI0zI0afPqxhmtohAMRQcciyAyqkz7Y/+5Q3ff95iSp2jjdpLlAaQzHQvQdH1+lAaO vNcjgNbIBMs8zZ/6sC4eHx6896yc1BuZS7VFJdetVj0s1L0fF7OhjbxX4JpAORoVMgA6 +H4rsfXyPAmDJmfQKSx6uz1/35NYvU2Pl1DnPJOQOKplcxIo/tDbLPx1BT+lZI7sShf+ F7/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=I7YJVFpHyhttKaVQSn+im9bTu9lSBp0OqXLztLyaCtY=; fh=+hW3MtQl/yR3/KP6cmTDji8FPPB57ns5y2h83Iij0Q0=; b=UnVUsVu6ixebmkekuXDZRCm8pBZLd66vat/S/X5TiLkDgA1YDS2lxDfXnHuUIdROPe 4/gK8OFJx/yY5z1ihw4XnCwFRXDzJSiMXZBuZMcSFNutdtV99U86mpb7ripqmxvc8Zxd 5eMy8Ei5mQ21Ub7cwC9q48rvwZWBL7ZhAW5T9ji4Stdcas6mVt0RzWg3P+1yv2Zkw9KF hwyQMJG3vrzBTrKFQAPMU0BbFm0WNEVgiU8a0UajH6zeFaiXvKlyPqIcDdKL2kMXRF+u VjwbQI2METskyz280CsSE1bSDTqnxwsa8EZh6lFldcVO5HXoQlu95hfGEUWQ3NdHX580 jWIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=bJfVVmN2; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-54825-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54825-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com X-Forwarded-Encrypted: i=1; AJvYcCW6vtTBwOSdGxAzYKzsNhapeiS5KxVBZmms2Ap0oCQYWOAYW99SLc9OTAhEw/M9zcz58rdwPKHdYRdGFCt0KMuSyYFjrQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o21-20020a05620a2a1500b007859019f10dsi1132528qkp.203.2024.02.06.04.01.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 04:01:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54825-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=@marvell.com header.s=pfpt0220 header.b=bJfVVmN2; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-54825-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54825-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.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 BC2C71C20AE8 for ; Tue, 6 Feb 2024 12:01:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CC30132C2C; Tue, 6 Feb 2024 11:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="bJfVVmN2" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 7CADF132C2B; Tue, 6 Feb 2024 11:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707219921; cv=none; b=kszi8mhfZlftwtHdFn4OlizFdmy4h2R4j9vsGfpqCORhFrP6QYp1tS09TJBChT+43FIq1m2dX3pNHfW3CFE6VQ5YEVA5utCKQd78wloUqBj1ukrcWrOrQDhiJc4vWwIfpWRnpZntok1CJHellmTAvbWwEMaINI7pitjQir9Fni0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707219921; c=relaxed/simple; bh=CvtzeV3LJoPwbA5d/XDUSj8ICkXD0P1E718iT2JTfg8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OxMRgoA1XutswAHQg1g/VuPAnfaMqvfB4O7uT8q0Uxt4wHkO+74/fYdwa9KHasMsuNAMFET/zy5gfl1HfYoVVcrG/J5XlI7OjbmRrRnbV2aB6vj/6i7Yc9wMxINhPmz217XAwqhzqPcLgd4Tof0ST2RCxs5hUv27EI0pSXOO+d0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=bJfVVmN2; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 416B5pjH027405; Tue, 6 Feb 2024 03:45:16 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=I7YJVFpHyhttKaVQSn+im9bTu9lSBp0OqXLztLyaCtY=; b=bJf VVmN27517dICSL874oGjKtDHMq5puiyUCjqonmrgFWzrxh8rcXSKH10NZ1PeW1lf 40izrpQFdeNKO7bdFeHCvt6/+32X9Cn10uCu+jzQwu9Ud73evXKFpf1jM1BsUWMA P3Edr9NICGZ3OWjWtTOOwdUpeNWku7zfLB/Qkt1K/pjpO6eI1WV3SHolB4ZQqPZN rA4vY9UkCJi+J0N8iep5An+O2au0AuaAgS2fEurOUPrFUFDeLIgLtnN8tvKkoE1H 2PULZ/q4R2j1bq93/Ge8701F6AzVFXVdvQYo0ph2O6cMf3EyEjNn668uqysxL/kf Ep+C9bJRHF+IzCjpgiw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3w38u81xvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 06 Feb 2024 03:45:16 -0800 (PST) Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 6 Feb 2024 03:45:14 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 6 Feb 2024 03:45:14 -0800 Received: from localhost.localdomain (unknown [10.110.150.250]) by maili.marvell.com (Postfix) with ESMTP id 0E5723F7088; Tue, 6 Feb 2024 03:45:14 -0800 (PST) From: Piyush Malgujar To: , , CC: , , , Piyush Malgujar Subject: [PATCH v3 4/4] i2c: thunderx: Adding ioclk support Date: Tue, 6 Feb 2024 03:43:49 -0800 Message-ID: <20240206114349.32197-5-pmalgujar@marvell.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240206114349.32197-1-pmalgujar@marvell.com> References: <20240206114349.32197-1-pmalgujar@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: z5SwNWQCHvtpq0aAnR00QFbgnzIt3PiB X-Proofpoint-GUID: z5SwNWQCHvtpq0aAnR00QFbgnzIt3PiB 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-06_04,2024-01-31_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790150841550104576 X-GMAIL-MSGID: 1790150841550104576 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 --- drivers/i2c/busses/i2c-thunderx-pcidrv.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c index 31f11b77ab663626967c86086a03213876bf4a07..15cf794a776533d1b0dbb08597fc0d9acf791b44 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 OTX2_REF_FREQ_DEFAULT 100000000 #define TWSI_INT_ENA_W1C 0x1028 @@ -100,7 +100,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: @@ -182,7 +183,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; @@ -196,12 +196,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) @@ -213,6 +213,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 = OTX2_REF_FREQ_DEFAULT; + else + thunder_i2c_clock_enable(dev, i2c); + octeon_i2c_set_clock(i2c); i2c->adap = thunderx_i2c_ops; @@ -240,6 +243,8 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev, error: thunder_i2c_clock_disable(dev, i2c->clk); + if (!IS_LS_FREQ(i2c->twsi_freq)) + thunder_i2c_clock_disable(dev, i2c->clk); return ret; }