mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 04:45:23 +07:00
b24413180f
Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
311 lines
7.3 KiB
C
311 lines
7.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Glue code for the ISP1760 driver and bus
|
|
* Currently there is support for
|
|
* - OpenFirmware
|
|
* - PCI
|
|
* - PDEV (generic platform device centralized driver model)
|
|
*
|
|
* (c) 2007 Sebastian Siewior <bigeasy@linutronix.de>
|
|
*
|
|
*/
|
|
|
|
#include <linux/usb.h>
|
|
#include <linux/io.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/usb/isp1760.h>
|
|
#include <linux/usb/hcd.h>
|
|
|
|
#include "isp1760-core.h"
|
|
#include "isp1760-regs.h"
|
|
|
|
#ifdef CONFIG_USB_PCI
|
|
#include <linux/pci.h>
|
|
#endif
|
|
|
|
#ifdef CONFIG_USB_PCI
|
|
static int isp1761_pci_init(struct pci_dev *dev)
|
|
{
|
|
resource_size_t mem_start;
|
|
resource_size_t mem_length;
|
|
u8 __iomem *iobase;
|
|
u8 latency, limit;
|
|
int retry_count;
|
|
u32 reg_data;
|
|
|
|
/* Grab the PLX PCI shared memory of the ISP 1761 we need */
|
|
mem_start = pci_resource_start(dev, 3);
|
|
mem_length = pci_resource_len(dev, 3);
|
|
if (mem_length < 0xffff) {
|
|
printk(KERN_ERR "memory length for this resource is wrong\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
if (!request_mem_region(mem_start, mem_length, "ISP-PCI")) {
|
|
printk(KERN_ERR "host controller already in use\n");
|
|
return -EBUSY;
|
|
}
|
|
|
|
/* map available memory */
|
|
iobase = ioremap_nocache(mem_start, mem_length);
|
|
if (!iobase) {
|
|
printk(KERN_ERR "Error ioremap failed\n");
|
|
release_mem_region(mem_start, mem_length);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
/* bad pci latencies can contribute to overruns */
|
|
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &latency);
|
|
if (latency) {
|
|
pci_read_config_byte(dev, PCI_MAX_LAT, &limit);
|
|
if (limit && limit < latency)
|
|
pci_write_config_byte(dev, PCI_LATENCY_TIMER, limit);
|
|
}
|
|
|
|
/* Try to check whether we can access Scratch Register of
|
|
* Host Controller or not. The initial PCI access is retried until
|
|
* local init for the PCI bridge is completed
|
|
*/
|
|
retry_count = 20;
|
|
reg_data = 0;
|
|
while ((reg_data != 0xFACE) && retry_count) {
|
|
/*by default host is in 16bit mode, so
|
|
* io operations at this stage must be 16 bit
|
|
* */
|
|
writel(0xface, iobase + HC_SCRATCH_REG);
|
|
udelay(100);
|
|
reg_data = readl(iobase + HC_SCRATCH_REG) & 0x0000ffff;
|
|
retry_count--;
|
|
}
|
|
|
|
iounmap(iobase);
|
|
release_mem_region(mem_start, mem_length);
|
|
|
|
/* Host Controller presence is detected by writing to scratch register
|
|
* and reading back and checking the contents are same or not
|
|
*/
|
|
if (reg_data != 0xFACE) {
|
|
dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
/* Grab the PLX PCI mem maped port start address we need */
|
|
mem_start = pci_resource_start(dev, 0);
|
|
mem_length = pci_resource_len(dev, 0);
|
|
|
|
if (!request_mem_region(mem_start, mem_length, "ISP1761 IO MEM")) {
|
|
printk(KERN_ERR "request region #1\n");
|
|
return -EBUSY;
|
|
}
|
|
|
|
iobase = ioremap_nocache(mem_start, mem_length);
|
|
if (!iobase) {
|
|
printk(KERN_ERR "ioremap #1\n");
|
|
release_mem_region(mem_start, mem_length);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
/* configure PLX PCI chip to pass interrupts */
|
|
#define PLX_INT_CSR_REG 0x68
|
|
reg_data = readl(iobase + PLX_INT_CSR_REG);
|
|
reg_data |= 0x900;
|
|
writel(reg_data, iobase + PLX_INT_CSR_REG);
|
|
|
|
/* done with PLX IO access */
|
|
iounmap(iobase);
|
|
release_mem_region(mem_start, mem_length);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int isp1761_pci_probe(struct pci_dev *dev,
|
|
const struct pci_device_id *id)
|
|
{
|
|
unsigned int devflags = 0;
|
|
int ret;
|
|
|
|
if (!dev->irq)
|
|
return -ENODEV;
|
|
|
|
if (pci_enable_device(dev) < 0)
|
|
return -ENODEV;
|
|
|
|
ret = isp1761_pci_init(dev);
|
|
if (ret < 0)
|
|
goto error;
|
|
|
|
pci_set_master(dev);
|
|
|
|
dev->dev.dma_mask = NULL;
|
|
ret = isp1760_register(&dev->resource[3], dev->irq, 0, &dev->dev,
|
|
devflags);
|
|
if (ret < 0)
|
|
goto error;
|
|
|
|
return 0;
|
|
|
|
error:
|
|
pci_disable_device(dev);
|
|
return ret;
|
|
}
|
|
|
|
static void isp1761_pci_remove(struct pci_dev *dev)
|
|
{
|
|
isp1760_unregister(&dev->dev);
|
|
|
|
pci_disable_device(dev);
|
|
}
|
|
|
|
static void isp1761_pci_shutdown(struct pci_dev *dev)
|
|
{
|
|
printk(KERN_ERR "ips1761_pci_shutdown\n");
|
|
}
|
|
|
|
static const struct pci_device_id isp1760_plx[] = {
|
|
{
|
|
.class = PCI_CLASS_BRIDGE_OTHER << 8,
|
|
.class_mask = ~0,
|
|
.vendor = PCI_VENDOR_ID_PLX,
|
|
.device = 0x5406,
|
|
.subvendor = PCI_VENDOR_ID_PLX,
|
|
.subdevice = 0x9054,
|
|
},
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(pci, isp1760_plx);
|
|
|
|
static struct pci_driver isp1761_pci_driver = {
|
|
.name = "isp1760",
|
|
.id_table = isp1760_plx,
|
|
.probe = isp1761_pci_probe,
|
|
.remove = isp1761_pci_remove,
|
|
.shutdown = isp1761_pci_shutdown,
|
|
};
|
|
#endif
|
|
|
|
static int isp1760_plat_probe(struct platform_device *pdev)
|
|
{
|
|
unsigned long irqflags;
|
|
unsigned int devflags = 0;
|
|
struct resource *mem_res;
|
|
struct resource *irq_res;
|
|
int ret;
|
|
|
|
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
|
if (!irq_res) {
|
|
pr_warn("isp1760: IRQ resource not available\n");
|
|
return -ENODEV;
|
|
}
|
|
irqflags = irq_res->flags & IRQF_TRIGGER_MASK;
|
|
|
|
if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
|
|
struct device_node *dp = pdev->dev.of_node;
|
|
u32 bus_width = 0;
|
|
|
|
if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
|
|
devflags |= ISP1760_FLAG_ISP1761;
|
|
|
|
/* Some systems wire up only 16 of the 32 data lines */
|
|
of_property_read_u32(dp, "bus-width", &bus_width);
|
|
if (bus_width == 16)
|
|
devflags |= ISP1760_FLAG_BUS_WIDTH_16;
|
|
|
|
if (of_property_read_bool(dp, "port1-otg"))
|
|
devflags |= ISP1760_FLAG_OTG_EN;
|
|
|
|
if (of_property_read_bool(dp, "analog-oc"))
|
|
devflags |= ISP1760_FLAG_ANALOG_OC;
|
|
|
|
if (of_property_read_bool(dp, "dack-polarity"))
|
|
devflags |= ISP1760_FLAG_DACK_POL_HIGH;
|
|
|
|
if (of_property_read_bool(dp, "dreq-polarity"))
|
|
devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
|
|
} else if (dev_get_platdata(&pdev->dev)) {
|
|
struct isp1760_platform_data *pdata =
|
|
dev_get_platdata(&pdev->dev);
|
|
|
|
if (pdata->is_isp1761)
|
|
devflags |= ISP1760_FLAG_ISP1761;
|
|
if (pdata->bus_width_16)
|
|
devflags |= ISP1760_FLAG_BUS_WIDTH_16;
|
|
if (pdata->port1_otg)
|
|
devflags |= ISP1760_FLAG_OTG_EN;
|
|
if (pdata->analog_oc)
|
|
devflags |= ISP1760_FLAG_ANALOG_OC;
|
|
if (pdata->dack_polarity_high)
|
|
devflags |= ISP1760_FLAG_DACK_POL_HIGH;
|
|
if (pdata->dreq_polarity_high)
|
|
devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
|
|
}
|
|
|
|
ret = isp1760_register(mem_res, irq_res->start, irqflags, &pdev->dev,
|
|
devflags);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
pr_info("ISP1760 USB device initialised\n");
|
|
return 0;
|
|
}
|
|
|
|
static int isp1760_plat_remove(struct platform_device *pdev)
|
|
{
|
|
isp1760_unregister(&pdev->dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_OF
|
|
static const struct of_device_id isp1760_of_match[] = {
|
|
{ .compatible = "nxp,usb-isp1760", },
|
|
{ .compatible = "nxp,usb-isp1761", },
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(of, isp1760_of_match);
|
|
#endif
|
|
|
|
static struct platform_driver isp1760_plat_driver = {
|
|
.probe = isp1760_plat_probe,
|
|
.remove = isp1760_plat_remove,
|
|
.driver = {
|
|
.name = "isp1760",
|
|
.of_match_table = of_match_ptr(isp1760_of_match),
|
|
},
|
|
};
|
|
|
|
static int __init isp1760_init(void)
|
|
{
|
|
int ret, any_ret = -ENODEV;
|
|
|
|
isp1760_init_kmem_once();
|
|
|
|
ret = platform_driver_register(&isp1760_plat_driver);
|
|
if (!ret)
|
|
any_ret = 0;
|
|
#ifdef CONFIG_USB_PCI
|
|
ret = pci_register_driver(&isp1761_pci_driver);
|
|
if (!ret)
|
|
any_ret = 0;
|
|
#endif
|
|
|
|
if (any_ret)
|
|
isp1760_deinit_kmem_cache();
|
|
return any_ret;
|
|
}
|
|
module_init(isp1760_init);
|
|
|
|
static void __exit isp1760_exit(void)
|
|
{
|
|
platform_driver_unregister(&isp1760_plat_driver);
|
|
#ifdef CONFIG_USB_PCI
|
|
pci_unregister_driver(&isp1761_pci_driver);
|
|
#endif
|
|
isp1760_deinit_kmem_cache();
|
|
}
|
|
module_exit(isp1760_exit);
|