~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-omap2/i2c.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Helper module for board specific I2C bus registration
  4  *
  5  * Copyright (C) 2009 Nokia Corporation.
  6  */
  7 
  8 #include "soc.h"
  9 #include "omap_hwmod.h"
 10 #include "omap_device.h"
 11 
 12 #include "prm.h"
 13 #include "common.h"
 14 #include "i2c.h"
 15 
 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
 20 
 21 #define MAX_OMAP_I2C_HWMOD_NAME_LEN     16
 22 
 23 /**
 24  * omap_i2c_reset - reset the omap i2c module.
 25  * @oh: struct omap_hwmod *
 26  *
 27  * The i2c moudle in omap2, omap3 had a special sequence to reset. The
 28  * sequence is:
 29  * - Disable the I2C.
 30  * - Write to SOFTRESET bit.
 31  * - Enable the I2C.
 32  * - Poll on the RESETDONE bit.
 33  * The sequence is implemented in below function. This is called for 2420,
 34  * 2430 and omap3.
 35  */
 36 int omap_i2c_reset(struct omap_hwmod *oh)
 37 {
 38         u32 v;
 39         u16 i2c_con;
 40         int c = 0;
 41 
 42         if (soc_is_omap24xx() || soc_is_omap34xx() || soc_is_am35xx())
 43                 i2c_con = OMAP2_I2C_CON_OFFSET;
 44         else
 45                 i2c_con = OMAP4_I2C_CON_OFFSET;
 46 
 47         /* Disable I2C */
 48         v = omap_hwmod_read(oh, i2c_con);
 49         v &= ~I2C_EN;
 50         omap_hwmod_write(v, oh, i2c_con);
 51 
 52         /* Write to the SOFTRESET bit */
 53         omap_hwmod_softreset(oh);
 54 
 55         /* Enable I2C */
 56         v = omap_hwmod_read(oh, i2c_con);
 57         v |= I2C_EN;
 58         omap_hwmod_write(v, oh, i2c_con);
 59 
 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);
 65 
 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);
 69         else
 70                 pr_debug("%s: %s: softreset in %d usec\n", __func__,
 71                         oh->name, c);
 72 
 73         return 0;
 74 }
 75 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php