Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7478097rdb; Wed, 3 Jan 2024 18:44:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnS33dG7o571Z4xZXo+O2BYXP9pMSzE79CLLc53pKZTA9RS2F/nkj4yIEOUS77MV8+Pcz7 X-Received: by 2002:a05:6a20:1607:b0:198:680c:7677 with SMTP id l7-20020a056a20160700b00198680c7677mr1446346pzj.18.1704336280793; Wed, 03 Jan 2024 18:44:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704336280; cv=none; d=google.com; s=arc-20160816; b=0Zj9QZkPMxhDwWK9+sU6ogkApFJiCMb2ybpodXOqGgdyG2Z3wNceWXKWbk/7QYZ9zz xQbtuAwMt4oUybIqyld414OehNYRJ0gRGjls3ZXw2LhIlSOVoyZaLEG1d7pfV9rrSiyT bkY3+UhAHOeoF9IJCKhjgZ257q/Z1QYm5/gj9PGioN8+fxBrK6KR3S5HI7Xkqi3T+wMe uOIlOfkvwApoFI0BRcmkDI8JhFVtqItwf9cZ9QYKvW9koINcykFCbKEZ6ak5yhHhowRM /fnHl7KdDSS2tP8Gijlyyh1uWwgAF0tw3EwAULFzGaG5MrZT2VAM7u7aTF0di/MRDeWJ c4dw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q1WoOfYQYpJ89GbLobB3gm8w+8c0DRDgDbcjkN8OlvA=; fh=C9TL9yCnGisUiZfdvbqmpU1FLQkakKnDf/rl0GO1YOw=; b=HKtsDccE5eTCqbjZrdNUF7T7vjpN4aLkvjjo9CSh/+yxvhYL0TGDlGhD+Daejc6exD +BoPXtCO+x9NQYgXv+a0b0qvYvbK+SiP5J3mWwoCksfVy8DuaE6mG7tP1xi5R4/SrETn UnfbL6lQBP39QHW7wAwd5hQLwC+52ZFew7my51M3aDvdHDfKrp/ac5NAUvOHAr/SJErq ypNIN5u5GBHjfkssOBtUY7uVDKWheB60NqYGxDmESmb0K72BkV5N4qeJYUUo++leFW+x Rzy+D28tbrvt3GLopfr/ff2DAhUMRtidVsUdsYbTVvvuc6yU1Rpdm2Ad5qGyloPFFRBW k4Lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16208-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f10-20020a056a0022ca00b006d9a562c7d5si18572489pfj.83.2024.01.03.18.44.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 18:44:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16208-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DE04BB24E7B for ; Thu, 4 Jan 2024 02:44:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B06715487; Thu, 4 Jan 2024 02:43:39 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [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 4069812E65 for ; Thu, 4 Jan 2024 02:43:37 +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 4042h9eS001917; Thu, 4 Jan 2024 10:43:09 +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 4T59h94VLzz2Qby50; Thu, 4 Jan 2024 10:36:25 +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; Thu, 4 Jan 2024 10:43:07 +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 3/4] gpio: eic-sprd: Modify the calculation method of eic number Date: Thu, 4 Jan 2024 10:42:43 +0800 Message-ID: <20240104024244.12163-4-Wenhua.Lin@unisoc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240104024244.12163-1-Wenhua.Lin@unisoc.com> References: <20240104024244.12163-1-Wenhua.Lin@unisoc.com> 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: SHCAS03.spreadtrum.com (10.0.1.207) To shmbx06.spreadtrum.com (10.0.1.11) X-MAIL:SHSQR01.spreadtrum.com 4042h9eS001917 When the soc changes, the corresponding gpio-eic-sprd.c code needs to be modified, and the corresponding Document must also be modified, which is quite troublesome. To avoid modifying the driver file, the number of eics is automatically calculated by matching dts nodes. Signed-off-by: Wenhua Lin --- drivers/gpio/gpio-eic-sprd.c | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c index e492157e5154..1ca3c444957c 100644 --- a/drivers/gpio/gpio-eic-sprd.c +++ b/drivers/gpio/gpio-eic-sprd.c @@ -109,34 +109,32 @@ static struct sprd_eic *to_sprd_eic(struct notifier_block *nb) struct sprd_eic_variant_data { enum sprd_eic_type type; - u32 num_eics; }; +#define SPRD_EIC_VAR_DATA(soc_name) \ +static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = { \ + .type = SPRD_EIC_DEBOUNCE, \ +}; \ + \ +static const struct sprd_eic_variant_data soc_name##_eic_latch_data = { \ + .type = SPRD_EIC_LATCH, \ +}; \ + \ +static const struct sprd_eic_variant_data soc_name##_eic_async_data = { \ + .type = SPRD_EIC_ASYNC, \ +}; \ + \ +static const struct sprd_eic_variant_data soc_name##_eic_sync_data = { \ + .type = SPRD_EIC_SYNC, \ +} + +SPRD_EIC_VAR_DATA(sc9860); + static const char *sprd_eic_label_name[SPRD_EIC_MAX] = { "eic-debounce", "eic-latch", "eic-async", "eic-sync", }; -static const struct sprd_eic_variant_data sc9860_eic_dbnc_data = { - .type = SPRD_EIC_DEBOUNCE, - .num_eics = 8, -}; - -static const struct sprd_eic_variant_data sc9860_eic_latch_data = { - .type = SPRD_EIC_LATCH, - .num_eics = 8, -}; - -static const struct sprd_eic_variant_data sc9860_eic_async_data = { - .type = SPRD_EIC_ASYNC, - .num_eics = 8, -}; - -static const struct sprd_eic_variant_data sc9860_eic_sync_data = { - .type = SPRD_EIC_SYNC, - .num_eics = 8, -}; - static inline void __iomem *sprd_eic_offset_base(struct sprd_eic *sprd_eic, unsigned int bank) { @@ -607,6 +605,7 @@ static int sprd_eic_probe(struct platform_device *pdev) struct gpio_irq_chip *irq; struct sprd_eic *sprd_eic; struct resource *res; + u16 num_banks = 0; int ret, i; pdata = of_device_get_match_data(dev); @@ -640,10 +639,12 @@ static int sprd_eic_probe(struct platform_device *pdev) sprd_eic->base[i] = devm_ioremap_resource(dev, res); if (IS_ERR(sprd_eic->base[i])) return PTR_ERR(sprd_eic->base[i]); + + num_banks++; } sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type]; - sprd_eic->chip.ngpio = pdata->num_eics; + sprd_eic->chip.ngpio = num_banks * SPRD_EIC_PER_BANK_NR; sprd_eic->chip.base = -1; sprd_eic->chip.parent = dev; sprd_eic->chip.direction_input = sprd_eic_direction_input; -- 2.17.1