diff options
author | Arnd Bergmann <arnd@arndb.de> | 2012-04-22 16:54:46 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-04-22 16:54:46 -0400 |
commit | 3f81b2c49d31e763a9c1da831ceb6cef087cf6c6 (patch) | |
tree | e261299ccded5d87db92850b8dfdadab8ae2c514 | |
parent | e816b57a337ea3b755de72bec38c10c864f23015 (diff) | |
parent | 6b866c151ad9ea44799b32c3a8c90a03c5b981da (diff) |
Merge branch 'stmp_device' of git://git.pengutronix.de/git/wsa/linux into next/stmp-dev
Wolfram Sang <w.sang@pengutronix.de> writes:
This series makes support for a certain type of devices mach independant. We
want that because such devices (having a special register layout) have been
found in mach-mxs and mach-mx6 meanwhile.
Since there is no subsystem maintainer for lib/ and the use case is
currently only for ARM systems, I have agreed to merge these through
the arm-soc tree.
* 'stmp_device' of git://git.pengutronix.de/git/wsa/linux:
i2c: mxs: use global reset function
lib: add support for stmp-style devices
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | drivers/i2c/busses/Kconfig | 1 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-mxs.c | 9 | ||||
-rw-r--r-- | include/linux/stmp_device.h | 20 | ||||
-rw-r--r-- | lib/Kconfig | 3 | ||||
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/stmp_device.c | 80 |
6 files changed, 108 insertions, 7 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index d2c5095deeac..ccfd37db3dfc 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -483,6 +483,7 @@ config I2C_MV64XXX | |||
483 | config I2C_MXS | 483 | config I2C_MXS |
484 | tristate "Freescale i.MX28 I2C interface" | 484 | tristate "Freescale i.MX28 I2C interface" |
485 | depends on SOC_IMX28 | 485 | depends on SOC_IMX28 |
486 | select STMP_DEVICE | ||
486 | help | 487 | help |
487 | Say Y here if you want to use the I2C bus controller on | 488 | Say Y here if you want to use the I2C bus controller on |
488 | the Freescale i.MX28 processors. | 489 | the Freescale i.MX28 processors. |
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c index 3d471d56bf15..083480241945 100644 --- a/drivers/i2c/busses/i2c-mxs.c +++ b/drivers/i2c/busses/i2c-mxs.c | |||
@@ -26,8 +26,7 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | 29 | #include <linux/stmp_device.h> | |
30 | #include <mach/common.h> | ||
31 | 30 | ||
32 | #define DRIVER_NAME "mxs-i2c" | 31 | #define DRIVER_NAME "mxs-i2c" |
33 | 32 | ||
@@ -111,13 +110,9 @@ struct mxs_i2c_dev { | |||
111 | struct i2c_adapter adapter; | 110 | struct i2c_adapter adapter; |
112 | }; | 111 | }; |
113 | 112 | ||
114 | /* | ||
115 | * TODO: check if calls to here are really needed. If not, we could get rid of | ||
116 | * mxs_reset_block and the mach-dependency. Needs an I2C analyzer, probably. | ||
117 | */ | ||
118 | static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) | 113 | static void mxs_i2c_reset(struct mxs_i2c_dev *i2c) |
119 | { | 114 | { |
120 | mxs_reset_block(i2c->regs); | 115 | stmp_reset_block(i2c->regs); |
121 | writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); | 116 | writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); |
122 | writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, | 117 | writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE, |
123 | i2c->regs + MXS_I2C_QUEUECTRL_SET); | 118 | i2c->regs + MXS_I2C_QUEUECTRL_SET); |
diff --git a/include/linux/stmp_device.h b/include/linux/stmp_device.h new file mode 100644 index 000000000000..6cf7ec9547cf --- /dev/null +++ b/include/linux/stmp_device.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * basic functions for devices following the "stmp" style register layout | ||
3 | * | ||
4 | * Copyright (C) 2011 Wolfram Sang, Pengutronix e.K. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifndef __STMP_DEVICE_H__ | ||
13 | #define __STMP_DEVICE_H__ | ||
14 | |||
15 | #define STMP_OFFSET_REG_SET 0x4 | ||
16 | #define STMP_OFFSET_REG_CLR 0x8 | ||
17 | #define STMP_OFFSET_REG_TOG 0xc | ||
18 | |||
19 | extern int stmp_reset_block(void __iomem *); | ||
20 | #endif /* __STMP_DEVICE_H__ */ | ||
diff --git a/lib/Kconfig b/lib/Kconfig index 4a8aba2e5cc0..c5da1548b964 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
@@ -33,6 +33,9 @@ config GENERIC_IO | |||
33 | boolean | 33 | boolean |
34 | default n | 34 | default n |
35 | 35 | ||
36 | config STMP_DEVICE | ||
37 | bool | ||
38 | |||
36 | config CRC_CCITT | 39 | config CRC_CCITT |
37 | tristate "CRC-CCITT functions" | 40 | tristate "CRC-CCITT functions" |
38 | help | 41 | help |
diff --git a/lib/Makefile b/lib/Makefile index 18515f0267c4..f78dbcdc7e3d 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -123,6 +123,8 @@ obj-$(CONFIG_SIGNATURE) += digsig.o | |||
123 | 123 | ||
124 | obj-$(CONFIG_CLZ_TAB) += clz_tab.o | 124 | obj-$(CONFIG_CLZ_TAB) += clz_tab.o |
125 | 125 | ||
126 | obj-$(CONFIG_STMP_DEVICE) += stmp_device.o | ||
127 | |||
126 | hostprogs-y := gen_crc32table | 128 | hostprogs-y := gen_crc32table |
127 | clean-files := crc32table.h | 129 | clean-files := crc32table.h |
128 | 130 | ||
diff --git a/lib/stmp_device.c b/lib/stmp_device.c new file mode 100644 index 000000000000..8ac9bcc4289a --- /dev/null +++ b/lib/stmp_device.c | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 ARM Limited | ||
3 | * Copyright (C) 2000 Deep Blue Solutions Ltd | ||
4 | * Copyright 2006-2007,2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
5 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
6 | * Copyright 2009 Ilya Yanok, Emcraft Systems Ltd, yanok@emcraft.com | ||
7 | * Copyright (C) 2011 Wolfram Sang, Pengutronix e.K. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | #include <linux/io.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/stmp_device.h> | ||
20 | |||
21 | #define STMP_MODULE_CLKGATE (1 << 30) | ||
22 | #define STMP_MODULE_SFTRST (1 << 31) | ||
23 | |||
24 | /* | ||
25 | * Clear the bit and poll it cleared. This is usually called with | ||
26 | * a reset address and mask being either SFTRST(bit 31) or CLKGATE | ||
27 | * (bit 30). | ||
28 | */ | ||
29 | static int stmp_clear_poll_bit(void __iomem *addr, u32 mask) | ||
30 | { | ||
31 | int timeout = 0x400; | ||
32 | |||
33 | writel(mask, addr + STMP_OFFSET_REG_CLR); | ||
34 | udelay(1); | ||
35 | while ((readl(addr) & mask) && --timeout) | ||
36 | /* nothing */; | ||
37 | |||
38 | return !timeout; | ||
39 | } | ||
40 | |||
41 | int stmp_reset_block(void __iomem *reset_addr) | ||
42 | { | ||
43 | int ret; | ||
44 | int timeout = 0x400; | ||
45 | |||
46 | /* clear and poll SFTRST */ | ||
47 | ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_SFTRST); | ||
48 | if (unlikely(ret)) | ||
49 | goto error; | ||
50 | |||
51 | /* clear CLKGATE */ | ||
52 | writel(STMP_MODULE_CLKGATE, reset_addr + STMP_OFFSET_REG_CLR); | ||
53 | |||
54 | /* set SFTRST to reset the block */ | ||
55 | writel(STMP_MODULE_SFTRST, reset_addr + STMP_OFFSET_REG_SET); | ||
56 | udelay(1); | ||
57 | |||
58 | /* poll CLKGATE becoming set */ | ||
59 | while ((!(readl(reset_addr) & STMP_MODULE_CLKGATE)) && --timeout) | ||
60 | /* nothing */; | ||
61 | if (unlikely(!timeout)) | ||
62 | goto error; | ||
63 | |||
64 | /* clear and poll SFTRST */ | ||
65 | ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_SFTRST); | ||
66 | if (unlikely(ret)) | ||
67 | goto error; | ||
68 | |||
69 | /* clear and poll CLKGATE */ | ||
70 | ret = stmp_clear_poll_bit(reset_addr, STMP_MODULE_CLKGATE); | ||
71 | if (unlikely(ret)) | ||
72 | goto error; | ||
73 | |||
74 | return 0; | ||
75 | |||
76 | error: | ||
77 | pr_err("%s(%p): module reset timeout\n", __func__, reset_addr); | ||
78 | return -ETIMEDOUT; | ||
79 | } | ||
80 | EXPORT_SYMBOL(stmp_reset_block); | ||