1 // SPDX-License-Identifier: GPL-2.0-only
3 * Helper module for board specific I2C bus registration
5 * Copyright (C) 2009 Nokia Corporation.
9 #include "omap_hwmod.h"
10 #include "omap_device.h"
16 /* In register I2C_CON, Bit 15 is the I2C enable bit */
17 #define I2C_EN BIT(15)
18 #define OMAP2_I2C_CON_OFFSET 0x24
19 #define OMAP4_I2C_CON_OFFSET 0xA4
21 #define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
24 * omap_i2c_reset - reset the omap i2c module.
25 * @oh: struct omap_hwmod *
27 * The i2c moudle in omap2, omap3 had a special sequence to reset. The
30 * - Write to SOFTRESET bit.
32 * - Poll on the RESETDONE bit.
33 * The sequence is implemented in below function. This is called for 2420,
36 int omap_i2c_reset(struct omap_hwmod
*oh
)
42 if (soc_is_omap24xx() || soc_is_omap34xx() || soc_is_am35xx())
43 i2c_con
= OMAP2_I2C_CON_OFFSET
;
45 i2c_con
= OMAP4_I2C_CON_OFFSET
;
48 v
= omap_hwmod_read(oh
, i2c_con
);
50 omap_hwmod_write(v
, oh
, i2c_con
);
52 /* Write to the SOFTRESET bit */
53 omap_hwmod_softreset(oh
);
56 v
= omap_hwmod_read(oh
, i2c_con
);
58 omap_hwmod_write(v
, oh
, i2c_con
);
60 /* Poll on RESETDONE bit */
61 omap_test_timeout((omap_hwmod_read(oh
,
62 oh
->class->sysc
->syss_offs
)
63 & SYSS_RESETDONE_MASK
),
64 MAX_MODULE_SOFTRESET_WAIT
, c
);
66 if (c
== MAX_MODULE_SOFTRESET_WAIT
)
67 pr_warn("%s: %s: softreset failed (waited %d usec)\n",
68 __func__
, oh
->name
, MAX_MODULE_SOFTRESET_WAIT
);
70 pr_debug("%s: %s: softreset in %d usec\n", __func__
,