aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/hdq1w.c72
-rw-r--r--arch/arm/plat-omap/include/plat/hdq1w.h36
3 files changed, 109 insertions, 1 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 4eee0f139cbd..385c083d24b2 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -4,7 +4,7 @@
4 4
5# Common support 5# Common support
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.o pm.o \ 6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.o pm.o \
7 common.o gpio.o dma.o wd_timer.o display.o i2c.o 7 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o
8 8
9omap-2-3-common = irq.o sdrc.o 9omap-2-3-common = irq.o sdrc.o
10hwmod-common = omap_hwmod.o \ 10hwmod-common = omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/hdq1w.c b/arch/arm/mach-omap2/hdq1w.c
new file mode 100644
index 000000000000..297ebe03f09c
--- /dev/null
+++ b/arch/arm/mach-omap2/hdq1w.c
@@ -0,0 +1,72 @@
1/*
2 * IP block integration code for the HDQ1W/1-wire IP block
3 *
4 * Copyright (C) 2012 Texas Instruments, Inc.
5 * Paul Walmsley
6 *
7 * Based on the I2C reset code in arch/arm/mach-omap2/i2c.c by
8 * Avinash.H.M <avinashhm@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * version 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 */
24
25#include <plat/omap_hwmod.h>
26#include <plat/hdq1w.h>
27
28#include "common.h"
29
30/* Maximum microseconds to wait for OMAP module to softreset */
31#define MAX_MODULE_SOFTRESET_WAIT 10000
32
33/**
34 * omap_hdq1w_reset - reset the OMAP HDQ1W module
35 * @oh: struct omap_hwmod *
36 *
37 * OCP soft reset the HDQ1W IP block. Section 20.6.1.4 "HDQ1W/1-Wire
38 * Software Reset" of the OMAP34xx Technical Reference Manual Revision
39 * ZR (SWPU223R) does not include the rather important fact that, for
40 * the reset to succeed, the HDQ1W module's internal clock gate must be
41 * programmed to allow the clock to propagate to the rest of the
42 * module. In this sense, it's rather similar to the I2C custom reset
43 * function. Returns 0.
44 */
45int omap_hdq1w_reset(struct omap_hwmod *oh)
46{
47 u32 v;
48 int c = 0;
49
50 /* Write to the SOFTRESET bit */
51 omap_hwmod_softreset(oh);
52
53 /* Enable the module's internal clocks */
54 v = omap_hwmod_read(oh, HDQ_CTRL_STATUS_OFFSET);
55 v |= 1 << HDQ_CTRL_STATUS_CLOCKENABLE_SHIFT;
56 omap_hwmod_write(v, oh, HDQ_CTRL_STATUS_OFFSET);
57
58 /* Poll on RESETDONE bit */
59 omap_test_timeout((omap_hwmod_read(oh,
60 oh->class->sysc->syss_offs)
61 & SYSS_RESETDONE_MASK),
62 MAX_MODULE_SOFTRESET_WAIT, c);
63
64 if (c == MAX_MODULE_SOFTRESET_WAIT)
65 pr_warning("%s: %s: softreset failed (waited %d usec)\n",
66 __func__, oh->name, MAX_MODULE_SOFTRESET_WAIT);
67 else
68 pr_debug("%s: %s: softreset in %d usec\n", __func__,
69 oh->name, c);
70
71 return 0;
72}
diff --git a/arch/arm/plat-omap/include/plat/hdq1w.h b/arch/arm/plat-omap/include/plat/hdq1w.h
new file mode 100644
index 000000000000..0c1efc846d8d
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/hdq1w.h
@@ -0,0 +1,36 @@
1/*
2 * Shared macros and function prototypes for the HDQ1W/1-wire IP block
3 *
4 * Copyright (C) 2012 Texas Instruments, Inc.
5 * Paul Walmsley
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 */
21#ifndef ARCH_ARM_MACH_OMAP2_HDQ1W_H
22#define ARCH_ARM_MACH_OMAP2_HDQ1W_H
23
24#include <plat/omap_hwmod.h>
25
26/*
27 * XXX A future cleanup patch should modify
28 * drivers/w1/masters/omap_hdq.c to use these macros
29 */
30#define HDQ_CTRL_STATUS_OFFSET 0x0c
31#define HDQ_CTRL_STATUS_CLOCKENABLE_SHIFT 5
32
33
34extern int omap_hdq1w_reset(struct omap_hwmod *oh);
35
36#endif