License cleanup: add SPDX GPL-2.0 license identifier to files with no license
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>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2012-03-19 19:36:10 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
|
|
|
|
#include <asm/div64.h>
|
|
|
|
|
|
|
|
#include "clk.h"
|
|
|
|
|
|
|
|
#define to_clk_pllv2(clk) (container_of(clk, struct clk_pllv2, clk))
|
|
|
|
|
|
|
|
/* PLL Register Offsets */
|
|
|
|
#define MXC_PLL_DP_CTL 0x00
|
|
|
|
#define MXC_PLL_DP_CONFIG 0x04
|
|
|
|
#define MXC_PLL_DP_OP 0x08
|
|
|
|
#define MXC_PLL_DP_MFD 0x0C
|
|
|
|
#define MXC_PLL_DP_MFN 0x10
|
|
|
|
#define MXC_PLL_DP_MFNMINUS 0x14
|
|
|
|
#define MXC_PLL_DP_MFNPLUS 0x18
|
|
|
|
#define MXC_PLL_DP_HFS_OP 0x1C
|
|
|
|
#define MXC_PLL_DP_HFS_MFD 0x20
|
|
|
|
#define MXC_PLL_DP_HFS_MFN 0x24
|
|
|
|
#define MXC_PLL_DP_MFN_TOGC 0x28
|
|
|
|
#define MXC_PLL_DP_DESTAT 0x2c
|
|
|
|
|
|
|
|
/* PLL Register Bit definitions */
|
|
|
|
#define MXC_PLL_DP_CTL_MUL_CTRL 0x2000
|
|
|
|
#define MXC_PLL_DP_CTL_DPDCK0_2_EN 0x1000
|
|
|
|
#define MXC_PLL_DP_CTL_DPDCK0_2_OFFSET 12
|
|
|
|
#define MXC_PLL_DP_CTL_ADE 0x800
|
|
|
|
#define MXC_PLL_DP_CTL_REF_CLK_DIV 0x400
|
|
|
|
#define MXC_PLL_DP_CTL_REF_CLK_SEL_MASK (3 << 8)
|
|
|
|
#define MXC_PLL_DP_CTL_REF_CLK_SEL_OFFSET 8
|
|
|
|
#define MXC_PLL_DP_CTL_HFSM 0x80
|
|
|
|
#define MXC_PLL_DP_CTL_PRE 0x40
|
|
|
|
#define MXC_PLL_DP_CTL_UPEN 0x20
|
|
|
|
#define MXC_PLL_DP_CTL_RST 0x10
|
|
|
|
#define MXC_PLL_DP_CTL_RCP 0x8
|
|
|
|
#define MXC_PLL_DP_CTL_PLM 0x4
|
|
|
|
#define MXC_PLL_DP_CTL_BRM0 0x2
|
|
|
|
#define MXC_PLL_DP_CTL_LRF 0x1
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_CONFIG_BIST 0x8
|
|
|
|
#define MXC_PLL_DP_CONFIG_SJC_CE 0x4
|
|
|
|
#define MXC_PLL_DP_CONFIG_AREN 0x2
|
|
|
|
#define MXC_PLL_DP_CONFIG_LDREQ 0x1
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_OP_MFI_OFFSET 4
|
|
|
|
#define MXC_PLL_DP_OP_MFI_MASK (0xF << 4)
|
|
|
|
#define MXC_PLL_DP_OP_PDF_OFFSET 0
|
|
|
|
#define MXC_PLL_DP_OP_PDF_MASK 0xF
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_MFD_OFFSET 0
|
|
|
|
#define MXC_PLL_DP_MFD_MASK 0x07FFFFFF
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_MFN_OFFSET 0x0
|
|
|
|
#define MXC_PLL_DP_MFN_MASK 0x07FFFFFF
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_MFN_TOGC_TOG_DIS (1 << 17)
|
|
|
|
#define MXC_PLL_DP_MFN_TOGC_TOG_EN (1 << 16)
|
|
|
|
#define MXC_PLL_DP_MFN_TOGC_CNT_OFFSET 0x0
|
|
|
|
#define MXC_PLL_DP_MFN_TOGC_CNT_MASK 0xFFFF
|
|
|
|
|
|
|
|
#define MXC_PLL_DP_DESTAT_TOG_SEL (1 << 31)
|
|
|
|
#define MXC_PLL_DP_DESTAT_MFN 0x07FFFFFF
|
|
|
|
|
|
|
|
#define MAX_DPLL_WAIT_TRIES 1000 /* 1000 * udelay(1) = 1ms */
|
|
|
|
|
|
|
|
struct clk_pllv2 {
|
|
|
|
struct clk_hw hw;
|
|
|
|
void __iomem *base;
|
|
|
|
};
|
|
|
|
|
2012-06-04 20:51:32 +08:00
|
|
|
static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate,
|
|
|
|
u32 dp_ctl, u32 dp_op, u32 dp_mfd, u32 dp_mfn)
|
2012-03-19 19:36:10 +08:00
|
|
|
{
|
2015-09-29 19:32:27 +08:00
|
|
|
long mfi, mfn, mfd, pdf, ref_clk;
|
2012-06-04 20:51:32 +08:00
|
|
|
unsigned long dbl;
|
2015-11-04 09:01:40 +08:00
|
|
|
u64 temp;
|
2012-03-19 19:36:10 +08:00
|
|
|
|
|
|
|
dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
|
|
|
|
|
|
|
|
pdf = dp_op & MXC_PLL_DP_OP_PDF_MASK;
|
|
|
|
mfi = (dp_op & MXC_PLL_DP_OP_MFI_MASK) >> MXC_PLL_DP_OP_MFI_OFFSET;
|
|
|
|
mfi = (mfi <= 5) ? 5 : mfi;
|
|
|
|
mfd = dp_mfd & MXC_PLL_DP_MFD_MASK;
|
2015-09-29 19:32:27 +08:00
|
|
|
mfn = dp_mfn & MXC_PLL_DP_MFN_MASK;
|
|
|
|
mfn = sign_extend32(mfn, 26);
|
2012-03-19 19:36:10 +08:00
|
|
|
|
|
|
|
ref_clk = 2 * parent_rate;
|
|
|
|
if (dbl != 0)
|
|
|
|
ref_clk *= 2;
|
|
|
|
|
|
|
|
ref_clk /= (pdf + 1);
|
2015-09-29 19:32:27 +08:00
|
|
|
temp = (u64) ref_clk * abs(mfn);
|
2012-03-19 19:36:10 +08:00
|
|
|
do_div(temp, mfd + 1);
|
|
|
|
if (mfn < 0)
|
2015-11-04 09:01:40 +08:00
|
|
|
temp = (ref_clk * mfi) - temp;
|
|
|
|
else
|
|
|
|
temp = (ref_clk * mfi) + temp;
|
2012-03-19 19:36:10 +08:00
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
|
2012-06-04 20:51:32 +08:00
|
|
|
static unsigned long clk_pllv2_recalc_rate(struct clk_hw *hw,
|
2012-03-19 19:36:10 +08:00
|
|
|
unsigned long parent_rate)
|
|
|
|
{
|
2012-06-04 20:51:32 +08:00
|
|
|
u32 dp_op, dp_mfd, dp_mfn, dp_ctl;
|
|
|
|
void __iomem *pllbase;
|
2012-03-19 19:36:10 +08:00
|
|
|
struct clk_pllv2 *pll = to_clk_pllv2(hw);
|
2012-06-04 20:51:32 +08:00
|
|
|
|
|
|
|
pllbase = pll->base;
|
|
|
|
|
|
|
|
dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
|
|
|
|
dp_op = __raw_readl(pllbase + MXC_PLL_DP_OP);
|
|
|
|
dp_mfd = __raw_readl(pllbase + MXC_PLL_DP_MFD);
|
|
|
|
dp_mfn = __raw_readl(pllbase + MXC_PLL_DP_MFN);
|
|
|
|
|
|
|
|
return __clk_pllv2_recalc_rate(parent_rate, dp_ctl, dp_op, dp_mfd, dp_mfn);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __clk_pllv2_set_rate(unsigned long rate, unsigned long parent_rate,
|
|
|
|
u32 *dp_op, u32 *dp_mfd, u32 *dp_mfn)
|
|
|
|
{
|
2012-03-19 19:36:10 +08:00
|
|
|
u32 reg;
|
|
|
|
long mfi, pdf, mfn, mfd = 999999;
|
2015-11-04 09:01:40 +08:00
|
|
|
u64 temp64;
|
2012-03-19 19:36:10 +08:00
|
|
|
unsigned long quad_parent_rate;
|
|
|
|
|
|
|
|
quad_parent_rate = 4 * parent_rate;
|
|
|
|
pdf = mfi = -1;
|
|
|
|
while (++pdf < 16 && mfi < 5)
|
|
|
|
mfi = rate * (pdf+1) / quad_parent_rate;
|
|
|
|
if (mfi > 15)
|
|
|
|
return -EINVAL;
|
|
|
|
pdf--;
|
|
|
|
|
2012-06-04 20:51:32 +08:00
|
|
|
temp64 = rate * (pdf + 1) - quad_parent_rate * mfi;
|
|
|
|
do_div(temp64, quad_parent_rate / 1000000);
|
2012-03-19 19:36:10 +08:00
|
|
|
mfn = (long)temp64;
|
|
|
|
|
2012-06-04 20:51:32 +08:00
|
|
|
reg = mfi << 4 | pdf;
|
|
|
|
|
|
|
|
*dp_op = reg;
|
|
|
|
*dp_mfd = mfd;
|
|
|
|
*dp_mfn = mfn;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_pllv2_set_rate(struct clk_hw *hw, unsigned long rate,
|
|
|
|
unsigned long parent_rate)
|
|
|
|
{
|
|
|
|
struct clk_pllv2 *pll = to_clk_pllv2(hw);
|
|
|
|
void __iomem *pllbase;
|
|
|
|
u32 dp_ctl, dp_op, dp_mfd, dp_mfn;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pllbase = pll->base;
|
|
|
|
|
|
|
|
|
|
|
|
ret = __clk_pllv2_set_rate(rate, parent_rate, &dp_op, &dp_mfd, &dp_mfn);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2012-03-19 19:36:10 +08:00
|
|
|
dp_ctl = __raw_readl(pllbase + MXC_PLL_DP_CTL);
|
|
|
|
/* use dpdck0_2 */
|
|
|
|
__raw_writel(dp_ctl | 0x1000L, pllbase + MXC_PLL_DP_CTL);
|
2012-06-04 18:21:21 +08:00
|
|
|
|
2012-06-04 20:51:32 +08:00
|
|
|
__raw_writel(dp_op, pllbase + MXC_PLL_DP_OP);
|
|
|
|
__raw_writel(dp_mfd, pllbase + MXC_PLL_DP_MFD);
|
|
|
|
__raw_writel(dp_mfn, pllbase + MXC_PLL_DP_MFN);
|
2012-03-19 19:36:10 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static long clk_pllv2_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
|
|
unsigned long *prate)
|
|
|
|
{
|
2012-06-04 20:51:32 +08:00
|
|
|
u32 dp_op, dp_mfd, dp_mfn;
|
|
|
|
|
|
|
|
__clk_pllv2_set_rate(rate, *prate, &dp_op, &dp_mfd, &dp_mfn);
|
|
|
|
return __clk_pllv2_recalc_rate(*prate, MXC_PLL_DP_CTL_DPDCK0_2_EN,
|
|
|
|
dp_op, dp_mfd, dp_mfn);
|
2012-03-19 19:36:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int clk_pllv2_prepare(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct clk_pllv2 *pll = to_clk_pllv2(hw);
|
|
|
|
u32 reg;
|
|
|
|
void __iomem *pllbase;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
pllbase = pll->base;
|
|
|
|
reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) | MXC_PLL_DP_CTL_UPEN;
|
|
|
|
__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
|
|
|
|
|
|
|
|
/* Wait for lock */
|
|
|
|
do {
|
|
|
|
reg = __raw_readl(pllbase + MXC_PLL_DP_CTL);
|
|
|
|
if (reg & MXC_PLL_DP_CTL_LRF)
|
|
|
|
break;
|
|
|
|
|
|
|
|
udelay(1);
|
|
|
|
} while (++i < MAX_DPLL_WAIT_TRIES);
|
|
|
|
|
|
|
|
if (i == MAX_DPLL_WAIT_TRIES) {
|
|
|
|
pr_err("MX5: pll locking failed\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clk_pllv2_unprepare(struct clk_hw *hw)
|
|
|
|
{
|
|
|
|
struct clk_pllv2 *pll = to_clk_pllv2(hw);
|
|
|
|
u32 reg;
|
|
|
|
void __iomem *pllbase;
|
|
|
|
|
|
|
|
pllbase = pll->base;
|
|
|
|
reg = __raw_readl(pllbase + MXC_PLL_DP_CTL) & ~MXC_PLL_DP_CTL_UPEN;
|
|
|
|
__raw_writel(reg, pllbase + MXC_PLL_DP_CTL);
|
|
|
|
}
|
|
|
|
|
2017-08-22 21:18:29 +08:00
|
|
|
static const struct clk_ops clk_pllv2_ops = {
|
2012-03-19 19:36:10 +08:00
|
|
|
.prepare = clk_pllv2_prepare,
|
|
|
|
.unprepare = clk_pllv2_unprepare,
|
|
|
|
.recalc_rate = clk_pllv2_recalc_rate,
|
|
|
|
.round_rate = clk_pllv2_round_rate,
|
|
|
|
.set_rate = clk_pllv2_set_rate,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct clk *imx_clk_pllv2(const char *name, const char *parent,
|
|
|
|
void __iomem *base)
|
|
|
|
{
|
|
|
|
struct clk_pllv2 *pll;
|
|
|
|
struct clk *clk;
|
|
|
|
struct clk_init_data init;
|
|
|
|
|
|
|
|
pll = kzalloc(sizeof(*pll), GFP_KERNEL);
|
|
|
|
if (!pll)
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
pll->base = base;
|
|
|
|
|
|
|
|
init.name = name;
|
|
|
|
init.ops = &clk_pllv2_ops;
|
|
|
|
init.flags = 0;
|
|
|
|
init.parent_names = &parent;
|
|
|
|
init.num_parents = 1;
|
|
|
|
|
|
|
|
pll->hw.init = &init;
|
|
|
|
|
|
|
|
clk = clk_register(NULL, &pll->hw);
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
kfree(pll);
|
|
|
|
|
|
|
|
return clk;
|
|
|
|
}
|