Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4418930pxf; Tue, 30 Mar 2021 07:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2kiTcauCkNa4mP3kLfnn+DMBaZRW/2Ymx0x9f8ppa4Fe1JGvunnlCIKMP2gLJ6EF4Nfxy X-Received: by 2002:a17:906:6c93:: with SMTP id s19mr33310590ejr.151.1617114231973; Tue, 30 Mar 2021 07:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617114231; cv=none; d=google.com; s=arc-20160816; b=Y6Lmr4U3CY1w7cyLjXdnNVPmqjQbSOB1HcwsfM8IiynedkSn/H1ufC9qCreZp7BcIt m+ln2HPJmlozmlMjOjkDWe9QZzfQ/yjv1QlosPMaAOq9V9p0LhVEF8Y7P+dN2sx2sVR8 Yrby4ydH71UtQzBBNWnTw2qEfS7/TYS2UKsKysRe8iX51pKKIzFQ+sAlgIlyA0tbnkbD iH0DhUK7o701hhgRlr+qyMlBNpA9NabZza11sAafGRLEwbYAgEPVRzWWiiMz0Mtslmm4 tFNIYvFo6sAktm6xFe8e8Wcx8DnSxALEtuSf4JGaVlGAfhXu38mhOWdRa3eMA0vyLHJt R28g== 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=Z+RyUm0UR6Yl/tNds6MEzRtS+lVW4mOikBXVxas5wNU=; b=KfEy5FQZHNEZ7/lOu8aNKMvtjDjJyJeR9GNoxq8IkZc07SmP8cogqlq07tfACHw+NT nfhaC1kv93k4YLxCvhz74wx+Xkxc/dZ56wcVw76MRhdxAyJ+UakriGudy3VfSpNzte9B zHHgUsDZ4Rej0IxZtyQ87RFpODILbV1FBsf8+KVwMCGEGGDnfAbujryt8cpsgl7pXAOO 3cnRk2pRVEFlxsQYFiBp9V+k6pR1rpy1/K8RcVoPArS4Q8jmuIljVHdgOrrkvli7BU4Y 7dPTgcPY9XwJ4qCToTP3tVoVwOrH7NkLe/7Ho0ABqBmQ+uu9lNsdX8Skm8JR3zQzvQ3m gHwg== 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 u12si16412502eda.121.2021.03.30.07.23.29; Tue, 30 Mar 2021 07:23:51 -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 S232067AbhC3OWj (ORCPT + 99 others); Tue, 30 Mar 2021 10:22:39 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:14641 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232002AbhC3OWK (ORCPT ); Tue, 30 Mar 2021 10:22:10 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4F8s5T4FkhznWLP; Tue, 30 Mar 2021 22:19:25 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Tue, 30 Mar 2021 22:21:56 +0800 From: Yicong Yang To: , , , , CC: , , , , , , , , , Subject: [PATCH v5 2/5] i2c: core: add api to provide frequency mode strings Date: Tue, 30 Mar 2021 22:19:23 +0800 Message-ID: <1617113966-40498-3-git-send-email-yangyicong@hisilicon.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1617113966-40498-1-git-send-email-yangyicong@hisilicon.com> References: <1617113966-40498-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. 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..6837e64 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(100KHz)"; + case I2C_MAX_FAST_MODE_FREQ: + return "Fast Mode(400KHz)"; + case I2C_MAX_FAST_MODE_PLUS_FREQ: + return "Fast Mode Plus(1.0MHz)"; + case I2C_MAX_TURBO_MODE_FREQ: + return "Turbo Mode(1.4MHz)"; + case I2C_MAX_HIGH_SPEED_MODE_FREQ: + return "High Speed Mode(3.4MHz)"; + case I2C_MAX_ULTRA_FAST_MODE_FREQ: + return "Ultra Fast Mode(5.0MHz)"; + default: + return "Unknown Mode"; + } +} + struct module; struct property_entry; -- 2.8.1