Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp416455pxf; Wed, 31 Mar 2021 06:43:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoMfkKHAAw0hdGiYWwFnFgWPis94d3RqKg6JxuT3SO90+GnQ/Cd22povqTfCF5aILGkfaD X-Received: by 2002:a17:906:78d:: with SMTP id l13mr3615572ejc.97.1617198202693; Wed, 31 Mar 2021 06:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617198202; cv=none; d=google.com; s=arc-20160816; b=kjGM79bjT/OHCOz/PcHT1IkbvzzG3xZA46N4x8Xhqjet48GzE7P174RLFoWXinK1Q9 0kacnAA6QKc3qqKx00B41aeNGnDONzIUGcuYHhlKJEJOjFC2ClcQ40LnjIN6GmLt7MqK MLSxmX/PBgGCW37TSbN1hf4pGqcEhZH83uPb0oqu6kWPnBbSEk6x2cbdzaii8+gBhDAK NN9Qywh9FHBwab8vH79UHIyMwdCQGAKquv8Fxc08Sdkxf1BuPzTwR+8xI2Y+sm5vkO0N wwEZBvSQ3w5UJsrBxMdjU23fA3muj4niBqM6zKMLTmIZc3RyaLt2l67T8hhfm07Guy75 saPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=moDQHYGNS5G49pTP75HCu1tnpD6hrKnaPjrern9xfsY=; b=rwmYJ4nyKIO+n33uoeXxtY87Skh41Tu6vNhrR5J9C3YIqqyD2YV9LkMPw0Dvdvy7MB qOg1zAk+J/rPe9rgmT24myozTq+uEbNwrEh8+uPkKS8AtjRTURPfmcGng0UE50TlkEog fPnhKZMc19/9fQZO+k4qg2WNwHoSKIGaOuPvq/ocIX03IEQLLrnoawsLoEoSI9Wg+mhZ uBb0P/FL1nDvLj9P4j+t1B3t/FddmQPDk7afp7/MMYClsFdGtAr4TM412M3eTpNvPH+L JCvt/G5RmJeWTTIW7ehAEcyoRwb095Ogo2caNrkGGXrISs2p6RwDnNr2cMvtfT7TOaz7 f25g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gy13si1755103ejb.397.2021.03.31.06.43.00; Wed, 31 Mar 2021 06:43:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236017AbhCaNjq (ORCPT + 99 others); Wed, 31 Mar 2021 09:39:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:15418 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235924AbhCaNjR (ORCPT ); Wed, 31 Mar 2021 09:39:17 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4F9S6b71TSzlWpC; Wed, 31 Mar 2021 21:37:27 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Wed, 31 Mar 2021 21:39:00 +0800 From: Yicong Yang To: , , , , CC: , , , , , , , , , Subject: [PATCH v6 2/5] i2c: core: add api to provide frequency mode strings Date: Wed, 31 Mar 2021 21:36:27 +0800 Message-ID: <1617197790-30627-3-git-send-email-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617197790-30627-1-git-send-email-yangyicong@hisilicon.com> References: <1617197790-30627-1-git-send-email-yangyicong@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some I2C drivers like Designware and HiSilicon will print the bus frequency mode information, so add a public one that everyone can make use of. Tested-by: Jarkko Nikula Reviewed-by: Jarkko Nikula Reviewed-by: Andy Shevchenko Signed-off-by: Yicong Yang --- include/linux/i2c.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 10bd0b0..7268180 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -47,6 +47,26 @@ typedef int (*i2c_slave_cb_t)(struct i2c_client *client, #define I2C_MAX_HIGH_SPEED_MODE_FREQ 3400000 #define I2C_MAX_ULTRA_FAST_MODE_FREQ 5000000 +static inline const char *i2c_freq_mode_string(u32 bus_freq_hz) +{ + switch (bus_freq_hz) { + case I2C_MAX_STANDARD_MODE_FREQ: + return "Standard Mode (100 kHz)"; + case I2C_MAX_FAST_MODE_FREQ: + return "Fast Mode (400 kHz)"; + case I2C_MAX_FAST_MODE_PLUS_FREQ: + return "Fast Mode Plus (1.0 MHz)"; + case I2C_MAX_TURBO_MODE_FREQ: + return "Turbo Mode (1.4 MHz)"; + case I2C_MAX_HIGH_SPEED_MODE_FREQ: + return "High Speed Mode (3.4 MHz)"; + case I2C_MAX_ULTRA_FAST_MODE_FREQ: + return "Ultra Fast Mode (5.0 MHz)"; + default: + return "Unknown Mode"; + } +} + struct module; struct property_entry; -- 2.8.1