summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-07-20 22:35:49 -0400
committerTom Rini <trini@konsulko.com>2018-07-20 22:35:49 -0400
commit83853366e3f9eb76426a6b1bda810e470bce04f0 (patch)
tree4e99633bca0ae2479b46f0e2885775aea5995e2d /drivers
parente0ed8332fa2fe684b4c8ba1caab991663730cbf0 (diff)
parenta2a5053a15e4059c7445737d60f7b8425ca863f8 (diff)
Merge branch 'master' of git://git.denx.de/u-boot-rockchip
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/rk_i2c.c94
1 files changed, 89 insertions, 5 deletions
diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
index 001af668a8..f9a5796b96 100644
--- a/drivers/i2c/rk_i2c.c
+++ b/drivers/i2c/rk_i2c.c
@@ -31,6 +31,18 @@ struct rk_i2c {
unsigned int speed;
};
+enum {
+ RK_I2C_LEGACY,
+ RK_I2C_NEW,
+};
+
+/**
+ * @controller_type: i2c controller type
+ */
+struct rk_i2c_soc_data {
+ int controller_type;
+};
+
static inline void rk_i2c_get_div(int div, int *divh, int *divl)
{
*divl = div / 2;
@@ -378,9 +390,38 @@ static int rockchip_i2c_ofdata_to_platdata(struct udevice *bus)
static int rockchip_i2c_probe(struct udevice *bus)
{
struct rk_i2c *priv = dev_get_priv(bus);
+ struct rk_i2c_soc_data *soc_data;
+ struct udevice *pinctrl;
+ int bus_nr;
+ int ret;
priv->regs = dev_read_addr_ptr(bus);
+ soc_data = (struct rk_i2c_soc_data*)dev_get_driver_data(bus);
+
+ if (soc_data->controller_type == RK_I2C_LEGACY) {
+ ret = dev_read_alias_seq(bus, &bus_nr);
+ if (ret < 0) {
+ debug("%s: Could not get alias for %s: %d\n",
+ __func__, bus->name, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
+ if (ret) {
+ debug("%s: Cannot find pinctrl device\n", __func__);
+ return ret;
+ }
+
+ /* pinctrl will switch I2C to new type */
+ ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_I2C0 + bus_nr);
+ if (ret) {
+ debug("%s: Failed to switch I2C to new type %s: %d\n",
+ __func__, bus->name, ret);
+ return ret;
+ }
+ }
+
return 0;
}
@@ -389,12 +430,55 @@ static const struct dm_i2c_ops rockchip_i2c_ops = {
.set_bus_speed = rockchip_i2c_set_bus_speed,
};
+static const struct rk_i2c_soc_data rk3066_soc_data = {
+ .controller_type = RK_I2C_LEGACY,
+};
+
+static const struct rk_i2c_soc_data rk3188_soc_data = {
+ .controller_type = RK_I2C_LEGACY,
+};
+
+static const struct rk_i2c_soc_data rk3228_soc_data = {
+ .controller_type = RK_I2C_NEW,
+};
+
+static const struct rk_i2c_soc_data rk3288_soc_data = {
+ .controller_type = RK_I2C_NEW,
+};
+
+static const struct rk_i2c_soc_data rk3328_soc_data = {
+ .controller_type = RK_I2C_NEW,
+};
+
+static const struct rk_i2c_soc_data rk3399_soc_data = {
+ .controller_type = RK_I2C_NEW,
+};
+
static const struct udevice_id rockchip_i2c_ids[] = {
- { .compatible = "rockchip,rk3066-i2c" },
- { .compatible = "rockchip,rk3188-i2c" },
- { .compatible = "rockchip,rk3288-i2c" },
- { .compatible = "rockchip,rk3328-i2c" },
- { .compatible = "rockchip,rk3399-i2c" },
+ {
+ .compatible = "rockchip,rk3066-i2c",
+ .data = (ulong)&rk3066_soc_data,
+ },
+ {
+ .compatible = "rockchip,rk3188-i2c",
+ .data = (ulong)&rk3188_soc_data,
+ },
+ {
+ .compatible = "rockchip,rk3228-i2c",
+ .data = (ulong)&rk3228_soc_data,
+ },
+ {
+ .compatible = "rockchip,rk3288-i2c",
+ .data = (ulong)&rk3288_soc_data,
+ },
+ {
+ .compatible = "rockchip,rk3328-i2c",
+ .data = (ulong)&rk3328_soc_data,
+ },
+ {
+ .compatible = "rockchip,rk3399-i2c",
+ .data = (ulong)&rk3399_soc_data,
+ },
{ }
};