From patchwork Thu Dec 7 10:27:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 120961 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8183230qgn; Thu, 7 Dec 2017 02:35:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMahAwfb3vmWta4t3AUQ3ErE+ygSjNamMpHe+DRQde/g1XAnrgysr9EyZhR99h7VKwYf9JOe X-Received: by 10.159.250.143 with SMTP id k15mr12977865pls.336.1512642933825; Thu, 07 Dec 2017 02:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512642933; cv=none; d=google.com; s=arc-20160816; b=jEa7JqaNgB8HTGRHMw5vf+U434jo1Xqm5S92vDFqz0bzi2mjerUwK+E4FoGxAmnsY3 PAt1ntORSR/X2ylCbytg7IQHVC5bHH8cHUNwyD3gqwfzRqQvd+FaINar8L/wPp3qcdu/ 2P/mJsgYbH3RVmzZ5UOBW4j/cwvJB6W3Cm6CshfKpMnCI187edzlN4koSqRyMJCdxzl8 UHvgQzJeQPWF0qwCSUwzSLSo2A0NZPLFydVz+25o+IlAyeggaf9Ibr8agPnc3g0bnSDs 9pTPNwvcynCRojttGowpwOw80BGtmJ++90cK7bmknwQZZhdfRvDD4tOG8M99n7upQ33+ Mx5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=baXZINT5NXXZVjgVmEu9nTnl6BEclj/wZveGtDlEkKg=; b=AdjMVA6Z46cLvPn+nD+yQZ/OWLZXzklJIa58PmrpTcMLGhDiBwRHd9YcrtdlRd8qyz bPKKHXJeyMcDK8Bx8Cgqa9Lb2UjmfV8Jy807Yi8MH6v0d9FRhTEBWs5CqSlWTiZAKbq3 0hGny3zwV3B1GqPGocFeAEEDG9UULlxVpLhSdiSLlgDymzagvhQ2ViK8eXmp+UJW8MR1 93iZ7B5ZOxPAhwYeWPtmpg0MHJjnseKPhbgyG/KvgP6nC2zAuZl3U7hN42KGSg7deqoJ /7iXIOsKMY+pW7cPO3qSnmVUGYTkI8FPoTQv07y39EnTNP+fBs6PL96CKsCmwqM6pELa DIBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYmfFbMd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w189si3508387pgd.73.2017.12.07.02.35.33; Thu, 07 Dec 2017 02:35:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WYmfFbMd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752951AbdLGKem (ORCPT + 21 others); Thu, 7 Dec 2017 05:34:42 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:44795 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752760AbdLGKam (ORCPT ); Thu, 7 Dec 2017 05:30:42 -0500 Received: by mail-wm0-f68.google.com with SMTP id t8so12130621wmc.3 for ; Thu, 07 Dec 2017 02:30:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=baXZINT5NXXZVjgVmEu9nTnl6BEclj/wZveGtDlEkKg=; b=WYmfFbMdBtm/tPeKwiqb9G1RL6ghkkNqFpzNwaK2wk7XhsV3No3A3wcApwK+lAtRI2 gn1wkMH8FR9zrnD7c2QeoXTetCGUt7QgURjuk07ybS/pvK/20EaEb1gNoQl6iRwL7AF1 zIPWcSemb5HNMsysM8B3OFwMJU+maGCu/o+C0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=baXZINT5NXXZVjgVmEu9nTnl6BEclj/wZveGtDlEkKg=; b=JgxLt3Oj9+/KyyoN8ZYj9dJI4AEjBEdGDtLMBBPt0/buoKE0VfXaqqTjFiARRIsUMN UgWyeSmbL+lCz4FD5C0YgQjKNIzqifdUiQE6Y6STaNAjK0wBMJs1ePEsY6xL3wl4c5gh LqxHpfbyfM9vAI/djXCI8BGJjNkeqDnzoZGI0O2GxU6oXRdBnll6OFu3svZn4+UxIrsW dmnIjor53iCKv1eH8VJ4zjPF4xSprYlfVCxauITL4eqmX0lW5bXYPlxUI6dl3W9v1RDT L71ziazJO0pfTJsRHqdRbfFcS6b39em5qFKvjeZTg8ShGOh5MI/Rr5vhZr6Q87nWesls LpKA== X-Gm-Message-State: AKGB3mIUH1HfCtuGBNUxxmPFFXidzbXGaiqkNZp1Y3Za7HPphnTpObIE 1Mcisn8PHOGn/kxejxuPRWkJSA== X-Received: by 10.28.158.206 with SMTP id h197mr671578wme.23.1512642640661; Thu, 07 Dec 2017 02:30:40 -0800 (PST) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id k2sm4837734wrg.4.2017.12.07.02.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 02:30:40 -0800 (PST) From: srinivas.kandagatla@linaro.org To: Mark Brown , Greg Kroah-Hartman , alsa-devel@alsa-project.org Cc: sdharia@codeaurora.org, Rob Herring , Mark Rutland , Jonathan Corbet , pombredanne@nexb.com, j.neuschaefer@gmx.net, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v9 05/13] slimbus: core: add support to device tree helper Date: Thu, 7 Dec 2017 10:27:12 +0000 Message-Id: <20171207102720.21071-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171207102720.21071-1-srinivas.kandagatla@linaro.org> References: <20171207102720.21071-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch adds support to parse slim devices from device tree. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/core.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) -- 2.15.0 diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index a59a88a7a52d..cd2a47dec635 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "slimbus.h" @@ -111,6 +112,9 @@ static int slim_add_device(struct slim_controller *ctrl, sbdev->dev.driver = NULL; sbdev->ctrl = ctrl; + if (node) + sbdev->dev.of_node = of_node_get(node); + dev_set_name(&sbdev->dev, "%x:%x:%x:%x", sbdev->e_addr.manf_id, sbdev->e_addr.prod_code, @@ -141,6 +145,50 @@ static struct slim_device *slim_alloc_device(struct slim_controller *ctrl, return sbdev; } +static void of_register_slim_devices(struct slim_controller *ctrl) +{ + struct device *dev = ctrl->dev; + struct device_node *node; + + if (!ctrl->dev->of_node) + return; + + for_each_child_of_node(ctrl->dev->of_node, node) { + struct slim_device *sbdev; + struct slim_eaddr e_addr; + const char *compat = NULL; + int reg[2], ret; + int manf_id, prod_code; + + compat = of_get_property(node, "compatible", NULL); + if (!compat) + continue; + + ret = sscanf(compat, "slim%x,%x", &manf_id, &prod_code); + if (ret != 2) { + dev_err(dev, "Manf ID & Product code not found %s\n", + compat); + continue; + } + + ret = of_property_read_u32_array(node, "reg", reg, 2); + if (ret) { + dev_err(dev, "Device and Instance id not found:%d\n", + ret); + continue; + } + + e_addr.dev_index = reg[0]; + e_addr.instance = reg[1]; + e_addr.manf_id = manf_id; + e_addr.prod_code = prod_code; + + sbdev = slim_alloc_device(ctrl, &e_addr, node); + if (!sbdev) + continue; + } +} + /* * slim_register_controller() - Controller bring-up and registration. * @@ -172,6 +220,8 @@ int slim_register_controller(struct slim_controller *ctrl) dev_dbg(ctrl->dev, "Bus [%s] registered:dev:%p\n", ctrl->name, ctrl->dev); + of_register_slim_devices(ctrl); + return 0; } EXPORT_SYMBOL_GPL(slim_register_controller);