]> Git Repo - J-u-boot.git/blobdiff - drivers/i2c/ast_i2c.c
dm: Avoid accessing seq directly
[J-u-boot.git] / drivers / i2c / ast_i2c.c
index 763183d64920353fbbdf6d86e968a95065418971..2d3fecaa14ea4d4047e1076374e8ce7e2b0a4fc7 100644 (file)
 #include <errno.h>
 #include <fdtdec.h>
 #include <i2c.h>
+#include <log.h>
 #include <asm/io.h>
 #include <asm/arch/scu_ast2500.h>
+#include <linux/delay.h>
+#include <linux/err.h>
 
 #include "ast_i2c.h"
 
@@ -84,14 +87,14 @@ static void ast_i2c_init_bus(struct udevice *dev)
               | I2CD_INTR_ABNORMAL, &priv->regs->icr);
 }
 
-static int ast_i2c_ofdata_to_platdata(struct udevice *dev)
+static int ast_i2c_of_to_plat(struct udevice *dev)
 {
        struct ast_i2c_priv *priv = dev_get_priv(dev);
        int ret;
 
-       priv->regs = devfdt_get_addr_ptr(dev);
-       if (IS_ERR(priv->regs))
-               return PTR_ERR(priv->regs);
+       priv->regs = dev_read_addr_ptr(dev);
+       if (!priv->regs)
+               return -EINVAL;
 
        ret = clk_get_by_index(dev, 0, &priv->clk);
        if (ret < 0) {
@@ -107,7 +110,7 @@ static int ast_i2c_probe(struct udevice *dev)
 {
        struct ast2500_scu *scu;
 
-       debug("Enabling I2C%u\n", dev->seq);
+       debug("Enabling I2C%u\n", dev_seq(dev));
 
        /*
         * Get all I2C devices out of Reset.
@@ -304,7 +307,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed)
        struct ast_i2c_regs *regs = priv->regs;
        ulong i2c_rate, divider;
 
-       debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed);
+       debug("Setting speed for I2C%d to <%u>\n", dev_seq(dev), speed);
        if (!speed) {
                debug("No valid speed specified\n");
                return -EINVAL;
@@ -314,7 +317,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed)
        divider = i2c_rate / speed;
 
        priv->speed = speed;
-       if (speed > I2C_HIGHSPEED_RATE) {
+       if (speed > I2C_SPEED_FAST_RATE) {
                debug("Enable High Speed\n");
                setbits_le32(&regs->fcr, I2CD_M_HIGH_SPEED_EN
                             | I2CD_M_SDA_DRIVE_1T_EN
@@ -348,7 +351,7 @@ U_BOOT_DRIVER(ast_i2c) = {
        .id = UCLASS_I2C,
        .of_match = ast_i2c_ids,
        .probe = ast_i2c_probe,
-       .ofdata_to_platdata = ast_i2c_ofdata_to_platdata,
-       .priv_auto_alloc_size = sizeof(struct ast_i2c_priv),
+       .of_to_plat = ast_i2c_of_to_plat,
+       .priv_auto      = sizeof(struct ast_i2c_priv),
        .ops = &ast_i2c_ops,
 };
This page took 0.028057 seconds and 4 git commands to generate.