From patchwork Sat Sep 10 20:54:43 2016
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: "Steven J. Hill" <steven.hill@cavium.com>
X-Patchwork-Id: 715815
Return-Path: <linux-kernel-owner@vger.kernel.org>
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
        id S1754623AbcIJVJj (ORCPT <rfc822;w@1wt.eu>);
        Sat, 10 Sep 2016 17:09:39 -0400
Received: from mail-by2nam01on0042.outbound.protection.outlook.com
 ([104.47.34.42]:2389
        "EHLO NAM01-BY2-obe.outbound.protection.outlook.com"
        rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP
        id S1753141AbcIJVJg (ORCPT <rfc822;linux-kernel@vger.kernel.org>);
        Sat, 10 Sep 2016 17:09:36 -0400
X-Greylist: delayed 103312 seconds by postgrey-1.27 at vger.kernel.org;
 Sat, 10 Sep 2016 17:09:36 EDT
Authentication-Results: spf=none (sender IP is )
 smtp.mailfrom=Steven.Hill@cavium.com;
Subject: [PATCH v3] usb: dwc3: OCTEON: add support for device tree
To: <linux-usb@vger.kernel.org>
CC: <linux-kernel@vger.kernel.org>, <linux-mips@linux-mips.org>,
        David Daney <david.daney@cavium.com>
From: "Steven J. Hill" <Steven.Hill@cavium.com>
Message-ID: <57D47313.7040109@cavium.com>
Date: Sat, 10 Sep 2016 15:54:43 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.8.0
MIME-Version: 1.0
X-Originating-IP: [173.22.239.243]
X-ClientProxiedBy: DM3PR10CA0031.namprd10.prod.outlook.com (10.164.12.41) To
 BN6PR07MB3204.namprd07.prod.outlook.com (10.172.105.150)
X-MS-Office365-Filtering-Correlation-Id: 950aad12-d869-42f4-59c2-08d3d9bcb395
X-Microsoft-Exchange-Diagnostics: 
 1;BN6PR07MB3204;2:AZfaNgeiGvvXvYsqi50sPaO42JE+iRoyASzOR0cb+B9w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xhyGDjwIf1o/M1keBEuo+WjNL5FctFRdULbEaRHRj6TUAmzV/aMFpYo01jk3qXVeg2JdJtStti7quNdV9LUh8omxhXQO5yZyFgRjuygyDjpxFxstdo6kxC8xRiZAHOP3sUIpxJy32v5+2jNgyntSNuTZbw9o7cKgimQ/rH6JWurqHOAjveN
X-Microsoft-Antispam-PRVS: 
 <BN6PR07MB3204B1118A44E8EEF47430B180FD0@BN6PR07MB3204.namprd07.prod.outlook.com>
X-Exchange-Antispam-Report-Test: UriScan:(17755550239193);
X-Exchange-Antispam-Report-CFA-Test: 
 BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046);SRVR:BN6PR07MB3204;BCL:0;PCL:0;RULEID:;SRVR:BN6PR07MB3204;
X-Forefront-PRVS: 0061C35778
X-Forefront-Antispam-Report: 
 SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(52084003)(229853001)(2906002)(23676002)(586003)(4326007)(105586002)(33656002)(189998001)(3846002)(4001350100001)(83506001)(42186005)(92566002)(4001430100002)(59896002)(80316001)(19580395003)(19580405001)(6116002)(230700001)(101416001)(81166006)(36756003)(2351001)(77096005)(97736004)(50466002)(47776003)(65956001)(66066001)(54356999)(68736007)(8676002)(65816999)(81156014)(50986999)(106356001)(7736002)(305945005)(107886002)(5660300001)(64126003)(110136002)(87266999)(86362001)(7846002)(65806001)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB3204;H:[10.0.0.4];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en;
X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN6PR07MB3204=3B23=3A9X51nb5?=
	=?utf-8?q?w7IrNBkco7E8pLNQ6p5jG+8fR3AqOUzkG6yKSz2W3kE54nH1sT7jJB1B9DqFz+Kh3?=
	=?utf-8?q?+icX4j9YiRoNFtqTA98Uo6Ivj+s4apLTHyvcKtC0ik+zJOMcSzJjF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5mslPZ/6zC9twxbFTNaRqHZQi3n5nnn8R18kRuVUp6xrs7gFXEw9bh91UFSFYcGULC4g+GpcVO/Pjap+Fb/i29+4RzzfXwQ5SaE/xonR+L2lKlv1Q6C8NlttA6cw/HnDylALoXojwJkyG/96uo0aVi8WzGYIjZU25MuDvEZyDzTpfzyaHH5iYHJWmFEV9aGyDNZZKwhQYY0iS/bOdP6XtkYTq0pBEtJAWYA5/OmhqgfeNWMtYmbQl3
