From patchwork Wed Nov 15 14:10:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 118959 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4365725qgn; Wed, 15 Nov 2017 06:14:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMYYP9M+aRvjEJvt8Ihgvpn9yvzxJyl2ITne5qVDCramQGTEhqb22WyQ4w/j8PJfHPhyaJQA X-Received: by 10.98.76.90 with SMTP id z87mr14117807pfa.194.1510755251620; Wed, 15 Nov 2017 06:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510755251; cv=none; d=google.com; s=arc-20160816; b=t+xObY8vgC25u4FGy9xb7g2bGH75cG0rmpP/LvUTLQFWrha+8/lRRpbJsVqE2AcIad iCrX28UxxIAwS6HEJS/5xh6hACBFDA5iGZ0ERZ9vbtB/PunyTqjafrcyAUuQPdMvkwZZ lwPm9BL3wGn/d0b+iZWxAI+PUt6GE1x7KLhH/6iT4N/zaiPpyhNV3mLqU5u2X/169J/8 hvqpWX/Ups6cenSqQmJ0P2Luj6+LJdjvzs5k05Sy2L0gXpyfXWoRoZxl8Akz8zSZQ0VW qKam4o67epFNW92dzx7Vg8IcZFGfs/hYX65bp23UR4K0WyOsiunDM+iYykKvbGENN7jc KMfw== 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=/rjgEZawIQntl4tZIsGQnGk7eXaavM/8aSTkjiKHp2s=; b=QIArbhtNOuSzGqOqe0UYPfLkVo4R/WcU4402BzI309QMvPzsQoooHeQtTwHcT8RCW+ TxRxJBhnKxw+upP/rxpuaRhgEAliNuFf3wUoMeo68YpMzUvp1Wn1RlLu9t5OP5qyxvR6 kvYptwTkXaR9u3eOGcijweMDj7v6elz5MxolPh7M614B+GA5XvC+gqB5uqwX/SeEZjJE xnQyEWKzlnaa80TI6cyYzJRkJTaonieCeY0wo12WyQGNjcaV50jvX9ttJWdOBTc81lYH 9S3qKpp5TUE3cKVtaBb6c+vGrkhX5ZHY6R1Ip8roqYNTqvrdNFzR/Wr+hkLMc0QH+8HC nagA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GgoTevjY; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 135si1601027pgh.503.2017.11.15.06.14.11; Wed, 15 Nov 2017 06:14:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GgoTevjY; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757323AbdKOOOH (ORCPT + 10 others); Wed, 15 Nov 2017 09:14:07 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:55029 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757271AbdKOONd (ORCPT ); Wed, 15 Nov 2017 09:13:33 -0500 Received: by mail-wr0-f193.google.com with SMTP id l22so20557600wrc.11 for ; Wed, 15 Nov 2017 06:13:32 -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=1Shk3HB+/o90xMcmE9oUAL57FgciUrEF3MQbNYzoRWo=; b=GgoTevjYQC7p4R18Ie5+pfzSYuD6TblH7SN5n9+VtQmtWfaAOyo9taV5x2OPxg6zfE 7VwAziLLZDRwQOEAstSJPJwOx0CXcjcMPTeYTV55ZNcpBJ/47806uHpirsuqSEx8FsqD vuiyMq4WMBeD5PNIgih5A2xOtbLCUQtAQS9XU= 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=1Shk3HB+/o90xMcmE9oUAL57FgciUrEF3MQbNYzoRWo=; b=PcgarfL7DvUXcOP7kl76VvzfCq/fDHw7UzOHUbcnOTAw/uQAIhzhjd59kCx2EnH56l Wt/BWXPw72to7osR+qX+z8sdZ0D62En0uUypQx1BnqHfBrn8XvNO3ILtme1BhwNJWF7t q1Ix1eekIgQKrRmDXcUrHR4nH2YVZpQsvFqbIuDSOV0zIdHqaxQQSFHz1uPfQ0plPsvQ xh++6GeMEiybesCenPxoI0+naF88ZWBYUMEOJSs1pNVQ7a1nbEk2E1jdfJ6coaPYMivi obxHCdBLDH63LEN4CLBTdpGNpLRWngw8B9OjbbytK2ZoJoDh5d9eVC90tDJef4K0wVoL vbRA== X-Gm-Message-State: AJaThX6E/+3fap1L1cUCEDglTGY5Oig5fA0uSEua5AbjdYSOgSTq4ISH wO5paud2W3cqaqvaGdJ9BXpGAg== X-Received: by 10.223.177.220 with SMTP id r28mr12444364wra.13.1510755212060; Wed, 15 Nov 2017 06:13:32 -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 m11sm56707wrf.56.2017.11.15.06.13.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Nov 2017 06:13:31 -0800 (PST) From: srinivas.kandagatla@linaro.org To: gregkh@linuxfoundation.org, broonie@kernel.org, alsa-devel@alsa-project.org Cc: sdharia@codeaurora.org, bp@suse.de, poeschel@lemonage.de, treding@nvidia.com, andreas.noever@gmail.com, alan@linux.intel.com, mathieu.poirier@linaro.org, daniel@ffwll.ch, jkosina@suse.cz, sharon.dvir1@mail.huji.ac.il, joe@perches.com, davem@davemloft.net, james.hogan@imgtec.com, michael.opdenacker@free-electrons.com, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, vinod.koul@intel.com, arnd@arndb.de, Srinivas Kandagatla Subject: [PATCH v7 05/13] slimbus: core: add support to device tree helper Date: Wed, 15 Nov 2017 14:10:35 +0000 Message-Id: <20171115141043.29202-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171115141043.29202-1-srinivas.kandagatla@linaro.org> References: <20171115141043.29202-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index d31a9c4fe7e9..f7b14961c7e3 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "slimbus.h" @@ -128,6 +129,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, @@ -160,6 +164,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. * @@ -191,6 +239,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);