mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-18 18:59:44 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
68 lines
2.1 KiB
C
68 lines
2.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2006 Freescale Semiconductor, Inc.
|
|
*
|
|
* Dave Liu <daveliu@freescale.com>
|
|
* based on source code of Shlomi Gridish
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <linux/errno.h>
|
|
#include <asm/io.h>
|
|
#include <asm/immap_83xx.h>
|
|
|
|
#define NUM_OF_PINS 32
|
|
void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign)
|
|
{
|
|
u32 pin_2bit_mask;
|
|
u32 pin_2bit_dir;
|
|
u32 pin_2bit_assign;
|
|
u32 pin_1bit_mask;
|
|
u32 tmp_val;
|
|
volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
|
|
volatile qepio83xx_t *par_io = (volatile qepio83xx_t *)&im->qepio;
|
|
|
|
/* Calculate pin location and 2bit mask and dir */
|
|
pin_2bit_mask = (u32)(0x3 << (NUM_OF_PINS-(pin%(NUM_OF_PINS/2)+1)*2));
|
|
pin_2bit_dir = (u32)(dir << (NUM_OF_PINS-(pin%(NUM_OF_PINS/2)+1)*2));
|
|
|
|
/* Setup the direction */
|
|
tmp_val = (pin > (NUM_OF_PINS/2) - 1) ? \
|
|
in_be32(&par_io->ioport[port].dir2) :
|
|
in_be32(&par_io->ioport[port].dir1);
|
|
|
|
if (pin > (NUM_OF_PINS/2) -1) {
|
|
out_be32(&par_io->ioport[port].dir2, ~pin_2bit_mask & tmp_val);
|
|
out_be32(&par_io->ioport[port].dir2, pin_2bit_dir | tmp_val);
|
|
} else {
|
|
out_be32(&par_io->ioport[port].dir1, ~pin_2bit_mask & tmp_val);
|
|
out_be32(&par_io->ioport[port].dir1, pin_2bit_dir | tmp_val);
|
|
}
|
|
|
|
/* Calculate pin location for 1bit mask */
|
|
pin_1bit_mask = (u32)(1 << (NUM_OF_PINS - (pin+1)));
|
|
|
|
/* Setup the open drain */
|
|
tmp_val = in_be32(&par_io->ioport[port].podr);
|
|
if (open_drain) {
|
|
out_be32(&par_io->ioport[port].podr, pin_1bit_mask | tmp_val);
|
|
} else {
|
|
out_be32(&par_io->ioport[port].podr, ~pin_1bit_mask & tmp_val);
|
|
}
|
|
|
|
/* Setup the assignment */
|
|
tmp_val = (pin > (NUM_OF_PINS/2) - 1) ?
|
|
in_be32(&par_io->ioport[port].ppar2):
|
|
in_be32(&par_io->ioport[port].ppar1);
|
|
pin_2bit_assign = (u32)(assign
|
|
<< (NUM_OF_PINS - (pin%(NUM_OF_PINS/2)+1)*2));
|
|
|
|
/* Clear and set 2 bits mask */
|
|
if (pin > (NUM_OF_PINS/2) - 1) {
|
|
out_be32(&par_io->ioport[port].ppar2, ~pin_2bit_mask & tmp_val);
|
|
out_be32(&par_io->ioport[port].ppar2, pin_2bit_assign | tmp_val);
|
|
} else {
|
|
out_be32(&par_io->ioport[port].ppar1, ~pin_2bit_mask & tmp_val);
|
|
out_be32(&par_io->ioport[port].ppar1, pin_2bit_assign | tmp_val);
|
|
}
|
|
}
|