From patchwork Thu Feb 9 10:51:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13134383 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 962F7C636D4 for ; Thu, 9 Feb 2023 10:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/seWGDIf6nVSogmnpGVEIYvXOiahOGWYraa8hWna8rE=; b=PU1IXnzmPL7J5U SgCcLy+w1SY8kWXKeTXvxmvODY3dB/F3SHQfdF8nrQrV7A7PjuQPf6Kb3cBskEy0FoML6tMwDolAx XybkL4vjMDZWABjNsKfoxHl4eMBmoc1ZBI8DXGiWyCX9wWa1v4AY65yvwSEXwQ4OmRDBuTgl2NY6P Ld0l2B7IKv4zQjkUCyIdSXP/8NSQLLb5NPsBdO6iX1SsYgQh+NlwKqLKZM+veYYp9INc6JK/K84Yc PjQU9fDprvHHUmjvdYqa63LAM7nk30MUZPuoSfsOVadOYEUAq9p277muGjFcDlIHZf79TaoQAv+E1 EOgv+X4ClBMykg5fpQbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ4YV-0015WM-FB; Thu, 09 Feb 2023 10:53:31 +0000 Received: from mx2.securetransport.de ([188.68.39.254]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ4YR-0015VH-3X for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 10:53:29 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.securetransport.de (Postfix) with ESMTPSA id 685565E9DA; Thu, 9 Feb 2023 11:52:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1675939967; bh=rIypa5wgaFQgkB38FGKqj8GeX3xjPSyXjalzqhgKna8=; h=From:To:CC:Subject:Date:From; b=Fn+A49E5ToBchG3vvkwIa761MxFIbMkSfdHkNwMsY+OMm4q/I91zYc3IVjCVgMdPS njG83IBXtrzmd29KXbLjtwiVTGptRP5rcLxUqxgmVjK7zmIg+oFVLOv1bhYnQ98OR1 Z0q6knKkRDUo9dYYdt57nI+D1Ya2KEPn/Ib7NbcjDGn/RdwX8GDj8qQftcy0/uV1sl xNfwnFVYSdD/BIeeH/CrS1KxqiP/JzN5+FnVNm5hUg3M42xNyIoETbS60C0/+PxgE9 tY/JlTj2gPMPCkLYWcda1LygS8+En0XCQsvB3/a8uk1ADMI83yF8e4obuxa5XB1a+c 1+E6VV54GmU0A== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21; Thu, 9 Feb 2023 11:52:34 +0100 Received: from Stretch-CN.dh-electronics.org (10.64.6.116) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21 via Frontend Transport; Thu, 9 Feb 2023 11:52:34 +0100 From: Christoph Niedermaier To: CC: Christoph Niedermaier , Support Opensource , Lee Jones , Adam Thomson , Liam Girdwood , Mark Brown , Marek Vasut , , Subject: [PATCH V2 1/2] mfd: da9062: Remove IRQ requirement Date: Thu, 9 Feb 2023 11:51:43 +0100 Message-ID: <20230209105144.9351-1-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_025327_487767_2C8D98BD X-CRM114-Status: GOOD ( 19.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch removes the requirement for an IRQ, because for the core functionality IRQ isn't needed. So this makes the DA9061/62 chip useable for designs which haven't connected the IRQ pin. Signed-off-by: Christoph Niedermaier Reviewed-by: Marek Vasut Reviewed-by: Adam Ward --- Cc: Support Opensource Cc: Lee Jones Cc: Adam Thomson Cc: Liam Girdwood Cc: Mark Brown Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: linux-kernel@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rebase on current next 20230209 - Add Lee Jones to Cc list --- drivers/mfd/da9062-core.c | 98 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c index 40cde51e5719..caa597400dd1 100644 --- a/drivers/mfd/da9062-core.c +++ b/drivers/mfd/da9062-core.c @@ -212,6 +212,27 @@ static const struct mfd_cell da9061_devs[] = { }, }; +static const struct mfd_cell da9061_devs_without_irq[] = { + { + .name = "da9061-core", + }, + { + .name = "da9062-regulators", + }, + { + .name = "da9061-watchdog", + .of_compatible = "dlg,da9061-watchdog", + }, + { + .name = "da9061-thermal", + .of_compatible = "dlg,da9061-thermal", + }, + { + .name = "da9061-onkey", + .of_compatible = "dlg,da9061-onkey", + }, +}; + static const struct resource da9062_core_resources[] = { DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ), }; @@ -288,6 +309,35 @@ static const struct mfd_cell da9062_devs[] = { }, }; +static const struct mfd_cell da9062_devs_without_irq[] = { + { + .name = "da9062-core", + }, + { + .name = "da9062-regulators", + }, + { + .name = "da9062-watchdog", + .of_compatible = "dlg,da9062-watchdog", + }, + { + .name = "da9062-thermal", + .of_compatible = "dlg,da9062-thermal", + }, + { + .name = "da9062-rtc", + .of_compatible = "dlg,da9062-rtc", + }, + { + .name = "da9062-onkey", + .of_compatible = "dlg,da9062-onkey", + }, + { + .name = "da9062-gpio", + .of_compatible = "dlg,da9062-gpio", + }, +}; + static int da9062_clear_fault_log(struct da9062 *chip) { int ret; @@ -625,7 +675,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c) { const struct i2c_device_id *id = i2c_client_get_device_id(i2c); struct da9062 *chip; - unsigned int irq_base; + unsigned int irq_base = 0; const struct mfd_cell *cell; const struct regmap_irq_chip *irq_chip; const struct regmap_config *config; @@ -645,21 +695,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c) i2c_set_clientdata(i2c, chip); chip->dev = &i2c->dev; - if (!i2c->irq) { - dev_err(chip->dev, "No IRQ configured\n"); - return -EINVAL; - } - switch (chip->chip_type) { case COMPAT_TYPE_DA9061: - cell = da9061_devs; - cell_num = ARRAY_SIZE(da9061_devs); + cell = i2c->irq ? da9061_devs : da9061_devs_without_irq; + cell_num = i2c->irq ? ARRAY_SIZE(da9061_devs) : ARRAY_SIZE(da9061_devs_without_irq); irq_chip = &da9061_irq_chip; config = &da9061_regmap_config; break; case COMPAT_TYPE_DA9062: - cell = da9062_devs; - cell_num = ARRAY_SIZE(da9062_devs); + cell = i2c->irq ? da9062_devs : da9062_devs_without_irq; + cell_num = i2c->irq ? ARRAY_SIZE(da9062_devs) : ARRAY_SIZE(da9062_devs_without_irq); irq_chip = &da9062_irq_chip; config = &da9062_regmap_config; break; @@ -695,29 +740,32 @@ static int da9062_i2c_probe(struct i2c_client *i2c) if (ret) return ret; - ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); - if (ret < 0) { - dev_err(chip->dev, "Failed to configure IRQ type\n"); - return ret; - } + if (i2c->irq) { + ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); + if (ret < 0) { + dev_err(chip->dev, "Failed to configure IRQ type\n"); + return ret; + } - ret = regmap_add_irq_chip(chip->regmap, i2c->irq, - trigger_type | IRQF_SHARED | IRQF_ONESHOT, - -1, irq_chip, &chip->regmap_irq); - if (ret) { - dev_err(chip->dev, "Failed to request IRQ %d: %d\n", - i2c->irq, ret); - return ret; - } + ret = regmap_add_irq_chip(chip->regmap, i2c->irq, + trigger_type | IRQF_SHARED | IRQF_ONESHOT, + -1, irq_chip, &chip->regmap_irq); + if (ret) { + dev_err(chip->dev, "Failed to request IRQ %d: %d\n", + i2c->irq, ret); + return ret; + } - irq_base = regmap_irq_chip_get_base(chip->regmap_irq); + irq_base = regmap_irq_chip_get_base(chip->regmap_irq); + } ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell, cell_num, NULL, irq_base, NULL); if (ret) { dev_err(chip->dev, "Cannot register child devices\n"); - regmap_del_irq_chip(i2c->irq, chip->regmap_irq); + if (i2c->irq) + regmap_del_irq_chip(i2c->irq, chip->regmap_irq); return ret; } From patchwork Thu Feb 9 10:51:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Niedermaier X-Patchwork-Id: 13134419 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DB4BC61DA4 for ; Thu, 9 Feb 2023 11:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B+eL/6diu8q1M5mZYCfbUBs0H2wWaAxDcwrdDkhhLqk=; b=0yfwL7NUGSnfDh MxOqvzqSyv53f16XY6j8vVEpIHJfe+H1qQBIOR+P01FLNRQIa33VFSl4xLMAVZgsky6DC3lZriMb6 prA4AuIBqO/GnwNr2Aj7Fzp5sSrSqvxD4OQgtTgImlchUsG2vvRlFO4KsyjZspOxIs+OEw1KZ165+ bV6NxHHN6fbBjWH6D7uggRu30EuFRXetjOJKu++U/g005Cqo139/tqEQrXbHQwY2fy5+ZjWQ2WPTs bJefnI8ZmRS2ZPp8X0hxVRX8lTG402X1V3VAiB2oPE0iMNvGYPjhvlxFU6XWhT5FUam/7dDIJ/WBb dpJC15uheyqHZBCTTrwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ4mp-001BHm-HO; Thu, 09 Feb 2023 11:08:19 +0000 Received: from mx2.securetransport.de ([2a03:4000:13:6c7::1]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ4ml-001BFm-Ik for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 11:08:17 +0000 Received: from mail.dh-electronics.com (unknown [77.24.89.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.securetransport.de (Postfix) with ESMTPSA id 535EB5E972; Thu, 9 Feb 2023 12:07:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dh-electronics.com; s=dhelectronicscom; t=1675940869; bh=coWQwRg2rue2zvnmiMjsKb1UY8225zzHmoCBOjlpM6c=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=On8IodrYmL27ETqQGCMBYPmwVcLNqksMDQRl8vr8eTwtVCWjNwK4qJKons/XzvSkN N9mTgYmerP0hdvKZUiLwn083OeWHQwOl+WI4iLI1xmrJIx2qZH9ISUP4RucbcC4Kqt Ybcq3376v6ZWrzbAGU1mNruGEY/cRP93DRu33yMQ1FJTCqNRrzg3Z9Vbbufn6zlGw4 wckKQOo8RhUgeEVbJni/Lnw+G/FTlmU0dFuo/pH4/MeU7fjZtaFbybZQ8X0dBQCjqz nDargxLpnNUwdXAzWj+L+bhvOeal5Y2LuW1e0IBcOmOb58/rXccfWkYV9EZ0Cre6M/ Ye6r+YvdzifhA== Received: from DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21; Thu, 9 Feb 2023 11:52:34 +0100 Received: from Stretch-CN.dh-electronics.org (10.64.6.116) by DHPWEX01.DH-ELECTRONICS.ORG (10.64.2.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.21 via Frontend Transport; Thu, 9 Feb 2023 11:52:34 +0100 From: Christoph Niedermaier To: CC: Christoph Niedermaier , Support Opensource , Adam Thomson , Liam Girdwood , Mark Brown , Marek Vasut , , Subject: [PATCH V2 2/2] regulator: da9062: Make the use of IRQ optional Date: Thu, 9 Feb 2023 11:51:44 +0100 Message-ID: <20230209105144.9351-2-cniedermaier@dh-electronics.com> X-Mailer: git-send-email 2.11.0 X-klartext: yes In-Reply-To: <20230209105144.9351-1-cniedermaier@dh-electronics.com> References: <20230209105144.9351-1-cniedermaier@dh-electronics.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_030815_868378_FAA5566F X-CRM114-Status: GOOD ( 16.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch makes the use of IRQ optional to make the DA9061/62 usable for designs that don't have the IRQ pin connected, because the regulator is usable without IRQ. Signed-off-by: Christoph Niedermaier Acked-by: Mark Brown Reviewed-by: Adam Ward --- Cc: Support Opensource Cc: Adam Thomson Cc: Liam Girdwood Cc: Mark Brown Cc: Marek Vasut Cc: kernel@dh-electronics.com Cc: linux-kernel@vger.kernel.org To: linux-arm-kernel@lists.infradead.org --- V2: - Rebase on current next 20230209 - Add Reviewed-by and Acked-by tags --- drivers/regulator/da9062-regulator.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c index 1a6324001027..653e1844dd61 100644 --- a/drivers/regulator/da9062-regulator.c +++ b/drivers/regulator/da9062-regulator.c @@ -1012,10 +1012,9 @@ static int da9062_regulator_probe(struct platform_device *pdev) } /* LDOs overcurrent event support */ - irq = platform_get_irq_byname(pdev, "LDO_LIM"); - if (irq < 0) - return irq; - regulators->irq_ldo_lim = irq; + regulators->irq_ldo_lim = platform_get_irq_byname_optional(pdev, "LDO_LIM"); + if (regulators->irq_ldo_lim < 0) + return 0; ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, da9062_ldo_lim_event,