2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2006-11-03 18:11:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Freescale Semiconductor, Inc.
|
|
|
|
*
|
|
|
|
* Dave Liu <daveliu@freescale.com>
|
|
|
|
* based on source code of Shlomi Gridish
|
|
|
|
*/
|
|
|
|
|
2016-09-21 02:28:53 +00:00
|
|
|
#include <common.h>
|
2016-09-21 02:28:55 +00:00
|
|
|
#include <linux/errno.h>
|
2016-09-21 02:28:53 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/immap_83xx.h>
|
2006-11-03 18:11:15 +00:00
|
|
|
|
|
|
|
#define NUM_OF_PINS 32
|
2020-02-03 09:23:53 +00:00
|
|
|
|
|
|
|
/** qe_cfg_iopin configure one io pin setting
|
|
|
|
*
|
|
|
|
* @par_io: pointer to parallel I/O base
|
|
|
|
* @port: io pin port
|
|
|
|
* @pin: io pin number which get configured
|
|
|
|
* @dir: direction of io pin 2 bits valid
|
|
|
|
* 00 = pin disabled
|
|
|
|
* 01 = output
|
|
|
|
* 10 = input
|
|
|
|
* 11 = pin is I/O
|
|
|
|
* @open_drain: is pin open drain
|
|
|
|
* @assign: pin assignment registers select the function of the pin
|
|
|
|
*/
|
|
|
|
static void qe_cfg_iopin(qepio83xx_t *par_io, u8 port, u8 pin, int dir,
|
|
|
|
int open_drain, int assign)
|
2006-11-03 18:11:15 +00:00
|
|
|
{
|
2020-02-03 09:23:53 +00:00
|
|
|
u32 dbit_mask;
|
|
|
|
u32 dbit_dir;
|
|
|
|
u32 dbit_asgn;
|
|
|
|
u32 bit_mask;
|
|
|
|
u32 tmp_val;
|
|
|
|
int offset;
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
|
|
|
|
offset = (NUM_OF_PINS - (pin % (NUM_OF_PINS / 2) + 1) * 2);
|
2006-11-03 18:11:15 +00:00
|
|
|
|
2015-12-16 17:25:42 +00:00
|
|
|
/* Calculate pin location and 2bit mask and dir */
|
2020-02-03 09:23:53 +00:00
|
|
|
dbit_mask = (u32)(0x3 << offset);
|
|
|
|
dbit_dir = (u32)(dir << offset);
|
2006-11-03 18:11:15 +00:00
|
|
|
|
|
|
|
/* Setup the direction */
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
tmp_val = (pin > (NUM_OF_PINS / 2) - 1) ?
|
2006-11-03 18:11:15 +00:00
|
|
|
in_be32(&par_io->ioport[port].dir2) :
|
|
|
|
in_be32(&par_io->ioport[port].dir1);
|
|
|
|
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
if (pin > (NUM_OF_PINS / 2) - 1) {
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].dir2, ~dbit_mask & tmp_val);
|
|
|
|
out_be32(&par_io->ioport[port].dir2, dbit_dir | tmp_val);
|
2006-11-03 18:11:15 +00:00
|
|
|
} else {
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].dir1, ~dbit_mask & tmp_val);
|
|
|
|
out_be32(&par_io->ioport[port].dir1, dbit_dir | tmp_val);
|
2006-11-03 18:11:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate pin location for 1bit mask */
|
2020-02-03 09:23:53 +00:00
|
|
|
bit_mask = (u32)(1 << (NUM_OF_PINS - (pin + 1)));
|
2006-11-03 18:11:15 +00:00
|
|
|
|
|
|
|
/* Setup the open drain */
|
|
|
|
tmp_val = in_be32(&par_io->ioport[port].podr);
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
if (open_drain)
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].podr, bit_mask | tmp_val);
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
else
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].podr, ~bit_mask & tmp_val);
|
2006-11-03 18:11:15 +00:00
|
|
|
|
|
|
|
/* Setup the assignment */
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
tmp_val = (pin > (NUM_OF_PINS / 2) - 1) ?
|
|
|
|
in_be32(&par_io->ioport[port].ppar2) :
|
2006-11-03 18:11:15 +00:00
|
|
|
in_be32(&par_io->ioport[port].ppar1);
|
2020-02-03 09:23:53 +00:00
|
|
|
dbit_asgn = (u32)(assign << offset);
|
2006-11-03 18:11:15 +00:00
|
|
|
|
|
|
|
/* Clear and set 2 bits mask */
|
powerpc, qe: fix codingstyle issues for drivers/qe
fix Codingstyle for files in drivers/qe, remaining following
check warnings:
$ ./scripts/checkpatch.pl -f drivers/qe/uec.h
CHECK: Macro argument reuse '_bd' - possible side-effects?
+#define BD_ADVANCE(_bd, _status, _base) \
+ (((_status) & BD_WRAP) ? (_bd) = \
+ ((struct buffer_descriptor *)(_base)) : ++(_bd))
total: 0 errors, 0 warnings, 1 checks, 692 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.h
total: 0 errors, 0 warnings, 0 checks, 214 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uccf.c
total: 0 errors, 0 warnings, 0 checks, 507 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec.c
total: 0 errors, 0 warnings, 0 checks, 1434 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/uec_phy.c
total: 0 errors, 0 warnings, 0 checks, 927 lines checked
$ ./scripts/checkpatch.pl -f drivers/qe/qe.c
CHECK: Lines should not end with a '('
+U_BOOT_CMD(
total: 0 errors, 0 warnings, 1 checks, 830 lines checked
Signed-off-by: Heiko Schocher <hs@denx.de>
2020-05-25 05:27:26 +00:00
|
|
|
if (pin > (NUM_OF_PINS / 2) - 1) {
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].ppar2, ~dbit_mask & tmp_val);
|
|
|
|
out_be32(&par_io->ioport[port].ppar2, dbit_asgn | tmp_val);
|
2006-11-03 18:11:15 +00:00
|
|
|
} else {
|
2020-02-03 09:23:53 +00:00
|
|
|
out_be32(&par_io->ioport[port].ppar1, ~dbit_mask & tmp_val);
|
|
|
|
out_be32(&par_io->ioport[port].ppar1, dbit_asgn | tmp_val);
|
2006-11-03 18:11:15 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-03 09:23:53 +00:00
|
|
|
|
|
|
|
#if !defined(CONFIG_PINCTRL)
|
|
|
|
/** qe_config_iopin configure one io pin setting
|
|
|
|
*
|
|
|
|
* @port: io pin port
|
|
|
|
* @pin: io pin number which get configured
|
|
|
|
* @dir: direction of io pin 2 bits valid
|
|
|
|
* 00 = pin disabled
|
|
|
|
* 01 = output
|
|
|
|
* 10 = input
|
|
|
|
* 11 = pin is I/O
|
|
|
|
* @open_drain: is pin open drain
|
|
|
|
* @assign: pin assignment registers select the function of the pin
|
|
|
|
*/
|
|
|
|
void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign)
|
|
|
|
{
|
|
|
|
immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
|
|
|
|
qepio83xx_t *par_io = (qepio83xx_t *)&im->qepio;
|
|
|
|
|
|
|
|
qe_cfg_iopin(par_io, port, pin, dir, open_drain, assign);
|
|
|
|
}
|
|
|
|
#endif
|