Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp146535lqb; Tue, 16 Apr 2024 11:09:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxV2YAIeWz7cg2rY8lyz0s8E8/SSCVJdutJ2l+YC4iT16eZEFDyMr5ZXGE6YomifbJB97BxLMYVqtpBYK42X75YFroRQQqo5KmGXkvfQ== X-Google-Smtp-Source: AGHT+IFK7pcTLC7hmYUlzCc4Et0zdsrOsjB+xhMZQ9YcHq2aeQtzFBxPALUnONHOkk5fV3xGQSix X-Received: by 2002:a17:903:20f:b0:1e3:cf18:7334 with SMTP id r15-20020a170903020f00b001e3cf187334mr10325869plh.27.1713290983381; Tue, 16 Apr 2024 11:09:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713290983; cv=pass; d=google.com; s=arc-20160816; b=QzrtTvnAIHdD2m28syt7YLkjVPbZQLJUymTbCCIecbEcensmCS3HeREeY0YQF4w4cu obugJJSdoaAyTwffgqt51MTGTxD/oXbwsYjRLbfDRu0AYwl/cuSg5DnfRic+94OWjQSs J11Iwew2YHBl+Qd5MflGfOySSEbmrxHilSXO97jaWk7cAicWskafaygc1I02PDaW5WhH whakWI/iVgSc+VICb8ay0g1wTdADFpkpgK3HtgKBh1OXmMcsFuI/YND2dislUsJQ6q0R XTEULEEsAA0or9wprxgHVybs+HJfmjVHRLCIs9vqe5eLrDmz1QZQFpEPqFB41Ms8RpAT tXJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=jfBrONQQ7jEqgKW5KCcnvgp1KEoPk8Do22dELHBXnrQ=; fh=GjufBiP4rwaY0vJf3/JqOhV3RPGxFQsh/u05gJkwe9s=; b=qiWhMSxjcvi6H0cHAAEufaC+ygwaOiff7z32DNoLuUA8keMcuMQjB2qIokFyCBpjZl tJ1eKpmeHIj70gVObxiPhliCXikVRZcf/0dUSMJOPGevknQKRRt3vtvkmNZpM8rJiynm F5bgq6bbLL02md9g5YFOEeiGZMKI7qvJIyhR74Q1s4SIroA/edaCosDIzMumC3yJNw5j Y92Q14+CTpGwkyZueHbMZxl361hhqIpnfntsE8N2m9x1yZh4zjv85ppbaikda0kABVUa X3QPLR1AcH9bFZhTJH1bszxWL6iI20P9mtNHpslSTSL6WZAGCbIkLe4gibtEx2H9od0G XxZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lJVGnBEw; 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-147353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147353-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y23-20020a17090264d700b001e49ad5a690si10075021pli.114.2024.04.16.11.09.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:09:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147353-linux.lists.archive=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=lJVGnBEw; 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-147353-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147353-linux.lists.archive=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 B0B5D284835 for ; Tue, 16 Apr 2024 18:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81578134CD4; Tue, 16 Apr 2024 18:09:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lJVGnBEw" 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 5F25A132C1F; Tue, 16 Apr 2024 18:09:27 +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=1713290969; cv=none; b=W00b2tOijeKEUUYAEju4khSb3ZC2jHg4T97VU+kRaUCiognwDmuIroHyeweG0NRbLzoqhl/+8DLohZinCX9UjV7Osq/85fhHMIjfyEBOwnSUr8xeu12kijTSSDFyyP1h6Y1HiYxFD6bNBxirdBCR0Amq7BLHAHkqFaB2+P8uNv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713290969; c=relaxed/simple; bh=QBJT0fvjo/sByvVdqWhfu7C0uSPTcABMfRn0BIp6lpA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cmglIK26F0UOUbhbfnlhiHgvDnENWNMLX3XHlG2l4pgocA4oDKuxjUS4a3AbaL3sbydaaulXgXXO9Lt9K1f4BS0PIyy1VVE3i2nClPCpl7JncC8NsPk4+yiuda7nmeNDSMushq1kLKCQeEMFWthEe/G1ERcUZtIG6cc0AcX2WM8= 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=lJVGnBEw; 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 (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43GI5beo022066; Tue, 16 Apr 2024 18:09:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=jfBrONQQ7jEqgKW5KCcnvgp1KEoPk8Do22dELHBXnrQ=; b=lJVGnBEwDgreOF3Ue6jX6Ov4xleZ8XKnqDGGvotfYVgKjraJtjPtvEkUPmlDCaPrvhxC n83sDnZFDxzCG7B4yBdG+DzpSl3dEkDAOFnftgauf9Pe757FUYGHxTjNa43UhC7/r4H1 6ymg9CejrR7HC2vxaQ1TE5aXEC+A58tOxI6OGFk/B8bMFfwhB26o5vms5TQ9WBwnZDX6 +9t4Gv4ERZE6Dpo6nuPI1/YjsuJCXmLf8Y1WNW8VTqX8GZPB+gd7l1aqaZxQt/ydW42X 65E+aOSPkF7B/4QdP+nK0ScSdgVqIaKB9+MLHjJdye21yJglgebflEha/2JKU4P7Osti qw== 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 3xhwrr032h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 18:09:08 +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 43GG05Xg015835; Tue, 16 Apr 2024 18:09:07 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xg5vm7kt8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 18:09:07 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43GI957s22807200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2024 18:09:07 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DCCA5805E; Tue, 16 Apr 2024 18:09:05 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E38135805A; Tue, 16 Apr 2024 18:09:04 +0000 (GMT) Received: from [9.61.157.174] (unknown [9.61.157.174]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 16 Apr 2024 18:09:04 +0000 (GMT) Message-ID: <2474f02c-c835-4691-b531-62c8c747aede@linux.ibm.com> Date: Tue, 16 Apr 2024 13:09:04 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 25/31] i2c: fsi: Calculate clock divider from local bus frequency To: Andi Shyti Cc: linux-fsi@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, 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 References: <20240226165321.91976-1-eajames@linux.ibm.com> <20240226165321.91976-26-eajames@linux.ibm.com> Content-Language: en-US From: Eddie James In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: QRXN4cZro-l8ZSyMN11WgV7XKQPY7orO X-Proofpoint-ORIG-GUID: QRXN4cZro-l8ZSyMN11WgV7XKQPY7orO 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-04-16_16,2024-04-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1011 suspectscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404160113 On 4/15/24 17:11, Andi Shyti wrote: > Hi Eddie, > >> @@ -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; > I don't see the need for initialization. Does device_property_read_u32 set clock if the property isn't found? If not, it needs to be initialized here. Or I can set it in an else statement from device_property_read_u32. > >> + >> + if (!device_property_read_u32(dev, "clock-frequency", &clock)) { >> + if (!clock) >> + clock = I2C_DEFAULT_CLK_RATE; >> + } > no need for brackets. Perhaps not, but checkpatch didn't complain, and I personally like brackets if multiple lines are included. > >> + >> + // i2c clock rate = local bus clock / (4 * (i2c clock div + 1)) > You forgot to remove this. I actually meant to leave that comment to explain how the clock rate is calculated, as the reverse calculation in the code is a little more confusing. > > Andi > >> + i2c->clock_div = (((lbus + (clock - 1)) / clock) / 4) - 1; >> + } >> >> rc = fsi_i2c_dev_init(i2c); >> if (rc) >> -- >> 2.39.3 >>