]> git.sur5r.net Git - u-boot/blobdiff - drivers/gpio/pca953x_gpio.c
Merge tag 'xilinx-for-v2018.03' of git://git.denx.de/u-boot-microblaze
[u-boot] / drivers / gpio / pca953x_gpio.c
index 791d1d15166f5585b5fe2df8537f43640144b2fd..a8a5a89c05c616804ba0fd1a77be9bdf93c3dcac 100644 (file)
@@ -50,8 +50,6 @@ enum {
 #define MAX_BANK 5
 #define BANK_SZ 8
 
-DECLARE_GLOBAL_DATA_PTR;
-
 /*
  * struct pca953x_info - Data for pca953x
  *
@@ -123,7 +121,8 @@ static int pca953x_read_regs(struct udevice *dev, int reg, u8 *val)
                ret = dm_i2c_read(dev, reg << 1, val, info->bank_count);
        } else if (info->gpio_count == 40) {
                /* Auto increment */
-               ret = dm_i2c_read(dev, (reg << 3) | 0x80, val, info->bank_count);
+               ret = dm_i2c_read(dev, (reg << 3) | 0x80, val,
+                                 info->bank_count);
        } else {
                dev_err(dev, "Unsupported now\n");
                return -EINVAL;
@@ -143,7 +142,7 @@ static int pca953x_is_output(struct udevice *dev, int offset)
        return !(info->reg_direction[bank] & (1 << off));
 }
 
-static int pca953x_get_value(struct udevice *dev, unsigned offset)
+static int pca953x_get_value(struct udevice *dev, uint offset)
 {
        int ret;
        u8 val = 0;
@@ -157,8 +156,7 @@ static int pca953x_get_value(struct udevice *dev, unsigned offset)
        return (val >> off) & 0x1;
 }
 
-static int pca953x_set_value(struct udevice *dev, unsigned offset,
-                            int value)
+static int pca953x_set_value(struct udevice *dev, uint offset, int value)
 {
        struct pca953x_info *info = dev_get_platdata(dev);
        int bank = offset / BANK_SZ;
@@ -180,7 +178,7 @@ static int pca953x_set_value(struct udevice *dev, unsigned offset,
        return 0;
 }
 
-static int pca953x_set_direction(struct udevice *dev, unsigned offset, int dir)
+static int pca953x_set_direction(struct udevice *dev, uint offset, int dir)
 {
        struct pca953x_info *info = dev_get_platdata(dev);
        int bank = offset / BANK_SZ;
@@ -202,13 +200,12 @@ static int pca953x_set_direction(struct udevice *dev, unsigned offset, int dir)
        return 0;
 }
 
-static int pca953x_direction_input(struct udevice *dev, unsigned offset)
+static int pca953x_direction_input(struct udevice *dev, uint offset)
 {
        return pca953x_set_direction(dev, offset, PCA953X_DIRECTION_IN);
 }
 
-static int pca953x_direction_output(struct udevice *dev, unsigned offset,
-                                   int value)
+static int pca953x_direction_output(struct udevice *dev, uint offset, int value)
 {
        /* Configure output value. */
        pca953x_set_value(dev, offset, value);
@@ -219,7 +216,7 @@ static int pca953x_direction_output(struct udevice *dev, unsigned offset,
        return 0;
 }
 
-static int pca953x_get_function(struct udevice *dev, unsigned offset)
+static int pca953x_get_function(struct udevice *dev, uint offset)
 {
        if (pca953x_is_output(dev, offset))
                return GPIOF_OUTPUT;
@@ -231,7 +228,7 @@ static int pca953x_xlate(struct udevice *dev, struct gpio_desc *desc,
                         struct ofnode_phandle_args *args)
 {
        desc->offset = args->args[0];
-       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
+       desc->flags = args->args[1] & (GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0);
 
        return 0;
 }
@@ -254,7 +251,7 @@ static int pca953x_probe(struct udevice *dev)
        ulong driver_data;
        int ret;
 
-       addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
+       addr = dev_read_addr(dev);
        if (addr == 0)
                return -ENODEV;