From patchwork Fri Jul 27 12:45:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10318 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3770723E23 for ; Fri, 27 Jul 2012 12:46:18 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 06CE4A1853E for ; Fri, 27 Jul 2012 12:46:17 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so3100971yen.11 for ; Fri, 27 Jul 2012 05:46:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=WdIn+eSQ65h/rOz2WJYkjnSkjH8lJu3a+6A8BhV4YnM=; b=a8fMsntZIbeK8M6vaXoRyZPNgn5HE7qmiQjbOASMPSA8IFDtvUakVSwGYMepNYsmbj iJDV99u8Ge5PSyraNy+brExXvWwO95gHwiIGSq+VFi8f0R3LYkFjQEV0hHDhO6kCfwZm //aOSQUuTAE6A8D8NFuXuTUVWFBCjIDGSU0cqsSjpnG0I1UYlPUxLbLIEfhchbSlKeJH hdxxY5DRNFX2sn/zBc6hYMHMwasd9nL8BSPY9pNK2/So7J3j2ZJmzNFV5fa92YTSh+Kd DrlinxiRXZ8mVh6h0TQa0vFXA7jdkPHZFPPMwHBN6cZMm35EiKnqB2/WVi1L+E5ezLV9 J1JA== Received: by 10.50.159.135 with SMTP id xc7mr4499366igb.1.1343393177604; Fri, 27 Jul 2012 05:46:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp29844icc; Fri, 27 Jul 2012 05:46:16 -0700 (PDT) Received: by 10.216.50.17 with SMTP id y17mr1229690web.154.1343393176108; Fri, 27 Jul 2012 05:46:16 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id n21si2630731wee.115.2012.07.27.05.46.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 05:46:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f172.google.com with SMTP id hm11so5802099wib.13 for ; Fri, 27 Jul 2012 05:46:16 -0700 (PDT) Received: by 10.180.14.193 with SMTP id r1mr5891543wic.19.1343393176004; Fri, 27 Jul 2012 05:46:16 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id dc3sm12342025wib.7.2012.07.27.05.46.14 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 05:46:15 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, olalilja@yahoo.se, ola.o.lilja@stericsson.com, alsa-devel@alsa-project.org, lrg@ti.com, broonie@opensource.wolfsonmicro.com, Lee Jones Subject: [PATCH 05/18] ASoC: Ux500: Enable ux500 MSP driver for Device Tree Date: Fri, 27 Jul 2012 13:45:49 +0100 Message-Id: <1343393162-11938-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343393162-11938-1-git-send-email-lee.jones@linaro.org> References: <1343393162-11938-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkjcFUNzpZfJoNCIrMfieUt4olaQkyFrjC/t6ZayvPHfemybgrPmIbkEGMWYaM7AoWKpJY1 Register both parts of the MSP driver from Device Tree so that they are probed when Device Tree is enabled. Also, as there is platform data involved, we ensure that there is allocated memory to place the configuration into and that the correct information is extracted from the DT binary. Signed-off-by: Lee Jones --- sound/soc/ux500/ux500_msp_dai.c | 6 ++++++ sound/soc/ux500/ux500_msp_i2s.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c index 772cb19..0f7dd49 100644 --- a/sound/soc/ux500/ux500_msp_dai.c +++ b/sound/soc/ux500/ux500_msp_dai.c @@ -833,10 +833,16 @@ static int __devexit ux500_msp_drv_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id ux500_msp_i2c_match[] = { + { .compatible = "stericsson,ux500-msp-i2s", }, + {}, +}; + static struct platform_driver msp_i2s_driver = { .driver = { .name = "ux500-msp-i2s", .owner = THIS_MODULE, + .of_match_table = ux500_msp_i2c_match, }, .probe = ux500_msp_drv_probe, .remove = ux500_msp_drv_remove, diff --git a/sound/soc/ux500/ux500_msp_i2s.c b/sound/soc/ux500/ux500_msp_i2s.c index 72ad6e8..1ecdec0 100644 --- a/sound/soc/ux500/ux500_msp_i2s.c +++ b/sound/soc/ux500/ux500_msp_i2s.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -685,6 +686,16 @@ int ux500_msp_i2s_close(struct ux500_msp *msp, unsigned int dir) } +void ux500_msp_i2s_of_init_msp(struct platform_device *pdev, + struct ux500_msp *msp, + struct device_node *np) +{ + if (of_get_property(np, "stericsson,use-pinctrl", NULL)) + msp->use_pinctrl = true; + else + msp->use_pinctrl = false; +} + int ux500_msp_i2s_init_msp(struct platform_device *pdev, struct ux500_msp **msp_p, struct msp_i2s_platform_data *platform_data) @@ -692,17 +703,33 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev, int ret = 0; struct resource *res = NULL; struct i2s_controller *i2s_cont; + struct device_node *np = pdev->dev.of_node; struct ux500_msp *msp; static int initialised = false; - dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__, - pdev->name, platform_data->id); - *msp_p = devm_kzalloc(&pdev->dev, sizeof(struct ux500_msp), GFP_KERNEL); msp = *msp_p; if (!msp) return -ENOMEM; + if (np) { + if (!platform_data) { + platform_data = devm_kzalloc(&pdev->dev, + sizeof(struct msp_i2s_platform_data), GFP_KERNEL); + if (!platform_data) + ret = -ENOMEM; + } + ux500_msp_i2s_of_init_msp(pdev, msp, np); + } else + if (!platform_data) + ret = -EINVAL; + + if (ret) + goto err_res; + + dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__, + pdev->name, platform_data->id); + msp->id = platform_data->id; msp->dev = &pdev->dev; msp->use_pinctrl = platform_data->use_pinctrl;