SpamDiagnosticOutput: 1:99
SpamDiagnosticMetadata: NSPM
X-OriginatorOrg: cavium.com
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2016 20:54:47.4516 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3204
Sender: linux-kernel-owner@vger.kernel.org
List-ID: <linux-kernel.vger.kernel.org>
X-Mailing-List: linux-kernel@vger.kernel.org
Content-Length: 3891
Lines: 122

This patch adds support to parse probe data for
the dwc3-octeon driver using device tree. The
DWC3 IP core is found on OCTEON III processors.

Signed-off-by: Steven J. Hill <Steven.Hill@cavium.com>

Changes in v3:
- Massive simplification of glue logic. Almost all the
  work is done in the SoC platform code.
Changes in v2:
- Changed comment block to acurately describe why the DMA
  properties are being set.
- Deleted 'dwc3_octeon_remove()' function as it serves
  no purpose. Also changed driver from tristate to a
  boolen as we have no plans to make it modular.
- Changed driver dependency from CAVIUM_OCTEON_SOC to
  CPU_CAVIUM_OCTEON || COMPILE_TEST per Balbi's request.
---
 drivers/usb/dwc3/Kconfig       | 10 +++++++
 drivers/usb/dwc3/Makefile      |  1 +
 drivers/usb/dwc3/dwc3-octeon.c | 61 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-octeon.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index a64ce1c..f2cb24b 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -105,4 +105,14 @@ config USB_DWC3_ST
 	  inside (i.e. STiH407).
 	  Say 'Y' or 'M' if you have one such device.

+config USB_DWC3_OCTEON
+	bool "Cavium OCTEON III Platforms"
+	depends on CPU_CAVIUM_OCTEON || COMPILE_TEST
+	depends on OF
+	default USB_DWC3
+	help
+	  Cavium OCTEON III SoCs with one DesignWare Core USB3 IP
+	  inside (i.e. cn71xx and cn78xx).
+	  Say 'Y' or 'M' if you have one such device.
+
 endif
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 22420e1..f1a7a3e 100644
--- a/drivers/usb/dwc3/Makefile	2020-05-25 17:25:49.436043599 -0400
+++ b/drivers/usb/dwc3/Makefile2	2020-05-25 17:28:14.810633829 -0400
@@ -49,4 +49,5 @@
 obj-$(CONFIG_USB_DWC3_KEYSTONE)		+= dwc3-keystone.o
 obj-$(CONFIG_USB_DWC3_OF_SIMPLE)	+= dwc3-of-simple.o
 obj-$(CONFIG_USB_DWC3_ST)		+= dwc3-st.o
+obj-$(CONFIG_USB_DWC3_OCTEON)		+= dwc3-octeon.o
 obj-$(CONFIG_USB_DWC3_QCOM)		+= dwc3-qcom.o
diff --git a/drivers/usb/dwc3/dwc3-octeon.c b/drivers/usb/dwc3/dwc3-octeon.c
new file mode 100644
index 0000000..ae84a01
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-octeon.c
@@ -0,0 +1,61 @@
+/**
+ * dwc3-octeon.c - Cavium OCTEON III DWC3 Specific Glue Layer
+ *
+ * Copyright (C) 2016 Cavium Networks
+ *
+ * Author: Steven J. Hill <steven.hill@cavium.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * Inspired by dwc3-exynos.c and dwc3-st.c files.
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/of.h>
+#include <linux/dma-mapping.h>
+
+static int dwc3_octeon_probe(struct platform_device *pdev)
+{
+	struct device		*dev = &pdev->dev;
+	int			ret;
+
+	/*
+	 * Right now device-tree probed devices do not provide
+	 * "dma-ranges" or "dma-coherent" properties.
+	 */
+	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
+static const struct of_device_id octeon_dwc3_match[] = {
+	{ .compatible = "cavium,octeon-7130-usb-uctl", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, octeon_dwc3_match);
+
+static struct platform_driver dwc3_octeon_driver = {
+	.probe		= dwc3_octeon_probe,
+	.driver		= {
+		.name	= "octeon-dwc3",
+		.of_match_table = octeon_dwc3_match,
+		.pm	= NULL,
+	},
+};
+module_platform_driver(dwc3_octeon_driver);
+
+MODULE_ALIAS("platform:octeon-dwc3");
+MODULE_AUTHOR("Steven J. Hill <steven.hill@cavium.com");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("DesignWare USB3 OCTEON Glue Layer");
