mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 10:33:27 +00:00
5a0e3ad6af
percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
213 lines
5.4 KiB
C
213 lines
5.4 KiB
C
/*
|
|
* arch/powerpc/sysdev/qe_lib/ucc.c
|
|
*
|
|
* QE UCC API Set - UCC specific routines implementations.
|
|
*
|
|
* Copyright (C) 2006 Freescale Semicondutor, Inc. All rights reserved.
|
|
*
|
|
* Authors: Shlomi Gridish <gridish@freescale.com>
|
|
* Li Yang <leoli@freescale.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*/
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/stddef.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/module.h>
|
|
|
|
#include <asm/irq.h>
|
|
#include <asm/io.h>
|
|
#include <asm/immap_qe.h>
|
|
#include <asm/qe.h>
|
|
#include <asm/ucc.h>
|
|
|
|
int ucc_set_qe_mux_mii_mng(unsigned int ucc_num)
|
|
{
|
|
unsigned long flags;
|
|
|
|
if (ucc_num > UCC_MAX_NUM - 1)
|
|
return -EINVAL;
|
|
|
|
spin_lock_irqsave(&cmxgcr_lock, flags);
|
|
clrsetbits_be32(&qe_immr->qmx.cmxgcr, QE_CMXGCR_MII_ENET_MNG,
|
|
ucc_num << QE_CMXGCR_MII_ENET_MNG_SHIFT);
|
|
spin_unlock_irqrestore(&cmxgcr_lock, flags);
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(ucc_set_qe_mux_mii_mng);
|
|
|
|
/* Configure the UCC to either Slow or Fast.
|
|
*
|
|
* A given UCC can be figured to support either "slow" devices (e.g. UART)
|
|
* or "fast" devices (e.g. Ethernet).
|
|
*
|
|
* 'ucc_num' is the UCC number, from 0 - 7.
|
|
*
|
|
* This function also sets the UCC_GUEMR_SET_RESERVED3 bit because that bit
|
|
* must always be set to 1.
|
|
*/
|
|
int ucc_set_type(unsigned int ucc_num, enum ucc_speed_type speed)
|
|
{
|
|
u8 __iomem *guemr;
|
|
|
|
/* The GUEMR register is at the same location for both slow and fast
|
|
devices, so we just use uccX.slow.guemr. */
|
|
switch (ucc_num) {
|
|
case 0: guemr = &qe_immr->ucc1.slow.guemr;
|
|
break;
|
|
case 1: guemr = &qe_immr->ucc2.slow.guemr;
|
|
break;
|
|
case 2: guemr = &qe_immr->ucc3.slow.guemr;
|
|
break;
|
|
case 3: guemr = &qe_immr->ucc4.slow.guemr;
|
|
break;
|
|
case 4: guemr = &qe_immr->ucc5.slow.guemr;
|
|
break;
|
|
case 5: guemr = &qe_immr->ucc6.slow.guemr;
|
|
break;
|
|
case 6: guemr = &qe_immr->ucc7.slow.guemr;
|
|
break;
|
|
case 7: guemr = &qe_immr->ucc8.slow.guemr;
|
|
break;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
|
|
clrsetbits_8(guemr, UCC_GUEMR_MODE_MASK,
|
|
UCC_GUEMR_SET_RESERVED3 | speed);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void get_cmxucr_reg(unsigned int ucc_num, __be32 __iomem **cmxucr,
|
|
unsigned int *reg_num, unsigned int *shift)
|
|
{
|
|
unsigned int cmx = ((ucc_num & 1) << 1) + (ucc_num > 3);
|
|
|
|
*reg_num = cmx + 1;
|
|
*cmxucr = &qe_immr->qmx.cmxucr[cmx];
|
|
*shift = 16 - 8 * (ucc_num & 2);
|
|
}
|
|
|
|
int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask)
|
|
{
|
|
__be32 __iomem *cmxucr;
|
|
unsigned int reg_num;
|
|
unsigned int shift;
|
|
|
|
/* check if the UCC number is in range. */
|
|
if (ucc_num > UCC_MAX_NUM - 1)
|
|
return -EINVAL;
|
|
|
|
get_cmxucr_reg(ucc_num, &cmxucr, ®_num, &shift);
|
|
|
|
if (set)
|
|
setbits32(cmxucr, mask << shift);
|
|
else
|
|
clrbits32(cmxucr, mask << shift);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int ucc_set_qe_mux_rxtx(unsigned int ucc_num, enum qe_clock clock,
|
|
enum comm_dir mode)
|
|
{
|
|
__be32 __iomem *cmxucr;
|
|
unsigned int reg_num;
|
|
unsigned int shift;
|
|
u32 clock_bits = 0;
|
|
|
|
/* check if the UCC number is in range. */
|
|
if (ucc_num > UCC_MAX_NUM - 1)
|
|
return -EINVAL;
|
|
|
|
/* The communications direction must be RX or TX */
|
|
if (!((mode == COMM_DIR_RX) || (mode == COMM_DIR_TX)))
|
|
return -EINVAL;
|
|
|
|
get_cmxucr_reg(ucc_num, &cmxucr, ®_num, &shift);
|
|
|
|
switch (reg_num) {
|
|
case 1:
|
|
switch (clock) {
|
|
case QE_BRG1: clock_bits = 1; break;
|
|
case QE_BRG2: clock_bits = 2; break;
|
|
case QE_BRG7: clock_bits = 3; break;
|
|
case QE_BRG8: clock_bits = 4; break;
|
|
case QE_CLK9: clock_bits = 5; break;
|
|
case QE_CLK10: clock_bits = 6; break;
|
|
case QE_CLK11: clock_bits = 7; break;
|
|
case QE_CLK12: clock_bits = 8; break;
|
|
case QE_CLK15: clock_bits = 9; break;
|
|
case QE_CLK16: clock_bits = 10; break;
|
|
default: break;
|
|
}
|
|
break;
|
|
case 2:
|
|
switch (clock) {
|
|
case QE_BRG5: clock_bits = 1; break;
|
|
case QE_BRG6: clock_bits = 2; break;
|
|
case QE_BRG7: clock_bits = 3; break;
|
|
case QE_BRG8: clock_bits = 4; break;
|
|
case QE_CLK13: clock_bits = 5; break;
|
|
case QE_CLK14: clock_bits = 6; break;
|
|
case QE_CLK19: clock_bits = 7; break;
|
|
case QE_CLK20: clock_bits = 8; break;
|
|
case QE_CLK15: clock_bits = 9; break;
|
|
case QE_CLK16: clock_bits = 10; break;
|
|
default: break;
|
|
}
|
|
break;
|
|
case 3:
|
|
switch (clock) {
|
|
case QE_BRG9: clock_bits = 1; break;
|
|
case QE_BRG10: clock_bits = 2; break;
|
|
case QE_BRG15: clock_bits = 3; break;
|
|
case QE_BRG16: clock_bits = 4; break;
|
|
case QE_CLK3: clock_bits = 5; break;
|
|
case QE_CLK4: clock_bits = 6; break;
|
|
case QE_CLK17: clock_bits = 7; break;
|
|
case QE_CLK18: clock_bits = 8; break;
|
|
case QE_CLK7: clock_bits = 9; break;
|
|
case QE_CLK8: clock_bits = 10; break;
|
|
case QE_CLK16: clock_bits = 11; break;
|
|
default: break;
|
|
}
|
|
break;
|
|
case 4:
|
|
switch (clock) {
|
|
case QE_BRG13: clock_bits = 1; break;
|
|
case QE_BRG14: clock_bits = 2; break;
|
|
case QE_BRG15: clock_bits = 3; break;
|
|
case QE_BRG16: clock_bits = 4; break;
|
|
case QE_CLK5: clock_bits = 5; break;
|
|
case QE_CLK6: clock_bits = 6; break;
|
|
case QE_CLK21: clock_bits = 7; break;
|
|
case QE_CLK22: clock_bits = 8; break;
|
|
case QE_CLK7: clock_bits = 9; break;
|
|
case QE_CLK8: clock_bits = 10; break;
|
|
case QE_CLK16: clock_bits = 11; break;
|
|
default: break;
|
|
}
|
|
break;
|
|
default: break;
|
|
}
|
|
|
|
/* Check for invalid combination of clock and UCC number */
|
|
if (!clock_bits)
|
|
return -ENOENT;
|
|
|
|
if (mode == COMM_DIR_RX)
|
|
shift += 4;
|
|
|
|
clrsetbits_be32(cmxucr, QE_CMXUCR_TX_CLK_SRC_MASK << shift,
|
|
clock_bits << shift);
|
|
|
|
return 0;
|
|
}
|