- struct mxc_gpio_plat *plat = dev->platdata;
- fdt_addr_t addr;
-
- /*
- * If platdata already exsits, directly return.
- * Actually only when DT is not supported, platdata
- * is statically initialized in U_BOOT_DEVICES.Here
- * will return.
- */
- if (plat)
- return 0;
-
- addr = devfdt_get_addr(dev);
- if (addr == FDT_ADDR_T_NONE)
- 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)
- return -ENOMEM;
+ struct mxc_gpio_plat *plat = dev_get_plat(dev);
+ if (!CONFIG_IS_ENABLED(OF_PLATDATA)) {
+ fdt_addr_t addr;
+ addr = dev_read_addr(dev);
+ if (addr == FDT_ADDR_T_NONE)
+ return -EINVAL;
+
+ plat->regs = (struct gpio_regs *)addr;
+ }
+ plat->bank_index = dev_seq(dev);