Received: by 2002:a17:906:3683:b0:98d:b2f5:1316 with SMTP id a3csp529027ejc; Thu, 10 Aug 2023 02:14:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGzndEf+kvK4+8el6VD7UXo10wtkaOXf4t7TrjiYr+jg8PyM1cL7UccOnQdcUHowAHhNAQ X-Received: by 2002:a05:620a:4714:b0:76c:c41a:f1a1 with SMTP id bs20-20020a05620a471400b0076cc41af1a1mr1897584qkb.8.1691658843376; Thu, 10 Aug 2023 02:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691658843; cv=none; d=google.com; s=arc-20160816; b=fFLCNbhO9MgDnKfgu0fY9I1CDoEMdSrwxxBmNugjiOpxZzIrTc9k421pYQHfe3GJAs z1zdy3/AmsW/z2X55v9D5xW+n7EKXJmkdx/qxFqT3JNldZ+QSelYG+AdJk47QnE4tiGJ gCCWQ6v3SvGR5oW7+J3q1dC2Li6nhD3CpYnCFxnmG3JFL5bMAmGqaeEIxwN1cg3XRzqd H+BUrbicFGDQudId3J9eq7lJDyn9jvDu8smWh320gteCdKAcwJk8/FQgFX3Vp3qcVfuM BvTTSwBKErsngZTYeoACyTY4QH0kxsvorDrhFzcx6/pWkGXGUoaciYm/urT75oqi9+e0 HPAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=JoA9tEsfgCbXlP9JNmKRE2up6ZCiUrVv5faRnSzzclg=; fh=1nuEoKRZGTl6oJPCwSAS7VDHkxIqGl3eRO68QMQPx6g=; b=neOLL3rnIsTqOzfdJoWrv/KNqc19YNudJslm493glRntPMpEFVMQrABE0QwtzdN3Pv JDykNoUGxzJLImCZW07gHzWAWlw4UCC6+8vBFi7wapq4JP7uyauMiTrNX9T6NtjO6aja +SWm1xOayfBhPN0Vpfw7mDgShluTvIac6HbdhO6ZG0jBOlbc/od1g9OFWO4CSSAp0PbK gViX2elS6BVeMwl3tPL6GNyJT/8IIPgaVNUSJ9Jo5Vd8ACsCTvRolMcEQFdjx7i0um8n BCVxuuD2Pw7f7SYTAqh4BMSGp6HMzTiqqIJdWhjivF2xz0U+/2nuXO/7nR4EPqiZRJZw 8A2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h17-20020a0cf211000000b0063d3863fcbfsi541206qvk.594.2023.08.10.02.14.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Aug 2023 02:14:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qU1jM-0008O3-QB; Thu, 10 Aug 2023 05:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qU1jM-0008Na-CZ; Thu, 10 Aug 2023 05:13:20 -0400 Received: from gandalf.ozlabs.org ([150.107.74.76]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qU1jJ-0007AL-OS; Thu, 10 Aug 2023 05:13:20 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4RM1Rl4qC4z4wy7; Thu, 10 Aug 2023 19:13:07 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4RM1Rj4F8Zz4wxm; Thu, 10 Aug 2023 19:13:04 +1000 (AEST) Message-ID: <7683a189-53cb-63f4-486b-534abbd5fd1d@kaod.org> Date: Thu, 10 Aug 2023 11:13:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] Aspeed: i2c: Fixed Tx and Rx error in BUFF Mode Content-Language: en-US To: Hang Yu <1339236493@qq.com>, qemu-devel@nongnu.org Cc: Peter Maydell , Andrew Jeffery , Joel Stanley , "open list:ASPEED BMCs" References: <20230804081142.52539-1-1339236493@qq.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <20230804081142.52539-1-1339236493@qq.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=150.107.74.76; envelope-from=SRS0=YB0G=D3=kaod.org=clg@ozlabs.org; helo=gandalf.ozlabs.org X-Spam_score_int: -57 X-Spam_score: -5.8 X-Spam_bar: ----- X-Spam_report: (-5.8 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-4.14, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: xvu2KVbnL94i Hello, On 8/4/23 10:11, Hang Yu via wrote: > 1. Fixed inconsistency between the bit field definition in register > I2CD_POOL_CTRL and the ast2600 datasheet > 2. Fixed issue of confusing RXSIZE and RXCOUNT, as well as forgetting > to add one to TXCOUNT and RXSIZE in buff mode > 3. Fixed issue with TXBUF transmission start position error in buff mode > 4. Added support for the BUFFER ORGANIZATION option in reg I2CC_POOL_CTRL This looks like 4 patches. Could split and resend a series please ? Also, Cc: these persons Joe Komlodi Peter Delevoryas since they have been involved with the AST2600 I2C implementation. > After adding these changes, QEMU can support driver code: > https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v5.15 > /drivers/i2c/busses/i2c-ast2600.c > > Signed-off-by: Hang Yu <1339236493@qq.com> This is very cryptic. Don't you have a corporate email ? Thanks, C. > --- > hw/i2c/aspeed_i2c.c | 21 ++++++--------------- > include/hw/i2c/aspeed_i2c.h | 5 +++-- > 2 files changed, 9 insertions(+), 17 deletions(-) > > diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c > index 1f071a3811..0e380d0bba 100644 > --- a/hw/i2c/aspeed_i2c.c > +++ b/hw/i2c/aspeed_i2c.c > @@ -236,7 +236,7 @@ static int aspeed_i2c_bus_send(AspeedI2CBus *bus, uint8_t pool_start) > uint32_t reg_byte_buf = aspeed_i2c_bus_byte_buf_offset(bus); > uint32_t reg_dma_len = aspeed_i2c_bus_dma_len_offset(bus); > int pool_tx_count = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_pool_ctrl, > - TX_COUNT); > + TX_COUNT)+1; > > if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, TX_BUFF_EN)) { > for (i = pool_start; i < pool_tx_count; i++) { > @@ -293,10 +293,12 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) > uint32_t reg_dma_len = aspeed_i2c_bus_dma_len_offset(bus); > uint32_t reg_dma_addr = aspeed_i2c_bus_dma_addr_offset(bus); > int pool_rx_count = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_pool_ctrl, > - RX_COUNT); > + RX_SIZE)+1; > > if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_BUFF_EN)) { > - uint8_t *pool_base = aic->bus_pool_base(bus); > + uint8_t *pool_base ; > + if(ARRAY_FIELD_EX32(bus->regs,I2CC_POOL_CTRL,BUF_ORGANIZATION))pool_base=aic->bus_pool_base(bus)+16; > + else pool_base= aic->bus_pool_base(bus); > > for (i = 0; i < pool_rx_count; i++) { > pool_base[i] = i2c_recv(bus->bus); > @@ -418,7 +420,7 @@ static void aspeed_i2c_bus_cmd_dump(AspeedI2CBus *bus) > uint32_t reg_intr_sts = aspeed_i2c_bus_intr_sts_offset(bus); > uint32_t reg_dma_len = aspeed_i2c_bus_dma_len_offset(bus); > if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_BUFF_EN)) { > - count = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_pool_ctrl, TX_COUNT); > + count = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_pool_ctrl, TX_COUNT)+1; > } else if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_DMA_EN)) { > count = bus->regs[reg_dma_len]; > } else { /* BYTE mode */ > @@ -449,7 +451,6 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) > uint8_t pool_start = 0; > uint32_t reg_intr_sts = aspeed_i2c_bus_intr_sts_offset(bus); > uint32_t reg_cmd = aspeed_i2c_bus_cmd_offset(bus); > - uint32_t reg_pool_ctrl = aspeed_i2c_bus_pool_ctrl_offset(bus); > uint32_t reg_dma_len = aspeed_i2c_bus_dma_len_offset(bus); > > if (!aspeed_i2c_check_sram(bus)) { > @@ -489,16 +490,6 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) > * else needs to be sent in this sequence. > */ > if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, TX_BUFF_EN)) { > - if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_pool_ctrl, TX_COUNT) > - == 1) { > - SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_TX_CMD, 0); > - } else { > - /* > - * Increase the start index in the TX pool buffer to > - * skip the address byte. > - */ > - pool_start++; > - } > } else if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, TX_DMA_EN)) { > if (bus->regs[reg_dma_len] == 0) { > SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_TX_CMD, 0); > diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h > index 51c944efea..88b144a599 100644 > --- a/include/hw/i2c/aspeed_i2c.h > +++ b/include/hw/i2c/aspeed_i2c.h > @@ -139,9 +139,9 @@ REG32(I2CD_CMD, 0x14) /* I2CD Command/Status */ > REG32(I2CD_DEV_ADDR, 0x18) /* Slave Device Address */ > SHARED_FIELD(SLAVE_DEV_ADDR1, 0, 7) > REG32(I2CD_POOL_CTRL, 0x1C) /* Pool Buffer Control */ > - SHARED_FIELD(RX_COUNT, 24, 5) > + SHARED_FIELD(RX_COUNT, 24, 6) > SHARED_FIELD(RX_SIZE, 16, 5) > - SHARED_FIELD(TX_COUNT, 9, 5) > + SHARED_FIELD(TX_COUNT, 8, 5) > FIELD(I2CD_POOL_CTRL, OFFSET, 2, 6) /* AST2400 */ > REG32(I2CD_BYTE_BUF, 0x20) /* Transmit/Receive Byte Buffer */ > SHARED_FIELD(RX_BUF, 8, 8) > @@ -162,6 +162,7 @@ REG32(I2CC_MS_TXRX_BYTE_BUF, 0x08) > /* 15:0 shared with I2CD_BYTE_BUF[15:0] */ > REG32(I2CC_POOL_CTRL, 0x0c) > /* 31:0 shared with I2CD_POOL_CTRL[31:0] */ > + FIELD(I2CC_POOL_CTRL, BUF_ORGANIZATION, 0, 1) /* AST2600 */ > REG32(I2CM_INTR_CTRL, 0x10) > REG32(I2CM_INTR_STS, 0x14) > FIELD(I2CM_INTR_STS, PKT_STATE, 28, 4)