From patchwork Fri Aug 14 19:31:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dustin Byford X-Patchwork-Id: 507563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2F8FE1401E7 for ; Sat, 15 Aug 2015 05:32:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b=QXu3sYB4; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751658AbbHNTcK (ORCPT ); Fri, 14 Aug 2015 15:32:10 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35227 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbbHNTcH (ORCPT ); Fri, 14 Aug 2015 15:32:07 -0400 Received: by pacgr6 with SMTP id gr6so65657751pac.2 for ; Fri, 14 Aug 2015 12:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5zOevlTVFexL6rCcvZQWPUG1bdb5KcTMi/wv5c0sP50=; b=QXu3sYB42cilJep70yzUs6piXalY6r5uygmFNHxMF8WAC3tfqKQfZhidSUBQOf6OSX ++yr+1Gb52XzIYRJ70Ekp9NqFeWoqgU0e0MiBwryCJlr4FpDexWOYp6jXvH/WIGmaEBT VcnYJ9kCpDZAFRy/I2Mr/YUnj0Q/+AzjMoLIY= 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:in-reply-to :references; bh=5zOevlTVFexL6rCcvZQWPUG1bdb5KcTMi/wv5c0sP50=; b=lkP3HISJBBC5QkT4sFcO08hJuGxDNF3HGn2+uxNISbjxANGI+XKNAykzhXP9gztWEc MM2iwrW3i7JOmgJ/jZLyw1umuWpZ6dnkn32pClGYCIbQA2VuW76A5ll1/luuWbUA2wvG NH6O5vsLpDLkT7R9IEPBc3VN7TBHS2fviYuHXnF66qT31LD/SXKpbou77jvRmpK2AyG5 HxcED+FhvsT1gkkazFOi/G2kJKPyokRrBlDUjdBiwxzx+ta5qMZWVqHNSfppNkTOfy1C ccktwCscpH/QAOcrMR+p2pfPvsGMUx1Af5esWUhHTVteP9agQ0zlWWG7oEd531Gjn0pR 17jA== X-Gm-Message-State: ALoCoQklUUpgv7abT0Kp8zHErG96Kb4tRhpaBy/h+q/hjznPRtyUgNKmOrAaCoI/EACc6RP/X9RL X-Received: by 10.66.243.70 with SMTP id ww6mr92200161pac.88.1439580726616; Fri, 14 Aug 2015 12:32:06 -0700 (PDT) Received: from magnum.cumulusnetworks.com ([216.129.126.126]) by smtp.gmail.com with ESMTPSA id yt9sm6928755pac.32.2015.08.14.12.32.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 12:32:06 -0700 (PDT) Received: by magnum.cumulusnetworks.com (Postfix, from userid 1016) id A7DE68A1D91; Fri, 14 Aug 2015 12:32:05 -0700 (PDT) From: Dustin Byford To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org, rjw@rjwysocki.net, linux-acpi@vger.kernel.org Subject: [RFC v2 1/1] i2c: acpi: scan ACPI enumerated I2C mux channels Date: Fri, 14 Aug 2015 12:31:33 -0700 Message-Id: <1439580693-5538-2-git-send-email-dustin@cumulusnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439580693-5538-1-git-send-email-dustin@cumulusnetworks.com> References: <1439580693-5538-1-git-send-email-dustin@cumulusnetworks.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Set an ACPI companion for I2C mux channels enumerated through ACPI and ensure they are scanned for devices. Signed-off-by: Dustin Byford --- drivers/i2c/i2c-core.c | 10 ++++++++++ drivers/i2c/i2c-mux.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index c83e4d1..23cc8e9 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -171,8 +171,18 @@ static void acpi_i2c_register_devices(struct i2c_adapter *adap) if (!adap->dev.parent) return; + /* + * Determine where to start walking the ACPI namespace. The common + * case is to start at the adapter's parent device. However, in + * the case of a "virtual" I2C adapter created to represent a mux + * channel the parent dev (pointing to the mux device) does not + * have an ACPI handle. Walk starting at the adapter instead. + */ handle = ACPI_HANDLE(adap->dev.parent); if (!handle) + handle = ACPI_HANDLE(&adap->dev); + + if (!handle) return; status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 2ba7c0f..2731b99 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -25,6 +25,7 @@ #include #include #include +#include /* multiplexer per channel data */ struct i2c_mux_priv { @@ -173,6 +174,13 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent, } } + /* + * Now try to populate the mux adapter's ACPI node. + */ + if (has_acpi_companion(mux_dev)) + acpi_preset_companion(&priv->adap.dev, ACPI_COMPANION(mux_dev), + chan_id); + if (force_nr) { priv->adap.nr = force_nr; ret = i2c_add_numbered_adapter(&priv->adap);