0001
0002
0003
0004
0005
0006
0007
0008 #include "soc.h"
0009 #include "omap_hwmod.h"
0010 #include "omap_device.h"
0011
0012 #include "prm.h"
0013 #include "common.h"
0014 #include "i2c.h"
0015
0016
0017 #define I2C_EN BIT(15)
0018 #define OMAP2_I2C_CON_OFFSET 0x24
0019 #define OMAP4_I2C_CON_OFFSET 0xA4
0020
0021 #define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 int omap_i2c_reset(struct omap_hwmod *oh)
0037 {
0038 u32 v;
0039 u16 i2c_con;
0040 int c = 0;
0041
0042 if (soc_is_omap24xx() || soc_is_omap34xx() || soc_is_am35xx())
0043 i2c_con = OMAP2_I2C_CON_OFFSET;
0044 else
0045 i2c_con = OMAP4_I2C_CON_OFFSET;
0046
0047
0048 v = omap_hwmod_read(oh, i2c_con);
0049 v &= ~I2C_EN;
0050 omap_hwmod_write(v, oh, i2c_con);
0051
0052
0053 omap_hwmod_softreset(oh);
0054
0055
0056 v = omap_hwmod_read(oh, i2c_con);
0057 v |= I2C_EN;
0058 omap_hwmod_write(v, oh, i2c_con);
0059
0060
0061 omap_test_timeout((omap_hwmod_read(oh,
0062 oh->class->sysc->syss_offs)
0063 & SYSS_RESETDONE_MASK),
0064 MAX_MODULE_SOFTRESET_WAIT, c);
0065
0066 if (c == MAX_MODULE_SOFTRESET_WAIT)
0067 pr_warn("%s: %s: softreset failed (waited %d usec)\n",
0068 __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
0069 else
0070 pr_debug("%s: %s: softreset in %d usec\n", __func__,
0071 oh->name, c);
0072
0073 return 0;
0074 }