From patchwork Fri Mar 15 10:30:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 780647 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F127B18E29; Fri, 15 Mar 2024 10:31:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498694; cv=none; b=dNQ7J0/j9eD+qJ2nesWbEd0UYItvQXV2LD1UFnV5apt1hPBxCGfU3BfZzHf2dZWvCycvMGB5F2GSNU1W7WZt5+m3h4Za+Wf50yGqHv4RcqKrn82IdJxoy8QxTBWPGxklv50zwaMxlXsZJKMz7wuD5RJQL5qciGWLR7E1yRk2j+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498694; c=relaxed/simple; bh=SE45kCzlVbgFgbJfsJGiklk8gwxB5yr4fkJazUtvOuc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c7XS5nUToRTa6C4Pj3Rx2piWpbfCUCvPQcvqTIddhO5LQPCi/Xd7gvvU9XE8SuY9DWCof50GVkjA3sPbOXPUH8vMOQEKny+MFIjyKmctzsIOZQ8Qj+fYFQz22P2/nt8EAVhSnLSdIJuaZ3oSl5/vXevdiuiRi5Vh6Cfei/8K71k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hejcy697; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hejcy697" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-41400332525so4406975e9.0; Fri, 15 Mar 2024 03:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710498691; x=1711103491; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GVKfKDU2lNUfwo4DLPyPwWk8pm2av3RhG8cnv+hn5O0=; b=hejcy697VhNkF2LCrzSUjzawPdeXTA2SAr7ekVHIO6Pig4Nqr6ZuMpyKT4M7GMbB2V 9iZq555qWAOIHnqg0gdN+oEHT89w98RHNzU6BCjlAJssNueFDf7YkLNZx67ugj6bXXEu dCxJUUadxqXZJbqvVVkrgMuHfm2EHF27+UP1lVLSRC6Fs1+5coZHkwTcIkfp3ebTfot8 1ZZcs+Fso24lhD22dhKMIT1T7oNyeZp97mFB+uGhO5Rw7J9LHRzf4EhCgm6G/sgBBhtV v3mS3pU203BTMH5fYJvbimop2TzGtJctrDtwW3DWezyai7yDkrPXnRIQg2mr6MQ0MjGW WeJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710498691; x=1711103491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GVKfKDU2lNUfwo4DLPyPwWk8pm2av3RhG8cnv+hn5O0=; b=bYHIIPB552RZhiJYuEPC8YWlpfQWM0k97kP0+96BKCGqSoc8e3Ta8x9ZxuhJg8x/GO TI7fMXodBauaYI1hsO5RI6iu6XdoPbIDEqX70XfPyDScvJT0j4Fm5S//oANNI6L9WNss 6zZMHrcQ61boQFvkMPxTEltdSy9KRV/Iun9L0MlhMa5e6UXWRBgLVr8JOz0r9HakyZp3 2wnhHV7oa6Uglat9HCztj2CBaPzIRtw32Yn6bxRYDnwd3BIZn539LSKYi2oCdYXSZxbG 29zZPm4UFq6OW7X8UC/EsHqhon/PWLA0qv42t3Fv3apQ8mOEYadSf3m2sgOy8nXLRIE+ Slig== X-Forwarded-Encrypted: i=1; AJvYcCWbnnRJTKxJ5oNMS1NAnWj70rwywmTu6ZJU7wSyAfCj79s8X8buODtDSfENXHQOcKawmsqG+2G6dUN/awJTBKJYSEyaK32n600BYpaPnAQU0pKUL3HYQTkFa2A9ZIF5AttHPoBi2Ecv0r7byryD4nRi+SrYNp9p3kWl/8DP8iunY5i8mQ== X-Gm-Message-State: AOJu0Ywqud6q/wO8D46zk6cNygqu65fK1Bir8U0a/EebA+BAXxIaeD6Y msGyA1NOzs5tyQGZZiIzBw4bmHw0qOmXf7k54YM66NaPyj6nG2Bg X-Google-Smtp-Source: AGHT+IH5thlB/KqkhMFZEtOkS5tP1abakNep+y6JmIhXw52Gx1sgBN36fINQ3j2zydBdEGQM8NEAzQ== X-Received: by 2002:a05:600c:3b1d:b0:412:b0cc:1c62 with SMTP id m29-20020a05600c3b1d00b00412b0cc1c62mr1766054wms.32.1710498691351; Fri, 15 Mar 2024 03:31:31 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:ae92:6adf:5cb6:274c]) by smtp.gmail.com with ESMTPSA id l19-20020a05600c4f1300b004130378fb77sm8676549wmq.6.2024.03.15.03.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 03:31:30 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Chris Brandt , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 1/4] dt-bindings: i2c: renesas,riic: Document R9A09G057 support Date: Fri, 15 Mar 2024 10:30:30 +0000 Message-Id: <20240315103033.141226-2-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Document support for the I2C Bus Interface (RIIC) available in the Renesas RZ/V2H(P) (R9A09G057) SoC. The RIIC interface in the Renesas RZ/V2H(P) differs from RZ/A in a couple of ways: - Register offsets for the RZ/V2H(P) SoC differ from those of the RZ/A SoC. - RZ/V2H register access is limited to 8-bit, whereas RZ/A supports 8/16/32-bit. - RZ/V2H has bit differences in the slave address register. To accommodate these differences in the existing driver, a new compatible string "renesas,riic-r9a09g057" is added. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven Acked-by: Rob Herring --- v1->v2 - Used a const for V2H SoC instead of enum in items list --- .../devicetree/bindings/i2c/renesas,riic.yaml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/renesas,riic.yaml b/Documentation/devicetree/bindings/i2c/renesas,riic.yaml index 2291a7cd619b..91ecf17b7a81 100644 --- a/Documentation/devicetree/bindings/i2c/renesas,riic.yaml +++ b/Documentation/devicetree/bindings/i2c/renesas,riic.yaml @@ -15,14 +15,17 @@ allOf: properties: compatible: - items: - - enum: - - renesas,riic-r7s72100 # RZ/A1H - - renesas,riic-r7s9210 # RZ/A2M - - renesas,riic-r9a07g043 # RZ/G2UL and RZ/Five - - renesas,riic-r9a07g044 # RZ/G2{L,LC} - - renesas,riic-r9a07g054 # RZ/V2L - - const: renesas,riic-rz # RZ/A or RZ/G2L + oneOf: + - items: + - enum: + - renesas,riic-r7s72100 # RZ/A1H + - renesas,riic-r7s9210 # RZ/A2M + - renesas,riic-r9a07g043 # RZ/G2UL and RZ/Five + - renesas,riic-r9a07g044 # RZ/G2{L,LC} + - renesas,riic-r9a07g054 # RZ/V2L + - const: renesas,riic-rz # RZ/A or RZ/G2L + + - const: renesas,riic-r9a09g057 # RZ/V2H(P) reg: maxItems: 1 From patchwork Fri Mar 15 10:30:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 780980 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6974199B0; Fri, 15 Mar 2024 10:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498696; cv=none; b=iTZucrxg+UOSJz1B6wdv+M9qPk2JBWKhDaA1K4Oi1xCFGrass/yHvLf393BG/95XhYdH7BxY7lDQG91XmD4AV6gFinQDLcAd+FTiuOlBjqK3EiXrKcoLPIZvC0kL1Pv8NJXkWLuZC3KIN+5ZW6cF+MKTd07xF1GWv5bNFxRVpvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498696; c=relaxed/simple; bh=xZD68RrjRgyuQtZF2fr+1DbEDpvBl8R2+TdDuvK0VSA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KLnF4ZRs1DNt7MhE5qo0D/8NWPfTM3FQZMFD/YMUJ8P6dU137qIpYyM8hkfa0uJGPnp1bjORYbHhhnnjy8RvE7ywJti4DBPuSge8hKZFPlUpPwWo/EGt+gOsNRkDwGqa6c7kiivE/NapYFyq4dtQljQQ7MGuTsD6Acb4LLW48Jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UkYAtukQ; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UkYAtukQ" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-413fff1dacfso3708575e9.2; Fri, 15 Mar 2024 03:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710498693; x=1711103493; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d+1se06mIEfqihG0q0TzaQqEvHL03XCt7GY9b7jj+so=; b=UkYAtukQ+JuNbmzj7du0PDJvMVL4X4vkkU5uxw8RJILCYztP9kWJu+/IvoxPaPi3cC udTJTg6pe0tXyJHE0JelPWO0JjGSWmLSIY3JT3ec2ayqP8KE98Ay/9ifey4TVOgr//rl OIATBB3DrDEwsCh5kPDD9BnWrEvSOQ8OqaaONxjI4XL8v5QOjRQb4aPEjKRrzhP6Bkzm x5/pYu5foYUvGghJ7QEgP2A9uHPnx7Ei6bSlLDrs+4gXEvs6rZYvCzJCCwcaOJLpC7oj +dm9WS00ed8C3xMWM9nn8PUT7KNeD5ut/Zfnnwzs9GVUcz/HgV2ApGFOyqARd7Vuygq2 9p4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710498693; x=1711103493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d+1se06mIEfqihG0q0TzaQqEvHL03XCt7GY9b7jj+so=; b=WM7zBMGQMVWXz1uwto/q0xFX/1SsB9WK74pJutFgoxgWyTAm0iUjIwr5DNUHvHyRR8 BVwDJU2MLVUHvyYIux8Kl0srUYkRwbSFJbJxhDyyKRLPoTal4Ta+lE8vxy0QL0mOUWMW GCTZyiKUOooBZ87dX3zZz7JfQuhCgim0CrCygBkuNTSZwKmeB3i6FBpLDRiCz7xBH1m8 jGZO5ryxZz5SVg0Pez59x57P5wozMygsxIt79aYXZs6OQaMDyYFdQKfjnomlrxpczz91 3cD11CMfy57fIkg9DiQYzsgWe9h55WXmfZx1lVmjWxlZ4YE5dImKqU6Z9elatHVz89lP 2yEg== X-Forwarded-Encrypted: i=1; AJvYcCXX5odU0DBAwveP+FAHUm9T6ijedna4DBHTa7OTq1OjSizDla8CsYd0QvjQbKTozX5TaF5kIOC9HUppIao2dk98/NnP8jdELhxiMNPTU/92RKtMx+N8te/f7xj+N2W+Yb2fElC2qb+UUBxDaWEbQw9QP8Cs2BR76cntP00jDY41fGCfkQ== X-Gm-Message-State: AOJu0Yw4MRVAq8TzXMVZrbFTCR4sA3W9/oLgRXqcpGpLBNhl2Yx4qfF6 8j8S97o5wUlpwC3Oyei6aMvknmpjU7C9Pr3DqGp8smz4czaXUObK X-Google-Smtp-Source: AGHT+IFI9utthlpZ5UUGSYEqz0PCHZYtlADr7SJoWMQgulMeM5b+BnethBqzN+ZOWRmIlKxXVVFgHg== X-Received: by 2002:a05:600c:524a:b0:413:f50f:b5b3 with SMTP id fc10-20020a05600c524a00b00413f50fb5b3mr1875908wmb.10.1710498692800; Fri, 15 Mar 2024 03:31:32 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:ae92:6adf:5cb6:274c]) by smtp.gmail.com with ESMTPSA id l19-20020a05600c4f1300b004130378fb77sm8676549wmq.6.2024.03.15.03.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 03:31:31 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Chris Brandt , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 2/4] i2c: riic: Introduce helper functions for I2C read/write operations Date: Fri, 15 Mar 2024 10:30:31 +0000 Message-Id: <20240315103033.141226-3-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Introduce helper functions for performing I2C read and write operations in the RIIC driver. These helper functions lay the groundwork for adding support for the RZ/V2H SoC. This is essential because the register offsets for the RZ/V2H SoC differ from those of the RZ/A SoC. By abstracting the read and write operations, we can seamlessly adapt the driver to support different SoC variants without extensive modifications. This patch is part of the preparation process for integrating support for the RZ/V2H SoC into the RIIC driver. Signed-off-by: Lad Prabhakar --- v1->v2 - Renamed i2c read/write to riic_readb/riic_writeb - Made riic as first parameter for riic_writeb --- drivers/i2c/busses/i2c-riic.c | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index e43ff483c56e..5eb25ef3abc4 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -105,9 +105,19 @@ struct riic_irq_desc { char *name; }; +static inline void riic_writeb(struct riic_dev *riic, u8 offset, u8 val) +{ + writeb(val, riic->base + offset); +} + +static inline u8 riic_readb(struct riic_dev *riic, u8 offset) +{ + return readb(riic->base + offset); +} + static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u8 reg) { - writeb((readb(riic->base + reg) & ~clear) | set, riic->base + reg); + riic_writeb(riic, reg, (riic_readb(riic, reg) & ~clear) | set); } static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) @@ -119,7 +129,7 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) pm_runtime_get_sync(adap->dev.parent); - if (readb(riic->base + RIIC_ICCR2) & ICCR2_BBSY) { + if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) { riic->err = -EBUSY; goto out; } @@ -127,7 +137,7 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) reinit_completion(&riic->msg_done); riic->err = 0; - writeb(0, riic->base + RIIC_ICSR2); + riic_writeb(riic, RIIC_ICSR2, 0); for (i = 0, start_bit = ICCR2_ST; i < num; i++) { riic->bytes_left = RIIC_INIT_MSG; @@ -135,9 +145,9 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) riic->msg = &msgs[i]; riic->is_last = (i == num - 1); - writeb(ICIER_NAKIE | ICIER_TIE, riic->base + RIIC_ICIER); + riic_writeb(riic, RIIC_ICIER, ICIER_NAKIE | ICIER_TIE); - writeb(start_bit, riic->base + RIIC_ICCR2); + riic_writeb(riic, RIIC_ICCR2, start_bit); time_left = wait_for_completion_timeout(&riic->msg_done, riic->adapter.timeout); if (time_left == 0) @@ -191,7 +201,7 @@ static irqreturn_t riic_tdre_isr(int irq, void *data) * value could be moved to the shadow shift register right away. So * this must be after updates to ICIER (where we want to disable TIE)! */ - writeb(val, riic->base + RIIC_ICDRT); + riic_writeb(riic, RIIC_ICDRT, val); return IRQ_HANDLED; } @@ -200,9 +210,9 @@ static irqreturn_t riic_tend_isr(int irq, void *data) { struct riic_dev *riic = data; - if (readb(riic->base + RIIC_ICSR2) & ICSR2_NACKF) { + if (riic_readb(riic, RIIC_ICSR2) & ICSR2_NACKF) { /* We got a NACKIE */ - readb(riic->base + RIIC_ICDRR); /* dummy read */ + riic_readb(riic, RIIC_ICDRR); /* dummy read */ riic_clear_set_bit(riic, ICSR2_NACKF, 0, RIIC_ICSR2); riic->err = -ENXIO; } else if (riic->bytes_left) { @@ -211,7 +221,7 @@ static irqreturn_t riic_tend_isr(int irq, void *data) if (riic->is_last || riic->err) { riic_clear_set_bit(riic, ICIER_TEIE, ICIER_SPIE, RIIC_ICIER); - writeb(ICCR2_SP, riic->base + RIIC_ICCR2); + riic_writeb(riic, RIIC_ICCR2, ICCR2_SP); } else { /* Transfer is complete, but do not send STOP */ riic_clear_set_bit(riic, ICIER_TEIE, 0, RIIC_ICIER); @@ -230,7 +240,7 @@ static irqreturn_t riic_rdrf_isr(int irq, void *data) if (riic->bytes_left == RIIC_INIT_MSG) { riic->bytes_left = riic->msg->len; - readb(riic->base + RIIC_ICDRR); /* dummy read */ + riic_readb(riic, RIIC_ICDRR); /* dummy read */ return IRQ_HANDLED; } @@ -238,7 +248,7 @@ static irqreturn_t riic_rdrf_isr(int irq, void *data) /* STOP must come before we set ACKBT! */ if (riic->is_last) { riic_clear_set_bit(riic, 0, ICIER_SPIE, RIIC_ICIER); - writeb(ICCR2_SP, riic->base + RIIC_ICCR2); + riic_writeb(riic, RIIC_ICCR2, ICCR2_SP); } riic_clear_set_bit(riic, 0, ICMR3_ACKBT, RIIC_ICMR3); @@ -248,7 +258,7 @@ static irqreturn_t riic_rdrf_isr(int irq, void *data) } /* Reading acks the RIE interrupt */ - *riic->buf = readb(riic->base + RIIC_ICDRR); + *riic->buf = riic_readb(riic, RIIC_ICDRR); riic->buf++; riic->bytes_left--; @@ -260,10 +270,10 @@ static irqreturn_t riic_stop_isr(int irq, void *data) struct riic_dev *riic = data; /* read back registers to confirm writes have fully propagated */ - writeb(0, riic->base + RIIC_ICSR2); - readb(riic->base + RIIC_ICSR2); - writeb(0, riic->base + RIIC_ICIER); - readb(riic->base + RIIC_ICIER); + riic_writeb(riic, RIIC_ICSR2, 0); + riic_readb(riic, RIIC_ICSR2); + riic_writeb(riic, RIIC_ICIER, 0); + riic_readb(riic, RIIC_ICIER); complete(&riic->msg_done); @@ -365,15 +375,15 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t) t->scl_rise_ns / (1000000000 / rate), cks, brl, brh); /* Changing the order of accessing IICRST and ICE may break things! */ - writeb(ICCR1_IICRST | ICCR1_SOWP, riic->base + RIIC_ICCR1); + riic_writeb(riic, RIIC_ICCR1, ICCR1_IICRST | ICCR1_SOWP); riic_clear_set_bit(riic, 0, ICCR1_ICE, RIIC_ICCR1); - writeb(ICMR1_CKS(cks), riic->base + RIIC_ICMR1); - writeb(brh | ICBR_RESERVED, riic->base + RIIC_ICBRH); - writeb(brl | ICBR_RESERVED, riic->base + RIIC_ICBRL); + riic_writeb(riic, RIIC_ICMR1, ICMR1_CKS(cks)); + riic_writeb(riic, RIIC_ICBRH, brh | ICBR_RESERVED); + riic_writeb(riic, RIIC_ICBRL, brl | ICBR_RESERVED); - writeb(0, riic->base + RIIC_ICSER); - writeb(ICMR3_ACKWP | ICMR3_RDRFS, riic->base + RIIC_ICMR3); + riic_writeb(riic, RIIC_ICSER, 0); + riic_writeb(riic, RIIC_ICMR3, ICMR3_ACKWP | ICMR3_RDRFS); riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); @@ -481,7 +491,7 @@ static void riic_i2c_remove(struct platform_device *pdev) struct riic_dev *riic = platform_get_drvdata(pdev); pm_runtime_get_sync(&pdev->dev); - writeb(0, riic->base + RIIC_ICIER); + riic_writeb(riic, RIIC_ICIER, 0); pm_runtime_put(&pdev->dev); i2c_del_adapter(&riic->adapter); pm_runtime_disable(&pdev->dev); From patchwork Fri Mar 15 10:30:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 780646 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 091A91B275; Fri, 15 Mar 2024 10:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498697; cv=none; b=oqOPPE0u3oY0ALTTMv9XGvlQ0Y0t50ZYD8YAGD7i5OBwJN8X3mcXuQ+JptJiFXF1g/DlvsXsp5rqG0mus30/eN+Or36EQbXX3zEsMLiFYZc00rYhPjzHBoUwY46L6U1iSiQRJ7OiisD09DRPaJFOTR4cRK+bf+rnlAyBdw+6+Ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498697; c=relaxed/simple; bh=9ZaYynsaCjU76O3Z51pWLQRwLV311S8QrPtofxK97f0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K3TomNcpT2AphsP0RnwoEM/gyZT9ATss8s/EkTnTwRNGUPNfxIZYHOu61lxBf1A92okA/AkYtiL674Tgw0O1Qmc2WYacGzXYH9VARUt+QG0kPVjoC+IWMgpgNAZaCIjhj9vjVJ9EtEqVsvzYZK+YeVKf1x+CEcX4t8Ic4v+53w8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HJTNTv4k; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HJTNTv4k" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-41324a16c9eso12228835e9.0; Fri, 15 Mar 2024 03:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710498694; x=1711103494; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XuhvpDK8oZ+Fu96smtWi//ks5eVckNXcaN8Zvrrlm7A=; b=HJTNTv4kKQXbfFg8lBgkveETJodUyV0UAa46iTrl0YPJxFXEoV4yVmSq0XJu4nA6di OLOym3AAjb1/5EMW9kQZluwoP+z03fnXsWaW7Q9UBI5PKTslr0N8eKyUfPODazDt5bfk aPVAZcORlPRHQvCVpYeYRUzxSESRju/KGYXCX8+j8yHKitgF0VK+WeSCFydFqO/3MUJ4 1rcBSRV1OLRT3jCDnaHqbw5m7mB4CJAYf6x5FB7CjtCEkzCiQhS3U0YWkVyXJJ240XnA EbuhbZT9rij0Wm9SdqS4ouCDAbHUSodn19BJ770kIX5ABWoZ24npvYSA5WJpTVdNn30Q ywAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710498694; x=1711103494; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XuhvpDK8oZ+Fu96smtWi//ks5eVckNXcaN8Zvrrlm7A=; b=R0TwHpvGWw0adJ/stAH/BvRh9uv5bF9xN2d2FXn3RsUjtH5ZwgD0xat/gkCUBDTjqO VcZKE89aDr302zqIWDBBRY/DGKwSv0riqfnqmI1atXO32HV/RQz7MLqsMwqMVSP7aJ2p JmiwuONiEQ42imYj3em4ZlFoVJrpRBpcxDo8pOcJetwEY1YuHau2qOlSsYf1mVmInzXV EMNwNwVLMibh+xS0gBxXAa/Le9DKPw0VXMhn5Yx/0fSDxIt/CIB7pw0jzcZxdKctWwR1 srolBYUfCJSlSw6hj3N/f5vO8aurxAeJsLAnURW+HKyDIPMlNVaaQRZ3VesmL7cluo+q Rg+A== X-Forwarded-Encrypted: i=1; AJvYcCXDR7zMVEeIZJL3FW9lGCrRET/L//2k2wip9ZcHqv6LjIzelhH58U8l1ZdpstFIvujVaMdOXKG9JiUhKmRrNKBDQ5/Lo4/daF52XqxXssvA07j3qbAizve0Sx4pe/kmyXm6kakbgHP/uPoQkitpQZ4cluE0ls9PV6Ea9rJQGIeuaB1Wgg== X-Gm-Message-State: AOJu0YzVo/VxPgGHCug8TqR+9PBPpnvkyBwDssukQYQwgs021//rmpXd j4JRuGVv2dGVrAusMNSj6XAEkUAEFvR+wS1N8O0sATW++GlPETcr X-Google-Smtp-Source: AGHT+IGIoXXZYmYXNu4w56ZmaBywNx018d+0XN7X5GOY1kEAfQHTdwD5iZXKsOexcAo3l685XFCZcQ== X-Received: by 2002:a05:600c:5187:b0:413:f1d7:eec9 with SMTP id fa7-20020a05600c518700b00413f1d7eec9mr3735593wmb.31.1710498694373; Fri, 15 Mar 2024 03:31:34 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:ae92:6adf:5cb6:274c]) by smtp.gmail.com with ESMTPSA id l19-20020a05600c4f1300b004130378fb77sm8676549wmq.6.2024.03.15.03.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 03:31:33 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Chris Brandt , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 3/4] i2c: riic: Pass register offsets and chip details as OF data Date: Fri, 15 Mar 2024 10:30:32 +0000 Message-Id: <20240315103033.141226-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar With an increasing number of SoCs reusing this driver, each with slight variations in the RIIC IP, it becomes necessary to support passing these details as OF data. This approach simplifies the extension of the driver for other SoCs. This patch lays the groundwork for adding support for the Renesas RZ/V2H SoC. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- v1->v2 - Dropped family from struct riic_of_data - Included RIIC_REG_END in enum list as flexible array member in a struct with no named members is not allowed --- drivers/i2c/busses/i2c-riic.c | 56 +++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 5eb25ef3abc4..3ae2d5c2f85a 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -46,18 +46,6 @@ #include #include -#define RIIC_ICCR1 0x00 -#define RIIC_ICCR2 0x04 -#define RIIC_ICMR1 0x08 -#define RIIC_ICMR3 0x10 -#define RIIC_ICSER 0x18 -#define RIIC_ICIER 0x1c -#define RIIC_ICSR2 0x24 -#define RIIC_ICBRL 0x34 -#define RIIC_ICBRH 0x38 -#define RIIC_ICDRT 0x3c -#define RIIC_ICDRR 0x40 - #define ICCR1_ICE 0x80 #define ICCR1_IICRST 0x40 #define ICCR1_SOWP 0x10 @@ -87,6 +75,25 @@ #define RIIC_INIT_MSG -1 +enum riic_reg_list { + RIIC_ICCR1 = 0, + RIIC_ICCR2, + RIIC_ICMR1, + RIIC_ICMR3, + RIIC_ICSER, + RIIC_ICIER, + RIIC_ICSR2, + RIIC_ICBRL, + RIIC_ICBRH, + RIIC_ICDRT, + RIIC_ICDRR, + RIIC_REG_END, +}; + +struct riic_of_data { + u8 regs[RIIC_REG_END]; +}; + struct riic_dev { void __iomem *base; u8 *buf; @@ -94,6 +101,7 @@ struct riic_dev { int bytes_left; int err; int is_last; + const struct riic_of_data *info; struct completion msg_done; struct i2c_adapter adapter; struct clk *clk; @@ -107,12 +115,12 @@ struct riic_irq_desc { static inline void riic_writeb(struct riic_dev *riic, u8 offset, u8 val) { - writeb(val, riic->base + offset); + writeb(val, riic->base + riic->info->regs[offset]); } static inline u8 riic_readb(struct riic_dev *riic, u8 offset) { - return readb(riic->base + offset); + return readb(riic->base + riic->info->regs[offset]); } static inline void riic_clear_set_bit(struct riic_dev *riic, u8 clear, u8 set, u8 reg) @@ -453,6 +461,8 @@ static int riic_i2c_probe(struct platform_device *pdev) } } + riic->info = of_device_get_match_data(&pdev->dev); + adap = &riic->adapter; i2c_set_adapdata(adap, riic); strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); @@ -497,8 +507,24 @@ static void riic_i2c_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } +static const struct riic_of_data riic_rz_a_info = { + .regs = { + [RIIC_ICCR1] = 0x00, + [RIIC_ICCR2] = 0x04, + [RIIC_ICMR1] = 0x08, + [RIIC_ICMR3] = 0x10, + [RIIC_ICSER] = 0x18, + [RIIC_ICIER] = 0x1c, + [RIIC_ICSR2] = 0x24, + [RIIC_ICBRL] = 0x34, + [RIIC_ICBRH] = 0x38, + [RIIC_ICDRT] = 0x3c, + [RIIC_ICDRR] = 0x40, + }, +}; + static const struct of_device_id riic_i2c_dt_ids[] = { - { .compatible = "renesas,riic-rz", }, + { .compatible = "renesas,riic-rz", .data = &riic_rz_a_info }, { /* Sentinel */ }, }; From patchwork Fri Mar 15 10:30:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prabhakar X-Patchwork-Id: 780979 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F5561B941; Fri, 15 Mar 2024 10:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498700; cv=none; b=UfAbxMbCMQZrsZEPjog8/VzQqw8I9h83U21z6mfEgC3coOATUHXUuhKHmlZIml6wAAJ0o6duboa3f29iWViawLjA5ftkxWgWsrMt/ZXW1nbGkX1EN21uacqf/ZB2uzVuoY/jwWnAEcTuOeOUjDmWsnXOYNS7gEu2NYtJUkU5lu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710498700; c=relaxed/simple; bh=lRdqpTT0gh2WtHqWtaq0VJmI8rtEhSLoMt9GWGgjokU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nt30VvA4Cx2C5nIbmlQe/5C7c7OwKLV5DIzLDI4K/anuXVHLr6LXof1EKx/9yYNuxKs7uWtAUDVphSRzA2L7FsgpNEK26Oa0L/f2eQOIm7lWhDOMfGKhkwDVEs/2fRc4fdCVaacLMZVeVaU6iVAG2m5Rbv3QMzai6QCxTu3+mFA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EvbZYSn6; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EvbZYSn6" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-414037e9acdso1373245e9.1; Fri, 15 Mar 2024 03:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710498697; x=1711103497; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CckpNQcaclBaLWHE4esIu6A7ypiEpjVfV/EelIKw3g8=; b=EvbZYSn6h9lgNKXlmyPhhkg7F+jCKjeoIr/Zy3hG1+rq90r6YEiqmEDhdTP4Eo2R5+ U9+uCwY+EQlUyXbPc2o1ISJmhwj+AIS1C8tvIX1XbL/zr/78G3YfpGgSGkRJ0ybgYnFE /qI72i8/l5UEnq2/0pMvJhhillHUBsQvZjxeEgYGBFZYKZIGFKvwRY46dGfQZnryxYjJ gqZxYIuBGKfBswe8xt+sHk6s1uuPVwScG2xdl2hc5/P3AmOniujkBwJ7Wys8FXFJcfgu pI/6uPSQ/bGWOaKGlDexQ7+MDGdzAA2hjKl5XzRsYhjcclGvuWYvIZFz8BNqprMjVKVm s0Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710498697; x=1711103497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CckpNQcaclBaLWHE4esIu6A7ypiEpjVfV/EelIKw3g8=; b=AkcpaVN2VHQ6SDhBbvaJUWZ0XkieDTlx2iW18UZNymsmzddq8pb1zMHdD4a210DXJa ZgbIHSO08xH0TEAR42hHmNuQvqxcO4zY5B8Rabx/PZ+FFIvZam+u6aJrCMbVt4z9ZZc7 4hlvg6IC0UG0fdkOR+qyB/C3d7pIgipVglOa/3a0ouLIrAWg928RuNPDNnf4kRYitEtp +8V/WnICTEHRyclqm3LDNS0atqntWUixSmxLqY/I5Rt9IJtR6oM9vYFO8egjj2Ika5Pe tDYbLJwnHHonHRIH3VLYXgk0FgVjvgb90XGrNRS+FZZmL6mAPCICG08CdBsXiHwVWuSZ CXsg== X-Forwarded-Encrypted: i=1; AJvYcCXU3s80mGSpF6wXlbha6BLTNf5OEvkOP2ObsdAHJetNFN7tnN3ndGQNNlbRCuFM8Ffy+fIJEnT7EqIrFbfDL5b4KK0ukqiLrr1SUD5XYtOCgrM1zn2uKf74PjXRnrh1irv0NftGzbHRkYNOBXbdvVgkiKHL9njnATVhWIfoQIOMcc7P5Q== X-Gm-Message-State: AOJu0Yy+7fxwgG9igEUD54VcjLOg1TO9iG7QBNrfPQNKBWNAfw2VQKiW 44e27ut1cVmQ4tdwTFZBIr3+CDo/3cfNs8kcOC9TurdV1qBiqQed X-Google-Smtp-Source: AGHT+IGHdpZ3MrSAR8C+LtQYj0s4PZhbJXP8cthDm4G5cDLoC6N21cKw5gg26nHFO/y1GLUSHk5d8A== X-Received: by 2002:a05:600c:5187:b0:413:f1d7:ee09 with SMTP id fa7-20020a05600c518700b00413f1d7ee09mr4194825wmb.15.1710498696399; Fri, 15 Mar 2024 03:31:36 -0700 (PDT) Received: from prasmi.home ([2a00:23c8:2500:a01:ae92:6adf:5cb6:274c]) by smtp.gmail.com with ESMTPSA id l19-20020a05600c4f1300b004130378fb77sm8676549wmq.6.2024.03.15.03.31.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 03:31:34 -0700 (PDT) From: Prabhakar X-Google-Original-From: Prabhakar To: Geert Uytterhoeven , Chris Brandt , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Magnus Damm , Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Prabhakar , Fabrizio Castro , Lad Prabhakar Subject: [PATCH v2 4/4] i2c: riic: Add support for R9A09G057 SoC Date: Fri, 15 Mar 2024 10:30:33 +0000 Message-Id: <20240315103033.141226-5-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20240315103033.141226-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Lad Prabhakar Extend the RIIC driver to support the RZ/V2H(P) ("R9A09G057") SoC. It accomplishes this by appending the compatible string list and passing the RZ/V2H-specific OF data. Signed-off-by: Lad Prabhakar --- v1->v2 - Dropped setting family --- drivers/i2c/busses/i2c-riic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c index 3ae2d5c2f85a..861b244d5118 100644 --- a/drivers/i2c/busses/i2c-riic.c +++ b/drivers/i2c/busses/i2c-riic.c @@ -523,8 +523,25 @@ static const struct riic_of_data riic_rz_a_info = { }, }; +static const struct riic_of_data riic_rz_v2h_info = { + .regs = { + [RIIC_ICCR1] = 0x00, + [RIIC_ICCR2] = 0x01, + [RIIC_ICMR1] = 0x02, + [RIIC_ICMR3] = 0x04, + [RIIC_ICSER] = 0x06, + [RIIC_ICIER] = 0x07, + [RIIC_ICSR2] = 0x09, + [RIIC_ICBRL] = 0x10, + [RIIC_ICBRH] = 0x11, + [RIIC_ICDRT] = 0x12, + [RIIC_ICDRR] = 0x13, + }, +}; + static const struct of_device_id riic_i2c_dt_ids[] = { { .compatible = "renesas,riic-rz", .data = &riic_rz_a_info }, + { .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info }, { /* Sentinel */ }, };