mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 03:25:20 +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>
255 lines
6.1 KiB
C
255 lines
6.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Alchemy Development Board example suspend userspace interface.
|
|
*
|
|
* (c) 2008 Manuel Lauss <mano@roarinelk.homelinux.net>
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/suspend.h>
|
|
#include <linux/sysfs.h>
|
|
#include <asm/mach-au1x00/au1000.h>
|
|
#include <asm/mach-au1x00/gpio-au1000.h>
|
|
#include <asm/mach-db1x00/bcsr.h>
|
|
|
|
/*
|
|
* Generic suspend userspace interface for Alchemy development boards.
|
|
* This code exports a few sysfs nodes under /sys/power/db1x/ which
|
|
* can be used by userspace to en/disable all au1x-provided wakeup
|
|
* sources and configure the timeout after which the the TOYMATCH2 irq
|
|
* is to trigger a wakeup.
|
|
*/
|
|
|
|
|
|
static unsigned long db1x_pm_sleep_secs;
|
|
static unsigned long db1x_pm_wakemsk;
|
|
static unsigned long db1x_pm_last_wakesrc;
|
|
|
|
static int db1x_pm_enter(suspend_state_t state)
|
|
{
|
|
unsigned short bcsrs[16];
|
|
int i, j, hasint;
|
|
|
|
/* save CPLD regs */
|
|
hasint = bcsr_read(BCSR_WHOAMI);
|
|
hasint = BCSR_WHOAMI_BOARD(hasint) >= BCSR_WHOAMI_DB1200;
|
|
j = (hasint) ? BCSR_MASKSET : BCSR_SYSTEM;
|
|
|
|
for (i = BCSR_STATUS; i <= j; i++)
|
|
bcsrs[i] = bcsr_read(i);
|
|
|
|
/* shut off hexleds */
|
|
bcsr_write(BCSR_HEXCLEAR, 3);
|
|
|
|
/* enable GPIO based wakeup */
|
|
alchemy_gpio1_input_enable();
|
|
|
|
/* clear and setup wake cause and source */
|
|
alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
|
|
alchemy_wrsys(0, AU1000_SYS_WAKESRC);
|
|
|
|
alchemy_wrsys(db1x_pm_wakemsk, AU1000_SYS_WAKEMSK);
|
|
|
|
/* setup 1Hz-timer-based wakeup: wait for reg access */
|
|
while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20)
|
|
asm volatile ("nop");
|
|
|
|
alchemy_wrsys(alchemy_rdsys(AU1000_SYS_TOYREAD) + db1x_pm_sleep_secs,
|
|
AU1000_SYS_TOYMATCH2);
|
|
|
|
/* wait for value to really hit the register */
|
|
while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_M20)
|
|
asm volatile ("nop");
|
|
|
|
/* ...and now the sandman can come! */
|
|
au_sleep();
|
|
|
|
|
|
/* restore CPLD regs */
|
|
for (i = BCSR_STATUS; i <= BCSR_SYSTEM; i++)
|
|
bcsr_write(i, bcsrs[i]);
|
|
|
|
/* restore CPLD int registers */
|
|
if (hasint) {
|
|
bcsr_write(BCSR_INTCLR, 0xffff);
|
|
bcsr_write(BCSR_MASKCLR, 0xffff);
|
|
bcsr_write(BCSR_INTSTAT, 0xffff);
|
|
bcsr_write(BCSR_INTSET, bcsrs[BCSR_INTSET]);
|
|
bcsr_write(BCSR_MASKSET, bcsrs[BCSR_MASKSET]);
|
|
}
|
|
|
|
/* light up hexleds */
|
|
bcsr_write(BCSR_HEXCLEAR, 0);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int db1x_pm_begin(suspend_state_t state)
|
|
{
|
|
if (!db1x_pm_wakemsk) {
|
|
printk(KERN_ERR "db1x: no wakeup source activated!\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void db1x_pm_end(void)
|
|
{
|
|
/* read and store wakeup source, the clear the register. To
|
|
* be able to clear it, WAKEMSK must be cleared first.
|
|
*/
|
|
db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC);
|
|
|
|
alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
|
|
alchemy_wrsys(0, AU1000_SYS_WAKESRC);
|
|
}
|
|
|
|
static const struct platform_suspend_ops db1x_pm_ops = {
|
|
.valid = suspend_valid_only_mem,
|
|
.begin = db1x_pm_begin,
|
|
.enter = db1x_pm_enter,
|
|
.end = db1x_pm_end,
|
|
};
|
|
|
|
#define ATTRCMP(x) (0 == strcmp(attr->attr.name, #x))
|
|
|
|
static ssize_t db1x_pmattr_show(struct kobject *kobj,
|
|
struct kobj_attribute *attr,
|
|
char *buf)
|
|
{
|
|
int idx;
|
|
|
|
if (ATTRCMP(timer_timeout))
|
|
return sprintf(buf, "%lu\n", db1x_pm_sleep_secs);
|
|
|
|
else if (ATTRCMP(timer))
|
|
return sprintf(buf, "%u\n",
|
|
!!(db1x_pm_wakemsk & SYS_WAKEMSK_M2));
|
|
|
|
else if (ATTRCMP(wakesrc))
|
|
return sprintf(buf, "%lu\n", db1x_pm_last_wakesrc);
|
|
|
|
else if (ATTRCMP(gpio0) || ATTRCMP(gpio1) || ATTRCMP(gpio2) ||
|
|
ATTRCMP(gpio3) || ATTRCMP(gpio4) || ATTRCMP(gpio5) ||
|
|
ATTRCMP(gpio6) || ATTRCMP(gpio7)) {
|
|
idx = (attr->attr.name)[4] - '0';
|
|
return sprintf(buf, "%d\n",
|
|
!!(db1x_pm_wakemsk & SYS_WAKEMSK_GPIO(idx)));
|
|
|
|
} else if (ATTRCMP(wakemsk)) {
|
|
return sprintf(buf, "%08lx\n", db1x_pm_wakemsk);
|
|
}
|
|
|
|
return -ENOENT;
|
|
}
|
|
|
|
static ssize_t db1x_pmattr_store(struct kobject *kobj,
|
|
struct kobj_attribute *attr,
|
|
const char *instr,
|
|
size_t bytes)
|
|
{
|
|
unsigned long l;
|
|
int tmp;
|
|
|
|
if (ATTRCMP(timer_timeout)) {
|
|
tmp = kstrtoul(instr, 0, &l);
|
|
if (tmp)
|
|
return tmp;
|
|
|
|
db1x_pm_sleep_secs = l;
|
|
|
|
} else if (ATTRCMP(timer)) {
|
|
if (instr[0] != '0')
|
|
db1x_pm_wakemsk |= SYS_WAKEMSK_M2;
|
|
else
|
|
db1x_pm_wakemsk &= ~SYS_WAKEMSK_M2;
|
|
|
|
} else if (ATTRCMP(gpio0) || ATTRCMP(gpio1) || ATTRCMP(gpio2) ||
|
|
ATTRCMP(gpio3) || ATTRCMP(gpio4) || ATTRCMP(gpio5) ||
|
|
ATTRCMP(gpio6) || ATTRCMP(gpio7)) {
|
|
tmp = (attr->attr.name)[4] - '0';
|
|
if (instr[0] != '0') {
|
|
db1x_pm_wakemsk |= SYS_WAKEMSK_GPIO(tmp);
|
|
} else {
|
|
db1x_pm_wakemsk &= ~SYS_WAKEMSK_GPIO(tmp);
|
|
}
|
|
|
|
} else if (ATTRCMP(wakemsk)) {
|
|
tmp = kstrtoul(instr, 0, &l);
|
|
if (tmp)
|
|
return tmp;
|
|
|
|
db1x_pm_wakemsk = l & 0x0000003f;
|
|
|
|
} else
|
|
bytes = -ENOENT;
|
|
|
|
return bytes;
|
|
}
|
|
|
|
#define ATTR(x) \
|
|
static struct kobj_attribute x##_attribute = \
|
|
__ATTR(x, 0664, db1x_pmattr_show, \
|
|
db1x_pmattr_store);
|
|
|
|
ATTR(gpio0) /* GPIO-based wakeup enable */
|
|
ATTR(gpio1)
|
|
ATTR(gpio2)
|
|
ATTR(gpio3)
|
|
ATTR(gpio4)
|
|
ATTR(gpio5)
|
|
ATTR(gpio6)
|
|
ATTR(gpio7)
|
|
ATTR(timer) /* TOYMATCH2-based wakeup enable */
|
|
ATTR(timer_timeout) /* timer-based wakeup timeout value, in seconds */
|
|
ATTR(wakesrc) /* contents of SYS_WAKESRC after last wakeup */
|
|
ATTR(wakemsk) /* direct access to SYS_WAKEMSK */
|
|
|
|
#define ATTR_LIST(x) & x ## _attribute.attr
|
|
static struct attribute *db1x_pmattrs[] = {
|
|
ATTR_LIST(gpio0),
|
|
ATTR_LIST(gpio1),
|
|
ATTR_LIST(gpio2),
|
|
ATTR_LIST(gpio3),
|
|
ATTR_LIST(gpio4),
|
|
ATTR_LIST(gpio5),
|
|
ATTR_LIST(gpio6),
|
|
ATTR_LIST(gpio7),
|
|
ATTR_LIST(timer),
|
|
ATTR_LIST(timer_timeout),
|
|
ATTR_LIST(wakesrc),
|
|
ATTR_LIST(wakemsk),
|
|
NULL, /* terminator */
|
|
};
|
|
|
|
static struct attribute_group db1x_pmattr_group = {
|
|
.name = "db1x",
|
|
.attrs = db1x_pmattrs,
|
|
};
|
|
|
|
/*
|
|
* Initialize suspend interface
|
|
*/
|
|
static int __init pm_init(void)
|
|
{
|
|
/* init TOY to tick at 1Hz if not already done. No need to wait
|
|
* for confirmation since there's plenty of time from here to
|
|
* the next suspend cycle.
|
|
*/
|
|
if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767)
|
|
alchemy_wrsys(32767, AU1000_SYS_TOYTRIM);
|
|
|
|
db1x_pm_last_wakesrc = alchemy_rdsys(AU1000_SYS_WAKESRC);
|
|
|
|
alchemy_wrsys(0, AU1000_SYS_WAKESRC);
|
|
alchemy_wrsys(0, AU1000_SYS_WAKEMSK);
|
|
|
|
suspend_set_ops(&db1x_pm_ops);
|
|
|
|
return sysfs_create_group(power_kobj, &db1x_pmattr_group);
|
|
}
|
|
|
|
late_initcall(pm_init);
|