From patchwork Wed Aug 8 08:30:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 954836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41ll2V4P7Qz9s4V for ; Wed, 8 Aug 2018 18:30:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727198AbeHHKsy (ORCPT ); Wed, 8 Aug 2018 06:48:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727177AbeHHKsx (ORCPT ); Wed, 8 Aug 2018 06:48:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C2EC8197037; Wed, 8 Aug 2018 08:30:15 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93C7A2027047; Wed, 8 Aug 2018 08:30:13 +0000 (UTC) From: Hans de Goede To: "Rafael J . Wysocki" , Len Brown , Andy Shevchenko , Mika Westerberg , Darren Hart , Wolfram Sang Cc: Hans de Goede , Srinivas Pandruvada , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Heikki Krogerus , John Garry , linux-i2c@vger.kernel.org Subject: [PATCH v4 2/4] ACPI / scan: Create platform device for fwnodes with multiple i2c devices Date: Wed, 8 Aug 2018 10:30:04 +0200 Message-Id: <20180808083006.31919-3-hdegoede@redhat.com> In-Reply-To: <20180808083006.31919-1-hdegoede@redhat.com> References: <20180808083006.31919-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 08 Aug 2018 08:30:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 08 Aug 2018 08:30:15 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Some devices have multiple I2cSerialBus resources and for things to work an i2c-client must be instantiated for each, each with its own i2c_device_id. Normally we only instantiate an i2c-client for the first resource, using the ACPI HID as id. This commit adds a list of HIDs of devices, which need multiple i2c-clients instantiated from a single fwnode, to acpi_device_enumeration_by_parent and makes acpi_device_enumeration_by_parent return false for these devices so that a platform device will be instantiated. This allows the drivers/platform/x86/i2c-multi-instantiate.c driver, which knows which i2c_device_id to use for each resource, to bind to the fwnode and initiate an i2c-client for each resource. Signed-off-by: Hans de Goede --- Changes in v3: -New patch in v3 of this patch-set Changes in v4: -Some small code-style fixes --- drivers/acpi/scan.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 6799d00dd790..b51913372e21 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1540,6 +1540,18 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) { struct list_head resource_list; bool is_serial_bus_slave = false; + /* + * These devices have multiple I2cSerialBus resources and an i2c-client + * must be instantiated for each, each with its own i2c_device_id. + * Normally we only instantiate an i2c-client for the first resource, + * using the ACPI HID as id. These special cases are handled by the + * drivers/platform/x86/i2c-multi-instantiate.c driver, which knows + * which i2c_device_id to use for each resource. + */ + static const struct acpi_device_id i2c_multi_instantiate_ids[] = { + {"BSG1160", }, + {} + }; if (acpi_is_indirect_io_slave(device)) return true; @@ -1551,6 +1563,10 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) fwnode_property_present(&device->fwnode, "baud"))) return true; + /* Instantiate a pdev for the i2c-multi-instantiate drv to bind to */ + if (!acpi_match_device_ids(device, i2c_multi_instantiate_ids)) + return false; + INIT_LIST_HEAD(&resource_list); acpi_dev_get_resources(device, &resource_list, acpi_check_serial_bus_slave,