From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BE4DC433EF for ; Mon, 27 Jun 2022 17:36:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1CA784420; Mon, 27 Jun 2022 19:36:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="O1ATcVzt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A085E843E6; Mon, 27 Jun 2022 19:36:00 +0200 (CEST) Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) (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 870428430F for ; Mon, 27 Jun 2022 19:35:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf32.google.com with SMTP id p31so15766632qvp.5 for ; Mon, 27 Jun 2022 10:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q8XsahGMIFWeWiBrMfsJIqTGiMzIs6Ds42u2U2XB3K8=; b=O1ATcVztsgFhqZB8i+4rlGvZH8ERRlrbz2gjm5t49WCtSZuIEfajL8kDC0tI6TfPAF iUFHozXqybtSk9VEceYfZxKyztj7HyxyU47J/ZqbMpc63cBGGPMsgsOrfhg+zYJxA+kC HfWsJCJpONtyJChOuxmr14UB94TlF14ac9oYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q8XsahGMIFWeWiBrMfsJIqTGiMzIs6Ds42u2U2XB3K8=; b=f4788i0+1JEukdo/zXKlbtNqd0XJmoAwCMQlaWpZTmqnSl8hWro3HdtxyZfWxyuJkn 289jDgzv/qO5jkgduAaBLiHIio43xx5DZznIT686xI3AgozHzEu1oSVg6mG3ZkPaAYtj 5Zg2ufcwaqOtdvZkSL5PUFznmktkjroDo0SwYhi7k9gYe6a97O0dgHWFUP5IhOzlk7mn ICDpGiXjwpKsqEuQBWDUBpADdoOR7jAsiRrj7XGzwQMhwX7E9fGhm927nbIq5bIl0Izf 4/9FAoaVz3tO6sAyp1k0f60o5amPc7D6BtdpCv7aELsKXfeDqqq9YaGLMmpSW3x2KDVi sAIw== X-Gm-Message-State: AJIora+2o8Xj87yajrIqzDWJanqvDZrSlsT0aImKOvGPg2WRCYobqNxT ddaYH6tTn+Op5+drI5XvM9mvxhmWoC3tZA== X-Google-Smtp-Source: AGRyM1tR0vA95EDBR0nHWhMN9/NRBweD0IEksVUHoPW7S2AweounH1A+jxxfcRk8zpwfoozDwFOGGw== X-Received: by 2002:ad4:5c8d:0:b0:470:4649:e3c9 with SMTP id o13-20020ad45c8d000000b004704649e3c9mr451278qvh.43.1656351355943; Mon, 27 Jun 2022 10:35:55 -0700 (PDT) Received: from bill-the-cat.lan (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id j17-20020a05620a289100b006a793bde241sm9471398qkp.63.2022.06.27.10.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 10:35:55 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Cc: David Lechner Subject: [PATCH 4/6] legoev3: Migrate to DM_I2C Date: Mon, 27 Jun 2022 13:35:49 -0400 Message-Id: <20220627173551.1199243-4-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220627173551.1199243-1-trini@konsulko.com> References: <20220627173551.1199243-1-trini@konsulko.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Perform a basic migration of the calls in setup_serial_number() to DM so that we can switch to using DM_I2C on this platform. Cc: David Lechner Signed-off-by: Tom Rini --- board/lego/ev3/legoev3.c | 15 +++++++++++++-- configs/legoev3_defconfig | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/board/lego/ev3/legoev3.c b/board/lego/ev3/legoev3.c index 980ffef4cdfd..834926013101 100644 --- a/board/lego/ev3/legoev3.c +++ b/board/lego/ev3/legoev3.c @@ -27,6 +27,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -57,6 +58,8 @@ const int lpsc_size = ARRAY_SIZE(lpsc); */ static void setup_serial_number(void) { + struct udevice *idev, *ibus; + int ret; u32 offset; char serial_number[13]; u8 buf[6]; @@ -65,7 +68,15 @@ static void setup_serial_number(void) if (env_get("serial#")) return; - if (i2c_read(EEPROM_I2C_ADDR, EEPROM_REV_OFFSET, 2, buf, 2)) { + ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &ibus); + if (ret) + return; + + ret = dm_i2c_probe(ibus, EEPROM_I2C_ADDR, 0, &idev); + if (ret) + return; + + if (dm_i2c_read(idev, EEPROM_REV_OFFSET, buf, 2)) { printf("\nEEPROM revision read failed!\n"); return; } @@ -83,7 +94,7 @@ static void setup_serial_number(void) /* EEPROM rev 3 has Bluetooth address where rev should be */ offset = (eeprom_rev == 3) ? EEPROM_REV_OFFSET : EEPROM_BDADDR_OFFSET; - if (i2c_read(EEPROM_I2C_ADDR, offset, 2, buf, 6)) { + if (dm_i2c_read(idev, offset, buf, 6)) { printf("\nEEPROM serial read failed!\n"); return; } diff --git a/configs/legoev3_defconfig b/configs/legoev3_defconfig index 3612afb463c2..36e3d7069238 100644 --- a/configs/legoev3_defconfig +++ b/configs/legoev3_defconfig @@ -46,7 +46,7 @@ CONFIG_VERSION_VARIABLE=y # CONFIG_NET is not set CONFIG_DM=y # CONFIG_DM_DEVICE_REMOVE is not set -CONFIG_SYS_I2C_LEGACY=y +CONFIG_DM_I2C=y CONFIG_SYS_I2C_DAVINCI=y CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y -- 2.25.1