2007-03-24 14:45:34 +00:00
|
|
|
/*
|
2008-06-23 09:15:09 +00:00
|
|
|
* (C) Copyright 2007-2008
|
2007-03-24 14:45:34 +00:00
|
|
|
* Stefan Roese, DENX Software Engineering, sr@denx.de.
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/io.h>
|
2010-09-16 12:30:37 +00:00
|
|
|
#include <asm/ppc4xx-gpio.h>
|
2007-03-24 14:45:34 +00:00
|
|
|
|
2010-09-12 04:21:37 +00:00
|
|
|
/* Only compile this file for boards with GPIO support */
|
|
|
|
#if defined(GPIO0_BASE)
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_4xx_GPIO_TABLE)
|
|
|
|
gpio_param_s const gpio_tab[GPIO_GROUP_MAX][GPIO_MAX] = CONFIG_SYS_4xx_GPIO_TABLE;
|
2007-03-24 14:45:34 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(GPIO0_OSRL)
|
|
|
|
/* Only some 4xx variants support alternate funtions on the GPIO's */
|
|
|
|
void gpio_config(int pin, int in_out, int gpio_alt, int out_val)
|
|
|
|
{
|
|
|
|
u32 mask;
|
|
|
|
u32 mask2;
|
|
|
|
u32 val;
|
|
|
|
u32 offs = 0;
|
|
|
|
u32 offs2 = 0;
|
|
|
|
int pin2 = pin << 1;
|
|
|
|
|
|
|
|
if (pin >= GPIO_MAX) {
|
|
|
|
offs = 0x100;
|
|
|
|
pin -= GPIO_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pin >= GPIO_MAX/2) {
|
2007-12-11 12:38:19 +00:00
|
|
|
offs2 = 0x4;
|
2007-03-24 14:45:34 +00:00
|
|
|
pin2 = (pin - GPIO_MAX/2) << 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mask = 0x80000000 >> pin;
|
2008-06-23 09:15:09 +00:00
|
|
|
mask2 = 0xc0000000 >> pin2;
|
2007-03-24 14:45:34 +00:00
|
|
|
|
|
|
|
/* first set TCR to 0 */
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_TCR + offs, in_be32((void *)GPIO0_TCR + offs) & ~mask);
|
2007-03-24 14:45:34 +00:00
|
|
|
|
|
|
|
if (in_out == GPIO_OUT) {
|
2007-11-15 13:23:55 +00:00
|
|
|
val = in_be32((void *)GPIO0_OSRL + offs + offs2) & ~mask2;
|
2007-03-24 14:45:34 +00:00
|
|
|
switch (gpio_alt) {
|
|
|
|
case GPIO_ALT1:
|
|
|
|
val |= GPIO_ALT1_SEL >> pin2;
|
|
|
|
break;
|
|
|
|
case GPIO_ALT2:
|
|
|
|
val |= GPIO_ALT2_SEL >> pin2;
|
|
|
|
break;
|
|
|
|
case GPIO_ALT3:
|
|
|
|
val |= GPIO_ALT3_SEL >> pin2;
|
|
|
|
break;
|
|
|
|
}
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_OSRL + offs + offs2, val);
|
2007-03-24 14:45:34 +00:00
|
|
|
|
|
|
|
/* setup requested output value */
|
|
|
|
if (out_val == GPIO_OUT_0)
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_OR + offs,
|
|
|
|
in_be32((void *)GPIO0_OR + offs) & ~mask);
|
2007-03-24 14:45:34 +00:00
|
|
|
else if (out_val == GPIO_OUT_1)
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_OR + offs,
|
|
|
|
in_be32((void *)GPIO0_OR + offs) | mask);
|
2007-03-24 14:45:34 +00:00
|
|
|
|
|
|
|
/* now configure TCR to drive output if selected */
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_TCR + offs,
|
|
|
|
in_be32((void *)GPIO0_TCR + offs) | mask);
|
2007-03-24 14:45:34 +00:00
|
|
|
} else {
|
2007-11-15 13:23:55 +00:00
|
|
|
val = in_be32((void *)GPIO0_ISR1L + offs + offs2) & ~mask2;
|
2007-03-24 14:45:34 +00:00
|
|
|
val |= GPIO_IN_SEL >> pin2;
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_ISR1L + offs + offs2, val);
|
2007-03-24 14:45:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* GPIO_OSRL */
|
|
|
|
|
|
|
|
void gpio_write_bit(int pin, int val)
|
|
|
|
{
|
|
|
|
u32 offs = 0;
|
|
|
|
|
|
|
|
if (pin >= GPIO_MAX) {
|
|
|
|
offs = 0x100;
|
|
|
|
pin -= GPIO_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val)
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_OR + offs,
|
|
|
|
in_be32((void *)GPIO0_OR + offs) | GPIO_VAL(pin));
|
2007-03-24 14:45:34 +00:00
|
|
|
else
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO0_OR + offs,
|
|
|
|
in_be32((void *)GPIO0_OR + offs) & ~GPIO_VAL(pin));
|
2007-03-24 14:45:34 +00:00
|
|
|
}
|
|
|
|
|
2007-06-15 05:39:43 +00:00
|
|
|
int gpio_read_out_bit(int pin)
|
|
|
|
{
|
|
|
|
u32 offs = 0;
|
|
|
|
|
|
|
|
if (pin >= GPIO_MAX) {
|
|
|
|
offs = 0x100;
|
|
|
|
pin -= GPIO_MAX;
|
|
|
|
}
|
|
|
|
|
2007-11-15 13:23:55 +00:00
|
|
|
return (in_be32((void *)GPIO0_OR + offs) & GPIO_VAL(pin) ? 1 : 0);
|
2007-06-15 05:39:43 +00:00
|
|
|
}
|
|
|
|
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
int gpio_read_in_bit(int pin)
|
|
|
|
{
|
|
|
|
u32 offs = 0;
|
|
|
|
|
|
|
|
if (pin >= GPIO_MAX) {
|
|
|
|
offs = 0x100;
|
|
|
|
pin -= GPIO_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (in_be32((void *)GPIO0_IR + offs) & GPIO_VAL(pin) ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
#if defined(CONFIG_SYS_4xx_GPIO_TABLE)
|
2007-03-24 14:45:34 +00:00
|
|
|
void gpio_set_chip_configuration(void)
|
|
|
|
{
|
|
|
|
unsigned char i=0, j=0, offs=0, gpio_core;
|
|
|
|
unsigned long reg, core_add;
|
|
|
|
|
|
|
|
for (gpio_core=0; gpio_core<GPIO_GROUP_MAX; gpio_core++) {
|
|
|
|
j = 0;
|
|
|
|
offs = 0;
|
|
|
|
/* GPIO config of the GPIOs 0 to 31 */
|
|
|
|
for (i=0; i<GPIO_MAX; i++, j++) {
|
|
|
|
if (i == GPIO_MAX/2) {
|
|
|
|
offs = 4;
|
|
|
|
j = i-16;
|
|
|
|
}
|
|
|
|
|
|
|
|
core_add = gpio_tab[gpio_core][i].add;
|
|
|
|
|
|
|
|
if ((gpio_tab[gpio_core][i].in_out == GPIO_IN) ||
|
|
|
|
(gpio_tab[gpio_core][i].in_out == GPIO_BI)) {
|
|
|
|
|
|
|
|
switch (gpio_tab[gpio_core][i].alt_nb) {
|
|
|
|
case GPIO_SEL:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT1:
|
2007-11-15 13:23:55 +00:00
|
|
|
reg = in_be32((void *)GPIO_IS1(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
|
|
|
reg = reg | (GPIO_IN_SEL >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_IS1(core_add+offs), reg);
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT2:
|
2007-11-15 13:23:55 +00:00
|
|
|
reg = in_be32((void *)GPIO_IS2(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
|
|
|
reg = reg | (GPIO_IN_SEL >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_IS2(core_add+offs), reg);
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT3:
|
2007-11-15 13:23:55 +00:00
|
|
|
reg = in_be32((void *)GPIO_IS3(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
|
|
|
reg = reg | (GPIO_IN_SEL >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_IS3(core_add+offs), reg);
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((gpio_tab[gpio_core][i].in_out == GPIO_OUT) ||
|
|
|
|
(gpio_tab[gpio_core][i].in_out == GPIO_BI)) {
|
|
|
|
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
u32 gpio_alt_sel = 0;
|
|
|
|
|
2007-03-24 14:45:34 +00:00
|
|
|
switch (gpio_tab[gpio_core][i].alt_nb) {
|
|
|
|
case GPIO_SEL:
|
2007-11-15 13:23:55 +00:00
|
|
|
/*
|
|
|
|
* Setup output value
|
|
|
|
* 1 -> high level
|
|
|
|
* 0 -> low level
|
|
|
|
* else -> don't touch
|
|
|
|
*/
|
|
|
|
reg = in_be32((void *)GPIO_OR(core_add));
|
|
|
|
if (gpio_tab[gpio_core][i].out_val == GPIO_OUT_1)
|
|
|
|
reg |= (0x80000000 >> (i));
|
|
|
|
else if (gpio_tab[gpio_core][i].out_val == GPIO_OUT_0)
|
|
|
|
reg &= ~(0x80000000 >> (i));
|
|
|
|
out_be32((void *)GPIO_OR(core_add), reg);
|
|
|
|
|
|
|
|
reg = in_be32((void *)GPIO_TCR(core_add)) |
|
|
|
|
(0x80000000 >> (i));
|
|
|
|
out_be32((void *)GPIO_TCR(core_add), reg);
|
|
|
|
|
|
|
|
reg = in_be32((void *)GPIO_OS(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_OS(core_add+offs), reg);
|
|
|
|
reg = in_be32((void *)GPIO_TS(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_TS(core_add+offs), reg);
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT1:
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
gpio_alt_sel = GPIO_ALT1_SEL;
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT2:
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
gpio_alt_sel = GPIO_ALT2_SEL;
|
2007-03-24 14:45:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIO_ALT3:
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
gpio_alt_sel = GPIO_ALT3_SEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 != gpio_alt_sel) {
|
2007-11-15 13:23:55 +00:00
|
|
|
reg = in_be32((void *)GPIO_OS(core_add+offs))
|
2007-03-24 14:45:34 +00:00
|
|
|
& ~(GPIO_MASK >> (j*2));
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
reg = reg | (gpio_alt_sel >> (j*2));
|
2007-11-15 13:23:55 +00:00
|
|
|
out_be32((void *)GPIO_OS(core_add+offs), reg);
|
ppc4xx: Add functionality to GPIO support
This patch makes two additions to GPIO support:
First, it adds function gpio_read_in_bit() to read the a bit from the
GPIO Input Register (GPIOx_IR) in the same way that function
gpio_read_out_bit() reads a bit from the GPIO Output Register
(GPIOx_OR).
Second, it modifies function gpio_set_chip_configuration() to provide
an additional option for configuring the GPIO from the
"CFG_4xx_GPIO_TABLE".
According to the 440EPx User's Manual, when an alternate output is used,
the three-state control is configured in one of two ways, depending on
the particular output. The first option is to select the corresponding
alternate three-state control in the GPIOx_TRSH/L registers. The second
option is to select the GPIO Three-State Control Register (GPIOx_TCR) in
the GPIOx_TRSH/L registers, and set the corresponding bit in the
GPIOx_TCR register to enable the output. For example, the Manual
specifies configuring the GPIO00 Alternate 1 Signal (PreAddr07) to use
the alternate three-state control (first option), and specifies
configuring the GPIO32 Alternate 1 Signal (USB2OM0) with the output
enabled in the GPIOx_TCR register (second option).
Currently, gpio_set_chip_configuration() configures all alternate signal
outputs to use the first option. This patch allow the second option to
be selected by setting the "out_val" element in the table entry to
"GPIO_OUT_1". The first option is used when the "out_val" element is
set to "GPIO_OUT_0". Because "out_val" is not currently used when an
alternate signal is selected, and because all current GPIO tables set
"out_val" to "GPIO_OUT_0" for all alternate signals, this patch should
not change any existing configurations.
Signed-off-by: Larry Johnson <lrj@acm.org>
2008-01-03 23:54:00 +00:00
|
|
|
|
|
|
|
if (gpio_tab[gpio_core][i].out_val == GPIO_OUT_1) {
|
|
|
|
reg = in_be32((void *)GPIO_TCR(core_add))
|
|
|
|
| (0x80000000 >> (i));
|
|
|
|
out_be32((void *)GPIO_TCR(core_add), reg);
|
|
|
|
reg = in_be32((void *)GPIO_TS(core_add+offs))
|
|
|
|
& ~(GPIO_MASK >> (j*2));
|
|
|
|
out_be32((void *)GPIO_TS(core_add+offs), reg);
|
|
|
|
} else {
|
|
|
|
reg = in_be32((void *)GPIO_TCR(core_add))
|
|
|
|
& ~(0x80000000 >> (i));
|
|
|
|
out_be32((void *)GPIO_TCR(core_add), reg);
|
|
|
|
reg = in_be32((void *)GPIO_TS(core_add+offs))
|
|
|
|
& ~(GPIO_MASK >> (j*2));
|
|
|
|
reg = reg | (gpio_alt_sel >> (j*2));
|
|
|
|
out_be32((void *)GPIO_TS(core_add+offs), reg);
|
|
|
|
}
|
2007-03-24 14:45:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-12 04:21:37 +00:00
|
|
|
|
|
|
|
#endif /* GPIO0_BASE */
|
2008-10-16 13:01:15 +00:00
|
|
|
#endif /* CONFIG_SYS_4xx_GPIO_TABLE */
|