From patchwork Tue Mar 12 18:41:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brown X-Patchwork-Id: 2258111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 84311DF23A for ; Tue, 12 Mar 2013 18:50:19 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFUCW-0000Kw-TP; Tue, 12 Mar 2013 18:45:29 +0000 Received: from wolverine02.qualcomm.com ([199.106.114.251]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UFU9M-0007cT-S0 for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2013 18:42:17 +0000 X-IronPort-AV: E=Sophos;i="4.84,832,1355126400"; d="scan'208";a="29083607" Received: from pdmz-ns-mip.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.114.10]) by wolverine02.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Mar 2013 11:42:04 -0700 Received: from codeaurora.org (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id 919AA10004B5; Tue, 12 Mar 2013 11:42:04 -0700 (PDT) From: David Brown To: Greg Kroah-Hartman Subject: [PATCH v2 05/11] SSBI: Convert SSBI to device tree Date: Tue, 12 Mar 2013 11:41:50 -0700 Message-Id: <1363113716-25897-6-git-send-email-davidb@codeaurora.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1363113716-25897-1-git-send-email-davidb@codeaurora.org> References: <1362616187-21089-1-git-send-email-davidb@codeaurora.org> <1363113716-25897-1-git-send-email-davidb@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130312_144213_294171_7571B333 X-CRM114-Status: GOOD ( 24.02 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.251 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King , linux-doc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Grant Likely , Bryan Huntsman , Rob Landley , Daniel Walker , David Brown , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The SSBI bus is exclusive to the Qualcomm MSM targets, and all SoCs using it will be using device tree. Convert this driver to indentify with device tree. This makes the bus probing a good bit simpler, since the attaching of child nodes can be represented directly in the devicetree, rather than having to be inferred by name. Signed-off-by: David Brown --- Documentation/devicetree/bindings/arm/msm/ssbi.txt | 18 +++++ arch/arm/boot/dts/msm8660-surf.dts | 6 ++ arch/arm/boot/dts/msm8960-cdp.dts | 6 ++ drivers/ssbi/ssbi.c | 81 +++++++++------------- 4 files changed, 62 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/msm/ssbi.txt diff --git a/Documentation/devicetree/bindings/arm/msm/ssbi.txt b/Documentation/devicetree/bindings/arm/msm/ssbi.txt new file mode 100644 index 0000000..54fd5ce --- /dev/null +++ b/Documentation/devicetree/bindings/arm/msm/ssbi.txt @@ -0,0 +1,18 @@ +* Qualcomm SSBI + +Some Qualcomm MSM devices contain a point-to-point serial bus used to +communicate with a limited range of devices (mostly power management +chips). + +These require the following properties: + +- compatible: "qcom,ssbi" + +- qcom,controller-type + indicates the SSBI bus variant the controller should use to talk + with the slave device. This should be one of "ssbi", "ssbi2", or + "pmic-arbiter". The type chosen is determined by the attached + slave. + +The slave device should be the single child node of the ssbi device +with a compatible field. diff --git a/arch/arm/boot/dts/msm8660-surf.dts b/arch/arm/boot/dts/msm8660-surf.dts index 31f2157..67f8670 100644 --- a/arch/arm/boot/dts/msm8660-surf.dts +++ b/arch/arm/boot/dts/msm8660-surf.dts @@ -38,4 +38,10 @@ <0x19c00000 0x1000>; interrupts = <0 195 0x0>; }; + + qcom,ssbi@500000 { + compatible = "qcom,ssbi"; + reg = <0x500000 0x1000>; + qcom,controller-type = "pmic-arbiter"; + }; }; diff --git a/arch/arm/boot/dts/msm8960-cdp.dts b/arch/arm/boot/dts/msm8960-cdp.dts index 9e621b5..c9b09a8 100644 --- a/arch/arm/boot/dts/msm8960-cdp.dts +++ b/arch/arm/boot/dts/msm8960-cdp.dts @@ -38,4 +38,10 @@ <0x16400000 0x1000>; interrupts = <0 154 0x0>; }; + + qcom,ssbi@500000 { + compatible = "qcom,ssbi"; + reg = <0x500000 0x1000>; + qcom,controller-type = "pmic-arbiter"; + }; }; diff --git a/drivers/ssbi/ssbi.c b/drivers/ssbi/ssbi.c index da086d4..6fbcb25 100644 --- a/drivers/ssbi/ssbi.c +++ b/drivers/ssbi/ssbi.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include /* SSBI 2.0 controller registers */ #define SSBI2_CMD 0x0008 @@ -261,56 +263,13 @@ int msm_ssbi_write(struct device *dev, u16 addr, u8 *buf, int len) } EXPORT_SYMBOL_GPL(msm_ssbi_write); -static int msm_ssbi_add_slave(struct msm_ssbi *ssbi, - const struct msm_ssbi_slave_info *slave) -{ - struct platform_device *slave_pdev; - int ret; - - if (ssbi->slave) { - pr_err("slave already attached??\n"); - return -EBUSY; - } - - slave_pdev = platform_device_alloc(slave->name, -1); - if (!slave_pdev) { - pr_err("cannot allocate pdev for slave '%s'", slave->name); - ret = -ENOMEM; - goto err; - } - - slave_pdev->dev.parent = ssbi->dev; - slave_pdev->dev.platform_data = slave->platform_data; - - ret = platform_device_add(slave_pdev); - if (ret) { - pr_err("cannot add slave platform device for '%s'\n", - slave->name); - goto err; - } - - ssbi->slave = &slave_pdev->dev; - return 0; - -err: - if (slave_pdev) - platform_device_put(slave_pdev); - return ret; -} - static int msm_ssbi_probe(struct platform_device *pdev) { - const struct msm_ssbi_platform_data *pdata = pdev->dev.platform_data; + struct device_node *np = pdev->dev.of_node; struct resource *mem_res; struct msm_ssbi *ssbi; int ret = 0; - - if (!pdata) { - pr_err("missing platform data\n"); - return -EINVAL; - } - - pr_debug("%s\n", pdata->slave.name); + const char *type; ssbi = kzalloc(sizeof(struct msm_ssbi), GFP_KERNEL); if (!ssbi) { @@ -334,7 +293,25 @@ static int msm_ssbi_probe(struct platform_device *pdev) ssbi->dev = &pdev->dev; platform_set_drvdata(pdev, ssbi); - ssbi->controller_type = pdata->controller_type; + type = of_get_property(np, "qcom,controller-type", NULL); + if (type == NULL) { + pr_err("Missing qcom,controller-type property\n"); + ret = -EINVAL; + goto err_ssbi_controller; + } + dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type); + if (strcmp(type, "ssbi") == 0) + ssbi->controller_type = MSM_SBI_CTRL_SSBI; + else if (strcmp(type, "ssbi2") == 0) + ssbi->controller_type = MSM_SBI_CTRL_SSBI2; + else if (strcmp(type, "pmic-arbiter") == 0) + ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; + else { + pr_err("Unknown qcom,controller-type\n"); + ret = -EINVAL; + goto err_ssbi_controller; + } + if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { ssbi->read = msm_ssbi_pa_read_bytes; ssbi->write = msm_ssbi_pa_write_bytes; @@ -345,13 +322,13 @@ static int msm_ssbi_probe(struct platform_device *pdev) spin_lock_init(&ssbi->lock); - ret = msm_ssbi_add_slave(ssbi, &pdata->slave); + ret = of_platform_populate(np, NULL, NULL, &pdev->dev); if (ret) - goto err_ssbi_add_slave; + goto err_ssbi_controller; return 0; -err_ssbi_add_slave: +err_ssbi_controller: platform_set_drvdata(pdev, NULL); iounmap(ssbi->base); err_ioremap: @@ -370,12 +347,18 @@ static int msm_ssbi_remove(struct platform_device *pdev) return 0; } +static struct of_device_id ssbi_match_table[] = { + { .compatible = "qcom,ssbi" }, + {} +}; + static struct platform_driver msm_ssbi_driver = { .probe = msm_ssbi_probe, .remove = msm_ssbi_remove, .driver = { .name = "msm_ssbi", .owner = THIS_MODULE, + .of_match_table = ssbi_match_table, }, };