1 | Last handful of arm patches before softfreeze... | 1 | Arm queue; bugfixes only. |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit a98135f727595382e200d04c2996e868b7925a01: | 3 | thanks |
4 | -- PMM | ||
4 | 5 | ||
5 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000) | 6 | The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739: |
7 | |||
8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000) | ||
6 | 9 | ||
7 | are available in the Git repository at: | 10 | are available in the Git repository at: |
8 | 11 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200317 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117 |
10 | 13 | ||
11 | for you to fetch changes up to e88d3671e3bbd59d385838a4101ea19cdcf47309: | 14 | for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42: |
12 | 15 | ||
13 | hw/arm/pxa2xx: Do not wire up OHCI for PXA255 (2020-03-17 11:36:48 +0000) | 16 | tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000) |
14 | 17 | ||
15 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
16 | target-arm: | 19 | target-arm queue: |
17 | * hw/arm/pxa2xx: Do not wire up OHCI for PXA255 | 20 | * hw/arm/virt: ARM_VIRT must select ARM_GIC |
18 | * aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command | 21 | * exynos: Fix bad printf format specifiers |
19 | * m25p80: Improve command handling for Jedec and unsupported commands | 22 | * hw/input/ps2.c: Remove remnants of printf debug |
20 | * hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() | 23 | * target/openrisc: Remove dead code attempting to check "is timer disabled" |
21 | * hw/arm/fsl-imx6, imx6ul: Wire up USB controllers | 24 | * register: Remove unnecessary NULL check |
22 | * hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices | 25 | * util/cutils: Fix Coverity array overrun in freq_to_str() |
26 | * configure: Make "does libgio work" test pull in some actual functions | ||
27 | * tmp105: reset the T_low and T_High registers | ||
28 | * tmp105: Correct handling of temperature limit checks | ||
23 | 29 | ||
24 | ---------------------------------------------------------------- | 30 | ---------------------------------------------------------------- |
25 | Chen Qun (1): | 31 | Alex Chen (1): |
26 | hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() | 32 | exynos: Fix bad printf format specifiers |
27 | 33 | ||
28 | Guenter Roeck (10): | 34 | Alistair Francis (1): |
29 | hw/usb: Add basic i.MX USB Phy support | 35 | register: Remove unnecessary NULL check |
30 | hw/arm/fsl-imx6ul: Fix USB interrupt numbers | ||
31 | hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices | ||
32 | hw/arm/fsl-imx6ul: Wire up USB controllers | ||
33 | hw/arm/fsl-imx6: Wire up USB controllers | ||
34 | m25p80: Convert to support tracing | ||
35 | m25p80: Improve command handling for Jedec commands | ||
36 | m25p80: Improve command handling for unsupported commands | ||
37 | aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command | ||
38 | hw/arm/pxa2xx: Do not wire up OHCI for PXA255 | ||
39 | 36 | ||
40 | hw/usb/Makefile.objs | 2 + | 37 | Andrew Jones (1): |
41 | include/hw/arm/fsl-imx6.h | 6 ++ | 38 | hw/arm/virt: ARM_VIRT must select ARM_GIC |
42 | include/hw/arm/fsl-imx6ul.h | 16 ++- | ||
43 | include/hw/usb/imx-usb-phy.h | 53 ++++++++++ | ||
44 | hw/arm/fsl-imx6.c | 36 +++++++ | ||
45 | hw/arm/fsl-imx6ul.c | 49 ++++++++++ | ||
46 | hw/arm/pxa2xx.c | 3 - | ||
47 | hw/block/m25p80.c | 58 +++++------ | ||
48 | hw/net/imx_fec.c | 6 +- | ||
49 | hw/ssi/aspeed_smc.c | 2 +- | ||
50 | hw/usb/imx-usb-phy.c | 225 +++++++++++++++++++++++++++++++++++++++++++ | ||
51 | MAINTAINERS | 2 + | ||
52 | hw/arm/Kconfig | 1 + | ||
53 | hw/block/trace-events | 16 +++ | ||
54 | hw/usb/Kconfig | 5 + | ||
55 | 15 files changed, 444 insertions(+), 36 deletions(-) | ||
56 | create mode 100644 include/hw/usb/imx-usb-phy.h | ||
57 | create mode 100644 hw/usb/imx-usb-phy.c | ||
58 | 39 | ||
40 | Peter Maydell (5): | ||
41 | hw/input/ps2.c: Remove remnants of printf debug | ||
42 | target/openrisc: Remove dead code attempting to check "is timer disabled" | ||
43 | configure: Make "does libgio work" test pull in some actual functions | ||
44 | hw/misc/tmp105: reset the T_low and T_High registers | ||
45 | tmp105: Correct handling of temperature limit checks | ||
46 | |||
47 | Philippe Mathieu-Daudé (1): | ||
48 | util/cutils: Fix Coverity array overrun in freq_to_str() | ||
49 | |||
50 | configure | 11 +++++-- | ||
51 | hw/misc/tmp105.h | 7 +++++ | ||
52 | hw/core/register.c | 4 --- | ||
53 | hw/input/ps2.c | 9 ------ | ||
54 | hw/misc/tmp105.c | 73 ++++++++++++++++++++++++++++++++++++++------ | ||
55 | hw/timer/exynos4210_mct.c | 4 +-- | ||
56 | hw/timer/exynos4210_pwm.c | 8 ++--- | ||
57 | target/openrisc/sys_helper.c | 3 -- | ||
58 | util/cutils.c | 3 +- | ||
59 | hw/arm/Kconfig | 1 + | ||
60 | 10 files changed, 89 insertions(+), 34 deletions(-) | ||
61 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Andrew Jones <drjones@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add basic USB PHY support as implemented in i.MX23, i.MX28, i.MX6, | 3 | The removal of the selection of A15MPCORE from ARM_VIRT also |
4 | and i.MX7 SoCs. | 4 | removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC. |
5 | 5 | ||
6 | The only support really needed - at least to boot Linux - is support | 6 | Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals") |
7 | for soft reset, which needs to reset various registers to their initial | 7 | Reported-by: Miroslav Rezanina <mrezanin@redhat.com> |
8 | value. Otherwise, just record register values. | 8 | Signed-off-by: Andrew Jones <drjones@redhat.com> |
9 | 9 | Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com> | |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
11 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 11 | Message-id: 20201111143440.112763-1-drjones@redhat.com |
12 | Message-id: 20200313014551.12554-2-linux@roeck-us.net | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | hw/usb/Makefile.objs | 2 + | 14 | hw/arm/Kconfig | 1 + |
16 | include/hw/usb/imx-usb-phy.h | 53 +++++++++ | 15 | 1 file changed, 1 insertion(+) |
17 | hw/usb/imx-usb-phy.c | 225 +++++++++++++++++++++++++++++++++++ | ||
18 | MAINTAINERS | 2 + | ||
19 | hw/arm/Kconfig | 1 + | ||
20 | hw/usb/Kconfig | 5 + | ||
21 | 6 files changed, 288 insertions(+) | ||
22 | create mode 100644 include/hw/usb/imx-usb-phy.h | ||
23 | create mode 100644 hw/usb/imx-usb-phy.c | ||
24 | 16 | ||
25 | diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/usb/Makefile.objs | ||
28 | +++ b/hw/usb/Makefile.objs | ||
29 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XEN) += xen-usb.o | ||
30 | xen-usb.o-cflags := $(LIBUSB_CFLAGS) | ||
31 | xen-usb.o-libs := $(LIBUSB_LIBS) | ||
32 | endif | ||
33 | + | ||
34 | +common-obj-$(CONFIG_IMX_USBPHY) += imx-usb-phy.o | ||
35 | diff --git a/include/hw/usb/imx-usb-phy.h b/include/hw/usb/imx-usb-phy.h | ||
36 | new file mode 100644 | ||
37 | index XXXXXXX..XXXXXXX | ||
38 | --- /dev/null | ||
39 | +++ b/include/hw/usb/imx-usb-phy.h | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | +#ifndef IMX_USB_PHY_H | ||
42 | +#define IMX_USB_PHY_H | ||
43 | + | ||
44 | +#include "hw/sysbus.h" | ||
45 | +#include "qemu/bitops.h" | ||
46 | + | ||
47 | +enum IMXUsbPhyRegisters { | ||
48 | + USBPHY_PWD, | ||
49 | + USBPHY_PWD_SET, | ||
50 | + USBPHY_PWD_CLR, | ||
51 | + USBPHY_PWD_TOG, | ||
52 | + USBPHY_TX, | ||
53 | + USBPHY_TX_SET, | ||
54 | + USBPHY_TX_CLR, | ||
55 | + USBPHY_TX_TOG, | ||
56 | + USBPHY_RX, | ||
57 | + USBPHY_RX_SET, | ||
58 | + USBPHY_RX_CLR, | ||
59 | + USBPHY_RX_TOG, | ||
60 | + USBPHY_CTRL, | ||
61 | + USBPHY_CTRL_SET, | ||
62 | + USBPHY_CTRL_CLR, | ||
63 | + USBPHY_CTRL_TOG, | ||
64 | + USBPHY_STATUS, | ||
65 | + USBPHY_DEBUG = 0x14, | ||
66 | + USBPHY_DEBUG_SET, | ||
67 | + USBPHY_DEBUG_CLR, | ||
68 | + USBPHY_DEBUG_TOG, | ||
69 | + USBPHY_DEBUG0_STATUS, | ||
70 | + USBPHY_DEBUG1 = 0x1c, | ||
71 | + USBPHY_DEBUG1_SET, | ||
72 | + USBPHY_DEBUG1_CLR, | ||
73 | + USBPHY_DEBUG1_TOG, | ||
74 | + USBPHY_VERSION, | ||
75 | + USBPHY_MAX | ||
76 | +}; | ||
77 | + | ||
78 | +#define USBPHY_CTRL_SFTRST BIT(31) | ||
79 | + | ||
80 | +#define TYPE_IMX_USBPHY "imx.usbphy" | ||
81 | +#define IMX_USBPHY(obj) OBJECT_CHECK(IMXUSBPHYState, (obj), TYPE_IMX_USBPHY) | ||
82 | + | ||
83 | +typedef struct IMXUSBPHYState { | ||
84 | + /* <private> */ | ||
85 | + SysBusDevice parent_obj; | ||
86 | + | ||
87 | + /* <public> */ | ||
88 | + MemoryRegion iomem; | ||
89 | + | ||
90 | + uint32_t usbphy[USBPHY_MAX]; | ||
91 | +} IMXUSBPHYState; | ||
92 | + | ||
93 | +#endif /* IMX_USB_PHY_H */ | ||
94 | diff --git a/hw/usb/imx-usb-phy.c b/hw/usb/imx-usb-phy.c | ||
95 | new file mode 100644 | ||
96 | index XXXXXXX..XXXXXXX | ||
97 | --- /dev/null | ||
98 | +++ b/hw/usb/imx-usb-phy.c | ||
99 | @@ -XXX,XX +XXX,XX @@ | ||
100 | +/* | ||
101 | + * i.MX USB PHY | ||
102 | + * | ||
103 | + * Copyright (c) 2020 Guenter Roeck <linux@roeck-us.net> | ||
104 | + * | ||
105 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
106 | + * See the COPYING file in the top-level directory. | ||
107 | + * | ||
108 | + * We need to implement basic reset control in the PHY control register. | ||
109 | + * For everything else, it is sufficient to set whatever is written. | ||
110 | + */ | ||
111 | + | ||
112 | +#include "qemu/osdep.h" | ||
113 | +#include "hw/usb/imx-usb-phy.h" | ||
114 | +#include "migration/vmstate.h" | ||
115 | +#include "qemu/log.h" | ||
116 | +#include "qemu/module.h" | ||
117 | + | ||
118 | +static const VMStateDescription vmstate_imx_usbphy = { | ||
119 | + .name = TYPE_IMX_USBPHY, | ||
120 | + .version_id = 1, | ||
121 | + .minimum_version_id = 1, | ||
122 | + .fields = (VMStateField[]) { | ||
123 | + VMSTATE_UINT32_ARRAY(usbphy, IMXUSBPHYState, USBPHY_MAX), | ||
124 | + VMSTATE_END_OF_LIST() | ||
125 | + }, | ||
126 | +}; | ||
127 | + | ||
128 | +static void imx_usbphy_softreset(IMXUSBPHYState *s) | ||
129 | +{ | ||
130 | + s->usbphy[USBPHY_PWD] = 0x001e1c00; | ||
131 | + s->usbphy[USBPHY_TX] = 0x10060607; | ||
132 | + s->usbphy[USBPHY_RX] = 0x00000000; | ||
133 | + s->usbphy[USBPHY_CTRL] = 0xc0200000; | ||
134 | +} | ||
135 | + | ||
136 | +static void imx_usbphy_reset(DeviceState *dev) | ||
137 | +{ | ||
138 | + IMXUSBPHYState *s = IMX_USBPHY(dev); | ||
139 | + | ||
140 | + s->usbphy[USBPHY_STATUS] = 0x00000000; | ||
141 | + s->usbphy[USBPHY_DEBUG] = 0x7f180000; | ||
142 | + s->usbphy[USBPHY_DEBUG0_STATUS] = 0x00000000; | ||
143 | + s->usbphy[USBPHY_DEBUG1] = 0x00001000; | ||
144 | + s->usbphy[USBPHY_VERSION] = 0x04020000; | ||
145 | + | ||
146 | + imx_usbphy_softreset(s); | ||
147 | +} | ||
148 | + | ||
149 | +static uint64_t imx_usbphy_read(void *opaque, hwaddr offset, unsigned size) | ||
150 | +{ | ||
151 | + IMXUSBPHYState *s = (IMXUSBPHYState *)opaque; | ||
152 | + uint32_t index = offset >> 2; | ||
153 | + uint32_t value; | ||
154 | + | ||
155 | + switch (index) { | ||
156 | + case USBPHY_PWD_SET: | ||
157 | + case USBPHY_TX_SET: | ||
158 | + case USBPHY_RX_SET: | ||
159 | + case USBPHY_CTRL_SET: | ||
160 | + case USBPHY_DEBUG_SET: | ||
161 | + case USBPHY_DEBUG1_SET: | ||
162 | + /* | ||
163 | + * All REG_NAME_SET register access are in fact targeting the | ||
164 | + * REG_NAME register. | ||
165 | + */ | ||
166 | + value = s->usbphy[index - 1]; | ||
167 | + break; | ||
168 | + case USBPHY_PWD_CLR: | ||
169 | + case USBPHY_TX_CLR: | ||
170 | + case USBPHY_RX_CLR: | ||
171 | + case USBPHY_CTRL_CLR: | ||
172 | + case USBPHY_DEBUG_CLR: | ||
173 | + case USBPHY_DEBUG1_CLR: | ||
174 | + /* | ||
175 | + * All REG_NAME_CLR register access are in fact targeting the | ||
176 | + * REG_NAME register. | ||
177 | + */ | ||
178 | + value = s->usbphy[index - 2]; | ||
179 | + break; | ||
180 | + case USBPHY_PWD_TOG: | ||
181 | + case USBPHY_TX_TOG: | ||
182 | + case USBPHY_RX_TOG: | ||
183 | + case USBPHY_CTRL_TOG: | ||
184 | + case USBPHY_DEBUG_TOG: | ||
185 | + case USBPHY_DEBUG1_TOG: | ||
186 | + /* | ||
187 | + * All REG_NAME_TOG register access are in fact targeting the | ||
188 | + * REG_NAME register. | ||
189 | + */ | ||
190 | + value = s->usbphy[index - 3]; | ||
191 | + break; | ||
192 | + default: | ||
193 | + value = s->usbphy[index]; | ||
194 | + break; | ||
195 | + } | ||
196 | + return (uint64_t)value; | ||
197 | +} | ||
198 | + | ||
199 | +static void imx_usbphy_write(void *opaque, hwaddr offset, uint64_t value, | ||
200 | + unsigned size) | ||
201 | +{ | ||
202 | + IMXUSBPHYState *s = (IMXUSBPHYState *)opaque; | ||
203 | + uint32_t index = offset >> 2; | ||
204 | + | ||
205 | + switch (index) { | ||
206 | + case USBPHY_CTRL: | ||
207 | + s->usbphy[index] = value; | ||
208 | + if (value & USBPHY_CTRL_SFTRST) { | ||
209 | + imx_usbphy_softreset(s); | ||
210 | + } | ||
211 | + break; | ||
212 | + case USBPHY_PWD: | ||
213 | + case USBPHY_TX: | ||
214 | + case USBPHY_RX: | ||
215 | + case USBPHY_STATUS: | ||
216 | + case USBPHY_DEBUG: | ||
217 | + case USBPHY_DEBUG1: | ||
218 | + s->usbphy[index] = value; | ||
219 | + break; | ||
220 | + case USBPHY_CTRL_SET: | ||
221 | + s->usbphy[index - 1] |= value; | ||
222 | + if (value & USBPHY_CTRL_SFTRST) { | ||
223 | + imx_usbphy_softreset(s); | ||
224 | + } | ||
225 | + break; | ||
226 | + case USBPHY_PWD_SET: | ||
227 | + case USBPHY_TX_SET: | ||
228 | + case USBPHY_RX_SET: | ||
229 | + case USBPHY_DEBUG_SET: | ||
230 | + case USBPHY_DEBUG1_SET: | ||
231 | + /* | ||
232 | + * All REG_NAME_SET register access are in fact targeting the | ||
233 | + * REG_NAME register. So we change the value of the REG_NAME | ||
234 | + * register, setting bits passed in the value. | ||
235 | + */ | ||
236 | + s->usbphy[index - 1] |= value; | ||
237 | + break; | ||
238 | + case USBPHY_PWD_CLR: | ||
239 | + case USBPHY_TX_CLR: | ||
240 | + case USBPHY_RX_CLR: | ||
241 | + case USBPHY_CTRL_CLR: | ||
242 | + case USBPHY_DEBUG_CLR: | ||
243 | + case USBPHY_DEBUG1_CLR: | ||
244 | + /* | ||
245 | + * All REG_NAME_CLR register access are in fact targeting the | ||
246 | + * REG_NAME register. So we change the value of the REG_NAME | ||
247 | + * register, unsetting bits passed in the value. | ||
248 | + */ | ||
249 | + s->usbphy[index - 2] &= ~value; | ||
250 | + break; | ||
251 | + case USBPHY_CTRL_TOG: | ||
252 | + s->usbphy[index - 3] ^= value; | ||
253 | + if ((value & USBPHY_CTRL_SFTRST) && | ||
254 | + (s->usbphy[index - 3] & USBPHY_CTRL_SFTRST)) { | ||
255 | + imx_usbphy_softreset(s); | ||
256 | + } | ||
257 | + break; | ||
258 | + case USBPHY_PWD_TOG: | ||
259 | + case USBPHY_TX_TOG: | ||
260 | + case USBPHY_RX_TOG: | ||
261 | + case USBPHY_DEBUG_TOG: | ||
262 | + case USBPHY_DEBUG1_TOG: | ||
263 | + /* | ||
264 | + * All REG_NAME_TOG register access are in fact targeting the | ||
265 | + * REG_NAME register. So we change the value of the REG_NAME | ||
266 | + * register, toggling bits passed in the value. | ||
267 | + */ | ||
268 | + s->usbphy[index - 3] ^= value; | ||
269 | + break; | ||
270 | + default: | ||
271 | + /* Other registers are read-only */ | ||
272 | + break; | ||
273 | + } | ||
274 | +} | ||
275 | + | ||
276 | +static const struct MemoryRegionOps imx_usbphy_ops = { | ||
277 | + .read = imx_usbphy_read, | ||
278 | + .write = imx_usbphy_write, | ||
279 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
280 | + .valid = { | ||
281 | + /* | ||
282 | + * Our device would not work correctly if the guest was doing | ||
283 | + * unaligned access. This might not be a limitation on the real | ||
284 | + * device but in practice there is no reason for a guest to access | ||
285 | + * this device unaligned. | ||
286 | + */ | ||
287 | + .min_access_size = 4, | ||
288 | + .max_access_size = 4, | ||
289 | + .unaligned = false, | ||
290 | + }, | ||
291 | +}; | ||
292 | + | ||
293 | +static void imx_usbphy_realize(DeviceState *dev, Error **errp) | ||
294 | +{ | ||
295 | + IMXUSBPHYState *s = IMX_USBPHY(dev); | ||
296 | + | ||
297 | + memory_region_init_io(&s->iomem, OBJECT(s), &imx_usbphy_ops, s, | ||
298 | + "imx-usbphy", 0x1000); | ||
299 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
300 | +} | ||
301 | + | ||
302 | +static void imx_usbphy_class_init(ObjectClass *klass, void *data) | ||
303 | +{ | ||
304 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
305 | + | ||
306 | + dc->reset = imx_usbphy_reset; | ||
307 | + dc->vmsd = &vmstate_imx_usbphy; | ||
308 | + dc->desc = "i.MX USB PHY Module"; | ||
309 | + dc->realize = imx_usbphy_realize; | ||
310 | +} | ||
311 | + | ||
312 | +static const TypeInfo imx_usbphy_info = { | ||
313 | + .name = TYPE_IMX_USBPHY, | ||
314 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
315 | + .instance_size = sizeof(IMXUSBPHYState), | ||
316 | + .class_init = imx_usbphy_class_init, | ||
317 | +}; | ||
318 | + | ||
319 | +static void imx_usbphy_register_types(void) | ||
320 | +{ | ||
321 | + type_register_static(&imx_usbphy_info); | ||
322 | +} | ||
323 | + | ||
324 | +type_init(imx_usbphy_register_types) | ||
325 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
326 | index XXXXXXX..XXXXXXX 100644 | ||
327 | --- a/MAINTAINERS | ||
328 | +++ b/MAINTAINERS | ||
329 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/sabrelite.c | ||
330 | F: hw/arm/fsl-imx6.c | ||
331 | F: hw/misc/imx6_*.c | ||
332 | F: hw/ssi/imx_spi.c | ||
333 | +F: hw/usb/imx-usb-phy.c | ||
334 | +F: include/hw/usb/imx-usb-phy.h | ||
335 | F: include/hw/arm/fsl-imx6.h | ||
336 | F: include/hw/misc/imx6_*.h | ||
337 | F: include/hw/ssi/imx_spi.h | ||
338 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 17 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
339 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
340 | --- a/hw/arm/Kconfig | 19 | --- a/hw/arm/Kconfig |
341 | +++ b/hw/arm/Kconfig | 20 | +++ b/hw/arm/Kconfig |
342 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6 | 21 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
343 | select IMX | 22 | imply VFIO_PLATFORM |
344 | select IMX_FEC | 23 | imply VFIO_XGMAC |
345 | select IMX_I2C | 24 | imply TPM_TIS_SYSBUS |
346 | + select IMX_USBPHY | 25 | + select ARM_GIC |
347 | select SDHCI | 26 | select ACPI |
348 | 27 | select ARM_SMMUV3 | |
349 | config ASPEED_SOC | 28 | select GPIO_KEY |
350 | diff --git a/hw/usb/Kconfig b/hw/usb/Kconfig | ||
351 | index XXXXXXX..XXXXXXX 100644 | ||
352 | --- a/hw/usb/Kconfig | ||
353 | +++ b/hw/usb/Kconfig | ||
354 | @@ -XXX,XX +XXX,XX @@ config USB_STORAGE_MTP | ||
355 | bool | ||
356 | default y | ||
357 | depends on USB | ||
358 | + | ||
359 | +config IMX_USBPHY | ||
360 | + bool | ||
361 | + default y | ||
362 | + depends on USB | ||
363 | -- | 29 | -- |
364 | 2.20.1 | 30 | 2.20.1 |
365 | 31 | ||
366 | 32 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
2 | 1 | ||
3 | USB1 and USB2 interrupt numbers were swapped. USB_PHY2 interrupt number | ||
4 | is 45. That didn't really matter up to now since the interrupts were not | ||
5 | used, but it needs to be fixed to be able to wire up the USB controllers. | ||
6 | |||
7 | Fixes: 31cbf933f0e ("i.MX6UL: Add i.MX6UL SOC") | ||
8 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Message-id: 20200313014551.12554-3-linux@roeck-us.net | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/fsl-imx6ul.h | 6 +++--- | ||
14 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/fsl-imx6ul.h | ||
19 | +++ b/include/hw/arm/fsl-imx6ul.h | ||
20 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULIRQs { | ||
21 | FSL_IMX6UL_UART7_IRQ = 39, | ||
22 | FSL_IMX6UL_UART8_IRQ = 40, | ||
23 | |||
24 | - FSL_IMX6UL_USB1_IRQ = 42, | ||
25 | - FSL_IMX6UL_USB2_IRQ = 43, | ||
26 | + FSL_IMX6UL_USB1_IRQ = 43, | ||
27 | + FSL_IMX6UL_USB2_IRQ = 42, | ||
28 | FSL_IMX6UL_USB_PHY1_IRQ = 44, | ||
29 | - FSL_IMX6UL_USB_PHY2_IRQ = 44, | ||
30 | + FSL_IMX6UL_USB_PHY2_IRQ = 45, | ||
31 | |||
32 | FSL_IMX6UL_CAAM_JQ2_IRQ = 46, | ||
33 | FSL_IMX6UL_CAAM_ERR_IRQ = 47, | ||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
2 | 1 | ||
3 | Recent Linux kernels (post v4.20) crash due to accesses to flexcan | ||
4 | and pwm controllers. Instantiate as unimplemented devices to work | ||
5 | around the problem. | ||
6 | |||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
8 | Message-id: 20200313014551.12554-4-linux@roeck-us.net | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/fsl-imx6ul.c | 14 ++++++++++++++ | ||
13 | 1 file changed, 14 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/fsl-imx6ul.c | ||
18 | +++ b/hw/arm/fsl-imx6ul.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
20 | */ | ||
21 | create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000); | ||
22 | |||
23 | + /* | ||
24 | + * PWM | ||
25 | + */ | ||
26 | + create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000); | ||
27 | + create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000); | ||
28 | + create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000); | ||
29 | + create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000); | ||
30 | + | ||
31 | + /* | ||
32 | + * CAN | ||
33 | + */ | ||
34 | + create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000); | ||
35 | + create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000); | ||
36 | + | ||
37 | /* | ||
38 | * APHB_DMA | ||
39 | */ | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
1 | From: Chen Qun <kuhn.chenqun@huawei.com> | 1 | From: Alex Chen <alex.chen@huawei.com> |
---|---|---|---|
2 | 2 | ||
3 | The current code causes clang static code analyzer generate warning: | 3 | We should use printf format specifier "%u" instead of "%d" for |
4 | hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read | 4 | argument of type "unsigned int". |
5 | value = value & 0x0000000f; | ||
6 | ^ ~~~~~~~~~~~~~~~~~~ | ||
7 | hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read | ||
8 | value = value & 0x000000fd; | ||
9 | ^ ~~~~~~~~~~~~~~~~~~ | ||
10 | |||
11 | According to the definition of the function, the two “value” assignments | ||
12 | should be written to registers. | ||
13 | 5 | ||
14 | Reported-by: Euler Robot <euler.robot@huawei.com> | 6 | Reported-by: Euler Robot <euler.robot@huawei.com> |
15 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> | 7 | Signed-off-by: Alex Chen <alex.chen@huawei.com> |
16 | Message-id: 20200313123242.13236-1-kuhn.chenqun@huawei.com | 8 | Message-id: 20201111073651.72804-1-alex.chen@huawei.com |
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 11 | --- |
20 | hw/net/imx_fec.c | 6 ++++-- | 12 | hw/timer/exynos4210_mct.c | 4 ++-- |
21 | 1 file changed, 4 insertions(+), 2 deletions(-) | 13 | hw/timer/exynos4210_pwm.c | 8 ++++---- |
14 | 2 files changed, 6 insertions(+), 6 deletions(-) | ||
22 | 15 | ||
23 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 16 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c |
24 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/net/imx_fec.c | 18 | --- a/hw/timer/exynos4210_mct.c |
26 | +++ b/hw/net/imx_fec.c | 19 | +++ b/hw/timer/exynos4210_mct.c |
27 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) | 20 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id) |
28 | break; | 21 | /* If CSTAT is pending and IRQ is enabled */ |
29 | case ENET_TGSR: | 22 | if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) && |
30 | /* implement clear timer flag */ | 23 | (s->reg.int_enb & G_INT_ENABLE(id))) { |
31 | - value = value & 0x0000000f; | 24 | - DPRINTF("gcmp timer[%d] IRQ\n", id); |
32 | + s->regs[index] &= ~(value & 0x0000000f); /* all bits W1C */ | 25 | + DPRINTF("gcmp timer[%u] IRQ\n", id); |
33 | break; | 26 | qemu_irq_raise(s->irq[id]); |
34 | case ENET_TCSR0: | 27 | } |
35 | case ENET_TCSR1: | 28 | } |
36 | case ENET_TCSR2: | 29 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) |
37 | case ENET_TCSR3: | 30 | MCT_CFG_GET_DIVIDER(s->reg_mct_cfg)); |
38 | - value = value & 0x000000fd; | 31 | |
39 | + s->regs[index] &= ~(value & 0x00000080); /* W1C bits */ | 32 | if (freq != s->freq) { |
40 | + s->regs[index] &= ~0x0000007d; /* writable fields */ | 33 | - DPRINTF("freq=%dHz\n", s->freq); |
41 | + s->regs[index] |= (value & 0x0000007d); | 34 | + DPRINTF("freq=%uHz\n", s->freq); |
42 | break; | 35 | |
43 | case ENET_TCCR0: | 36 | /* global timer */ |
44 | case ENET_TCCR1: | 37 | tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq); |
38 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/hw/timer/exynos4210_pwm.c | ||
41 | +++ b/hw/timer/exynos4210_pwm.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id) | ||
43 | |||
44 | if (freq != s->timer[id].freq) { | ||
45 | ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq); | ||
46 | - DPRINTF("freq=%dHz\n", s->timer[id].freq); | ||
47 | + DPRINTF("freq=%uHz\n", s->timer[id].freq); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque) | ||
52 | uint32_t id = s->id; | ||
53 | bool cmp; | ||
54 | |||
55 | - DPRINTF("timer %d tick\n", id); | ||
56 | + DPRINTF("timer %u tick\n", id); | ||
57 | |||
58 | /* set irq status */ | ||
59 | p->reg_tint_cstat |= TINT_CSTAT_STATUS(id); | ||
60 | |||
61 | /* raise IRQ */ | ||
62 | if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) { | ||
63 | - DPRINTF("timer %d IRQ\n", id); | ||
64 | + DPRINTF("timer %u IRQ\n", id); | ||
65 | qemu_irq_raise(p->timer[id].irq); | ||
66 | } | ||
67 | |||
68 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque) | ||
69 | } | ||
70 | |||
71 | if (cmp) { | ||
72 | - DPRINTF("auto reload timer %d count to %x\n", id, | ||
73 | + DPRINTF("auto reload timer %u count to %x\n", id, | ||
74 | p->timer[id].reg_tcntb); | ||
75 | ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb); | ||
76 | ptimer_run(p->timer[id].ptimer, 1); | ||
45 | -- | 77 | -- |
46 | 2.20.1 | 78 | 2.20.1 |
47 | 79 | ||
48 | 80 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | In commit 5edab03d4040 we added tracepoints to the ps2 keyboard |
---|---|---|---|
2 | and mouse emulation. However we didn't remove all the debug-by-printf | ||
3 | support. In fact there is only one printf() remaining, and it is | ||
4 | redundant with the trace_ps2_write_mouse() event next to it. | ||
5 | Remove the printf() and the now-unused DEBUG* macros. | ||
2 | 6 | ||
3 | The Linux kernel recently started using FAST_READ_4 commands. | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This results in flash read failures. At the same time, the m25p80 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
5 | emulation is seen to read 8 more bytes than expected. Adjusting the | 9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> |
6 | expected number of dummy cycles to match FAST_READ fixes the problem. | 10 | Message-id: 20201101133258.4240-1-peter.maydell@linaro.org |
11 | --- | ||
12 | hw/input/ps2.c | 9 --------- | ||
13 | 1 file changed, 9 deletions(-) | ||
7 | 14 | ||
8 | Fixes: f95c4bffdc4c ("aspeed/smc: snoop SPI transfers to fake dummy cycles") | 15 | diff --git a/hw/input/ps2.c b/hw/input/ps2.c |
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/ssi/aspeed_smc.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/ssi/aspeed_smc.c | 17 | --- a/hw/input/ps2.c |
20 | +++ b/hw/ssi/aspeed_smc.c | 18 | +++ b/hw/input/ps2.c |
21 | @@ -XXX,XX +XXX,XX @@ static int aspeed_smc_num_dummies(uint8_t command) | 19 | @@ -XXX,XX +XXX,XX @@ |
22 | case FAST_READ: | 20 | |
23 | case DOR: | 21 | #include "trace.h" |
24 | case QOR: | 22 | |
25 | + case FAST_READ_4: | 23 | -/* debug PC keyboard */ |
26 | case DOR_4: | 24 | -//#define DEBUG_KBD |
27 | case QOR_4: | 25 | - |
28 | return 1; | 26 | -/* debug PC keyboard : only mouse */ |
29 | case DIOR: | 27 | -//#define DEBUG_MOUSE |
30 | - case FAST_READ_4: | 28 | - |
31 | case DIOR_4: | 29 | /* Keyboard Commands */ |
32 | return 2; | 30 | #define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ |
33 | case QIOR: | 31 | #define KBD_CMD_ECHO 0xEE |
32 | @@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val) | ||
33 | PS2MouseState *s = (PS2MouseState *)opaque; | ||
34 | |||
35 | trace_ps2_write_mouse(opaque, val); | ||
36 | -#ifdef DEBUG_MOUSE | ||
37 | - printf("kbd: write mouse 0x%02x\n", val); | ||
38 | -#endif | ||
39 | switch(s->common.write_cmd) { | ||
40 | default: | ||
41 | case -1: | ||
34 | -- | 42 | -- |
35 | 2.20.1 | 43 | 2.20.1 |
36 | 44 | ||
37 | 45 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | In the mtspr helper we attempt to check for "is the timer disabled" |
---|---|---|---|
2 | with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE | ||
3 | is zero and the condition is always false (Coverity complains about | ||
4 | the dead code.) | ||
2 | 5 | ||
3 | Whenever an unsupported command is encountered, the current code | 6 | The correct check would be to test whether the TTMR_M field in the |
4 | interprets each transferred byte as new command. Most of the time, those | 7 | register is equal to TIMER_NONE instead. However, the |
5 | 'commands' are interpreted as new unknown commands. However, in rare | 8 | cpu_openrisc_timer_update() function checks whether the timer is |
6 | cases, it may be that for example address or length information | 9 | enabled (it looks at cpu->env.is_counting, which is set to 0 via |
7 | passed with the original command is by itself a valid command. | 10 | cpu_openrisc_count_stop() when the TTMR_M field is set to |
8 | If that happens, the state machine may get completely confused and, | 11 | TIMER_NONE), so there's no need to check for "timer disabled" in the |
9 | worst case, start writing data into the flash or even erase it. | 12 | target/openrisc code. Instead, simply remove the dead code. |
10 | 13 | ||
11 | To avoid the problem, transition into STATE_READING_DATA and keep | 14 | Fixes: Coverity CID 1005812 |
12 | sending a value of 0 until the chip is deselected after encountering | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | an unsupported command. | 16 | Acked-by: Stafford Horne <shorne@gmail.com> |
17 | Message-id: 20201103114654.18540-1-peter.maydell@linaro.org | ||
18 | --- | ||
19 | target/openrisc/sys_helper.c | 3 --- | ||
20 | 1 file changed, 3 deletions(-) | ||
14 | 21 | ||
15 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 22 | diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c |
16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
17 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/block/m25p80.c | 5 +++++ | ||
21 | 1 file changed, 5 insertions(+) | ||
22 | |||
23 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/block/m25p80.c | 24 | --- a/target/openrisc/sys_helper.c |
26 | +++ b/hw/block/m25p80.c | 25 | +++ b/target/openrisc/sys_helper.c |
27 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 26 | @@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) |
28 | s->quad_enable = false; | 27 | |
28 | case TO_SPR(10, 1): /* TTCR */ | ||
29 | cpu_openrisc_count_set(cpu, rb); | ||
30 | - if (env->ttmr & TIMER_NONE) { | ||
31 | - return; | ||
32 | - } | ||
33 | cpu_openrisc_timer_update(cpu); | ||
29 | break; | 34 | break; |
30 | default: | 35 | #endif |
31 | + s->pos = 0; | ||
32 | + s->len = 1; | ||
33 | + s->state = STATE_READING_DATA; | ||
34 | + s->data_read_loop = true; | ||
35 | + s->data[0] = 0; | ||
36 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value); | ||
37 | break; | ||
38 | } | ||
39 | -- | 36 | -- |
40 | 2.20.1 | 37 | 2.20.1 |
41 | 38 | ||
42 | 39 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Alistair Francis <alistair.francis@wdc.com> |
---|---|---|---|
2 | 2 | ||
3 | PXA255 does not support a USB OHCI controller, so don't wire it up. | 3 | This patch fixes CID 1432800 by removing an unnecessary check. |
4 | 4 | ||
5 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 5 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> |
6 | Message-id: 20200313160215.28155-1-linux@roeck-us.net | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 8 | --- |
10 | hw/arm/pxa2xx.c | 3 --- | 9 | hw/core/register.c | 4 ---- |
11 | 1 file changed, 3 deletions(-) | 10 | 1 file changed, 4 deletions(-) |
12 | 11 | ||
13 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 12 | diff --git a/hw/core/register.c b/hw/core/register.c |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/pxa2xx.c | 14 | --- a/hw/core/register.c |
16 | +++ b/hw/arm/pxa2xx.c | 15 | +++ b/hw/core/register.c |
17 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) | 16 | @@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner, |
18 | s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); | 17 | int index = rae[i].addr / data_size; |
19 | } | 18 | RegisterInfo *r = &ri[index]; |
20 | 19 | ||
21 | - sysbus_create_simple("sysbus-ohci", 0x4c000000, | 20 | - if (data + data_size * index == 0 || !&rae[i]) { |
22 | - qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); | 21 | - continue; |
22 | - } | ||
23 | - | 23 | - |
24 | s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000); | 24 | /* Init the register, this will zero it. */ |
25 | s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000); | 25 | object_initialize((void *)r, sizeof(*r), TYPE_REGISTER); |
26 | 26 | ||
27 | -- | 27 | -- |
28 | 2.20.1 | 28 | 2.20.1 |
29 | 29 | ||
30 | 30 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | When requesting JEDEC data using the JEDEC_READ command, the Linux kernel | 3 | Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN): |
4 | always requests 6 bytes. The current implementation only returns three | ||
5 | bytes, and interprets the remaining three bytes as new commands. | ||
6 | While this does not matter most of the time, it is at the very least | ||
7 | confusing. To avoid the problem, always report up to 6 bytes of JEDEC | ||
8 | data. Fill remaining data with 0. | ||
9 | 4 | ||
10 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 5 | >>> Overrunning array "suffixes" of 7 8-byte elements at element |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | index 7 (byte offset 63) using index "idx" (which evaluates to 7). |
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | |
13 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 8 | Note, the biggest input value freq_to_str() can accept is UINT64_MAX, |
9 | which is ~18.446 EHz, less than 1000 EHz. | ||
10 | |||
11 | Reported-by: Eduardo Habkost <ehabkost@redhat.com> | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> | ||
15 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
16 | Message-id: 20201101215755.2021421-1-f4bug@amsat.org | ||
17 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 20 | --- |
16 | hw/block/m25p80.c | 5 ++++- | 21 | util/cutils.c | 3 ++- |
17 | 1 file changed, 4 insertions(+), 1 deletion(-) | 22 | 1 file changed, 2 insertions(+), 1 deletion(-) |
18 | 23 | ||
19 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 24 | diff --git a/util/cutils.c b/util/cutils.c |
20 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/block/m25p80.c | 26 | --- a/util/cutils.c |
22 | +++ b/hw/block/m25p80.c | 27 | +++ b/util/cutils.c |
23 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 28 | @@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz) |
24 | for (i = 0; i < s->pi->id_len; i++) { | 29 | double freq = freq_hz; |
25 | s->data[i] = s->pi->id[i]; | 30 | size_t idx = 0; |
26 | } | 31 | |
27 | + for (; i < SPI_NOR_MAX_ID_LEN; i++) { | 32 | - while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) { |
28 | + s->data[i] = 0; | 33 | + while (freq >= 1000.0) { |
29 | + } | 34 | freq /= 1000.0; |
30 | 35 | idx++; | |
31 | - s->len = s->pi->id_len; | 36 | } |
32 | + s->len = SPI_NOR_MAX_ID_LEN; | 37 | + assert(idx < ARRAY_SIZE(suffixes)); |
33 | s->pos = 0; | 38 | |
34 | s->state = STATE_READING_DATA; | 39 | return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]); |
35 | break; | 40 | } |
36 | -- | 41 | -- |
37 | 2.20.1 | 42 | 2.20.1 |
38 | 43 | ||
39 | 44 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | In commit 76346b6264a9b01979 we tried to add a configure check that |
---|---|---|---|
2 | the libgio pkg-config data was correct, which builds an executable | ||
3 | linked against it. Unfortunately this doesn't catch the problem | ||
4 | (missing static library dependency info), because a "do nothing" test | ||
5 | source file doesn't have any symbol references that cause the linker | ||
6 | to pull in .o files from libgio.a, and so we don't see the "missing | ||
7 | symbols from libmount" error that a full QEMU link triggers. | ||
2 | 8 | ||
3 | With this patch, the USB controllers on 'sabrelite' are detected | 9 | (The ineffective test went unnoticed because of a typo that |
4 | and can be used to boot the system. | 10 | effectively disabled libgio unconditionally, but after commit |
11 | 3569a5dfc11f2 fixed that, a static link of the system emulator on | ||
12 | Ubuntu stopped working again.) | ||
5 | 13 | ||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 14 | Improve the gio test by having the test source fragment reference a |
7 | Message-id: 20200313014551.12554-6-linux@roeck-us.net | 15 | g_dbus function (which is what is indirectly causing us to end up |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | wanting functions from libmount). |
17 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | ||
20 | Message-id: 20201116104617.18333-1-peter.maydell@linaro.org | ||
10 | --- | 21 | --- |
11 | include/hw/arm/fsl-imx6.h | 6 ++++++ | 22 | configure | 11 +++++++++-- |
12 | hw/arm/fsl-imx6.c | 36 ++++++++++++++++++++++++++++++++++++ | 23 | 1 file changed, 9 insertions(+), 2 deletions(-) |
13 | 2 files changed, 42 insertions(+) | ||
14 | 24 | ||
15 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | 25 | diff --git a/configure b/configure |
16 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100755 |
17 | --- a/include/hw/arm/fsl-imx6.h | 27 | --- a/configure |
18 | +++ b/include/hw/arm/fsl-imx6.h | 28 | +++ b/configure |
19 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then |
20 | #include "hw/sd/sdhci.h" | 30 | # Check that the libraries actually work -- Ubuntu 18.04 ships |
21 | #include "hw/ssi/imx_spi.h" | 31 | # with pkg-config --static --libs data for gio-2.0 that is missing |
22 | #include "hw/net/imx_fec.h" | 32 | # -lblkid and will give a link error. |
23 | +#include "hw/usb/chipidea.h" | 33 | - write_c_skeleton |
24 | +#include "hw/usb/imx-usb-phy.h" | 34 | - if compile_prog "" "$gio_libs" ; then |
25 | #include "exec/memory.h" | 35 | + cat > $TMPC <<EOF |
26 | #include "cpu.h" | 36 | +#include <gio/gio.h> |
27 | 37 | +int main(void) | |
28 | @@ -XXX,XX +XXX,XX @@ | 38 | +{ |
29 | #define FSL_IMX6_NUM_ESDHCS 4 | 39 | + g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0); |
30 | #define FSL_IMX6_NUM_ECSPIS 5 | 40 | + return 0; |
31 | #define FSL_IMX6_NUM_WDTS 2 | 41 | +} |
32 | +#define FSL_IMX6_NUM_USB_PHYS 2 | 42 | +EOF |
33 | +#define FSL_IMX6_NUM_USBS 4 | 43 | + if compile_prog "$gio_cflags" "$gio_libs" ; then |
34 | 44 | gio=yes | |
35 | typedef struct FslIMX6State { | 45 | else |
36 | /*< private >*/ | 46 | gio=no |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | ||
38 | SDHCIState esdhc[FSL_IMX6_NUM_ESDHCS]; | ||
39 | IMXSPIState spi[FSL_IMX6_NUM_ECSPIS]; | ||
40 | IMX2WdtState wdt[FSL_IMX6_NUM_WDTS]; | ||
41 | + IMXUSBPHYState usbphy[FSL_IMX6_NUM_USB_PHYS]; | ||
42 | + ChipideaState usb[FSL_IMX6_NUM_USBS]; | ||
43 | IMXFECState eth; | ||
44 | MemoryRegion rom; | ||
45 | MemoryRegion caam; | ||
46 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/fsl-imx6.c | ||
49 | +++ b/hw/arm/fsl-imx6.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "qemu/osdep.h" | ||
52 | #include "qapi/error.h" | ||
53 | #include "hw/arm/fsl-imx6.h" | ||
54 | +#include "hw/usb/imx-usb-phy.h" | ||
55 | #include "hw/boards.h" | ||
56 | #include "hw/qdev-properties.h" | ||
57 | #include "sysemu/sysemu.h" | ||
58 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj) | ||
59 | TYPE_IMX_USDHC); | ||
60 | } | ||
61 | |||
62 | + for (i = 0; i < FSL_IMX6_NUM_USB_PHYS; i++) { | ||
63 | + snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
64 | + sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]), | ||
65 | + TYPE_IMX_USBPHY); | ||
66 | + } | ||
67 | + for (i = 0; i < FSL_IMX6_NUM_USBS; i++) { | ||
68 | + snprintf(name, NAME_SIZE, "usb%d", i); | ||
69 | + sysbus_init_child_obj(obj, name, &s->usb[i], sizeof(s->usb[i]), | ||
70 | + TYPE_CHIPIDEA); | ||
71 | + } | ||
72 | + | ||
73 | for (i = 0; i < FSL_IMX6_NUM_ECSPIS; i++) { | ||
74 | snprintf(name, NAME_SIZE, "spi%d", i + 1); | ||
75 | sysbus_init_child_obj(obj, name, &s->spi[i], sizeof(s->spi[i]), | ||
76 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
77 | esdhc_table[i].irq)); | ||
78 | } | ||
79 | |||
80 | + /* USB */ | ||
81 | + for (i = 0; i < FSL_IMX6_NUM_USB_PHYS; i++) { | ||
82 | + object_property_set_bool(OBJECT(&s->usbphy[i]), true, "realized", | ||
83 | + &error_abort); | ||
84 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | ||
85 | + FSL_IMX6_USBPHY1_ADDR + i * 0x1000); | ||
86 | + } | ||
87 | + for (i = 0; i < FSL_IMX6_NUM_USBS; i++) { | ||
88 | + static const int FSL_IMX6_USBn_IRQ[] = { | ||
89 | + FSL_IMX6_USB_OTG_IRQ, | ||
90 | + FSL_IMX6_USB_HOST1_IRQ, | ||
91 | + FSL_IMX6_USB_HOST2_IRQ, | ||
92 | + FSL_IMX6_USB_HOST3_IRQ, | ||
93 | + }; | ||
94 | + | ||
95 | + object_property_set_bool(OBJECT(&s->usb[i]), true, "realized", | ||
96 | + &error_abort); | ||
97 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
98 | + FSL_IMX6_USBOH3_USB_ADDR + i * 0x200); | ||
99 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
100 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
101 | + FSL_IMX6_USBn_IRQ[i])); | ||
102 | + } | ||
103 | + | ||
104 | /* Initialize all ECSPI */ | ||
105 | for (i = 0; i < FSL_IMX6_NUM_ECSPIS; i++) { | ||
106 | static const struct { | ||
107 | -- | 47 | -- |
108 | 2.20.1 | 48 | 2.20.1 |
109 | 49 | ||
110 | 50 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the |
---|---|---|---|
2 | power-up reset values for the T_low and T_high registers are 80 degrees C | ||
3 | and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These | ||
4 | values are then shifted right by four bits to give the register reset | ||
5 | values, since both registers store the 12 bits of temperature data in bits | ||
6 | [15..4] of a 16 bit register. | ||
2 | 7 | ||
3 | IMX6UL USB controllers are quite similar to IMX7 USB controllers. | 8 | We were resetting these registers to zero, which is problematic for Linux |
4 | Wire them up the same way. | 9 | guests which enable the alert interrupt and then immediately take an |
10 | unexpected overtemperature alert because the current temperature is above | ||
11 | freezing... | ||
5 | 12 | ||
6 | The only real difference is that wiring up phy devices is necessary | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | to avoid phy reset timeouts in the Linux kernel. | 14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
15 | Message-id: 20201110150023.25533-2-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/misc/tmp105.c | 3 +++ | ||
18 | 1 file changed, 3 insertions(+) | ||
8 | 19 | ||
9 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 20 | diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c |
10 | Message-id: 20200313014551.12554-5-linux@roeck-us.net | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | include/hw/arm/fsl-imx6ul.h | 10 ++++++++++ | ||
15 | hw/arm/fsl-imx6ul.c | 35 +++++++++++++++++++++++++++++++++++ | ||
16 | 2 files changed, 45 insertions(+) | ||
17 | |||
18 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/fsl-imx6ul.h | 22 | --- a/hw/misc/tmp105.c |
21 | +++ b/include/hw/arm/fsl-imx6ul.h | 23 | +++ b/hw/misc/tmp105.c |
22 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c) |
23 | #include "hw/sd/sdhci.h" | 25 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; |
24 | #include "hw/ssi/imx_spi.h" | 26 | s->alarm = 0; |
25 | #include "hw/net/imx_fec.h" | 27 | |
26 | +#include "hw/usb/chipidea.h" | 28 | + s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */ |
27 | +#include "hw/usb/imx-usb-phy.h" | 29 | + s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */ |
28 | #include "exec/memory.h" | ||
29 | #include "cpu.h" | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration { | ||
32 | FSL_IMX6UL_NUM_I2CS = 4, | ||
33 | FSL_IMX6UL_NUM_ECSPIS = 4, | ||
34 | FSL_IMX6UL_NUM_ADCS = 2, | ||
35 | + FSL_IMX6UL_NUM_USB_PHYS = 2, | ||
36 | + FSL_IMX6UL_NUM_USBS = 2, | ||
37 | }; | ||
38 | |||
39 | typedef struct FslIMX6ULState { | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6ULState { | ||
41 | IMXFECState eth[FSL_IMX6UL_NUM_ETHS]; | ||
42 | SDHCIState usdhc[FSL_IMX6UL_NUM_USDHCS]; | ||
43 | IMX2WdtState wdt[FSL_IMX6UL_NUM_WDTS]; | ||
44 | + IMXUSBPHYState usbphy[FSL_IMX6UL_NUM_USB_PHYS]; | ||
45 | + ChipideaState usb[FSL_IMX6UL_NUM_USBS]; | ||
46 | MemoryRegion rom; | ||
47 | MemoryRegion caam; | ||
48 | MemoryRegion ocram; | ||
49 | @@ -XXX,XX +XXX,XX @@ enum FslIMX6ULMemoryMap { | ||
50 | FSL_IMX6UL_EPIT2_ADDR = 0x020D4000, | ||
51 | FSL_IMX6UL_EPIT1_ADDR = 0x020D0000, | ||
52 | FSL_IMX6UL_SNVS_HP_ADDR = 0x020CC000, | ||
53 | + FSL_IMX6UL_USBPHY2_ADDR = 0x020CA000, | ||
54 | + FSL_IMX6UL_USBPHY2_SIZE = (4 * 1024), | ||
55 | + FSL_IMX6UL_USBPHY1_ADDR = 0x020C9000, | ||
56 | + FSL_IMX6UL_USBPHY1_SIZE = (4 * 1024), | ||
57 | FSL_IMX6UL_ANALOG_ADDR = 0x020C8000, | ||
58 | FSL_IMX6UL_CCM_ADDR = 0x020C4000, | ||
59 | FSL_IMX6UL_WDOG2_ADDR = 0x020C0000, | ||
60 | diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/hw/arm/fsl-imx6ul.c | ||
63 | +++ b/hw/arm/fsl-imx6ul.c | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | #include "qapi/error.h" | ||
66 | #include "hw/arm/fsl-imx6ul.h" | ||
67 | #include "hw/misc/unimp.h" | ||
68 | +#include "hw/usb/imx-usb-phy.h" | ||
69 | #include "hw/boards.h" | ||
70 | #include "sysemu/sysemu.h" | ||
71 | #include "qemu/error-report.h" | ||
72 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj) | ||
73 | TYPE_IMX_ENET); | ||
74 | } | ||
75 | |||
76 | + /* USB */ | ||
77 | + for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
78 | + snprintf(name, NAME_SIZE, "usbphy%d", i); | ||
79 | + sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]), | ||
80 | + TYPE_IMX_USBPHY); | ||
81 | + } | ||
82 | + for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
83 | + snprintf(name, NAME_SIZE, "usb%d", i); | ||
84 | + sysbus_init_child_obj(obj, name, &s->usb[i], sizeof(s->usb[i]), | ||
85 | + TYPE_CHIPIDEA); | ||
86 | + } | ||
87 | + | 30 | + |
88 | /* | 31 | tmp105_interrupt_update(s); |
89 | * SDHCI | 32 | } |
90 | */ | 33 | |
91 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) | ||
92 | FSL_IMX6UL_ENETn_TIMER_IRQ[i])); | ||
93 | } | ||
94 | |||
95 | + /* USB */ | ||
96 | + for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) { | ||
97 | + object_property_set_bool(OBJECT(&s->usbphy[i]), true, "realized", | ||
98 | + &error_abort); | ||
99 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usbphy[i]), 0, | ||
100 | + FSL_IMX6UL_USBPHY1_ADDR + i * 0x1000); | ||
101 | + } | ||
102 | + | ||
103 | + for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) { | ||
104 | + static const int FSL_IMX6UL_USBn_IRQ[] = { | ||
105 | + FSL_IMX6UL_USB1_IRQ, | ||
106 | + FSL_IMX6UL_USB2_IRQ, | ||
107 | + }; | ||
108 | + object_property_set_bool(OBJECT(&s->usb[i]), true, "realized", | ||
109 | + &error_abort); | ||
110 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
111 | + FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200); | ||
112 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0, | ||
113 | + qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
114 | + FSL_IMX6UL_USBn_IRQ[i])); | ||
115 | + } | ||
116 | + | ||
117 | /* | ||
118 | * USDHC | ||
119 | */ | ||
120 | -- | 34 | -- |
121 | 2.20.1 | 35 | 2.20.1 |
122 | 36 | ||
123 | 37 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device |
---|---|---|---|
2 | signals an alert when the temperature equals or exceeds the T_high value and | ||
3 | then remains high until a device register is read or the device responds to | ||
4 | the SMBUS Alert Response address, or the device is put into Shutdown Mode. | ||
5 | Thereafter the Alert pin will only be re-signalled when temperature falls | ||
6 | below T_low; alert can then be cleared in the same set of ways, and the | ||
7 | device returns to its initial "alert when temperature goes above T_high" | ||
8 | mode. (If this textual description is confusing, see figure 3 in the | ||
9 | TI datasheet at https://www.ti.com/lit/gpn/tmp105 .) | ||
2 | 10 | ||
3 | While at it, add some trace messages to help debug problems | 11 | We were misimplementing this as a simple "always alert if temperature is |
4 | seen when running the latest Linux kernel. | 12 | above T_high or below T_low" condition, which gives a spurious alert on |
13 | startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset | ||
14 | limit values. | ||
5 | 15 | ||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 16 | Implement the correct (hysteresis) behaviour by tracking whether we |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 17 | are currently looking for the temperature to rise over T_high or |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 18 | for it to fall below T_low. Our implementation of the comparator |
19 | mode (TM==0) wasn't wrong, but rephrase it to match the way that | ||
20 | interrupt mode is now handled for clarity. | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 23 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Message-id: 20201110150023.25533-3-peter.maydell@linaro.org |
11 | --- | 25 | --- |
12 | hw/block/m25p80.c | 48 ++++++++++++++++++++----------------------- | 26 | hw/misc/tmp105.h | 7 +++++ |
13 | hw/block/trace-events | 16 +++++++++++++++ | 27 | hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++------- |
14 | 2 files changed, 38 insertions(+), 26 deletions(-) | 28 | 2 files changed, 68 insertions(+), 9 deletions(-) |
15 | 29 | ||
16 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 30 | diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h |
17 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/block/m25p80.c | 32 | --- a/hw/misc/tmp105.h |
19 | +++ b/hw/block/m25p80.c | 33 | +++ b/hw/misc/tmp105.h |
20 | @@ -XXX,XX +XXX,XX @@ | 34 | @@ -XXX,XX +XXX,XX @@ struct TMP105State { |
21 | #include "qemu/module.h" | 35 | int16_t limit[2]; |
22 | #include "qemu/error-report.h" | 36 | int faults; |
23 | #include "qapi/error.h" | 37 | uint8_t alarm; |
24 | - | 38 | + /* |
25 | -#ifndef M25P80_ERR_DEBUG | 39 | + * The TMP105 initially looks for a temperature rising above T_high; |
26 | -#define M25P80_ERR_DEBUG 0 | 40 | + * once this is detected, the condition it looks for next is the |
27 | -#endif | 41 | + * temperature falling below T_low. This flag is false when initially |
28 | - | 42 | + * looking for T_high, true when looking for T_low. |
29 | -#define DB_PRINT_L(level, ...) do { \ | 43 | + */ |
30 | - if (M25P80_ERR_DEBUG > (level)) { \ | 44 | + bool detect_falling; |
31 | - fprintf(stderr, ": %s: ", __func__); \ | 45 | }; |
32 | - fprintf(stderr, ## __VA_ARGS__); \ | 46 | |
33 | - } \ | 47 | #endif |
34 | -} while (0) | 48 | diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c |
35 | +#include "trace.h" | 49 | index XXXXXXX..XXXXXXX 100644 |
36 | 50 | --- a/hw/misc/tmp105.c | |
37 | /* Fields for FlashPartInfo->flags */ | 51 | +++ b/hw/misc/tmp105.c |
38 | 52 | @@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s) | |
39 | @@ -XXX,XX +XXX,XX @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd) | 53 | return; |
40 | abort(); | ||
41 | } | 54 | } |
42 | 55 | ||
43 | - DB_PRINT_L(0, "offset = %#x, len = %d\n", offset, len); | 56 | - if ((s->config >> 1) & 1) { /* TM */ |
44 | + trace_m25p80_flash_erase(s, offset, len); | 57 | - if (s->temperature >= s->limit[1]) |
45 | + | 58 | - s->alarm = 1; |
46 | if ((s->pi->flags & capa_to_assert) != capa_to_assert) { | 59 | - else if (s->temperature < s->limit[0]) |
47 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: %d erase size not supported by" | 60 | - s->alarm = 1; |
48 | " device\n", len); | 61 | + if (s->config >> 1 & 1) { |
49 | @@ -XXX,XX +XXX,XX @@ void flash_write8(Flash *s, uint32_t addr, uint8_t data) | 62 | + /* |
63 | + * TM == 1 : Interrupt mode. We signal Alert when the | ||
64 | + * temperature rises above T_high, and expect the guest to clear | ||
65 | + * it (eg by reading a device register). | ||
66 | + */ | ||
67 | + if (s->detect_falling) { | ||
68 | + if (s->temperature < s->limit[0]) { | ||
69 | + s->alarm = 1; | ||
70 | + s->detect_falling = false; | ||
71 | + } | ||
72 | + } else { | ||
73 | + if (s->temperature >= s->limit[1]) { | ||
74 | + s->alarm = 1; | ||
75 | + s->detect_falling = true; | ||
76 | + } | ||
77 | + } | ||
78 | } else { | ||
79 | - if (s->temperature >= s->limit[1]) | ||
80 | - s->alarm = 1; | ||
81 | - else if (s->temperature < s->limit[0]) | ||
82 | - s->alarm = 0; | ||
83 | + /* | ||
84 | + * TM == 0 : Comparator mode. We signal Alert when the temperature | ||
85 | + * rises above T_high, and stop signalling it when the temperature | ||
86 | + * falls below T_low. | ||
87 | + */ | ||
88 | + if (s->detect_falling) { | ||
89 | + if (s->temperature < s->limit[0]) { | ||
90 | + s->alarm = 0; | ||
91 | + s->detect_falling = false; | ||
92 | + } | ||
93 | + } else { | ||
94 | + if (s->temperature >= s->limit[1]) { | ||
95 | + s->alarm = 1; | ||
96 | + s->detect_falling = true; | ||
97 | + } | ||
98 | + } | ||
50 | } | 99 | } |
51 | 100 | ||
52 | if ((prev ^ data) & data) { | 101 | tmp105_interrupt_update(s); |
53 | - DB_PRINT_L(1, "programming zero to one! addr=%" PRIx32 " %" PRIx8 | 102 | @@ -XXX,XX +XXX,XX @@ static int tmp105_post_load(void *opaque, int version_id) |
54 | - " -> %" PRIx8 "\n", addr, prev, data); | ||
55 | + trace_m25p80_programming_zero_to_one(s, addr, prev, data); | ||
56 | } | ||
57 | |||
58 | if (s->pi->flags & EEPROM) { | ||
59 | @@ -XXX,XX +XXX,XX @@ static void complete_collecting_data(Flash *s) | ||
60 | |||
61 | s->state = STATE_IDLE; | ||
62 | |||
63 | + trace_m25p80_complete_collecting(s, s->cmd_in_progress, n, s->ear, | ||
64 | + s->cur_addr); | ||
65 | + | ||
66 | switch (s->cmd_in_progress) { | ||
67 | case DPP: | ||
68 | case QPP: | ||
69 | @@ -XXX,XX +XXX,XX @@ static void reset_memory(Flash *s) | ||
70 | break; | ||
71 | } | ||
72 | |||
73 | - DB_PRINT_L(0, "Reset done.\n"); | ||
74 | + trace_m25p80_reset_done(s); | ||
75 | } | ||
76 | |||
77 | static void decode_fast_read_cmd(Flash *s) | ||
78 | @@ -XXX,XX +XXX,XX @@ static void decode_qio_read_cmd(Flash *s) | ||
79 | |||
80 | static void decode_new_cmd(Flash *s, uint32_t value) | ||
81 | { | ||
82 | - s->cmd_in_progress = value; | ||
83 | int i; | ||
84 | - DB_PRINT_L(0, "decoded new command:%x\n", value); | ||
85 | + | ||
86 | + s->cmd_in_progress = value; | ||
87 | + trace_m25p80_command_decoded(s, value); | ||
88 | |||
89 | if (value != RESET_MEMORY) { | ||
90 | s->reset_enable = false; | ||
91 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
92 | break; | ||
93 | |||
94 | case JEDEC_READ: | ||
95 | - DB_PRINT_L(0, "populated jedec code\n"); | ||
96 | + trace_m25p80_populated_jedec(s); | ||
97 | for (i = 0; i < s->pi->id_len; i++) { | ||
98 | s->data[i] = s->pi->id[i]; | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
101 | case BULK_ERASE_60: | ||
102 | case BULK_ERASE: | ||
103 | if (s->write_enable) { | ||
104 | - DB_PRINT_L(0, "chip erase\n"); | ||
105 | + trace_m25p80_chip_erase(s); | ||
106 | flash_erase(s, 0, BULK_ERASE); | ||
107 | } else { | ||
108 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: chip erase with write " | ||
109 | @@ -XXX,XX +XXX,XX @@ static int m25p80_cs(SSISlave *ss, bool select) | ||
110 | s->data_read_loop = false; | ||
111 | } | ||
112 | |||
113 | - DB_PRINT_L(0, "%sselect\n", select ? "de" : ""); | ||
114 | + trace_m25p80_select(s, select ? "de" : ""); | ||
115 | |||
116 | return 0; | 103 | return 0; |
117 | } | 104 | } |
118 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | 105 | |
119 | Flash *s = M25P80(ss); | 106 | +static bool detect_falling_needed(void *opaque) |
120 | uint32_t r = 0; | 107 | +{ |
121 | 108 | + TMP105State *s = opaque; | |
122 | + trace_m25p80_transfer(s, s->state, s->len, s->needed_bytes, s->pos, | ||
123 | + s->cur_addr, (uint8_t)tx); | ||
124 | + | 109 | + |
125 | switch (s->state) { | 110 | + /* |
126 | 111 | + * We only need to migrate the detect_falling bool if it's set; | |
127 | case STATE_PAGE_PROGRAM: | 112 | + * for migration from older machines we assume that it is false |
128 | - DB_PRINT_L(1, "page program cur_addr=%#" PRIx32 " data=%" PRIx8 "\n", | 113 | + * (ie temperature is not out of range). |
129 | - s->cur_addr, (uint8_t)tx); | 114 | + */ |
130 | + trace_m25p80_page_program(s, s->cur_addr, (uint8_t)tx); | 115 | + return s->detect_falling; |
131 | flash_write8(s, s->cur_addr, (uint8_t)tx); | 116 | +} |
132 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | 117 | + |
133 | break; | 118 | +static const VMStateDescription vmstate_tmp105_detect_falling = { |
134 | 119 | + .name = "TMP105/detect-falling", | |
135 | case STATE_READ: | 120 | + .version_id = 1, |
136 | r = s->storage[s->cur_addr]; | 121 | + .minimum_version_id = 1, |
137 | - DB_PRINT_L(1, "READ 0x%" PRIx32 "=%" PRIx8 "\n", s->cur_addr, | 122 | + .needed = detect_falling_needed, |
138 | - (uint8_t)r); | 123 | + .fields = (VMStateField[]) { |
139 | + trace_m25p80_read_byte(s, s->cur_addr, (uint8_t)r); | 124 | + VMSTATE_BOOL(detect_falling, TMP105State), |
140 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | 125 | + VMSTATE_END_OF_LIST() |
141 | break; | 126 | + } |
142 | 127 | +}; | |
143 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | 128 | + |
144 | } | 129 | static const VMStateDescription vmstate_tmp105 = { |
145 | 130 | .name = "TMP105", | |
146 | r = s->data[s->pos]; | 131 | .version_id = 0, |
147 | + trace_m25p80_read_data(s, s->pos, (uint8_t)r); | 132 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = { |
148 | s->pos++; | 133 | VMSTATE_UINT8(alarm, TMP105State), |
149 | if (s->pos == s->len) { | 134 | VMSTATE_I2C_SLAVE(i2c, TMP105State), |
150 | s->pos = 0; | 135 | VMSTATE_END_OF_LIST() |
151 | @@ -XXX,XX +XXX,XX @@ static void m25p80_realize(SSISlave *ss, Error **errp) | 136 | + }, |
152 | return; | 137 | + .subsections = (const VMStateDescription*[]) { |
153 | } | 138 | + &vmstate_tmp105_detect_falling, |
154 | 139 | + NULL | |
155 | - DB_PRINT_L(0, "Binding to IF_MTD drive\n"); | ||
156 | + trace_m25p80_binding(s); | ||
157 | s->storage = blk_blockalign(s->blk, s->size); | ||
158 | |||
159 | if (blk_pread(s->blk, 0, s->storage, s->size) != s->size) { | ||
160 | @@ -XXX,XX +XXX,XX @@ static void m25p80_realize(SSISlave *ss, Error **errp) | ||
161 | return; | ||
162 | } | ||
163 | } else { | ||
164 | - DB_PRINT_L(0, "No BDRV - binding to RAM\n"); | ||
165 | + trace_m25p80_binding_no_bdrv(s); | ||
166 | s->storage = blk_blockalign(NULL, s->size); | ||
167 | memset(s->storage, 0xFF, s->size); | ||
168 | } | 140 | } |
169 | diff --git a/hw/block/trace-events b/hw/block/trace-events | 141 | }; |
170 | index XXXXXXX..XXXXXXX 100644 | 142 | |
171 | --- a/hw/block/trace-events | 143 | @@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c) |
172 | +++ b/hw/block/trace-events | 144 | s->config = 0; |
173 | @@ -XXX,XX +XXX,XX @@ xen_block_blockdev_add(char *str) "%s" | 145 | s->faults = tmp105_faultq[(s->config >> 3) & 3]; |
174 | xen_block_blockdev_del(const char *node_name) "%s" | 146 | s->alarm = 0; |
175 | xen_block_device_create(unsigned int number) "%u" | 147 | + s->detect_falling = false; |
176 | xen_block_device_destroy(unsigned int number) "%u" | 148 | |
177 | + | 149 | s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */ |
178 | +# m25p80.c | 150 | s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */ |
179 | +m25p80_flash_erase(void *s, int offset, uint32_t len) "[%p] offset = 0x%"PRIx32", len = %u" | ||
180 | +m25p80_programming_zero_to_one(void *s, uint32_t addr, uint8_t prev, uint8_t data) "[%p] programming zero to one! addr=0x%"PRIx32" 0x%"PRIx8" -> 0x%"PRIx8 | ||
181 | +m25p80_reset_done(void *s) "[%p] Reset done." | ||
182 | +m25p80_command_decoded(void *s, uint32_t cmd) "[%p] new command:0x%"PRIx32 | ||
183 | +m25p80_complete_collecting(void *s, uint32_t cmd, int n, uint8_t ear, uint32_t cur_addr) "[%p] decode cmd: 0x%"PRIx32" len %d ear 0x%"PRIx8" addr 0x%"PRIx32 | ||
184 | +m25p80_populated_jedec(void *s) "[%p] populated jedec code" | ||
185 | +m25p80_chip_erase(void *s) "[%p] chip erase" | ||
186 | +m25p80_select(void *s, const char *what) "[%p] %sselect" | ||
187 | +m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_addr=0x%"PRIx32" data=0x%"PRIx8 | ||
188 | +m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8 | ||
189 | +m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8 | ||
190 | +m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8 | ||
191 | +m25p80_binding(void *s) "[%p] Binding to IF_MTD drive" | ||
192 | +m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM" | ||
193 | -- | 151 | -- |
194 | 2.20.1 | 152 | 2.20.1 |
195 | 153 | ||
196 | 154 | diff view generated by jsdifflib |