2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-05-25 13:15:20 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2016
|
2018-03-06 07:04:58 +00:00
|
|
|
* Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
2016-05-25 13:15:20 +00:00
|
|
|
*
|
|
|
|
* based on arch/powerpc/include/asm/mpc85xx_gpio.h, which is
|
|
|
|
*
|
|
|
|
* Copyright 2010 eXMeritus, A Boeing Company
|
2020-09-24 13:40:50 +00:00
|
|
|
* Copyright 2020 NXP
|
2016-05-25 13:15:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <mapmem.h>
|
2018-01-15 10:07:49 +00:00
|
|
|
#include <asm/gpio.h>
|
2020-09-24 13:40:50 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <dm/of_access.h>
|
2016-05-25 13:15:20 +00:00
|
|
|
|
|
|
|
struct ccsr_gpio {
|
|
|
|
u32 gpdir;
|
|
|
|
u32 gpodr;
|
|
|
|
u32 gpdat;
|
|
|
|
u32 gpier;
|
|
|
|
u32 gpimr;
|
|
|
|
u32 gpicr;
|
2020-09-24 13:40:50 +00:00
|
|
|
u32 gpibe;
|
2016-05-25 13:15:20 +00:00
|
|
|
};
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data {
|
2016-05-25 13:15:20 +00:00
|
|
|
/* The bank's register base in memory */
|
|
|
|
struct ccsr_gpio __iomem *base;
|
|
|
|
/* The address of the registers; used to identify the bank */
|
|
|
|
ulong addr;
|
|
|
|
/* The GPIO count of the bank */
|
|
|
|
uint gpio_count;
|
|
|
|
/* The GPDAT register cannot be used to determine the value of output
|
|
|
|
* pins on MPC8572/MPC8536, so we shadow it and use the shadowed value
|
2018-01-15 10:07:46 +00:00
|
|
|
* for output pins
|
|
|
|
*/
|
2016-05-25 13:15:20 +00:00
|
|
|
u32 dat_shadow;
|
2018-01-15 10:07:49 +00:00
|
|
|
ulong type;
|
2020-09-24 13:40:50 +00:00
|
|
|
bool little_endian;
|
2018-01-15 10:07:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MPC8XXX_GPIO_TYPE,
|
|
|
|
MPC5121_GPIO_TYPE,
|
2016-05-25 13:15:20 +00:00
|
|
|
};
|
|
|
|
|
2018-01-15 10:07:46 +00:00
|
|
|
inline u32 gpio_mask(uint gpio)
|
|
|
|
{
|
2016-05-25 13:15:20 +00:00
|
|
|
return (1U << (31 - (gpio)));
|
|
|
|
}
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
static inline u32 mpc8xxx_gpio_get_val(struct udevice *dev, u32 mask)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
|
|
|
|
|
|
|
if (data->little_endian)
|
|
|
|
return in_le32(&data->base->gpdat) & mask;
|
|
|
|
else
|
|
|
|
return in_be32(&data->base->gpdat) & mask;
|
2016-05-25 13:15:20 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
static inline u32 mpc8xxx_gpio_get_dir(struct udevice *dev, u32 mask)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
|
|
|
|
|
|
|
if (data->little_endian)
|
|
|
|
return in_le32(&data->base->gpdir) & mask;
|
|
|
|
else
|
|
|
|
return in_be32(&data->base->gpdir) & mask;
|
2016-05-25 13:15:20 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
static inline int mpc8xxx_gpio_open_drain_val(struct udevice *dev, u32 mask)
|
2016-05-25 13:15:22 +00:00
|
|
|
{
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
|
|
|
|
|
|
|
if (data->little_endian)
|
|
|
|
return in_le32(&data->base->gpodr) & mask;
|
|
|
|
else
|
|
|
|
return in_be32(&data->base->gpodr) & mask;
|
2016-05-25 13:15:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
static inline void mpc8xxx_gpio_open_drain_on(struct udevice *dev, u32
|
2016-05-25 13:15:22 +00:00
|
|
|
gpios)
|
|
|
|
{
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2016-05-25 13:15:22 +00:00
|
|
|
/* GPODR register 1 -> open drain on */
|
2020-09-24 13:40:50 +00:00
|
|
|
if (data->little_endian)
|
|
|
|
setbits_le32(&data->base->gpodr, gpios);
|
|
|
|
else
|
|
|
|
setbits_be32(&data->base->gpodr, gpios);
|
2016-05-25 13:15:22 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
static inline void mpc8xxx_gpio_open_drain_off(struct udevice *dev,
|
2016-05-25 13:15:22 +00:00
|
|
|
u32 gpios)
|
|
|
|
{
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2016-05-25 13:15:22 +00:00
|
|
|
/* GPODR register 0 -> open drain off (actively driven) */
|
2020-09-24 13:40:50 +00:00
|
|
|
if (data->little_endian)
|
|
|
|
clrbits_le32(&data->base->gpodr, gpios);
|
|
|
|
else
|
|
|
|
clrbits_be32(&data->base->gpodr, gpios);
|
2016-05-25 13:15:22 +00:00
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2020-01-28 12:04:33 +00:00
|
|
|
u32 mask = gpio_mask(gpio);
|
|
|
|
|
|
|
|
/* GPDIR register 0 -> input */
|
2020-09-24 13:40:50 +00:00
|
|
|
if (data->little_endian)
|
|
|
|
clrbits_le32(&data->base->gpdir, mask);
|
|
|
|
else
|
|
|
|
clrbits_be32(&data->base->gpdir, mask);
|
2016-05-25 13:15:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2020-01-28 12:04:34 +00:00
|
|
|
struct ccsr_gpio *base = data->base;
|
|
|
|
u32 mask = gpio_mask(gpio);
|
|
|
|
u32 gpdir;
|
2016-05-25 13:15:20 +00:00
|
|
|
|
|
|
|
if (value) {
|
2020-01-28 12:04:34 +00:00
|
|
|
data->dat_shadow |= mask;
|
2016-05-25 13:15:20 +00:00
|
|
|
} else {
|
2020-01-28 12:04:34 +00:00
|
|
|
data->dat_shadow &= ~mask;
|
2016-05-25 13:15:20 +00:00
|
|
|
}
|
2020-01-28 12:04:34 +00:00
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
if (data->little_endian)
|
|
|
|
gpdir = in_le32(&base->gpdir);
|
|
|
|
else
|
|
|
|
gpdir = in_be32(&base->gpdir);
|
|
|
|
|
2020-01-28 12:04:34 +00:00
|
|
|
gpdir |= gpio_mask(gpio);
|
2020-09-24 13:40:50 +00:00
|
|
|
|
|
|
|
if (data->little_endian) {
|
|
|
|
out_le32(&base->gpdat, gpdir & data->dat_shadow);
|
|
|
|
out_le32(&base->gpdir, gpdir);
|
|
|
|
} else {
|
|
|
|
out_be32(&base->gpdat, gpdir & data->dat_shadow);
|
|
|
|
out_be32(&base->gpdir, gpdir);
|
|
|
|
}
|
2020-01-28 12:04:34 +00:00
|
|
|
|
2016-05-25 13:15:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_direction_output(struct udevice *dev, uint gpio,
|
2016-05-25 13:15:20 +00:00
|
|
|
int value)
|
|
|
|
{
|
2018-01-15 10:07:49 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
|
|
|
|
|
|
|
/* GPIO 28..31 are input only on MPC5121 */
|
|
|
|
if (data->type == MPC5121_GPIO_TYPE && gpio >= 28)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
return mpc8xxx_gpio_set_value(dev, gpio, value);
|
2016-05-25 13:15:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_get_value(struct udevice *dev, uint gpio)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2016-05-25 13:15:20 +00:00
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
if (!!mpc8xxx_gpio_get_dir(dev, gpio_mask(gpio))) {
|
2016-05-25 13:15:20 +00:00
|
|
|
/* Output -> use shadowed value */
|
|
|
|
return !!(data->dat_shadow & gpio_mask(gpio));
|
|
|
|
}
|
2018-01-15 10:07:46 +00:00
|
|
|
|
|
|
|
/* Input -> read value from GPDAT register */
|
2020-09-24 13:40:50 +00:00
|
|
|
return !!mpc8xxx_gpio_get_val(dev, gpio_mask(gpio));
|
2016-05-25 13:15:20 +00:00
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_get_function(struct udevice *dev, uint gpio)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
|
|
|
int dir;
|
|
|
|
|
2020-09-24 13:40:50 +00:00
|
|
|
dir = !!mpc8xxx_gpio_get_dir(dev, gpio_mask(gpio));
|
2016-05-25 13:15:20 +00:00
|
|
|
return dir ? GPIOF_OUTPUT : GPIOF_INPUT;
|
|
|
|
}
|
|
|
|
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
2020-12-03 23:55:21 +00:00
|
|
|
static int mpc8xxx_gpio_of_to_plat(struct udevice *dev)
|
2018-01-15 10:07:46 +00:00
|
|
|
{
|
2020-12-03 23:55:20 +00:00
|
|
|
struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev);
|
2020-09-24 13:40:50 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2016-05-25 13:15:20 +00:00
|
|
|
fdt_addr_t addr;
|
2020-09-24 13:40:50 +00:00
|
|
|
u32 i;
|
|
|
|
u32 reg[4];
|
|
|
|
|
2020-12-19 17:40:14 +00:00
|
|
|
if (ofnode_read_bool(dev_ofnode(dev), "little-endian"))
|
2020-09-24 13:40:50 +00:00
|
|
|
data->little_endian = true;
|
|
|
|
|
|
|
|
if (data->little_endian)
|
|
|
|
dev_read_u32_array(dev, "reg", reg, 4);
|
|
|
|
else
|
|
|
|
dev_read_u32_array(dev, "reg", reg, 2);
|
|
|
|
|
|
|
|
if (data->little_endian) {
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
reg[i] = be32_to_cpu(reg[i]);
|
|
|
|
}
|
2018-01-15 10:07:50 +00:00
|
|
|
|
|
|
|
addr = dev_translate_address(dev, reg);
|
2016-05-25 13:15:20 +00:00
|
|
|
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
plat->addr = addr;
|
2020-09-24 13:40:50 +00:00
|
|
|
|
|
|
|
if (data->little_endian)
|
|
|
|
plat->size = reg[3];
|
|
|
|
else
|
|
|
|
plat->size = reg[1];
|
|
|
|
|
2018-01-15 10:07:50 +00:00
|
|
|
plat->ngpios = dev_read_u32_default(dev, "ngpios", 32);
|
2016-05-25 13:15:20 +00:00
|
|
|
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
static int mpc8xxx_gpio_plat_to_priv(struct udevice *dev)
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
{
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data *priv = dev_get_priv(dev);
|
2020-12-03 23:55:20 +00:00
|
|
|
struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev);
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
unsigned long size = plat->size;
|
2018-01-15 10:07:49 +00:00
|
|
|
ulong driver_data = dev_get_driver_data(dev);
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
size = 0x100;
|
|
|
|
|
|
|
|
priv->addr = plat->addr;
|
2018-01-15 10:07:50 +00:00
|
|
|
priv->base = map_sysmem(plat->addr, size);
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
|
|
|
|
if (!priv->base)
|
2016-05-25 13:15:20 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
priv->gpio_count = plat->ngpios;
|
|
|
|
priv->dat_shadow = 0;
|
2016-05-25 13:15:20 +00:00
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
priv->type = driver_data;
|
|
|
|
|
2016-05-25 13:15:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static int mpc8xxx_gpio_probe(struct udevice *dev)
|
2016-05-25 13:15:20 +00:00
|
|
|
{
|
|
|
|
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
|
2018-01-15 10:07:48 +00:00
|
|
|
struct mpc8xxx_gpio_data *data = dev_get_priv(dev);
|
2016-05-25 13:15:20 +00:00
|
|
|
char name[32], *str;
|
|
|
|
|
2020-12-03 23:55:23 +00:00
|
|
|
mpc8xxx_gpio_plat_to_priv(dev);
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
|
2016-05-25 13:15:20 +00:00
|
|
|
snprintf(name, sizeof(name), "MPC@%lx_", data->addr);
|
|
|
|
str = strdup(name);
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2020-12-19 17:40:14 +00:00
|
|
|
if (ofnode_device_is_compatible(dev_ofnode(dev), "fsl,qoriq-gpio")) {
|
2020-09-24 13:40:50 +00:00
|
|
|
unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio)
|
|
|
|
- sizeof(u32);
|
|
|
|
|
|
|
|
out_be32((unsigned int *)gpibe, 0xffffffff);
|
|
|
|
}
|
|
|
|
|
2016-05-25 13:15:20 +00:00
|
|
|
uc_priv->bank_name = str;
|
|
|
|
uc_priv->gpio_count = data->gpio_count;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static const struct dm_gpio_ops gpio_mpc8xxx_ops = {
|
|
|
|
.direction_input = mpc8xxx_gpio_direction_input,
|
|
|
|
.direction_output = mpc8xxx_gpio_direction_output,
|
|
|
|
.get_value = mpc8xxx_gpio_get_value,
|
|
|
|
.set_value = mpc8xxx_gpio_set_value,
|
|
|
|
.get_function = mpc8xxx_gpio_get_function,
|
2016-05-25 13:15:20 +00:00
|
|
|
};
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
static const struct udevice_id mpc8xxx_gpio_ids[] = {
|
2018-01-15 10:07:49 +00:00
|
|
|
{ .compatible = "fsl,pq3-gpio", .data = MPC8XXX_GPIO_TYPE },
|
|
|
|
{ .compatible = "fsl,mpc8308-gpio", .data = MPC8XXX_GPIO_TYPE },
|
|
|
|
{ .compatible = "fsl,mpc8349-gpio", .data = MPC8XXX_GPIO_TYPE },
|
|
|
|
{ .compatible = "fsl,mpc8572-gpio", .data = MPC8XXX_GPIO_TYPE},
|
|
|
|
{ .compatible = "fsl,mpc8610-gpio", .data = MPC8XXX_GPIO_TYPE},
|
|
|
|
{ .compatible = "fsl,mpc5121-gpio", .data = MPC5121_GPIO_TYPE, },
|
|
|
|
{ .compatible = "fsl,qoriq-gpio", .data = MPC8XXX_GPIO_TYPE },
|
2016-05-25 13:15:20 +00:00
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
2018-01-15 10:07:48 +00:00
|
|
|
U_BOOT_DRIVER(gpio_mpc8xxx) = {
|
|
|
|
.name = "gpio_mpc8xxx",
|
2016-05-25 13:15:20 +00:00
|
|
|
.id = UCLASS_GPIO,
|
2018-01-15 10:07:48 +00:00
|
|
|
.ops = &gpio_mpc8xxx_ops,
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
2020-12-03 23:55:21 +00:00
|
|
|
.of_to_plat = mpc8xxx_gpio_of_to_plat,
|
2020-12-03 23:55:18 +00:00
|
|
|
.plat_auto = sizeof(struct mpc8xxx_gpio_plat),
|
2018-01-15 10:07:48 +00:00
|
|
|
.of_match = mpc8xxx_gpio_ids,
|
dm: gpio: MPC85XX GPIO platform data support
Define a platform data structure for the MPC85XX GPIO driver to allow
use of the driver without device tree. Users should define the GPIO
blocks for their platform like this:
struct mpc85xx_gpio_plat gpio_blocks[] = {
{
.addr = 0x130000,
.ngpios = 32,
},
{
.addr = 0x131000,
.ngpios = 32,
},
};
U_BOOT_DEVICES(my_platform_gpios) = {
{ "gpio_mpc85xx", &gpio_blocks[0] },
{ "gpio_mpc85xx", &gpio_blocks[1] },
};
This is intended to build upon the recent submission of the base
MPC85XX driver from Mario Six. We need to use that new driver
without dts support and this patch gives us that flexibility.
This has been tested on a Freescale T2080 CPU, although only the first
GPIO block.
Signed-off-by: Hamish Martin <hamish.martin@alliedtelesis.co.nz>
Reviewed-by: Mario Six <mario.six@gdsys.cc>
Tested-by: Mario Six <mario.six@gdsys.cc>
Acked-by: Simon Glass <sjg@chromium.org>
2016-06-13 22:17:05 +00:00
|
|
|
#endif
|
2018-01-15 10:07:48 +00:00
|
|
|
.probe = mpc8xxx_gpio_probe,
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct mpc8xxx_gpio_data),
|
2016-05-25 13:15:20 +00:00
|
|
|
};
|