Skip to content

Commit

Permalink
i2c: riic: Add RZ/G2L support
Browse files Browse the repository at this point in the history
RZ/G2L i2c controller is compatible with RZ/A i2c controller.
By default IP is in reset state, so need to perform release
reset before accessing any register.

Signed-off-by: Biju Das <[email protected]>
Reviewed-by: Lad Prabhakar <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
  • Loading branch information
bijudas authored and wsakernel committed Jun 20, 2021
1 parent a431a09 commit 010e765
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion drivers/i2c/busses/i2c-riic.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>

#define RIIC_ICCR1 0x00
#define RIIC_ICCR2 0x04
Expand Down Expand Up @@ -86,6 +88,11 @@

#define RIIC_INIT_MSG -1

enum riic_type {
RIIC_RZ_A,
RIIC_RZ_G2L,
};

struct riic_dev {
void __iomem *base;
u8 *buf;
Expand Down Expand Up @@ -395,7 +402,9 @@ static int riic_i2c_probe(struct platform_device *pdev)
struct i2c_adapter *adap;
struct resource *res;
struct i2c_timings i2c_t;
struct reset_control *rstc;
int i, ret;
enum riic_type type;

riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL);
if (!riic)
Expand All @@ -412,6 +421,17 @@ static int riic_i2c_probe(struct platform_device *pdev)
return PTR_ERR(riic->clk);
}

type = (enum riic_type)of_device_get_match_data(&pdev->dev);
if (type == RIIC_RZ_G2L) {
rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(rstc)) {
dev_err(&pdev->dev, "Error: missing reset ctrl\n");
return PTR_ERR(rstc);
}

reset_control_deassert(rstc);
}

for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) {
res = platform_get_resource(pdev, IORESOURCE_IRQ, riic_irqs[i].res_num);
if (!res)
Expand Down Expand Up @@ -472,7 +492,8 @@ static int riic_i2c_remove(struct platform_device *pdev)
}

static const struct of_device_id riic_i2c_dt_ids[] = {
{ .compatible = "renesas,riic-rz" },
{ .compatible = "renesas,riic-r9a07g044", .data = (void *)RIIC_RZ_G2L },
{ .compatible = "renesas,riic-rz", .data = (void *)RIIC_RZ_A },
{ /* Sentinel */ },
};

Expand Down

0 comments on commit 010e765

Please sign in to comment.