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 96213C433F5 for ; Sat, 18 Dec 2021 13:45:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C469B830E8; Sat, 18 Dec 2021 14:44:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1639835099; bh=LRZ1KnTvseBnXakIMl3U0chWi1VVpLb4daVZyHLHliM=; h=Date:Subject:From:To:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uJJRIApJdDh7BbE+Fk8+1j0ONMzA2QJg4Yoc8ewoLfJPneOcntduqg2vtVRVZbAl+ iHEI/ZdPChWLL7gEyge7dY5jI4R/wwl9EO71bEkibJHXCXmCECmyo69s9Q+wRTtLU8 RQysV32h+nmhCd1JxQVH7b1kmZHMdik3m7YZWPd51kS7KJ39OOCbIeWXc/dF8bjdWU Z6FmtwciIyswNfshDT2xDmuIEK3urjdQDd5zBgQSG/3HSKEkaFock/z5CrqY7bcOoX YUPetRq8vmXYc7tYZu6Kb7fwYm3hXvOJcXEzjz3iHdFGVgWCYGO4nu/DjoSaMmX9Uq 2rxhiyqwHDT6g== Received: by phobos.denx.de (Postfix, from userid 109) id 5998D830D9; Sat, 18 Dec 2021 14:44:57 +0100 (CET) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F2EB4830F5 for ; Sat, 18 Dec 2021 14:44:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:105:465:1:4:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4JGRtC32khzQjbj for ; Sat, 18 Dec 2021 14:44:51 +0100 (CET) Message-ID: <99433fe0-d280-b0ac-ff00-155d6b78f2c2@denx.de> Date: Sat, 18 Dec 2021 14:44:47 +0100 MIME-Version: 1.0 Subject: Re: [PATCH 8/9] arm: mvebu: axp: ddr: Switch to using DM I2C API Content-Language: en-US From: Stefan Roese To: u-boot@lists.denx.de References: <20211118081939.861407-1-sr@denx.de> <20211118081939.861407-8-sr@denx.de> In-Reply-To: <20211118081939.861407-8-sr@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean On 11/18/21 09:19, Stefan Roese wrote: > No functional change intended. This patch switches from the legacy I2C > API to the DM I2C API, so that this code can be used with DM I2C > enabled. > > Signed-off-by: Stefan Roese Applied to u-boot-marvell/next Thanks, Stefan > --- > drivers/ddr/marvell/axp/ddr3_init.c | 16 +++++++++++----- > drivers/ddr/marvell/axp/ddr3_init.h | 2 +- > drivers/ddr/marvell/axp/ddr3_spd.c | 16 ++++++++++++++-- > 3 files changed, 26 insertions(+), 8 deletions(-) > > diff --git a/drivers/ddr/marvell/axp/ddr3_init.c b/drivers/ddr/marvell/axp/ddr3_init.c > index c5aa1ac18f51..a9dcb74cecb7 100644 > --- a/drivers/ddr/marvell/axp/ddr3_init.c > +++ b/drivers/ddr/marvell/axp/ddr3_init.c > @@ -361,12 +361,18 @@ static u32 ddr3_init_main(void) > __maybe_unused u32 ddr_width = BUS_WIDTH; > __maybe_unused int status; > __maybe_unused u32 win_backup[16]; > + __maybe_unused struct udevice *udev; > + __maybe_unused int ret; > > /* SoC/Board special Initializtions */ > fab_opt = ddr3_get_fab_opt(); > > #ifdef CONFIG_SPD_EEPROM > - i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); > + ret = i2c_get_chip_for_busnum(0, BUS_WIDTH_ECC_TWSI_ADDR, 1, &udev); > + if (ret) { > + printf("Cannot find SPD EEPROM\n"); > + return MV_DDR3_TRAINING_ERR_BAD_DIMM_SETUP; > + } > #endif > > ddr3_print_version(); > @@ -438,7 +444,7 @@ static u32 ddr3_init_main(void) > > #if defined(ECC_SUPPORT) && defined(AUTO_DETECTION_SUPPORT) > ecc = 0; > - if (ddr3_check_config(BUS_WIDTH_ECC_TWSI_ADDR, CONFIG_ECC)) > + if (ddr3_check_config(udev, CONFIG_ECC)) > ecc = 1; > #endif > > @@ -483,7 +489,7 @@ static u32 ddr3_init_main(void) > * Dynamically Set 32Bit and ECC for AXP (Relevant only for > * Marvell DB boards) > */ > - if (ddr3_check_config(BUS_WIDTH_ECC_TWSI_ADDR, CONFIG_BUS_WIDTH)) { > + if (ddr3_check_config(udev, CONFIG_BUS_WIDTH)) { > ddr_width = 32; > DEBUG_INIT_S("DDR3 Training Sequence - DRAM bus width 32Bit\n"); > } > @@ -904,7 +910,7 @@ void ddr3_static_mc_init(void) > * Notes: Only Available for ArmadaXP/Armada 370 DB boards > * Returns: None. > */ > -int ddr3_check_config(u32 twsi_addr, MV_CONFIG_TYPE config_type) > +int ddr3_check_config(struct udevice *udev, MV_CONFIG_TYPE config_type) > { > #ifdef AUTO_DETECTION_SUPPORT > u8 data = 0; > @@ -916,7 +922,7 @@ int ddr3_check_config(u32 twsi_addr, MV_CONFIG_TYPE config_type) > else > offset = 0; > > - ret = i2c_read(twsi_addr, offset, 1, (u8 *)&data, 1); > + ret = dm_i2c_read(udev, offset, &data, 1); > if (!ret) { > switch (config_type) { > case CONFIG_ECC: > diff --git a/drivers/ddr/marvell/axp/ddr3_init.h b/drivers/ddr/marvell/axp/ddr3_init.h > index 9a21886ac3e7..a26bd2a120e9 100644 > --- a/drivers/ddr/marvell/axp/ddr3_init.h > +++ b/drivers/ddr/marvell/axp/ddr3_init.h > @@ -101,7 +101,7 @@ void fix_pll_val(u8 target_fab); > u32 ddr3_get_fab_opt(void); > u32 ddr3_get_cpu_freq(void); > u32 ddr3_get_vco_freq(void); > -int ddr3_check_config(u32 addr, MV_CONFIG_TYPE config_type); > +int ddr3_check_config(struct udevice *udev, MV_CONFIG_TYPE config_type); > u32 ddr3_get_static_mc_value(u32 reg_addr, u32 offset1, u32 mask1, u32 offset2, > u32 mask2); > u32 ddr3_cl_to_valid_cl(u32 cl); > diff --git a/drivers/ddr/marvell/axp/ddr3_spd.c b/drivers/ddr/marvell/axp/ddr3_spd.c > index dd772e63ab19..4763403c1278 100644 > --- a/drivers/ddr/marvell/axp/ddr3_spd.c > +++ b/drivers/ddr/marvell/axp/ddr3_spd.c > @@ -209,13 +209,19 @@ static u32 ddr3_get_dimm_num(u32 *dimm_addr) > /* Read the dimm eeprom */ > for (dimm_cur_addr = MAX_DIMM_ADDR; dimm_cur_addr > MIN_DIMM_ADDR; > dimm_cur_addr--) { > + struct udevice *udev; > + > data[SPD_DEV_TYPE_BYTE] = 0; > > /* Far-End DIMM must be connected */ > if ((dimm_num == 0) && (dimm_cur_addr < FAR_END_DIMM_ADDR)) > return 0; > > - ret = i2c_read(dimm_cur_addr, 0, 1, (uchar *)data, 3); > + ret = i2c_get_chip_for_busnum(0, dimm_cur_addr, 1, &udev); > + if (ret) > + continue; > + > + ret = dm_i2c_read(udev, 0, data, 3); > if (!ret) { > if (data[SPD_DEV_TYPE_BYTE] == SPD_MEM_TYPE_DDR3) { > dimm_addr[dimm_num] = dimm_cur_addr; > @@ -245,9 +251,15 @@ int ddr3_spd_init(MV_DIMM_INFO *info, u32 dimm_addr, u32 dimm_width) > __maybe_unused u8 vendor_high, vendor_low; > > if (dimm_addr != 0) { > + struct udevice *udev; > + > memset(spd_data, 0, SPD_SIZE * sizeof(u8)); > > - ret = i2c_read(dimm_addr, 0, 1, (uchar *)spd_data, SPD_SIZE); > + ret = i2c_get_chip_for_busnum(0, dimm_addr, 1, &udev); > + if (ret) > + return MV_DDR3_TRAINING_ERR_TWSI_FAIL; > + > + ret = dm_i2c_read(udev, 0, spd_data, SPD_SIZE); > if (ret) > return MV_DDR3_TRAINING_ERR_TWSI_FAIL; > } > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de