Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6415177rdb; Tue, 2 Jan 2024 00:29:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/WubIfHjhEQXfxkcixEfStjjuUyFwBq5ffs0Jz6hjm5OugQY0IDc0HSCX6hmRG9k0mW6z X-Received: by 2002:a50:8e0e:0:b0:553:826b:b2b with SMTP id 14-20020a508e0e000000b00553826b0b2bmr16040800edw.13.1704184171778; Tue, 02 Jan 2024 00:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704184171; cv=none; d=google.com; s=arc-20160816; b=qt38uTQUcO0lK4TOJ9gLZel9VNYwrMyq9E9m/PWs1BEYqQKIGcOeiTD1AkJQG7ni7X 9kyo3gyts4qiB40igEnTFZr2K/hjOBkf3N5p+3tlh8FJO3l+Oe4lKKSsU6n6lMe22mmH vtOAHoDKyY3xrlHgKRsli8k0vaC/tI+Fp+U+72N2tQnad9xiAEf47qbnz2KbBwNyb/SN pMmk3+oev9ytW8+8q+eXfkj9vn5y4S53VJvDLgLKzUJv90WohotMewbaZIZ7w71Nx6uG AzxgSU5teActmBA+6FgNJgNWLck2X42N+TWAr6yau3+jm+nKhpqSPp3K7rbGEfRZOr8B Ruvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=ip9/7a4p+0m0gFIVXQIdlFUV7IXuO7uDMM2YHDf3zX4=; fh=C9TL9yCnGisUiZfdvbqmpU1FLQkakKnDf/rl0GO1YOw=; b=OBjFfKpP8aEpAWjxgXz+aUgVOrZeehn/iNPpRNN5q0KxVj0HT+rgaImp2JBdm+da7Q yWLnxXfm5dZruG7mqSmc7tS7wIx78ugIIkULxiQMs5LyLBmQDHjScPHDmhUBonADQ8Pk Ou4CO+6ikubMfMHfDGOS1l1vwSRIhGYaasxjc4JHbMTT7205+Zox0Jee37cHst+sBBmE 2BoeAjc/iUyEm58RKgPUKlx7VYRAIQLVBTlM/MgJ/xRNXQoKeyxazbpfQJ+AwBAWH9B9 I47BWkm81izdB17O/GRasrns1MCe6OoJC6rpD+u4Rm5zYCYotmhPBs7fXjArpzGCcmpL Ix3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14146-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q16-20020a056402519000b0054cb3786d5dsi10936612edd.393.2024.01.02.00.29.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 00:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14146-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8675E1F21A26 for ; Tue, 2 Jan 2024 08:29:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F4F74C8F; Tue, 2 Jan 2024 08:29:24 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBB0246A3 for ; Tue, 2 Jan 2024 08:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4028SX5a044296; Tue, 2 Jan 2024 16:28:33 +0800 (+08) (envelope-from Wenhua.Lin@unisoc.com) Received: from SHDLP.spreadtrum.com (shmbx06.spreadtrum.com [10.0.1.11]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4T45Rj2tMfz2Qxlxk; Tue, 2 Jan 2024 16:21:53 +0800 (CST) Received: from xm9614pcu.spreadtrum.com (10.13.2.29) by shmbx06.spreadtrum.com (10.0.1.11) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Tue, 2 Jan 2024 16:28:32 +0800 From: Wenhua Lin To: Linus Walleij , Andy Shevchenko , Bartosz Golaszewski CC: Orson Zhai , Baolin Wang , Chunyan Zhang , , , wenhua lin , Wenhua Lin , Xiongpeng Wu Subject: [PATCH V3] gpio: pmic-eic-sprd: Configure the bit corresponding to the EIC through offset Date: Tue, 2 Jan 2024 16:28:29 +0800 Message-ID: <20240102082829.30874-1-Wenhua.Lin@unisoc.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To shmbx06.spreadtrum.com (10.0.1.11) X-MAIL:SHSQR01.spreadtrum.com 4028SX5a044296 A bank PMIC EIC contains 16 EICs, and the operating registers are BIT0-BIT15, such as BIT0 of the register operated by EIC0. Using the one-dimensional array reg[CACHE_NR_REGS] for maintenance will cause the configuration of other EICs to be affected when operating a certain EIC. In order to solve this problem, configure the bit corresponding to the EIC through offset. Signed-off-by: Wenhua Lin --- Change in V3: -Change title. -Change commit message. -Delete the modification of the two-dimensional array maintenance pmic eic, and add the corresponding bits to configure the eic according to the offset. --- --- drivers/gpio/gpio-pmic-eic-sprd.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-pmic-eic-sprd.c b/drivers/gpio/gpio-pmic-eic-sprd.c index 01c0fd0a9d8c..d9b228bea42e 100644 --- a/drivers/gpio/gpio-pmic-eic-sprd.c +++ b/drivers/gpio/gpio-pmic-eic-sprd.c @@ -151,8 +151,8 @@ static void sprd_pmic_eic_irq_mask(struct irq_data *data) struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); u32 offset = irqd_to_hwirq(data); - pmic_eic->reg[REG_IE] = 0; - pmic_eic->reg[REG_TRIG] = 0; + pmic_eic->reg[REG_IE] &= ~BIT(offset); + pmic_eic->reg[REG_TRIG] &= ~BIT(offset); gpiochip_disable_irq(chip, offset); } @@ -165,8 +165,8 @@ static void sprd_pmic_eic_irq_unmask(struct irq_data *data) gpiochip_enable_irq(chip, offset); - pmic_eic->reg[REG_IE] = 1; - pmic_eic->reg[REG_TRIG] = 1; + pmic_eic->reg[REG_IE] |= BIT(offset); + pmic_eic->reg[REG_TRIG] |= BIT(offset); } static int sprd_pmic_eic_irq_set_type(struct irq_data *data, @@ -174,13 +174,14 @@ static int sprd_pmic_eic_irq_set_type(struct irq_data *data, { struct gpio_chip *chip = irq_data_get_irq_chip_data(data); struct sprd_pmic_eic *pmic_eic = gpiochip_get_data(chip); + u32 offset = irqd_to_hwirq(data); switch (flow_type) { case IRQ_TYPE_LEVEL_HIGH: - pmic_eic->reg[REG_IEV] = 1; + pmic_eic->reg[REG_IEV] |= BIT(offset); break; case IRQ_TYPE_LEVEL_LOW: - pmic_eic->reg[REG_IEV] = 0; + pmic_eic->reg[REG_IEV] &= ~BIT(offset); break; case IRQ_TYPE_EDGE_RISING: case IRQ_TYPE_EDGE_FALLING: @@ -222,15 +223,15 @@ static void sprd_pmic_eic_bus_sync_unlock(struct irq_data *data) sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV, 1); } else { sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IEV, - pmic_eic->reg[REG_IEV]); + !!(pmic_eic->reg[REG_IEV] & BIT(offset))); } /* Set irq unmask */ sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_IE, - pmic_eic->reg[REG_IE]); + !!(pmic_eic->reg[REG_IE] & BIT(offset))); /* Generate trigger start pulse for debounce EIC */ sprd_pmic_eic_update(chip, offset, SPRD_PMIC_EIC_TRIG, - pmic_eic->reg[REG_TRIG]); + !!(pmic_eic->reg[REG_TRIG] & BIT(offset))); mutex_unlock(&pmic_eic->buslock); } -- 2.17.1