#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"
| 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) {
{
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.
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;
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(®s->fcr, I2CD_M_HIGH_SPEED_EN
| I2CD_M_SDA_DRIVE_1T_EN
.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,
};