Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * IP block integration code for the HDQ1W/1-wire IP block
0004  *
0005  * Copyright (C) 2012 Texas Instruments, Inc.
0006  * Paul Walmsley
0007  *
0008  * Based on the I2C reset code in arch/arm/mach-omap2/i2c.c by
0009  *     Avinash.H.M <avinashhm@ti.com>
0010  */
0011 
0012 #include <linux/kernel.h>
0013 #include <linux/init.h>
0014 #include <linux/err.h>
0015 #include <linux/platform_device.h>
0016 
0017 #include "soc.h"
0018 #include "omap_hwmod.h"
0019 #include "omap_device.h"
0020 #include "hdq1w.h"
0021 
0022 #include "prm.h"
0023 #include "common.h"
0024 
0025 /**
0026  * omap_hdq1w_reset - reset the OMAP HDQ1W module
0027  * @oh: struct omap_hwmod *
0028  *
0029  * OCP soft reset the HDQ1W IP block.  Section 20.6.1.4 "HDQ1W/1-Wire
0030  * Software Reset" of the OMAP34xx Technical Reference Manual Revision
0031  * ZR (SWPU223R) does not include the rather important fact that, for
0032  * the reset to succeed, the HDQ1W module's internal clock gate must be
0033  * programmed to allow the clock to propagate to the rest of the
0034  * module.  In this sense, it's rather similar to the I2C custom reset
0035  * function.  Returns 0.
0036  */
0037 int omap_hdq1w_reset(struct omap_hwmod *oh)
0038 {
0039     u32 v;
0040     int c = 0;
0041 
0042     /* Write to the SOFTRESET bit */
0043     omap_hwmod_softreset(oh);
0044 
0045     /* Enable the module's internal clocks */
0046     v = omap_hwmod_read(oh, HDQ_CTRL_STATUS_OFFSET);
0047     v |= 1 << HDQ_CTRL_STATUS_CLOCKENABLE_SHIFT;
0048     omap_hwmod_write(v, oh, HDQ_CTRL_STATUS_OFFSET);
0049 
0050     /* Poll on RESETDONE bit */
0051     omap_test_timeout((omap_hwmod_read(oh,
0052                        oh->class->sysc->syss_offs)
0053                & SYSS_RESETDONE_MASK),
0054               MAX_MODULE_SOFTRESET_WAIT, c);
0055 
0056     if (c == MAX_MODULE_SOFTRESET_WAIT)
0057         pr_warn("%s: %s: softreset failed (waited %d usec)\n",
0058             __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
0059     else
0060         pr_debug("%s: %s: softreset in %d usec\n", __func__,
0061              oh->name, c);
0062 
0063     return 0;
0064 }