From patchwork Thu Jan 23 18:48:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1228440 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BwO01MhG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 483WXx0vjbz9sNF for ; Fri, 24 Jan 2020 05:49:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B7B6B8192E; Thu, 23 Jan 2020 19:49:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BwO01MhG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B42BF818F2; Thu, 23 Jan 2020 19:49:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A23CE817C0 for ; Thu, 23 Jan 2020 19:49:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd41.google.com with SMTP id m25so3988761ioo.8 for ; Thu, 23 Jan 2020 10:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=reJpE5BTe15+T1B08XeNyqpTzd1iC9g+FNHbHYLx4RM=; b=BwO01MhG2cOtPjvk12T0u8dMGMOkOFb/RYnfSRHX0hvxsWNsAUWYoKiEQL/GVyWUGz 0LAZtDa9UbD6mqawMxLGpIaxnCVTuIbYHtNepXpDotbe2LOjMhQQ/Eo0W0X8YAL+k5ak ZqmhVcoeM23d3/mwn7pHeDBJky0ljifmm3M/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=reJpE5BTe15+T1B08XeNyqpTzd1iC9g+FNHbHYLx4RM=; b=rIEB9R8r6/LqMwRl6dz4w9GhcvNUAwGCI1JBeOeNo6SryIcBUNK1L410TUmUzDM7ac SZgkZ3ZWEb0LmvGpXlDCfKz+8AVIimomTEIZaTRrPq6lzaSiYbw33dczrEeCFRMYV6x4 NHpVM3nakJU0Z4DTNJLqgIv3EccrstFNC0reF4mIAdSSOtxRYthhWO13SW67ABDUuPaT y3gbjs2EU6/m4Pnrf/2O7T+iVLrbFrVogMkSHe7/2fP32YFpiANyKEKoUiYGtJDFuskV yEI9z1GRwcRE4bpU7kvlxA1XhuIeCTZtC5le39WdY7UWm4QmqV7HX2dsSzf/fqkv4Upk NKcw== X-Gm-Message-State: APjAAAUzFX/8ca0czGDGt9dnG4xgO2qZsT7hsMn1D2ujdC/8Q5Wr0QjC g5pt2EIfXd/QvpHRtKUO7DvdhjmTGFOoKw== X-Google-Smtp-Source: APXvYqzg5aWnbLWwuOUmUqRrz5n+onGJgm1GzW+xPzPyZAxkXahm0qz8tZ1AdbjPDLt/batMxCl2xQ== X-Received: by 2002:a5d:9dc5:: with SMTP id 5mr8315104ioo.111.1579805349401; Thu, 23 Jan 2020 10:49:09 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id u16sm860662iln.40.2020.01.23.10.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 10:49:09 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v3 05/23] i2c: designware_i2c: Use an enum for selected speed mode Date: Thu, 23 Jan 2020 11:48:08 -0700 Message-Id: <20200123114556.v3.5.I27c709972965d4def442964747f030db90bf05b9@changeid> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200123184826.116850-1-sjg@chromium.org> References: <20200123184826.116850-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jun Chen Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Group these #defines into an enum to make it easier to understand the relationship between them. Signed-off-by: Simon Glass Reviewed-by: Jun Chen Reviewed-by: Heiko Schocher --- Changes in v3: None Changes in v2: None drivers/i2c/designware_i2c.c | 2 +- drivers/i2c/designware_i2c.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c index dd1cc0b823..2416ef32f9 100644 --- a/drivers/i2c/designware_i2c.c +++ b/drivers/i2c/designware_i2c.c @@ -57,10 +57,10 @@ static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs *i2c_base, unsigned int speed, unsigned int bus_mhz) { + enum i2c_speed_mode i2c_spd; unsigned int cntl; unsigned int hcnt, lcnt; unsigned int ena; - int i2c_spd; /* Allow high speed if there is no config, or the config allows it */ if (speed >= I2C_HIGH_SPEED && diff --git a/drivers/i2c/designware_i2c.h b/drivers/i2c/designware_i2c.h index d4c1ca0cc3..569cab6fd3 100644 --- a/drivers/i2c/designware_i2c.h +++ b/drivers/i2c/designware_i2c.h @@ -136,9 +136,13 @@ struct i2c_regs { #define IC_STATUS_ACT 0x0001 /* Speed Selection */ -#define IC_SPEED_MODE_STANDARD 1 -#define IC_SPEED_MODE_FAST 2 -#define IC_SPEED_MODE_HIGH 3 +enum i2c_speed_mode { + IC_SPEED_MODE_STANDARD, + IC_SPEED_MODE_FAST, + IC_SPEED_MODE_HIGH, + + IC_SPEED_MODE_COUNT, +}; #define I2C_HIGH_SPEED 3400000 #define I2C_FAST_SPEED 400000