From patchwork Fri Jan 6 03:25:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 6080 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 9263E23E14 for ; Fri, 6 Jan 2012 03:26:08 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 887F4A183D9 for ; Fri, 6 Jan 2012 03:26:08 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so1087490eaa.11 for ; Thu, 05 Jan 2012 19:26:08 -0800 (PST) Received: by 10.205.120.14 with SMTP id fw14mr1894172bkc.53.1325820368327; Thu, 05 Jan 2012 19:26:08 -0800 (PST) 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.205.82.144 with SMTP id ac16cs418492bkc; Thu, 5 Jan 2012 19:26:08 -0800 (PST) Received: by 10.68.74.230 with SMTP id x6mr11288078pbv.49.1325820365998; Thu, 05 Jan 2012 19:26:05 -0800 (PST) Received: from TX2EHSOBE009.bigfish.com (tx2ehsobe004.messaging.microsoft.com. [65.55.88.14]) by mx.google.com with ESMTPS id e6si75422253pbd.48.2012.01.05.19.26.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 19:26:05 -0800 (PST) Received-SPF: neutral (google.com: 65.55.88.14 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) client-ip=65.55.88.14; Authentication-Results: mx.google.com; spf=neutral (google.com: 65.55.88.14 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) smtp.mail=richard.zhao@linaro.org Received: from mail47-tx2-R.bigfish.com (10.9.14.254) by TX2EHSOBE009.bigfish.com (10.9.40.29) with Microsoft SMTP Server id 14.1.225.23; Fri, 6 Jan 2012 03:26:04 +0000 Received: from mail47-tx2 (localhost [127.0.0.1]) by mail47-tx2-R.bigfish.com (Postfix) with ESMTP id 30EA1801AD; Fri, 6 Jan 2012 03:26:04 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh87h2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-DOMAIN-IP-MATCH: fail Received: from mail47-tx2 (localhost.localdomain [127.0.0.1]) by mail47-tx2 (MessageSwitch) id 1325820363503921_6781; Fri, 6 Jan 2012 03:26:03 +0000 (UTC) Received: from TX2EHSMHS037.bigfish.com (unknown [10.9.14.247]) by mail47-tx2.bigfish.com (Postfix) with ESMTP id 6CABF70005B; Fri, 6 Jan 2012 03:26:03 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS037.bigfish.com (10.9.99.137) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 6 Jan 2012 03:26:01 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.355.3; Thu, 5 Jan 2012 21:26:00 -0600 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id q063Pl71021044; Thu, 5 Jan 2012 21:25:58 -0600 (CST) From: Richard Zhao To: CC: , , , , Richard Zhao Subject: [PATCH 5/6] ARM: mxc: add dt support for audmux-v2 Date: Fri, 6 Jan 2012 11:25:42 +0800 Message-ID: <1325820343-11875-6-git-send-email-richard.zhao@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1325820343-11875-1-git-send-email-richard.zhao@linaro.org> References: <1325820343-11875-1-git-send-email-richard.zhao@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com If CONFIG_OF, we create a audmux device driver. For other platforms that don't set CONFIG_OF, it still initialize everything in postcore_initcall. I didn't create device driver for them, because it would be big change and one day the platforms will convert to device tree too. Signed-off-by: Richard Zhao --- arch/arm/plat-mxc/audmux-v2.c | 59 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c index 8cced35..87e05e2 100644 --- a/arch/arm/plat-mxc/audmux-v2.c +++ b/arch/arm/plat-mxc/audmux-v2.c @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include #include #include @@ -184,8 +186,64 @@ int mxc_audmux_v2_configure_port(unsigned int port, unsigned int ptcr, } EXPORT_SYMBOL_GPL(mxc_audmux_v2_configure_port); +#ifdef CONFIG_OF + +static int audmux_v2_probe(struct platform_device *pdev) +{ + struct resource *res; + int ret = 0; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + if (!request_mem_region(res->start, resource_size(res), "audmux_v2")) { + dev_err(&pdev->dev, "request_mem_region failed\n"); + return -EBUSY; + } + + audmux_base = ioremap(res->start, resource_size(res)); + if (!audmux_base) { + dev_err(&pdev->dev, "ioremap failed\n"); + ret = -ENODEV; + goto failed_ioremap; + } + + audmux_clk = clk_get(NULL, "audmux"); + if (IS_ERR(audmux_clk)) { + dev_warn(&pdev->dev, "%s: cannot get clock: %d\n", + __func__, ret); + audmux_clk = NULL; + } + + audmux_debugfs_init(); + return 0; + +failed_ioremap: + release_mem_region(res->start, resource_size(res)); + + return ret; +} + +static const struct of_device_id audmux_v2_dt_ids[] = { + { .compatible = "fsl,audmux-v2", }, + { /* sentinel */ } +}; + +static struct platform_driver audmux_v2_driver = { + .probe = audmux_v2_probe, + .driver = { + .name = "audmux_v2", + .of_match_table = audmux_v2_dt_ids, + }, +}; + +#endif + static int mxc_audmux_v2_init(void) { +#ifdef CONFIG_OF + return platform_driver_register(&audmux_v2_driver); +#else int ret; if (cpu_is_mx51()) { audmux_base = MX51_IO_ADDRESS(MX51_AUDMUX_BASE_ADDR); @@ -214,6 +272,7 @@ static int mxc_audmux_v2_init(void) audmux_debugfs_init(); return 0; +#endif } postcore_initcall(mxc_audmux_v2_init);