1 | v2: dropped a couple of cadence_gem changes to ID regs that | 1 | Last handful of arm patches before softfreeze... |
---|---|---|---|
2 | caused new clang sanitizer warnings. | ||
3 | 2 | ||
4 | -- PMM | 3 | The following changes since commit a98135f727595382e200d04c2996e868b7925a01: |
5 | 4 | ||
6 | The following changes since commit dddb37495b844270088e68e3bf30b764d48d863f: | 5 | Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000) |
7 | |||
8 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20181015.0' into staging (2018-10-15 18:44:04 +0100) | ||
9 | 6 | ||
10 | are available in the Git repository at: | 7 | are available in the Git repository at: |
11 | 8 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181016-1 | 9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200317 |
13 | 10 | ||
14 | for you to fetch changes up to 2ef297af07196c29446556537861f8e7dfeeae7b: | 11 | for you to fetch changes up to e88d3671e3bbd59d385838a4101ea19cdcf47309: |
15 | 12 | ||
16 | coccinelle: new inplace-byteswaps.cocci to remove inplace-byteswapping calls (2018-10-16 17:14:55 +0100) | 13 | hw/arm/pxa2xx: Do not wire up OHCI for PXA255 (2020-03-17 11:36:48 +0000) |
17 | 14 | ||
18 | ---------------------------------------------------------------- | 15 | ---------------------------------------------------------------- |
19 | target-arm queue: | 16 | target-arm: |
20 | * hw/arm/virt: add DT property /secure-chosen/stdout-path indicating secure UART | 17 | * hw/arm/pxa2xx: Do not wire up OHCI for PXA255 |
21 | * target/arm: Fix aarch64_sve_change_el wrt EL0 | 18 | * aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command |
22 | * target/arm: Define fields of ISAR registers | 19 | * m25p80: Improve command handling for Jedec and unsupported commands |
23 | * target/arm: Align cortex-r5 id_isar0 | 20 | * hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() |
24 | * target/arm: Fix cortex-a7 id_isar0 | 21 | * hw/arm/fsl-imx6, imx6ul: Wire up USB controllers |
25 | * net/cadence_gem: Fix various bugs, add support for new | 22 | * hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices |
26 | features that will be used by the Xilinx Versal board | ||
27 | * target-arm: powerctl: Enable HVC when starting CPUs to EL2 | ||
28 | * target/arm: Add the Cortex-A72 | ||
29 | * target/arm: Mark PMINTENCLR and PMINTENCLR_EL1 accesses as possibly doing IO | ||
30 | * target/arm: Mask PMOVSR writes based on supported counters | ||
31 | * target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write | ||
32 | * coccinelle: new inplace-byteswaps.cocci to remove inplace-byteswapping calls | ||
33 | 23 | ||
34 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
35 | Aaron Lindsay (2): | 25 | Chen Qun (1): |
36 | target/arm: Mark PMINTENCLR and PMINTENCLR_EL1 accesses as possibly doing IO | 26 | hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write() |
37 | target/arm: Mask PMOVSR writes based on supported counters | ||
38 | 27 | ||
39 | Edgar E. Iglesias (8): | 28 | Guenter Roeck (10): |
40 | net: cadence_gem: Disable TSU feature bit | 29 | hw/usb: Add basic i.MX USB Phy support |
41 | net: cadence_gem: Use uint32_t for 32bit descriptor words | 30 | hw/arm/fsl-imx6ul: Fix USB interrupt numbers |
42 | net: cadence_gem: Add macro with max number of descriptor words | 31 | hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices |
43 | net: cadence_gem: Add support for extended descriptors | 32 | hw/arm/fsl-imx6ul: Wire up USB controllers |
44 | net: cadence_gem: Add support for selecting the DMA MemoryRegion | 33 | hw/arm/fsl-imx6: Wire up USB controllers |
45 | net: cadence_gem: Implement support for 64bit descriptor addresses | 34 | m25p80: Convert to support tracing |
46 | target-arm: powerctl: Enable HVC when starting CPUs to EL2 | 35 | m25p80: Improve command handling for Jedec commands |
47 | target/arm: Add the Cortex-A72 | 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 | ||
48 | 39 | ||
49 | Jerome Forissier (1): | 40 | hw/usb/Makefile.objs | 2 + |
50 | hw/arm/virt: add DT property /secure-chosen/stdout-path indicating secure UART | 41 | include/hw/arm/fsl-imx6.h | 6 ++ |
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 | ||
51 | 58 | ||
52 | Peter Maydell (2): | ||
53 | target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write | ||
54 | coccinelle: new inplace-byteswaps.cocci to remove inplace-byteswapping calls | ||
55 | |||
56 | Richard Henderson (4): | ||
57 | target/arm: Fix aarch64_sve_change_el wrt EL0 | ||
58 | target/arm: Define fields of ISAR registers | ||
59 | target/arm: Align cortex-r5 id_isar0 | ||
60 | target/arm: Fix cortex-a7 id_isar0 | ||
61 | |||
62 | include/hw/net/cadence_gem.h | 7 +- | ||
63 | target/arm/cpu.h | 95 ++++++++++++++- | ||
64 | hw/arm/virt.c | 4 + | ||
65 | hw/net/cadence_gem.c | 185 ++++++++++++++++++++--------- | ||
66 | target/arm/arm-powerctl.c | 10 ++ | ||
67 | target/arm/cpu.c | 7 +- | ||
68 | target/arm/cpu64.c | 66 +++++++++- | ||
69 | target/arm/helper.c | 27 +++-- | ||
70 | target/arm/op_helper.c | 6 +- | ||
71 | scripts/coccinelle/inplace-byteswaps.cocci | 65 ++++++++++ | ||
72 | 10 files changed, 402 insertions(+), 70 deletions(-) | ||
73 | create mode 100644 scripts/coccinelle/inplace-byteswaps.cocci | ||
74 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Guenter Roeck <linux@roeck-us.net> | |
2 | |||
3 | Add basic USB PHY support as implemented in i.MX23, i.MX28, i.MX6, | ||
4 | and i.MX7 SoCs. | ||
5 | |||
6 | The only support really needed - at least to boot Linux - is support | ||
7 | for soft reset, which needs to reset various registers to their initial | ||
8 | value. Otherwise, just record register values. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
12 | Message-id: 20200313014551.12554-2-linux@roeck-us.net | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/usb/Makefile.objs | 2 + | ||
16 | include/hw/usb/imx-usb-phy.h | 53 +++++++++ | ||
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 | |||
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 | ||
339 | index XXXXXXX..XXXXXXX 100644 | ||
340 | --- a/hw/arm/Kconfig | ||
341 | +++ b/hw/arm/Kconfig | ||
342 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6 | ||
343 | select IMX | ||
344 | select IMX_FEC | ||
345 | select IMX_I2C | ||
346 | + select IMX_USBPHY | ||
347 | select SDHCI | ||
348 | |||
349 | config ASPEED_SOC | ||
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 | -- | ||
364 | 2.20.1 | ||
365 | |||
366 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | IMX6UL USB controllers are quite similar to IMX7 USB controllers. | ||
4 | Wire them up the same way. | ||
5 | |||
6 | The only real difference is that wiring up phy devices is necessary | ||
7 | to avoid phy reset timeouts in the Linux kernel. | ||
8 | |||
9 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
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 | ||
20 | --- a/include/hw/arm/fsl-imx6ul.h | ||
21 | +++ b/include/hw/arm/fsl-imx6ul.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "hw/sd/sdhci.h" | ||
24 | #include "hw/ssi/imx_spi.h" | ||
25 | #include "hw/net/imx_fec.h" | ||
26 | +#include "hw/usb/chipidea.h" | ||
27 | +#include "hw/usb/imx-usb-phy.h" | ||
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 | + | ||
88 | /* | ||
89 | * SDHCI | ||
90 | */ | ||
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 | -- | ||
121 | 2.20.1 | ||
122 | |||
123 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | With this patch, the USB controllers on 'sabrelite' are detected | ||
4 | and can be used to boot the system. | ||
5 | |||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
7 | Message-id: 20200313014551.12554-6-linux@roeck-us.net | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/fsl-imx6.h | 6 ++++++ | ||
12 | hw/arm/fsl-imx6.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 42 insertions(+) | ||
14 | |||
15 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/fsl-imx6.h | ||
18 | +++ b/include/hw/arm/fsl-imx6.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/sd/sdhci.h" | ||
21 | #include "hw/ssi/imx_spi.h" | ||
22 | #include "hw/net/imx_fec.h" | ||
23 | +#include "hw/usb/chipidea.h" | ||
24 | +#include "hw/usb/imx-usb-phy.h" | ||
25 | #include "exec/memory.h" | ||
26 | #include "cpu.h" | ||
27 | |||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | #define FSL_IMX6_NUM_ESDHCS 4 | ||
30 | #define FSL_IMX6_NUM_ECSPIS 5 | ||
31 | #define FSL_IMX6_NUM_WDTS 2 | ||
32 | +#define FSL_IMX6_NUM_USB_PHYS 2 | ||
33 | +#define FSL_IMX6_NUM_USBS 4 | ||
34 | |||
35 | typedef struct FslIMX6State { | ||
36 | /*< private >*/ | ||
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 | -- | ||
108 | 2.20.1 | ||
109 | |||
110 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Chen Qun <kuhn.chenqun@huawei.com> | ||
1 | 2 | ||
3 | The current code causes clang static code analyzer generate warning: | ||
4 | hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read | ||
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 | |||
14 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
15 | Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com> | ||
16 | Message-id: 20200313123242.13236-1-kuhn.chenqun@huawei.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/net/imx_fec.c | 6 ++++-- | ||
21 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
22 | |||
23 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/net/imx_fec.c | ||
26 | +++ b/hw/net/imx_fec.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value) | ||
28 | break; | ||
29 | case ENET_TGSR: | ||
30 | /* implement clear timer flag */ | ||
31 | - value = value & 0x0000000f; | ||
32 | + s->regs[index] &= ~(value & 0x0000000f); /* all bits W1C */ | ||
33 | break; | ||
34 | case ENET_TCSR0: | ||
35 | case ENET_TCSR1: | ||
36 | case ENET_TCSR2: | ||
37 | case ENET_TCSR3: | ||
38 | - value = value & 0x000000fd; | ||
39 | + s->regs[index] &= ~(value & 0x00000080); /* W1C bits */ | ||
40 | + s->regs[index] &= ~0x0000007d; /* writable fields */ | ||
41 | + s->regs[index] |= (value & 0x0000007d); | ||
42 | break; | ||
43 | case ENET_TCCR0: | ||
44 | case ENET_TCCR1: | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | While at it, add some trace messages to help debug problems | ||
4 | seen when running the latest Linux kernel. | ||
5 | |||
6 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/block/m25p80.c | 48 ++++++++++++++++++++----------------------- | ||
13 | hw/block/trace-events | 16 +++++++++++++++ | ||
14 | 2 files changed, 38 insertions(+), 26 deletions(-) | ||
15 | |||
16 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/block/m25p80.c | ||
19 | +++ b/hw/block/m25p80.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "qemu/module.h" | ||
22 | #include "qemu/error-report.h" | ||
23 | #include "qapi/error.h" | ||
24 | - | ||
25 | -#ifndef M25P80_ERR_DEBUG | ||
26 | -#define M25P80_ERR_DEBUG 0 | ||
27 | -#endif | ||
28 | - | ||
29 | -#define DB_PRINT_L(level, ...) do { \ | ||
30 | - if (M25P80_ERR_DEBUG > (level)) { \ | ||
31 | - fprintf(stderr, ": %s: ", __func__); \ | ||
32 | - fprintf(stderr, ## __VA_ARGS__); \ | ||
33 | - } \ | ||
34 | -} while (0) | ||
35 | +#include "trace.h" | ||
36 | |||
37 | /* Fields for FlashPartInfo->flags */ | ||
38 | |||
39 | @@ -XXX,XX +XXX,XX @@ static void flash_erase(Flash *s, int offset, FlashCMD cmd) | ||
40 | abort(); | ||
41 | } | ||
42 | |||
43 | - DB_PRINT_L(0, "offset = %#x, len = %d\n", offset, len); | ||
44 | + trace_m25p80_flash_erase(s, offset, len); | ||
45 | + | ||
46 | if ((s->pi->flags & capa_to_assert) != capa_to_assert) { | ||
47 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: %d erase size not supported by" | ||
48 | " device\n", len); | ||
49 | @@ -XXX,XX +XXX,XX @@ void flash_write8(Flash *s, uint32_t addr, uint8_t data) | ||
50 | } | ||
51 | |||
52 | if ((prev ^ data) & data) { | ||
53 | - DB_PRINT_L(1, "programming zero to one! addr=%" PRIx32 " %" PRIx8 | ||
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; | ||
117 | } | ||
118 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | ||
119 | Flash *s = M25P80(ss); | ||
120 | uint32_t r = 0; | ||
121 | |||
122 | + trace_m25p80_transfer(s, s->state, s->len, s->needed_bytes, s->pos, | ||
123 | + s->cur_addr, (uint8_t)tx); | ||
124 | + | ||
125 | switch (s->state) { | ||
126 | |||
127 | case STATE_PAGE_PROGRAM: | ||
128 | - DB_PRINT_L(1, "page program cur_addr=%#" PRIx32 " data=%" PRIx8 "\n", | ||
129 | - s->cur_addr, (uint8_t)tx); | ||
130 | + trace_m25p80_page_program(s, s->cur_addr, (uint8_t)tx); | ||
131 | flash_write8(s, s->cur_addr, (uint8_t)tx); | ||
132 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | ||
133 | break; | ||
134 | |||
135 | case STATE_READ: | ||
136 | r = s->storage[s->cur_addr]; | ||
137 | - DB_PRINT_L(1, "READ 0x%" PRIx32 "=%" PRIx8 "\n", s->cur_addr, | ||
138 | - (uint8_t)r); | ||
139 | + trace_m25p80_read_byte(s, s->cur_addr, (uint8_t)r); | ||
140 | s->cur_addr = (s->cur_addr + 1) & (s->size - 1); | ||
141 | break; | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSISlave *ss, uint32_t tx) | ||
144 | } | ||
145 | |||
146 | r = s->data[s->pos]; | ||
147 | + trace_m25p80_read_data(s, s->pos, (uint8_t)r); | ||
148 | s->pos++; | ||
149 | if (s->pos == s->len) { | ||
150 | s->pos = 0; | ||
151 | @@ -XXX,XX +XXX,XX @@ static void m25p80_realize(SSISlave *ss, Error **errp) | ||
152 | return; | ||
153 | } | ||
154 | |||
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 | } | ||
169 | diff --git a/hw/block/trace-events b/hw/block/trace-events | ||
170 | index XXXXXXX..XXXXXXX 100644 | ||
171 | --- a/hw/block/trace-events | ||
172 | +++ b/hw/block/trace-events | ||
173 | @@ -XXX,XX +XXX,XX @@ xen_block_blockdev_add(char *str) "%s" | ||
174 | xen_block_blockdev_del(const char *node_name) "%s" | ||
175 | xen_block_device_create(unsigned int number) "%u" | ||
176 | xen_block_device_destroy(unsigned int number) "%u" | ||
177 | + | ||
178 | +# m25p80.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 | -- | ||
194 | 2.20.1 | ||
195 | |||
196 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | When requesting JEDEC data using the JEDEC_READ command, the Linux kernel | ||
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 | |||
10 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/block/m25p80.c | 5 ++++- | ||
17 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
18 | |||
19 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/block/m25p80.c | ||
22 | +++ b/hw/block/m25p80.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
24 | for (i = 0; i < s->pi->id_len; i++) { | ||
25 | s->data[i] = s->pi->id[i]; | ||
26 | } | ||
27 | + for (; i < SPI_NOR_MAX_ID_LEN; i++) { | ||
28 | + s->data[i] = 0; | ||
29 | + } | ||
30 | |||
31 | - s->len = s->pi->id_len; | ||
32 | + s->len = SPI_NOR_MAX_ID_LEN; | ||
33 | s->pos = 0; | ||
34 | s->state = STATE_READING_DATA; | ||
35 | break; | ||
36 | -- | ||
37 | 2.20.1 | ||
38 | |||
39 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | Whenever an unsupported command is encountered, the current code | ||
4 | interprets each transferred byte as new command. Most of the time, those | ||
5 | 'commands' are interpreted as new unknown commands. However, in rare | ||
6 | cases, it may be that for example address or length information | ||
7 | passed with the original command is by itself a valid command. | ||
8 | If that happens, the state machine may get completely confused and, | ||
9 | worst case, start writing data into the flash or even erase it. | ||
10 | |||
11 | To avoid the problem, transition into STATE_READING_DATA and keep | ||
12 | sending a value of 0 until the chip is deselected after encountering | ||
13 | an unsupported command. | ||
14 | |||
15 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
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 | ||
25 | --- a/hw/block/m25p80.c | ||
26 | +++ b/hw/block/m25p80.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | ||
28 | s->quad_enable = false; | ||
29 | break; | ||
30 | default: | ||
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 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | The Linux kernel recently started using FAST_READ_4 commands. | ||
4 | This results in flash read failures. At the same time, the m25p80 | ||
5 | emulation is seen to read 8 more bytes than expected. Adjusting the | ||
6 | expected number of dummy cycles to match FAST_READ fixes the problem. | ||
7 | |||
8 | Fixes: f95c4bffdc4c ("aspeed/smc: snoop SPI transfers to fake dummy cycles") | ||
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 | ||
19 | --- a/hw/ssi/aspeed_smc.c | ||
20 | +++ b/hw/ssi/aspeed_smc.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static int aspeed_smc_num_dummies(uint8_t command) | ||
22 | case FAST_READ: | ||
23 | case DOR: | ||
24 | case QOR: | ||
25 | + case FAST_READ_4: | ||
26 | case DOR_4: | ||
27 | case QOR_4: | ||
28 | return 1; | ||
29 | case DIOR: | ||
30 | - case FAST_READ_4: | ||
31 | case DIOR_4: | ||
32 | return 2; | ||
33 | case QIOR: | ||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
1 | 2 | ||
3 | PXA255 does not support a USB OHCI controller, so don't wire it up. | ||
4 | |||
5 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
6 | Message-id: 20200313160215.28155-1-linux@roeck-us.net | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/pxa2xx.c | 3 --- | ||
11 | 1 file changed, 3 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/pxa2xx.c | ||
16 | +++ b/hw/arm/pxa2xx.c | ||
17 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) | ||
18 | s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi"); | ||
19 | } | ||
20 | |||
21 | - sysbus_create_simple("sysbus-ohci", 0x4c000000, | ||
22 | - qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1)); | ||
23 | - | ||
24 | s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000); | ||
25 | s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000); | ||
26 | |||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |