Commit 2cf3afcd4cbe0e32b8722fc291e9255de1b4d6c6
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "A set of updates and bugfixes for the new designware-baytrail driver. And a documentation bugfix" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: imx: add required clocks property to binding i2c: designware-baytrail: baytrail_i2c_acquire() might sleep i2c: designware-baytrail: cross-check lock functions i2c: designware-baytrail: fix sparse warnings i2c: designware-baytrail: fix typo in error path i2c: designware-baytrail: describe magic numbers
Showing 2 changed files Side-by-side Diff
Documentation/devicetree/bindings/i2c/i2c-imx.txt
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | - "fsl,vf610-i2c" for I2C compatible with the one integrated on Vybrid vf610 SoC |
8 | 8 | - reg : Should contain I2C/HS-I2C registers location and length |
9 | 9 | - interrupts : Should contain I2C/HS-I2C interrupt |
10 | +- clocks : Should contain the I2C/HS-I2C clock specifier | |
10 | 11 | |
11 | 12 | Optional properties: |
12 | 13 | - clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz. |
drivers/i2c/busses/i2c-designware-baytrail.c
... | ... | @@ -17,27 +17,31 @@ |
17 | 17 | #include <linux/acpi.h> |
18 | 18 | #include <linux/i2c.h> |
19 | 19 | #include <linux/interrupt.h> |
20 | + | |
20 | 21 | #include <asm/iosf_mbi.h> |
22 | + | |
21 | 23 | #include "i2c-designware-core.h" |
22 | 24 | |
23 | 25 | #define SEMAPHORE_TIMEOUT 100 |
24 | 26 | #define PUNIT_SEMAPHORE 0x7 |
27 | +#define PUNIT_SEMAPHORE_BIT BIT(0) | |
28 | +#define PUNIT_SEMAPHORE_ACQUIRE BIT(1) | |
25 | 29 | |
26 | 30 | static unsigned long acquired; |
27 | 31 | |
28 | 32 | static int get_sem(struct device *dev, u32 *sem) |
29 | 33 | { |
30 | - u32 reg_val; | |
34 | + u32 data; | |
31 | 35 | int ret; |
32 | 36 | |
33 | 37 | ret = iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_READ, PUNIT_SEMAPHORE, |
34 | - ®_val); | |
38 | + &data); | |
35 | 39 | if (ret) { |
36 | 40 | dev_err(dev, "iosf failed to read punit semaphore\n"); |
37 | 41 | return ret; |
38 | 42 | } |
39 | 43 | |
40 | - *sem = reg_val & 0x1; | |
44 | + *sem = data & PUNIT_SEMAPHORE_BIT; | |
41 | 45 | |
42 | 46 | return 0; |
43 | 47 | } |
44 | 48 | |
45 | 49 | |
46 | 50 | |
47 | 51 | |
48 | 52 | |
49 | 53 | |
50 | 54 | |
... | ... | @@ -52,27 +56,29 @@ |
52 | 56 | return; |
53 | 57 | } |
54 | 58 | |
55 | - data = data & 0xfffffffe; | |
59 | + data &= ~PUNIT_SEMAPHORE_BIT; | |
56 | 60 | if (iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE, |
57 | - PUNIT_SEMAPHORE, data)) | |
61 | + PUNIT_SEMAPHORE, data)) | |
58 | 62 | dev_err(dev, "iosf failed to reset punit semaphore during write\n"); |
59 | 63 | } |
60 | 64 | |
61 | -int baytrail_i2c_acquire(struct dw_i2c_dev *dev) | |
65 | +static int baytrail_i2c_acquire(struct dw_i2c_dev *dev) | |
62 | 66 | { |
63 | - u32 sem = 0; | |
67 | + u32 sem; | |
64 | 68 | int ret; |
65 | 69 | unsigned long start, end; |
66 | 70 | |
71 | + might_sleep(); | |
72 | + | |
67 | 73 | if (!dev || !dev->dev) |
68 | 74 | return -ENODEV; |
69 | 75 | |
70 | - if (!dev->acquire_lock) | |
76 | + if (!dev->release_lock) | |
71 | 77 | return 0; |
72 | 78 | |
73 | - /* host driver writes 0x2 to side band semaphore register */ | |
79 | + /* host driver writes to side band semaphore register */ | |
74 | 80 | ret = iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE, |
75 | - PUNIT_SEMAPHORE, 0x2); | |
81 | + PUNIT_SEMAPHORE, PUNIT_SEMAPHORE_ACQUIRE); | |
76 | 82 | if (ret) { |
77 | 83 | dev_err(dev->dev, "iosf punit semaphore request failed\n"); |
78 | 84 | return ret; |
... | ... | @@ -81,7 +87,7 @@ |
81 | 87 | /* host driver waits for bit 0 to be set in semaphore register */ |
82 | 88 | start = jiffies; |
83 | 89 | end = start + msecs_to_jiffies(SEMAPHORE_TIMEOUT); |
84 | - while (!time_after(jiffies, end)) { | |
90 | + do { | |
85 | 91 | ret = get_sem(dev->dev, &sem); |
86 | 92 | if (!ret && sem) { |
87 | 93 | acquired = jiffies; |
88 | 94 | |
... | ... | @@ -91,14 +97,14 @@ |
91 | 97 | } |
92 | 98 | |
93 | 99 | usleep_range(1000, 2000); |
94 | - } | |
100 | + } while (time_before(jiffies, end)); | |
95 | 101 | |
96 | 102 | dev_err(dev->dev, "punit semaphore timed out, resetting\n"); |
97 | 103 | reset_semaphore(dev->dev); |
98 | 104 | |
99 | 105 | ret = iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_READ, |
100 | - PUNIT_SEMAPHORE, &sem); | |
101 | - if (!ret) | |
106 | + PUNIT_SEMAPHORE, &sem); | |
107 | + if (ret) | |
102 | 108 | dev_err(dev->dev, "iosf failed to read punit semaphore\n"); |
103 | 109 | else |
104 | 110 | dev_err(dev->dev, "PUNIT SEM: %d\n", sem); |
105 | 111 | |
... | ... | @@ -107,9 +113,8 @@ |
107 | 113 | |
108 | 114 | return -ETIMEDOUT; |
109 | 115 | } |
110 | -EXPORT_SYMBOL(baytrail_i2c_acquire); | |
111 | 116 | |
112 | -void baytrail_i2c_release(struct dw_i2c_dev *dev) | |
117 | +static void baytrail_i2c_release(struct dw_i2c_dev *dev) | |
113 | 118 | { |
114 | 119 | if (!dev || !dev->dev) |
115 | 120 | return; |
... | ... | @@ -121,7 +126,6 @@ |
121 | 126 | dev_dbg(dev->dev, "punit semaphore held for %ums\n", |
122 | 127 | jiffies_to_msecs(jiffies - acquired)); |
123 | 128 | } |
124 | -EXPORT_SYMBOL(baytrail_i2c_release); | |
125 | 129 | |
126 | 130 | int i2c_dw_eval_lock_support(struct dw_i2c_dev *dev) |
127 | 131 | { |
... | ... | @@ -137,7 +141,6 @@ |
137 | 141 | return 0; |
138 | 142 | |
139 | 143 | status = acpi_evaluate_integer(handle, "_SEM", NULL, &shared_host); |
140 | - | |
141 | 144 | if (ACPI_FAILURE(status)) |
142 | 145 | return 0; |
143 | 146 | |
... | ... | @@ -153,7 +156,6 @@ |
153 | 156 | |
154 | 157 | return 0; |
155 | 158 | } |
156 | -EXPORT_SYMBOL(i2c_dw_eval_lock_support); | |
157 | 159 | |
158 | 160 | MODULE_AUTHOR("David E. Box <david.e.box@linux.intel.com>"); |
159 | 161 | MODULE_DESCRIPTION("Baytrail I2C Semaphore driver"); |