aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/adi_gpio2.c2
-rw-r--r--drivers/gpio/atmel_pio4.c12
-rw-r--r--drivers/gpio/imx_rgpio2p.c7
-rw-r--r--drivers/gpio/mxc_gpio.c7
-rw-r--r--drivers/gpio/omap_gpio.c8
-rw-r--r--drivers/gpio/pca953x_gpio.c11
-rw-r--r--drivers/gpio/tegra186_gpio.c2
-rw-r--r--drivers/gpio/vybrid_gpio.c25
8 files changed, 32 insertions, 42 deletions
diff --git a/drivers/gpio/adi_gpio2.c b/drivers/gpio/adi_gpio2.c
index 4db08a3..1012f2d 100644
--- a/drivers/gpio/adi_gpio2.c
+++ b/drivers/gpio/adi_gpio2.c
@@ -138,7 +138,7 @@ int peripheral_request(unsigned short per, const char *label)
return 0;
if (!(per & P_DEFINED))
- return -ENODEV;
+ return -EINVAL;
BUG_ON(ident >= MAX_RESOURCES);
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index f368946..30bc429 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -50,11 +50,11 @@ static int atmel_pio4_config_io_func(u32 port, u32 pin,
u32 reg, mask;
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
- return -ENODEV;
+ return -EINVAL;
port_base = atmel_pio4_port_base(port);
if (!port_base)
- return -ENODEV;
+ return -EINVAL;
mask = 1 << pin;
reg = func;
@@ -128,11 +128,11 @@ int atmel_pio4_set_pio_output(u32 port, u32 pin, u32 value)
u32 reg, mask;
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
- return -ENODEV;
+ return -EINVAL;
port_base = atmel_pio4_port_base(port);
if (!port_base)
- return -ENODEV;
+ return -EINVAL;
mask = 0x01 << pin;
reg = ATMEL_PIO_CFGR_FUNC_GPIO | ATMEL_PIO_DIR_MASK;
@@ -154,11 +154,11 @@ int atmel_pio4_get_pio_input(u32 port, u32 pin)
u32 reg, mask;
if (pin >= ATMEL_PIO_NPINS_PER_BANK)
- return -ENODEV;
+ return -EINVAL;
port_base = atmel_pio4_port_base(port);
if (!port_base)
- return -ENODEV;
+ return -EINVAL;
mask = 0x01 << pin;
reg = ATMEL_PIO_CFGR_FUNC_GPIO;
diff --git a/drivers/gpio/imx_rgpio2p.c b/drivers/gpio/imx_rgpio2p.c
index 5abc88b..7825714 100644
--- a/drivers/gpio/imx_rgpio2p.c
+++ b/drivers/gpio/imx_rgpio2p.c
@@ -168,13 +168,18 @@ static int imx_rgpio2p_bind(struct udevice *dev)
addr = devfdt_get_addr_index(dev, 1);
if (addr == FDT_ADDR_T_NONE)
- return -ENODEV;
+ return -EINVAL;
/*
* TODO:
* When every board is converted to driver model and DT is supported,
* this can be done by auto-alloc feature, but not using calloc
* to alloc memory for platdata.
+ *
+ * For example imx_rgpio2p_plat uses platform data rather than device
+ * tree.
+ *
+ * NOTE: DO NOT COPY this code if you are using device tree.
*/
plat = calloc(1, sizeof(*plat));
if (!plat)
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 0eb6c60..c480eba 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -304,13 +304,18 @@ static int mxc_gpio_bind(struct udevice *dev)
addr = devfdt_get_addr(dev);
if (addr == FDT_ADDR_T_NONE)
- return -ENODEV;
+ return -EINVAL;
/*
* TODO:
* When every board is converted to driver model and DT is supported,
* this can be done by auto-alloc feature, but not using calloc
* to alloc memory for platdata.
+ *
+ * For example mxc_plat below uses platform data rather than device
+ * tree.
+ *
+ * NOTE: DO NOT COPY this code if you are using device tree.
*/
plat = calloc(1, sizeof(*plat));
if (!plat)
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index b423e34..7243100 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -299,7 +299,7 @@ static int omap_gpio_probe(struct udevice *dev)
static int omap_gpio_bind(struct udevice *dev)
{
- struct omap_gpio_platdata *plat = dev->platdata;
+ struct omap_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t base_addr;
if (plat)
@@ -307,13 +307,17 @@ static int omap_gpio_bind(struct udevice *dev)
base_addr = devfdt_get_addr(dev);
if (base_addr == FDT_ADDR_T_NONE)
- return -ENODEV;
+ return -EINVAL;
/*
* TODO:
* When every board is converted to driver model and DT is
* supported, this can be done by auto-alloc feature, but
* not using calloc to alloc memory for platdata.
+ *
+ * For example am33xx_gpio uses platform data rather than device tree.
+ *
+ * NOTE: DO NOT COPY this code if you are using device tree.
*/
plat = calloc(1, sizeof(*plat));
if (!plat)
diff --git a/drivers/gpio/pca953x_gpio.c b/drivers/gpio/pca953x_gpio.c
index 4962f25..791d1d1 100644
--- a/drivers/gpio/pca953x_gpio.c
+++ b/drivers/gpio/pca953x_gpio.c
@@ -249,22 +249,11 @@ static int pca953x_probe(struct udevice *dev)
{
struct pca953x_info *info = dev_get_platdata(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
- struct dm_i2c_chip *chip = dev_get_parent_platdata(dev);
char name[32], *str;
int addr;
ulong driver_data;
int ret;
- if (!info) {
- dev_err(dev, "platdata not ready\n");
- return -ENOMEM;
- }
-
- if (!chip) {
- dev_err(dev, "i2c not ready\n");
- return -ENODEV;
- }
-
addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
if (addr == 0)
return -ENODEV;
diff --git a/drivers/gpio/tegra186_gpio.c b/drivers/gpio/tegra186_gpio.c
index c5a7e13..deb59e8 100644
--- a/drivers/gpio/tegra186_gpio.c
+++ b/drivers/gpio/tegra186_gpio.c
@@ -181,7 +181,7 @@ static int tegra186_gpio_bind(struct udevice *parent)
regs = (uint32_t *)devfdt_get_addr_name(parent, "gpio");
if (regs == (uint32_t *)FDT_ADDR_T_NONE)
- return -ENODEV;
+ return -EINVAL;
for (port = 0; port < ctlr_data->port_count; port++) {
struct tegra186_gpio_platdata *plat;
diff --git a/drivers/gpio/vybrid_gpio.c b/drivers/gpio/vybrid_gpio.c
index 89918e4..030e8d0 100644
--- a/drivers/gpio/vybrid_gpio.c
+++ b/drivers/gpio/vybrid_gpio.c
@@ -105,32 +105,18 @@ static int vybrid_gpio_probe(struct udevice *dev)
return 0;
}
-static int vybrid_gpio_bind(struct udevice *dev)
+static int vybrid_gpio_odata_to_platdata(struct udevice *dev)
{
- struct vybrid_gpio_platdata *plat = dev->platdata;
+ struct vybrid_gpio_platdata *plat = dev_get_platdata(dev);
fdt_addr_t base_addr;
- if (plat)
- return 0;
-
base_addr = devfdt_get_addr(dev);
if (base_addr == FDT_ADDR_T_NONE)
- return -ENODEV;
-
- /*
- * TODO:
- * When every board is converted to driver model and DT is
- * supported, this can be done by auto-alloc feature, but
- * not using calloc to alloc memory for platdata.
- */
- plat = calloc(1, sizeof(*plat));
- if (!plat)
- return -ENOMEM;
+ return -EINVAL;
plat->base = base_addr;
plat->chip = dev->req_seq;
plat->port_name = fdt_get_name(gd->fdt_blob, dev_of_offset(dev), NULL);
- dev->platdata = plat;
return 0;
}
@@ -144,8 +130,9 @@ U_BOOT_DRIVER(gpio_vybrid) = {
.name = "gpio_vybrid",
.id = UCLASS_GPIO,
.ops = &gpio_vybrid_ops,
+ .of_match = vybrid_gpio_ids,
+ .ofdata_to_platdata = vybrid_gpio_odata_to_platdata,
.probe = vybrid_gpio_probe,
.priv_auto_alloc_size = sizeof(struct vybrid_gpios),
- .of_match = vybrid_gpio_ids,
- .bind = vybrid_gpio_bind,
+ .platdata_auto_alloc_size = sizeof(struct vybrid_gpio_platdata),
};