From patchwork Tue Nov 29 10:12:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tnhuynh@apm.com X-Patchwork-Id: 9451367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F7BA60235 for ; Tue, 29 Nov 2016 10:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D02C2810E for ; Tue, 29 Nov 2016 10:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7198F2811D; Tue, 29 Nov 2016 10:13:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AA4128111 for ; Tue, 29 Nov 2016 10:13:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754940AbcK2KNl (ORCPT ); Tue, 29 Nov 2016 05:13:41 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:34321 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757077AbcK2KND (ORCPT ); Tue, 29 Nov 2016 05:13:03 -0500 Received: by mail-pf0-f169.google.com with SMTP id c4so31383961pfb.1 for ; Tue, 29 Nov 2016 02:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=UzYV4I+MDmR5fmrN8lXwVb/nsf6jbvzjDfn10XbbYXA=; b=SnASKHisxxbSzcMbtsb5AJaILQ0gMeOmxdAaKZMiRHCzW/+58ds0K3HlPKbGcmL5j7 VLY2b7qFswMLY1vli86AXB5xUd1cw9WnHZaiOUyQaeFiTFM5op96z5fFUK1oxTRx89Wj xfu4MDkzdUnv5rWnfZJMqiw4B1i4J2o6cO8Oo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UzYV4I+MDmR5fmrN8lXwVb/nsf6jbvzjDfn10XbbYXA=; b=RpSczZirw6/J2aEvdzNXuW+Ggk2pTWfaJY5noH9qgiumea+yeRXsDkOtXmGRYEw9UG CGpf70nhOzLhgXR0VkKHeFti9pWbZjDZewT1T5ELbRh6KKaHLZucu+S72p0vlxqXCb8z OLUdZ+qcejH4DhPyZOwWEM33PrFL8KP8k39oEwd8F8Jxylje2wyGmoPltnJT5WqNBLsG d8uZS/+Bf8Mj4JNhrbWqO/8A2EzmacbNyX5nBIvIdfsivZ+zBenw16UXbfounFKDpb/P 2uOHpKMLr6HQAoljAvpEmjXFVH1voQR54GdbiiMWV9COrLlxUN58yMFrEiGf/6l+2vNU VvYQ== X-Gm-Message-State: AKaTC01ZA+Ipkw1xmbjZ8fGin0PdGyvIHKDeoQPdDVku6FjCa4nI7g8g5AT1Q3eA32X3hGYY X-Received: by 10.98.32.151 with SMTP id m23mr27310192pfj.127.1480414382728; Tue, 29 Nov 2016 02:13:02 -0800 (PST) Received: from localhost.localdomain ([118.69.219.197]) by smtp.gmail.com with ESMTPSA id w16sm75958146pgc.30.2016.11.29.02.12.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 02:13:01 -0800 (PST) From: Tin Huynh To: Wolfram Sang , Peter Rosin Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Loc Ho , Thang Nguyen , Phong Vo , patches@apm.com, Tin Huynh Subject: [PATCH V5] i2c: mux: pca954x: Add ACPI support for pca954x Date: Tue, 29 Nov 2016 17:12:43 +0700 Message-Id: <1480414363-16318-1-git-send-email-tnhuynh@apm.com> X-Mailer: git-send-email 1.7.1 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch enables ACPI support for mux-pca954x driver. Signed-off-by: Tin Huynh Acked-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-pca954x.c | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) Change from V4: -Add ACPI_PTR. Change from V3: -Readd CONFIG_ACPI. Change from V2: -Remove CONFIG_ACPI. Change from V1 : -Don't shadow id variable. -Include sorted header. -Redefine acpi_device_id. -Add CONFIG_ACPI. diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 1091346..f81f8b5 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -35,6 +35,7 @@ * warranty of any kind, whether express or implied. */ +#include #include #include #include @@ -120,6 +121,21 @@ struct pca954x { }; MODULE_DEVICE_TABLE(i2c, pca954x_id); +#ifdef CONFIG_ACPI +static const struct acpi_device_id pca954x_acpi_ids[] = { + { .id = "PCA9540", .driver_data = pca_9540 }, + { .id = "PCA9542", .driver_data = pca_9540 }, + { .id = "PCA9543", .driver_data = pca_9543 }, + { .id = "PCA9544", .driver_data = pca_9544 }, + { .id = "PCA9545", .driver_data = pca_9545 }, + { .id = "PCA9546", .driver_data = pca_9545 }, + { .id = "PCA9547", .driver_data = pca_9547 }, + { .id = "PCA9548", .driver_data = pca_9548 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, pca954x_acpi_ids); +#endif + #ifdef CONFIG_OF static const struct of_device_id pca954x_of_match[] = { { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, @@ -245,8 +261,17 @@ static int pca954x_probe(struct i2c_client *client, match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev); if (match) data->chip = of_device_get_match_data(&client->dev); - else + else if (id) data->chip = &chips[id->driver_data]; + else { + const struct acpi_device_id *acpi_id; + + acpi_id = acpi_match_device(ACPI_PTR(pca954x_acpi_ids), + &client->dev); + if (!acpi_id) + return -ENODEV; + data->chip = &chips[acpi_id->driver_data]; + } data->last_chan = 0; /* force the first selection */ @@ -321,6 +346,7 @@ static int pca954x_resume(struct device *dev) .name = "pca954x", .pm = &pca954x_pm, .of_match_table = of_match_ptr(pca954x_of_match), + .acpi_match_table = ACPI_PTR(pca954x_acpi_ids), }, .probe = pca954x_probe, .remove = pca954x_remove,