From patchwork Mon Apr 27 22:37:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Bresticker X-Patchwork-Id: 6283931 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0D3639F326 for ; Mon, 27 Apr 2015 22:43:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E8B8A202F8 for ; Mon, 27 Apr 2015 22:43:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C399D202F0 for ; Mon, 27 Apr 2015 22:43:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ymrhb-0007cU-AD; Mon, 27 Apr 2015 22:40:35 +0000 Received: from mail-ob0-f201.google.com ([209.85.214.201]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YmrfW-0005Tc-5A for linux-arm-kernel@lists.infradead.org; Mon, 27 Apr 2015 22:38:27 +0000 Received: by obcwm4 with SMTP id wm4so7819424obc.0 for ; Mon, 27 Apr 2015 15:38:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Sg7g3HziMaFjWEUyTmLBZD9YM8JxOqAAsvhYmBhxoG0=; b=f0hwwPyhEbM2NNdg0d7ZIamEMH8p2tjRNQjDNdd/n43gZN9OSK+tI1cPugpX+TaTUG B0DwpQ67ZMCr/PMRBPk2Xj05JN2ElbmRUZVSGMZaRll4rO1oWfXJSE6U3R9KKrpfUwnw g5uDHjTExLLNXbsqquEjG+fwOMt7s8eHGTwNASr5ugEzVGHzVcmMgu0rv7QytbACUB/S ny/kMCON4ivYXx6t09AV7RllBM5y81rAMHQLOtzLZGMwirPPbnwF14NJ60scNHiJOgIf bUBUfL7fXmbg/D04bEe/PzGLh+85W4dcVa+ge8yuMDUgW5HyGZU0XPlavyscUZ+NEN+O 5V3Q== X-Gm-Message-State: ALoCoQmlR239XxZuvorliU3Y6Sa5RNQpSXf0+pFfOmlrZBTsko8PI1fGSE6nEA6mK2qDT+oB5axn X-Received: by 10.42.50.199 with SMTP id b7mr25792851icg.21.1430174284449; Mon, 27 Apr 2015 15:38:04 -0700 (PDT) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id v17si1180572yhc.0.2015.04.27.15.38.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2015 15:38:04 -0700 (PDT) Received: from abrestic.mtv.corp.google.com ([172.22.65.70]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id BawkJXMH.1; Mon, 27 Apr 2015 15:38:04 -0700 Received: by abrestic.mtv.corp.google.com (Postfix, from userid 137652) id 467D9A49BE; Mon, 27 Apr 2015 15:38:03 -0700 (PDT) From: Andrew Bresticker To: Stephen Warren , Thierry Reding , Alexandre Courbot Subject: [PATCH V7 5/9] mfd: Add driver for NVIDIA Tegra XUSB Date: Mon, 27 Apr 2015 15:37:18 -0700 Message-Id: <1430174242-29465-6-git-send-email-abrestic@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1430174242-29465-1-git-send-email-abrestic@chromium.org> References: <1430174242-29465-1-git-send-email-abrestic@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150427_153826_357250_99FAE1EB X-CRM114-Status: GOOD ( 16.53 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, Samuel Ortiz , Andrew Bresticker , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Lee Jones , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an MFD driver for the XUSB host complex found on NVIDIA Tegra124 and later SoCs. Signed-off-by: Andrew Bresticker Cc: Samuel Ortiz Cc: Lee Jones --- New for v7. --- drivers/mfd/Kconfig | 7 ++ drivers/mfd/Makefile | 1 + drivers/mfd/tegra-xusb.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++ include/soc/tegra/xusb.h | 19 ++++++ 4 files changed, 194 insertions(+) create mode 100644 drivers/mfd/tegra-xusb.c create mode 100644 include/soc/tegra/xusb.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d5ad04d..61872b4 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1430,6 +1430,13 @@ config MFD_STW481X in various ST Microelectronics and ST-Ericsson embedded Nomadik series. +config MFD_TEGRA_XUSB + tristate "NVIDIA Tegra XUSB" + depends on ARCH_TEGRA + select MFD_CORE + help + Support for the XUSB complex found on NVIDIA Tegra124 and later SoCs. + menu "Multimedia Capabilities Port drivers" depends on ARCH_SA1100 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 0e5cfeb..7588caf 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -181,6 +181,7 @@ obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o obj-$(CONFIG_MFD_DLN2) += dln2.o obj-$(CONFIG_MFD_RT5033) += rt5033.o obj-$(CONFIG_MFD_SKY81452) += sky81452.o +obj-$(CONFIG_MFD_TEGRA_XUSB) += tegra-xusb.o intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o diff --git a/drivers/mfd/tegra-xusb.c b/drivers/mfd/tegra-xusb.c new file mode 100644 index 0000000..d30d259 --- /dev/null +++ b/drivers/mfd/tegra-xusb.c @@ -0,0 +1,167 @@ +/* + * NVIDIA Tegra XUSB MFD driver + * + * Copyright (C) 2015 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct tegra_xusb_soc_data { + struct mfd_cell *devs; + unsigned int num_devs; +}; + +static struct resource tegra_xhci_resources[] = { + { + .name = "host", + .flags = IORESOURCE_IRQ, + }, + { + .name = "xhci", + .flags = IORESOURCE_MEM, + }, + { + .name = "ipfs", + .flags = IORESOURCE_MEM, + }, +}; + +static struct resource tegra_xusb_mbox_resources[] = { + { + .name = "smi", + .flags = IORESOURCE_IRQ, + }, +}; + +static struct mfd_cell tegra124_xusb_devs[] = { + { + .name = "tegra-xhci", + .of_compatible = "nvidia,tegra124-xhci", + }, + { + .name = "tegra-xusb-mbox", + .of_compatible = "nvidia,tegra124-xusb-mbox", + }, +}; + +static const struct tegra_xusb_soc_data tegra124_xusb_data = { + .devs = tegra124_xusb_devs, + .num_devs = ARRAY_SIZE(tegra124_xusb_devs), +}; + +static const struct of_device_id tegra_xusb_of_match[] = { + { .compatible = "nvidia,tegra124-xusb", .data = &tegra124_xusb_data }, + {}, +}; +MODULE_DEVICE_TABLE(of, tegra_xusb_of_match); + +static struct regmap_config tegra_fpci_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static int tegra_xusb_probe(struct platform_device *pdev) +{ + const struct tegra_xusb_soc_data *soc; + const struct of_device_id *match; + struct tegra_xusb *xusb; + struct resource *res; + void __iomem *fpci_base; + int irq, ret; + + xusb = devm_kzalloc(&pdev->dev, sizeof(*xusb), GFP_KERNEL); + if (!xusb) + return -ENOMEM; + platform_set_drvdata(pdev, xusb); + + match = of_match_node(tegra_xusb_of_match, pdev->dev.of_node); + soc = match->data; + + irq = platform_get_irq_byname(pdev, "host"); + if (irq < 0) + return irq; + tegra_xhci_resources[0].start = irq; + tegra_xhci_resources[0].end = irq; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "xhci"); + if (!res) + return -ENODEV; + tegra_xhci_resources[1].start = res->start; + tegra_xhci_resources[1].end = res->end; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ipfs"); + if (!res) + return -ENODEV; + tegra_xhci_resources[2].start = res->start; + tegra_xhci_resources[2].end = res->end; + + soc->devs[0].resources = tegra_xhci_resources; + soc->devs[0].num_resources = ARRAY_SIZE(tegra_xhci_resources); + + irq = platform_get_irq_byname(pdev, "smi"); + if (irq < 0) + return irq; + tegra_xusb_mbox_resources[0].start = irq; + tegra_xusb_mbox_resources[0].end = irq; + + soc->devs[1].resources = tegra_xusb_mbox_resources; + soc->devs[1].num_resources = ARRAY_SIZE(tegra_xusb_mbox_resources); + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fpci"); + fpci_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(fpci_base)) + return PTR_ERR(fpci_base); + + tegra_fpci_regmap_config.max_register = res->end - res->start - 3; + xusb->fpci_regs = devm_regmap_init_mmio(&pdev->dev, fpci_base, + &tegra_fpci_regmap_config); + if (IS_ERR(xusb->fpci_regs)) { + ret = PTR_ERR(xusb->fpci_regs); + dev_err(&pdev->dev, "Failed to init regmap: %d\n", ret); + return ret; + } + + ret = mfd_add_devices(&pdev->dev, -1, soc->devs, soc->num_devs, + NULL, 0, NULL); + if (ret) { + dev_err(&pdev->dev, "Failed to add MFD devices: %d\n", ret); + return ret; + } + + return 0; +} + +static int tegra_xusb_remove(struct platform_device *pdev) +{ + mfd_remove_devices(&pdev->dev); + + return 0; +} + +static struct platform_driver tegra_xusb_driver = { + .probe = tegra_xusb_probe, + .remove = tegra_xusb_remove, + .driver = { + .name = "tegra-xusb", + .of_match_table = tegra_xusb_of_match, + }, +}; +module_platform_driver(tegra_xusb_driver); + +MODULE_DESCRIPTION("NVIDIA Tegra XUSB MFD"); +MODULE_AUTHOR("Andrew Bresticker "); +MODULE_LICENSE("GPL v2"); diff --git a/include/soc/tegra/xusb.h b/include/soc/tegra/xusb.h new file mode 100644 index 0000000..9d28d90 --- /dev/null +++ b/include/soc/tegra/xusb.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2014 NVIDIA Corporation + * Copyright (C) 2014 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + */ + +#ifndef __SOC_TEGRA_XUSB_H__ +#define __SOC_TEGRA_XUSB_H__ + +struct regmap; + +struct tegra_xusb { + struct regmap *fpci_regs; +}; + +#endif /* __SOC_TEGRA_XUSB_H__ */