From patchwork Thu Jan 23 18:48:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1228450 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=Z2EJACl3; 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 483Wb647tWz9sNF for ; Fri, 24 Jan 2020 05:51:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92BF5819B1; Thu, 23 Jan 2020 19:49:51 +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="Z2EJACl3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F8D981993; Thu, 23 Jan 2020 19:49:31 +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-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (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 40D688194B for ; Thu, 23 Jan 2020 19:49:28 +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-il1-x143.google.com with SMTP id p8so2829236iln.12 for ; Thu, 23 Jan 2020 10:49:28 -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=94mAIKMZqPi8wf9DfSkZNzRLZxsiaXyPw++7CGplxlU=; b=Z2EJACl3wlPfj3XSG2Mt6GetvVsnlO/AaQ4HxSOaRXKmpfn6BKUSAY+E07O6KicUc3 D5t1Symf9CGZCxHN9Zp+9//5W9L1Uo2a84Tj6IzKdDp4G8GaCpZPayvLdt9oTq/cY6h9 CuX00GcXA2iewBpLrG1Go480pNsjtsHLn5fV4= 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=94mAIKMZqPi8wf9DfSkZNzRLZxsiaXyPw++7CGplxlU=; b=nXVJXToB5xoNSHLyrCm8TVJm0R6GuRt6d0hnsTGY8YNyg/9J51R9kfPyyeusQjzyVU e/R0bNtLOO2DFU7Povbh0Hgpo1BoTt6A3mcVU1Z9nEbuuyIqu28RyqY9l/zXJAej8+Ql egrIN/48FIvwC4YLyefSrWrIE1oQhzu17CbnLAouxx5qdB3FLc//HoGn8civcH9uUgbb gTkEXpmQ/YYlVN6GPz1UP6h2BtY8krLgAKF2I1DSblfus42aH3edQGiLQH0Mf7vTs3yM lhjGl7YPs0tUKKMcyA4zg7Z9OWyIGh+rzxBk5R3dpwoS3u2luDxhCX7rMQgGthfvxASf l6Aw== X-Gm-Message-State: APjAAAW0ngDqWtcW8tPDNZh77lzppFocEc2poxA+pi6CoOmu5ZZCs2/5 DcODmebuidutLHCKt7ZR8woE+fs99aTnog== X-Google-Smtp-Source: APXvYqzWbjxlnfZMEQuwuf3iDSB4bCXGEu8M9R4GzVmpRqfYZwqyzV9qlU/mpi4ipUFrjt/5KMGuDg== X-Received: by 2002:a92:9a47:: with SMTP id t68mr13131893ili.155.1579805366613; Thu, 23 Jan 2020 10:49:26 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 10:49:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v3 16/23] i2c: kona_i2c: Update to use standard enums for speed Date: Thu, 23 Jan 2020 11:48:19 -0700 Message-Id: <20200123114556.v3.16.Ie7424420136cfef8fd8002027a3988764fede49c@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 Update this driver to use the new standard enums for speed. Note: This driver needs to move to driver model. Signed-off-by: Simon Glass Reviewed-by: Heiko Schocher --- Changes in v3: None Changes in v2: None drivers/i2c/kona_i2c.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c index d13e4deee5..0726b4c956 100644 --- a/drivers/i2c/kona_i2c.c +++ b/drivers/i2c/kona_i2c.c @@ -98,12 +98,6 @@ enum bcm_kona_cmd_t { BCM_CMD_STOP, }; -enum bus_speed_index { - BCM_SPD_100K = 0, - BCM_SPD_400K, - BCM_SPD_1MHZ, -}; - /* Internal divider settings for standard mode, fast mode and fast mode plus */ struct bus_speed_cfg { uint8_t time_m; /* Number of cycles for setup time */ @@ -115,9 +109,9 @@ struct bus_speed_cfg { }; static const struct bus_speed_cfg std_cfg_table[] = { - [BCM_SPD_100K] = {0x01, 0x01, 0x03, 0x06, 0x00, 0x02}, - [BCM_SPD_400K] = {0x05, 0x01, 0x03, 0x05, 0x01, 0x02}, - [BCM_SPD_1MHZ] = {0x01, 0x01, 0x03, 0x01, 0x01, 0x03}, + [IC_SPEED_MODE_STANDARD] = {0x01, 0x01, 0x03, 0x06, 0x00, 0x02}, + [IC_SPEED_MODE_FAST] = {0x05, 0x01, 0x03, 0x05, 0x01, 0x02}, + [IC_SPEED_MODE_FAST_PLUS] = {0x01, 0x01, 0x03, 0x01, 0x01, 0x03}, }; struct bcm_kona_i2c_dev { @@ -127,8 +121,8 @@ struct bcm_kona_i2c_dev { }; /* Keep these two defines in sync */ -#define DEF_SPD 100000 -#define DEF_SPD_ENUM BCM_SPD_100K +#define DEF_SPD I2C_SPEED_STANDARD_RATE +#define DEF_SPD_ENUM IC_SPEED_MODE_STANDARD #define DEF_DEVICE(num) \ {(void *)CONFIG_SYS_I2C_BASE##num, DEF_SPD, &std_cfg_table[DEF_SPD_ENUM]} @@ -560,14 +554,14 @@ static uint bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev, uint speed) { switch (speed) { - case 100000: - dev->std_cfg = &std_cfg_table[BCM_SPD_100K]; + case I2C_SPEED_STANDARD_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_STANDARD]; break; - case 400000: - dev->std_cfg = &std_cfg_table[BCM_SPD_400K]; + case I2C_SPEED_FAST_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_FAST]; break; - case 1000000: - dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ]; + case I2C_SPEED_FAST_PLUS_RATE: + dev->std_cfg = &std_cfg_table[IC_SPEED_MODE_FAST_PLUS]; break; default: printf("%d hz bus speed not supported\n", speed);