1
Last handful of arm patches before softfreeze...
1
arm pullreq for rc1. All minor bugfixes, except for the sve-default-vector-length
2
patches, which are somewhere between a bugfix and a new feature.
2
3
3
The following changes since commit a98135f727595382e200d04c2996e868b7925a01:
4
thanks
5
-- PMM
4
6
5
Merge remote-tracking branch 'remotes/kraxel/tags/vga-20200316-pull-request' into staging (2020-03-16 14:55:59 +0000)
7
The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a:
8
9
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100)
6
10
7
are available in the Git repository at:
11
are available in the Git repository at:
8
12
9
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200317
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727
10
14
11
for you to fetch changes up to e88d3671e3bbd59d385838a4101ea19cdcf47309:
15
for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749:
12
16
13
hw/arm/pxa2xx: Do not wire up OHCI for PXA255 (2020-03-17 11:36:48 +0000)
17
hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100)
14
18
15
----------------------------------------------------------------
19
----------------------------------------------------------------
16
target-arm:
20
target-arm queue:
17
* hw/arm/pxa2xx: Do not wire up OHCI for PXA255
21
* hw/arm/smmuv3: Check 31st bit to see if CD is valid
18
* aspeed/smc: Fix number of dummy cycles for FAST_READ_4 command
22
* qemu-options.hx: Fix formatting of -machine memory-backend option
19
* m25p80: Improve command handling for Jedec and unsupported commands
23
* hw: aspeed_gpio: Fix memory size
20
* hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()
24
* hw/arm/nseries: Display hexadecimal value with '0x' prefix
21
* hw/arm/fsl-imx6, imx6ul: Wire up USB controllers
25
* Add sve-default-vector-length cpu property
22
* hw/arm/fsl-imx6ul: Instantiate unimplemented pwm and can devices
26
* docs: Update path that mentions deprecated.rst
27
* hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS
28
* hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING
29
* hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts
30
* target/arm: Report M-profile alignment faults correctly to the guest
31
* target/arm: Add missing 'return's after calling v7m_exception_taken()
32
* target/arm: Enforce that M-profile SP low 2 bits are always zero
23
33
24
----------------------------------------------------------------
34
----------------------------------------------------------------
25
Chen Qun (1):
35
Joe Komlodi (1):
26
hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()
36
hw/arm/smmuv3: Check 31st bit to see if CD is valid
27
37
28
Guenter Roeck (10):
38
Joel Stanley (1):
29
hw/usb: Add basic i.MX USB Phy support
39
hw: aspeed_gpio: Fix memory size
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
40
40
hw/usb/Makefile.objs | 2 +
41
Mao Zhongyi (1):
41
include/hw/arm/fsl-imx6.h | 6 ++
42
docs: Update path that mentions deprecated.rst
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
43
44
Peter Maydell (7):
45
qemu-options.hx: Fix formatting of -machine memory-backend option
46
target/arm: Enforce that M-profile SP low 2 bits are always zero
47
target/arm: Add missing 'return's after calling v7m_exception_taken()
48
target/arm: Report M-profile alignment faults correctly to the guest
49
hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts
50
hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING
51
hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS
52
53
Philippe Mathieu-Daudé (1):
54
hw/arm/nseries: Display hexadecimal value with '0x' prefix
55
56
Richard Henderson (3):
57
target/arm: Correctly bound length in sve_zcr_get_valid_len
58
target/arm: Export aarch64_sve_zcr_get_valid_len
59
target/arm: Add sve-default-vector-length cpu property
60
61
docs/system/arm/cpu-features.rst | 15 ++++++++++
62
configure | 2 +-
63
hw/arm/smmuv3-internal.h | 2 +-
64
target/arm/cpu.h | 5 ++++
65
target/arm/internals.h | 10 +++++++
66
hw/arm/nseries.c | 2 +-
67
hw/gpio/aspeed_gpio.c | 3 +-
68
hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++--------
69
target/arm/cpu.c | 14 ++++++++--
70
target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++
71
target/arm/gdbstub.c | 4 +++
72
target/arm/helper.c | 8 ++++--
73
target/arm/m_helper.c | 24 ++++++++++++----
74
target/arm/translate.c | 3 ++
75
target/i386/cpu.c | 2 +-
76
MAINTAINERS | 2 +-
77
qemu-options.hx | 30 +++++++++++---------
78
17 files changed, 183 insertions(+), 43 deletions(-)
79
diff view generated by jsdifflib
1
From: Chen Qun <kuhn.chenqun@huawei.com>
1
From: Joe Komlodi <joe.komlodi@xilinx.com>
2
2
3
The current code causes clang static code analyzer generate warning:
3
The bit to see if a CD is valid is the last bit of the first word of the CD.
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
4
11
According to the definition of the function, the two “value” assignments
5
Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>
12
should be written to registers.
6
Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com
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>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
9
---
20
hw/net/imx_fec.c | 6 ++++--
10
hw/arm/smmuv3-internal.h | 2 +-
21
1 file changed, 4 insertions(+), 2 deletions(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
22
12
23
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
13
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
24
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/net/imx_fec.c
15
--- a/hw/arm/smmuv3-internal.h
26
+++ b/hw/net/imx_fec.c
16
+++ b/hw/arm/smmuv3-internal.h
27
@@ -XXX,XX +XXX,XX @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)
17
@@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste)
28
break;
18
29
case ENET_TGSR:
19
/* CD fields */
30
/* implement clear timer flag */
20
31
- value = value & 0x0000000f;
21
-#define CD_VALID(x) extract32((x)->word[0], 30, 1)
32
+ s->regs[index] &= ~(value & 0x0000000f); /* all bits W1C */
22
+#define CD_VALID(x) extract32((x)->word[0], 31, 1)
33
break;
23
#define CD_ASID(x) extract32((x)->word[1], 16, 16)
34
case ENET_TCSR0:
24
#define CD_TTB(x, sel) \
35
case ENET_TCSR1:
25
({ \
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
--
26
--
46
2.20.1
27
2.20.1
47
28
48
29
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
The documentation of the -machine memory-backend has some minor
2
formatting errors:
3
* Misindentation of the initial line meant that the whole option
4
section is incorrectly indented in the HTML output compared to
5
the other -machine options
6
* The examples weren't indented, which meant that they were formatted
7
as plain run-on text including outputting the "::" as text.
8
* The a) b) list has no rst-format markup so it is rendered as
9
a single run-on paragraph
2
10
3
Whenever an unsupported command is encountered, the current code
11
Fix the formatting.
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
12
11
To avoid the problem, transition into STATE_READING_DATA and keep
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
sending a value of 0 until the chip is deselected after encountering
14
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
13
an unsupported command.
15
Message-id: 20210719105257.3599-1-peter.maydell@linaro.org
16
---
17
qemu-options.hx | 30 +++++++++++++++++-------------
18
1 file changed, 17 insertions(+), 13 deletions(-)
14
19
15
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
20
diff --git a/qemu-options.hx b/qemu-options.hx
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
21
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/block/m25p80.c
22
--- a/qemu-options.hx
26
+++ b/hw/block/m25p80.c
23
+++ b/qemu-options.hx
27
@@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value)
24
@@ -XXX,XX +XXX,XX @@ SRST
28
s->quad_enable = false;
25
Enables or disables ACPI Heterogeneous Memory Attribute Table
29
break;
26
(HMAT) support. The default is off.
30
default:
27
31
+ s->pos = 0;
28
- ``memory-backend='id'``
32
+ s->len = 1;
29
+ ``memory-backend='id'``
33
+ s->state = STATE_READING_DATA;
30
An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options.
34
+ s->data_read_loop = true;
31
Allows to use a memory backend as main RAM.
35
+ s->data[0] = 0;
32
36
qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value);
33
For example:
37
break;
34
::
38
}
35
- -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on
36
- -machine memory-backend=pc.ram
37
- -m 512M
38
+
39
+ -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on
40
+ -machine memory-backend=pc.ram
41
+ -m 512M
42
43
Migration compatibility note:
44
- a) as backend id one shall use value of 'default-ram-id', advertised by
45
- machine type (available via ``query-machines`` QMP command), if migration
46
- to/from old QEMU (<5.0) is expected.
47
- b) for machine types 4.0 and older, user shall
48
- use ``x-use-canonical-path-for-ramblock-id=off`` backend option
49
- if migration to/from old QEMU (<5.0) is expected.
50
+
51
+ * as backend id one shall use value of 'default-ram-id', advertised by
52
+ machine type (available via ``query-machines`` QMP command), if migration
53
+ to/from old QEMU (<5.0) is expected.
54
+ * for machine types 4.0 and older, user shall
55
+ use ``x-use-canonical-path-for-ramblock-id=off`` backend option
56
+ if migration to/from old QEMU (<5.0) is expected.
57
+
58
For example:
59
::
60
- -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off
61
- -machine memory-backend=pc.ram
62
- -m 512M
63
+
64
+ -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off
65
+ -machine memory-backend=pc.ram
66
+ -m 512M
67
ERST
68
69
HXCOMM Deprecated by -machine
39
--
70
--
40
2.20.1
71
2.20.1
41
72
42
73
diff view generated by jsdifflib
New patch
1
For M-profile, unlike A-profile, the low 2 bits of SP are defined to be
2
RES0H, which is to say that they must be hardwired to zero so that
3
guest attempts to write non-zero values to them are ignored.
1
4
5
Implement this behaviour by masking out the low bits:
6
* for writes to r13 by the gdbstub
7
* for writes to any of the various flavours of SP via MSR
8
* for writes to r13 via store_reg() in generated code
9
10
Note that all the direct uses of cpu_R[] in translate.c are in places
11
where the register is definitely not r13 (usually because that has
12
been checked for as an UNDEFINED or UNPREDICTABLE case and handled as
13
UNDEF).
14
15
All the other writes to regs[13] in C code are either:
16
* A-profile only code
17
* writes of values we can guarantee to be aligned, such as
18
- writes of previous-SP-value plus or minus a 4-aligned constant
19
- writes of the value in an SP limit register (which we already
20
enforce to be aligned)
21
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Message-id: 20210723162146.5167-2-peter.maydell@linaro.org
25
---
26
target/arm/gdbstub.c | 4 ++++
27
target/arm/m_helper.c | 14 ++++++++------
28
target/arm/translate.c | 3 +++
29
3 files changed, 15 insertions(+), 6 deletions(-)
30
31
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/gdbstub.c
34
+++ b/target/arm/gdbstub.c
35
@@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
36
37
if (n < 16) {
38
/* Core integer register. */
39
+ if (n == 13 && arm_feature(env, ARM_FEATURE_M)) {
40
+ /* M profile SP low bits are always 0 */
41
+ tmp &= ~3;
42
+ }
43
env->regs[n] = tmp;
44
return 4;
45
}
46
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/m_helper.c
49
+++ b/target/arm/m_helper.c
50
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
51
if (!env->v7m.secure) {
52
return;
53
}
54
- env->v7m.other_ss_msp = val;
55
+ env->v7m.other_ss_msp = val & ~3;
56
return;
57
case 0x89: /* PSP_NS */
58
if (!env->v7m.secure) {
59
return;
60
}
61
- env->v7m.other_ss_psp = val;
62
+ env->v7m.other_ss_psp = val & ~3;
63
return;
64
case 0x8a: /* MSPLIM_NS */
65
if (!env->v7m.secure) {
66
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
67
68
limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false];
69
70
+ val &= ~0x3;
71
+
72
if (val < limit) {
73
raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC());
74
}
75
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
76
break;
77
case 8: /* MSP */
78
if (v7m_using_psp(env)) {
79
- env->v7m.other_sp = val;
80
+ env->v7m.other_sp = val & ~3;
81
} else {
82
- env->regs[13] = val;
83
+ env->regs[13] = val & ~3;
84
}
85
break;
86
case 9: /* PSP */
87
if (v7m_using_psp(env)) {
88
- env->regs[13] = val;
89
+ env->regs[13] = val & ~3;
90
} else {
91
- env->v7m.other_sp = val;
92
+ env->v7m.other_sp = val & ~3;
93
}
94
break;
95
case 10: /* MSPLIM */
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/translate.c
99
+++ b/target/arm/translate.c
100
@@ -XXX,XX +XXX,XX @@ void store_reg(DisasContext *s, int reg, TCGv_i32 var)
101
*/
102
tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3);
103
s->base.is_jmp = DISAS_JUMP;
104
+ } else if (reg == 13 && arm_dc_feature(s, ARM_FEATURE_M)) {
105
+ /* For M-profile SP bits [1:0] are always zero */
106
+ tcg_gen_andi_i32(var, var, ~3);
107
}
108
tcg_gen_mov_i32(cpu_R[reg], var);
109
tcg_temp_free_i32(var);
110
--
111
2.20.1
112
113
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
In do_v7m_exception_exit(), we perform various checks as part of
2
performing the exception return. If one of these checks fails, the
3
architecture requires that we take an appropriate exception on the
4
existing stackframe. We implement this by calling
5
v7m_exception_taken() to set up to take the new exception, and then
6
immediately returning from do_v7m_exception_exit() without proceeding
7
any further with the unstack-and-exception-return process.
2
8
3
When requesting JEDEC data using the JEDEC_READ command, the Linux kernel
9
In a couple of checks that are new in v8.1M, we forgot the "return"
4
always requests 6 bytes. The current implementation only returns three
10
statement, with the effect that if bad code in the guest tripped over
5
bytes, and interprets the remaining three bytes as new commands.
11
these checks we would set up to take a UsageFault exception but then
6
While this does not matter most of the time, it is at the very least
12
blunder on trying to also unstack and return from the original
7
confusing. To avoid the problem, always report up to 6 bytes of JEDEC
13
exception, with the probable result that the guest would crash.
8
data. Fill remaining data with 0.
9
14
10
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
15
Add the missing return statements.
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
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>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20210723162146.5167-3-peter.maydell@linaro.org
15
---
20
---
16
hw/block/m25p80.c | 5 ++++-
21
target/arm/m_helper.c | 2 ++
17
1 file changed, 4 insertions(+), 1 deletion(-)
22
1 file changed, 2 insertions(+)
18
23
19
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
24
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
20
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/block/m25p80.c
26
--- a/target/arm/m_helper.c
22
+++ b/hw/block/m25p80.c
27
+++ b/target/arm/m_helper.c
23
@@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value)
28
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
24
for (i = 0; i < s->pi->id_len; i++) {
29
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
25
s->data[i] = s->pi->id[i];
30
"stackframe: NSACR prevents clearing FPU registers\n");
26
}
31
v7m_exception_taken(cpu, excret, true, false);
27
+ for (; i < SPI_NOR_MAX_ID_LEN; i++) {
32
+ return;
28
+ s->data[i] = 0;
33
} else if (!cpacr_pass) {
29
+ }
34
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
30
35
exc_secure);
31
- s->len = s->pi->id_len;
36
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
32
+ s->len = SPI_NOR_MAX_ID_LEN;
37
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
33
s->pos = 0;
38
"stackframe: CPACR prevents clearing FPU registers\n");
34
s->state = STATE_READING_DATA;
39
v7m_exception_taken(cpu, excret, true, false);
35
break;
40
+ return;
41
}
42
}
43
/* Clear s0..s15, FPSCR and VPR */
36
--
44
--
37
2.20.1
45
2.20.1
38
46
39
47
diff view generated by jsdifflib
New patch
1
For M-profile, we weren't reporting alignment faults triggered by the
2
generic TCG code correctly to the guest. These get passed into
3
arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile
4
style exception.fsr value of 1. We didn't check for this, and so
5
they fell through into the default of "assume this is an MPU fault"
6
and were reported to the guest as a data access violation MPU fault.
1
7
8
Report these alignment faults as UsageFaults which set the UNALIGNED
9
bit in the UFSR.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20210723162146.5167-4-peter.maydell@linaro.org
14
---
15
target/arm/m_helper.c | 8 ++++++++
16
1 file changed, 8 insertions(+)
17
18
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/m_helper.c
21
+++ b/target/arm/m_helper.c
22
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
23
env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
24
break;
25
case EXCP_UNALIGNED:
26
+ /* Unaligned faults reported by M-profile aware code */
27
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
28
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK;
29
break;
30
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
31
}
32
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
33
break;
34
+ case 0x1: /* Alignment fault reported by generic code */
35
+ qemu_log_mask(CPU_LOG_INT,
36
+ "...really UsageFault with UFSR.UNALIGNED\n");
37
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK;
38
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
39
+ env->v7m.secure);
40
+ break;
41
default:
42
/*
43
* All other FSR values are either MPU faults or "can't happen
44
--
45
2.20.1
46
47
diff view generated by jsdifflib
New patch
1
The ISCR.ISRPENDING bit is set when an external interrupt is pending.
2
This is true whether that external interrupt is enabled or not.
3
This means that we can't use 's->vectpending == 0' as a shortcut to
4
"ISRPENDING is zero", because s->vectpending indicates only the
5
highest priority pending enabled interrupt.
1
6
7
Remove the incorrect optimization so that if there is no pending
8
enabled interrupt we fall through to scanning through the whole
9
interrupt array.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20210723162146.5167-5-peter.maydell@linaro.org
14
---
15
hw/intc/armv7m_nvic.c | 9 ++++-----
16
1 file changed, 4 insertions(+), 5 deletions(-)
17
18
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/armv7m_nvic.c
21
+++ b/hw/intc/armv7m_nvic.c
22
@@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s)
23
{
24
int irq;
25
26
- /* We can shortcut if the highest priority pending interrupt
27
- * happens to be external or if there is nothing pending.
28
+ /*
29
+ * We can shortcut if the highest priority pending interrupt
30
+ * happens to be external; if not we need to check the whole
31
+ * vectors[] array.
32
*/
33
if (s->vectpending > NVIC_FIRST_IRQ) {
34
return true;
35
}
36
- if (s->vectpending == 0) {
37
- return false;
38
- }
39
40
for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) {
41
if (s->vectors[irq].pending) {
42
--
43
2.20.1
44
45
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of
2
the register. We were incorrectly masking it to 8 bits, so it would
3
report the wrong value if the pending exception was greater than 256.
4
Fix the bug.
2
5
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210723162146.5167-6-peter.maydell@linaro.org
13
---
9
---
14
hw/ssi/aspeed_smc.c | 2 +-
10
hw/intc/armv7m_nvic.c | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
16
12
17
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
13
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
18
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/ssi/aspeed_smc.c
15
--- a/hw/intc/armv7m_nvic.c
20
+++ b/hw/ssi/aspeed_smc.c
16
+++ b/hw/intc/armv7m_nvic.c
21
@@ -XXX,XX +XXX,XX @@ static int aspeed_smc_num_dummies(uint8_t command)
17
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
22
case FAST_READ:
18
/* VECTACTIVE */
23
case DOR:
19
val = cpu->env.v7m.exception;
24
case QOR:
20
/* VECTPENDING */
25
+ case FAST_READ_4:
21
- val |= (s->vectpending & 0xff) << 12;
26
case DOR_4:
22
+ val |= (s->vectpending & 0x1ff) << 12;
27
case QOR_4:
23
/* ISRPENDING - set if any external IRQ is pending */
28
return 1;
24
if (nvic_isrpending(s)) {
29
case DIOR:
25
val |= (1 << 22);
30
- case FAST_READ_4:
31
case DIOR_4:
32
return 2;
33
case QIOR:
34
--
26
--
35
2.20.1
27
2.20.1
36
28
37
29
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if
2
the register is accessed NonSecure and the highest priority pending
3
enabled exception (that would be returned in the VECTPENDING field)
4
targets Secure, then the VECTPENDING field must read 1 rather than
5
the exception number of the pending exception. Implement this.
2
6
3
Recent Linux kernels (post v4.20) crash due to accesses to flexcan
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
and pwm controllers. Instantiate as unimplemented devices to work
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
around the problem.
9
Message-id: 20210723162146.5167-7-peter.maydell@linaro.org
10
---
11
hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++-------
12
1 file changed, 24 insertions(+), 7 deletions(-)
6
13
7
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
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
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/fsl-imx6ul.c
16
--- a/hw/intc/armv7m_nvic.c
18
+++ b/hw/arm/fsl-imx6ul.c
17
+++ b/hw/intc/armv7m_nvic.c
19
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
18
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque)
20
*/
19
nvic_irq_update(s);
21
create_unimplemented_device("sdma", FSL_IMX6UL_SDMA_ADDR, 0x4000);
20
}
22
21
23
+ /*
22
+static bool vectpending_targets_secure(NVICState *s)
24
+ * PWM
23
+{
25
+ */
24
+ /* Return true if s->vectpending targets Secure state */
26
+ create_unimplemented_device("pwm1", FSL_IMX6UL_PWM1_ADDR, 0x4000);
25
+ if (s->vectpending_is_s_banked) {
27
+ create_unimplemented_device("pwm2", FSL_IMX6UL_PWM2_ADDR, 0x4000);
26
+ return true;
28
+ create_unimplemented_device("pwm3", FSL_IMX6UL_PWM3_ADDR, 0x4000);
27
+ }
29
+ create_unimplemented_device("pwm4", FSL_IMX6UL_PWM4_ADDR, 0x4000);
28
+ return !exc_is_banked(s->vectpending) &&
29
+ exc_targets_secure(s, s->vectpending);
30
+}
30
+
31
+
31
+ /*
32
void armv7m_nvic_get_pending_irq_info(void *opaque,
32
+ * CAN
33
int *pirq, bool *ptargets_secure)
33
+ */
34
{
34
+ create_unimplemented_device("can1", FSL_IMX6UL_CAN1_ADDR, 0x4000);
35
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque,
35
+ create_unimplemented_device("can2", FSL_IMX6UL_CAN2_ADDR, 0x4000);
36
36
+
37
assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq);
37
/*
38
38
* APHB_DMA
39
- if (s->vectpending_is_s_banked) {
39
*/
40
- targets_secure = true;
41
- } else {
42
- targets_secure = !exc_is_banked(pending) &&
43
- exc_targets_secure(s, pending);
44
- }
45
+ targets_secure = vectpending_targets_secure(s);
46
47
trace_nvic_get_pending_irq_info(pending, targets_secure);
48
49
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
50
/* VECTACTIVE */
51
val = cpu->env.v7m.exception;
52
/* VECTPENDING */
53
- val |= (s->vectpending & 0x1ff) << 12;
54
+ if (s->vectpending) {
55
+ /*
56
+ * From v8.1M VECTPENDING must read as 1 if accessed as
57
+ * NonSecure and the highest priority pending and enabled
58
+ * exception targets Secure.
59
+ */
60
+ int vp = s->vectpending;
61
+ if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) &&
62
+ vectpending_targets_secure(s)) {
63
+ vp = 1;
64
+ }
65
+ val |= (vp & 0x1ff) << 12;
66
+ }
67
/* ISRPENDING - set if any external IRQ is pending */
68
if (nvic_isrpending(s)) {
69
val |= (1 << 22);
40
--
70
--
41
2.20.1
71
2.20.1
42
72
43
73
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
2
2
3
Add basic USB PHY support as implemented in i.MX23, i.MX28, i.MX6,
3
Missed in commit f3478392 "docs: Move deprecation, build
4
and i.MX7 SoCs.
4
and license info out of system/"
5
5
6
The only support really needed - at least to boot Linux - is support
6
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
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>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
8
Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com
12
Message-id: 20200313014551.12554-2-linux@roeck-us.net
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
10
---
15
hw/usb/Makefile.objs | 2 +
11
configure | 2 +-
16
include/hw/usb/imx-usb-phy.h | 53 +++++++++
12
target/i386/cpu.c | 2 +-
17
hw/usb/imx-usb-phy.c | 225 +++++++++++++++++++++++++++++++++++
13
MAINTAINERS | 2 +-
18
MAINTAINERS | 2 +
14
3 files changed, 3 insertions(+), 3 deletions(-)
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
15
25
diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs
16
diff --git a/configure b/configure
17
index XXXXXXX..XXXXXXX 100755
18
--- a/configure
19
+++ b/configure
20
@@ -XXX,XX +XXX,XX @@ fi
21
22
if test -n "${deprecated_features}"; then
23
echo "Warning, deprecated features enabled."
24
- echo "Please see docs/system/deprecated.rst"
25
+ echo "Please see docs/about/deprecated.rst"
26
echo " features: ${deprecated_features}"
27
fi
28
29
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
26
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/usb/Makefile.objs
31
--- a/target/i386/cpu.c
28
+++ b/hw/usb/Makefile.objs
32
+++ b/target/i386/cpu.c
29
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XEN) += xen-usb.o
33
@@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = {
30
xen-usb.o-cflags := $(LIBUSB_CFLAGS)
34
* none", but this is just for compatibility while libvirt isn't
31
xen-usb.o-libs := $(LIBUSB_LIBS)
35
* adapted to resolve CPU model versions before creating VMs.
32
endif
36
* See "Runnability guarantee of CPU models" at
33
+
37
- * docs/system/deprecated.rst.
34
+common-obj-$(CONFIG_IMX_USBPHY) += imx-usb-phy.o
38
+ * docs/about/deprecated.rst.
35
diff --git a/include/hw/usb/imx-usb-phy.h b/include/hw/usb/imx-usb-phy.h
39
*/
36
new file mode 100644
40
X86CPUVersion default_cpu_version = 1;
37
index XXXXXXX..XXXXXXX
41
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
42
diff --git a/MAINTAINERS b/MAINTAINERS
326
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
327
--- a/MAINTAINERS
44
--- a/MAINTAINERS
328
+++ b/MAINTAINERS
45
+++ b/MAINTAINERS
329
@@ -XXX,XX +XXX,XX @@ F: hw/arm/sabrelite.c
46
@@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/*
330
F: hw/arm/fsl-imx6.c
47
331
F: hw/misc/imx6_*.c
48
Incompatible changes
332
F: hw/ssi/imx_spi.c
49
R: libvir-list@redhat.com
333
+F: hw/usb/imx-usb-phy.c
50
-F: docs/system/deprecated.rst
334
+F: include/hw/usb/imx-usb-phy.h
51
+F: docs/about/deprecated.rst
335
F: include/hw/arm/fsl-imx6.h
52
336
F: include/hw/misc/imx6_*.h
53
Build System
337
F: include/hw/ssi/imx_spi.h
54
------------
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
--
55
--
364
2.20.1
56
2.20.1
365
57
366
58
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
USB1 and USB2 interrupt numbers were swapped. USB_PHY2 interrupt number
3
Currently, our only caller is sve_zcr_len_for_el, which has
4
is 45. That didn't really matter up to now since the interrupts were not
4
already masked the length extracted from ZCR_ELx, so the
5
used, but it needs to be fixed to be able to wire up the USB controllers.
5
masking done here is a nop. But we will shortly have uses
6
from other locations, where the length will be unmasked.
6
7
7
Fixes: 31cbf933f0e ("i.MX6UL: Add i.MX6UL SOC")
8
Saturate the length to ARM_MAX_VQ instead of truncating to
8
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
9
the low 4 bits.
9
Message-id: 20200313014551.12554-3-linux@roeck-us.net
10
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20210723203344.968563-2-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
15
---
13
include/hw/arm/fsl-imx6ul.h | 6 +++---
16
target/arm/helper.c | 4 +++-
14
1 file changed, 3 insertions(+), 3 deletions(-)
17
1 file changed, 3 insertions(+), 1 deletion(-)
15
18
16
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/fsl-imx6ul.h
21
--- a/target/arm/helper.c
19
+++ b/include/hw/arm/fsl-imx6ul.h
22
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ enum FslIMX6ULIRQs {
23
@@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len)
21
FSL_IMX6UL_UART7_IRQ = 39,
24
{
22
FSL_IMX6UL_UART8_IRQ = 40,
25
uint32_t end_len;
23
26
24
- FSL_IMX6UL_USB1_IRQ = 42,
27
- end_len = start_len &= 0xf;
25
- FSL_IMX6UL_USB2_IRQ = 43,
28
+ start_len = MIN(start_len, ARM_MAX_VQ - 1);
26
+ FSL_IMX6UL_USB1_IRQ = 43,
29
+ end_len = start_len;
27
+ FSL_IMX6UL_USB2_IRQ = 42,
30
+
28
FSL_IMX6UL_USB_PHY1_IRQ = 44,
31
if (!test_bit(start_len, cpu->sve_vq_map)) {
29
- FSL_IMX6UL_USB_PHY2_IRQ = 44,
32
end_len = find_last_bit(cpu->sve_vq_map, start_len);
30
+ FSL_IMX6UL_USB_PHY2_IRQ = 45,
33
assert(end_len < start_len);
31
32
FSL_IMX6UL_CAAM_JQ2_IRQ = 46,
33
FSL_IMX6UL_CAAM_ERR_IRQ = 47,
34
--
34
--
35
2.20.1
35
2.20.1
36
36
37
37
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
PXA255 does not support a USB OHCI controller, so don't wire it up.
3
Rename from sve_zcr_get_valid_len and make accessible
4
from outside of helper.c.
4
5
5
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200313160215.28155-1-linux@roeck-us.net
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20210723203344.968563-3-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
hw/arm/pxa2xx.c | 3 ---
11
target/arm/internals.h | 10 ++++++++++
11
1 file changed, 3 deletions(-)
12
target/arm/helper.c | 4 ++--
13
2 files changed, 12 insertions(+), 2 deletions(-)
12
14
13
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
15
diff --git a/target/arm/internals.h b/target/arm/internals.h
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/pxa2xx.c
17
--- a/target/arm/internals.h
16
+++ b/hw/arm/pxa2xx.c
18
+++ b/target/arm/internals.h
17
@@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
19
@@ -XXX,XX +XXX,XX @@ void arm_translate_init(void);
18
s->ssp[i] = (SSIBus *)qdev_get_child_bus(dev, "ssi");
20
void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);
21
#endif /* CONFIG_TCG */
22
23
+/**
24
+ * aarch64_sve_zcr_get_valid_len:
25
+ * @cpu: cpu context
26
+ * @start_len: maximum len to consider
27
+ *
28
+ * Return the maximum supported sve vector length <= @start_len.
29
+ * Note that both @start_len and the return value are in units
30
+ * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128.
31
+ */
32
+uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len);
33
34
enum arm_fprounding {
35
FPROUNDING_TIEEVEN,
36
diff --git a/target/arm/helper.c b/target/arm/helper.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/helper.c
39
+++ b/target/arm/helper.c
40
@@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el)
41
return 0;
42
}
43
44
-static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len)
45
+uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len)
46
{
47
uint32_t end_len;
48
49
@@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el)
50
zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]);
19
}
51
}
20
52
21
- sysbus_create_simple("sysbus-ohci", 0x4c000000,
53
- return sve_zcr_get_valid_len(cpu, zcr_len);
22
- qdev_get_gpio_in(s->pic, PXA2XX_PIC_USBH1));
54
+ return aarch64_sve_zcr_get_valid_len(cpu, zcr_len);
23
-
55
}
24
s->pcmcia[0] = pxa2xx_pcmcia_init(address_space, 0x20000000);
56
25
s->pcmcia[1] = pxa2xx_pcmcia_init(address_space, 0x30000000);
57
static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
26
27
--
58
--
28
2.20.1
59
2.20.1
29
60
30
61
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
IMX6UL USB controllers are quite similar to IMX7 USB controllers.
3
Mirror the behavour of /proc/sys/abi/sve_default_vector_length
4
Wire them up the same way.
4
under the real linux kernel. We have no way of passing along
5
a real default across exec like the kernel can, but this is a
6
decent way of adjusting the startup vector length of a process.
5
7
6
The only real difference is that wiring up phy devices is necessary
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482
7
to avoid phy reset timeouts in the Linux kernel.
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
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>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20210723203344.968563-4-richard.henderson@linaro.org
12
[PMM: tweaked docs formatting, document -1 special-case,
13
added fixup patch from RTH mentioning QEMU's maximum veclen.]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
15
---
14
include/hw/arm/fsl-imx6ul.h | 10 ++++++++++
16
docs/system/arm/cpu-features.rst | 15 ++++++++
15
hw/arm/fsl-imx6ul.c | 35 +++++++++++++++++++++++++++++++++++
17
target/arm/cpu.h | 5 +++
16
2 files changed, 45 insertions(+)
18
target/arm/cpu.c | 14 ++++++--
19
target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++
20
4 files changed, 92 insertions(+), 2 deletions(-)
17
21
18
diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h
22
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
19
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/fsl-imx6ul.h
24
--- a/docs/system/arm/cpu-features.rst
21
+++ b/include/hw/arm/fsl-imx6ul.h
25
+++ b/docs/system/arm/cpu-features.rst
22
@@ -XXX,XX +XXX,XX @@
26
@@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector
23
#include "hw/sd/sdhci.h"
27
lengths is to explicitly enable each desired length. Therefore only
24
#include "hw/ssi/imx_spi.h"
28
example's (1), (4), and (6) exhibit recommended uses of the properties.
25
#include "hw/net/imx_fec.h"
29
26
+#include "hw/usb/chipidea.h"
30
+SVE User-mode Default Vector Length Property
27
+#include "hw/usb/imx-usb-phy.h"
31
+--------------------------------------------
28
#include "exec/memory.h"
32
+
29
#include "cpu.h"
33
+For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is
30
34
+defined to mirror the Linux kernel parameter file
31
@@ -XXX,XX +XXX,XX @@ enum FslIMX6ULConfiguration {
35
+``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``,
32
FSL_IMX6UL_NUM_I2CS = 4,
36
+is in units of bytes and must be between 16 and 8192.
33
FSL_IMX6UL_NUM_ECSPIS = 4,
37
+If not specified, the default vector length is 64.
34
FSL_IMX6UL_NUM_ADCS = 2,
38
+
35
+ FSL_IMX6UL_NUM_USB_PHYS = 2,
39
+If the default length is larger than the maximum vector length enabled,
36
+ FSL_IMX6UL_NUM_USBS = 2,
40
+the actual vector length will be reduced. Note that the maximum vector
37
};
41
+length supported by QEMU is 256.
38
42
+
39
typedef struct FslIMX6ULState {
43
+If this property is set to ``-1`` then the default vector length
40
@@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6ULState {
44
+is set to the maximum possible length.
41
IMXFECState eth[FSL_IMX6UL_NUM_ETHS];
45
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
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
46
index XXXXXXX..XXXXXXX 100644
62
--- a/hw/arm/fsl-imx6ul.c
47
--- a/target/arm/cpu.h
63
+++ b/hw/arm/fsl-imx6ul.c
48
+++ b/target/arm/cpu.h
64
@@ -XXX,XX +XXX,XX @@
49
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
65
#include "qapi/error.h"
50
/* Used to set the maximum vector length the cpu will support. */
66
#include "hw/arm/fsl-imx6ul.h"
51
uint32_t sve_max_vq;
67
#include "hw/misc/unimp.h"
52
68
+#include "hw/usb/imx-usb-phy.h"
53
+#ifdef CONFIG_USER_ONLY
69
#include "hw/boards.h"
54
+ /* Used to set the default vector length at process start. */
70
#include "sysemu/sysemu.h"
55
+ uint32_t sve_default_vq;
71
#include "qemu/error-report.h"
56
+#endif
72
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
57
+
73
TYPE_IMX_ENET);
58
/*
74
}
59
* In sve_vq_map each set bit is a supported vector length of
75
60
* (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector
76
+ /* USB */
61
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
77
+ for (i = 0; i < FSL_IMX6UL_NUM_USB_PHYS; i++) {
62
index XXXXXXX..XXXXXXX 100644
78
+ snprintf(name, NAME_SIZE, "usbphy%d", i);
63
--- a/target/arm/cpu.c
79
+ sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]),
64
+++ b/target/arm/cpu.c
80
+ TYPE_IMX_USBPHY);
65
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
81
+ }
66
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3);
82
+ for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
67
/* with reasonable vector length */
83
+ snprintf(name, NAME_SIZE, "usb%d", i);
68
if (cpu_isar_feature(aa64_sve, cpu)) {
84
+ sysbus_init_child_obj(obj, name, &s->usb[i], sizeof(s->usb[i]),
69
- env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3);
85
+ TYPE_CHIPIDEA);
70
+ env->vfp.zcr_el[1] =
71
+ aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1);
72
}
73
/*
74
* Enable TBI0 but not TBI1.
75
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj)
76
QLIST_INIT(&cpu->pre_el_change_hooks);
77
QLIST_INIT(&cpu->el_change_hooks);
78
79
-#ifndef CONFIG_USER_ONLY
80
+#ifdef CONFIG_USER_ONLY
81
+# ifdef TARGET_AARCH64
82
+ /*
83
+ * The linux kernel defaults to 512-bit vectors, when sve is supported.
84
+ * See documentation for /proc/sys/abi/sve_default_vector_length, and
85
+ * our corresponding sve-default-vector-length cpu property.
86
+ */
87
+ cpu->sve_default_vq = 4;
88
+# endif
89
+#else
90
/* Our inbound IRQ and FIQ lines */
91
if (kvm_enabled()) {
92
/* VIRQ and VFIQ are unused with KVM but we add them to maintain
93
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/target/arm/cpu64.c
96
+++ b/target/arm/cpu64.c
97
@@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp)
98
cpu->isar.id_aa64pfr0 = t;
99
}
100
101
+#ifdef CONFIG_USER_ONLY
102
+/* Mirror linux /proc/sys/abi/sve_default_vector_length. */
103
+static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v,
104
+ const char *name, void *opaque,
105
+ Error **errp)
106
+{
107
+ ARMCPU *cpu = ARM_CPU(obj);
108
+ int32_t default_len, default_vq, remainder;
109
+
110
+ if (!visit_type_int32(v, name, &default_len, errp)) {
111
+ return;
86
+ }
112
+ }
87
+
113
+
88
/*
114
+ /* Undocumented, but the kernel allows -1 to indicate "maximum". */
89
* SDHCI
115
+ if (default_len == -1) {
90
*/
116
+ cpu->sve_default_vq = ARM_MAX_VQ;
91
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)
117
+ return;
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
+ }
118
+ }
102
+
119
+
103
+ for (i = 0; i < FSL_IMX6UL_NUM_USBS; i++) {
120
+ default_vq = default_len / 16;
104
+ static const int FSL_IMX6UL_USBn_IRQ[] = {
121
+ remainder = default_len % 16;
105
+ FSL_IMX6UL_USB1_IRQ,
122
+
106
+ FSL_IMX6UL_USB2_IRQ,
123
+ /*
107
+ };
124
+ * Note that the 512 max comes from include/uapi/asm/sve_context.h
108
+ object_property_set_bool(OBJECT(&s->usb[i]), true, "realized",
125
+ * and is the maximum architectural width of ZCR_ELx.LEN.
109
+ &error_abort);
126
+ */
110
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->usb[i]), 0,
127
+ if (remainder || default_vq < 1 || default_vq > 512) {
111
+ FSL_IMX6UL_USBO2_USB_ADDR + i * 0x200);
128
+ error_setg(errp, "cannot set sve-default-vector-length");
112
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->usb[i]), 0,
129
+ if (remainder) {
113
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
130
+ error_append_hint(errp, "Vector length not a multiple of 16\n");
114
+ FSL_IMX6UL_USBn_IRQ[i]));
131
+ } else if (default_vq < 1) {
132
+ error_append_hint(errp, "Vector length smaller than 16\n");
133
+ } else {
134
+ error_append_hint(errp, "Vector length larger than %d\n",
135
+ 512 * 16);
136
+ }
137
+ return;
115
+ }
138
+ }
116
+
139
+
117
/*
140
+ cpu->sve_default_vq = default_vq;
118
* USDHC
141
+}
119
*/
142
+
143
+static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v,
144
+ const char *name, void *opaque,
145
+ Error **errp)
146
+{
147
+ ARMCPU *cpu = ARM_CPU(obj);
148
+ int32_t value = cpu->sve_default_vq * 16;
149
+
150
+ visit_type_int32(v, name, &value, errp);
151
+}
152
+#endif
153
+
154
void aarch64_add_sve_properties(Object *obj)
155
{
156
uint32_t vq;
157
@@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj)
158
object_property_add(obj, name, "bool", cpu_arm_get_sve_vq,
159
cpu_arm_set_sve_vq, NULL, NULL);
160
}
161
+
162
+#ifdef CONFIG_USER_ONLY
163
+ /* Mirror linux /proc/sys/abi/sve_default_vector_length. */
164
+ object_property_add(obj, "sve-default-vector-length", "int32",
165
+ cpu_arm_get_sve_default_vec_len,
166
+ cpu_arm_set_sve_default_vec_len, NULL, NULL);
167
+#endif
168
}
169
170
void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
120
--
171
--
121
2.20.1
172
2.20.1
122
173
123
174
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
While at it, add some trace messages to help debug problems
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
seen when running the latest Linux kernel.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Message-id: 20210726150953.1218690-1-f4bug@amsat.org
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
7
---
12
hw/block/m25p80.c | 48 ++++++++++++++++++++-----------------------
8
hw/arm/nseries.c | 2 +-
13
hw/block/trace-events | 16 +++++++++++++++
9
1 file changed, 1 insertion(+), 1 deletion(-)
14
2 files changed, 38 insertions(+), 26 deletions(-)
15
10
16
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
11
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/block/m25p80.c
13
--- a/hw/arm/nseries.c
19
+++ b/hw/block/m25p80.c
14
+++ b/hw/arm/nseries.c
20
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len)
21
#include "qemu/module.h"
16
default:
22
#include "qemu/error-report.h"
17
bad_cmd:
23
#include "qapi/error.h"
18
qemu_log_mask(LOG_GUEST_ERROR,
24
-
19
- "%s: unknown command %02x\n", __func__, s->cmd);
25
-#ifndef M25P80_ERR_DEBUG
20
+ "%s: unknown command 0x%02x\n", __func__, s->cmd);
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;
21
break;
71
}
22
}
72
23
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
--
24
--
194
2.20.1
25
2.20.1
195
26
196
27
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Joel Stanley <joel@jms.id.au>
2
2
3
With this patch, the USB controllers on 'sabrelite' are detected
3
The macro used to calculate the maximum memory size of the MMIO region
4
and can be used to boot the system.
4
had a mistake, causing all GPIO models to create a mapping of 0x9D8.
5
The intent was to have it be 0x9D8 - 0x800.
5
6
6
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
7
This extra size doesn't matter on ast2400 and ast2500, which have a 4KB
7
Message-id: 20200313014551.12554-6-linux@roeck-us.net
8
region set aside for the GPIO controller.
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
10
On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the
11
regions would overlap. Worse was the 1.8V controller would map over the
12
top of the following peripheral, which happens to be the RTC.
13
14
The mmio region used by each device is a maximum of 2KB, so avoid the
15
calculations and hard code this as the maximum.
16
17
Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation")
18
Signed-off-by: Joel Stanley <joel@jms.id.au>
19
Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com>
20
Reviewed-by: Cédric Le Goater <clg@kaod.org>
21
Message-id: 20210713065854.134634-2-joel@jms.id.au
22
[PMM: fix autocorrect error in commit message]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
24
---
11
include/hw/arm/fsl-imx6.h | 6 ++++++
25
hw/gpio/aspeed_gpio.c | 3 +--
12
hw/arm/fsl-imx6.c | 36 ++++++++++++++++++++++++++++++++++++
26
1 file changed, 1 insertion(+), 2 deletions(-)
13
2 files changed, 42 insertions(+)
14
27
15
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
28
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
16
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/fsl-imx6.h
30
--- a/hw/gpio/aspeed_gpio.c
18
+++ b/include/hw/arm/fsl-imx6.h
31
+++ b/hw/gpio/aspeed_gpio.c
19
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@
20
#include "hw/sd/sdhci.h"
33
#define GPIO_1_8V_MEM_SIZE 0x9D8
21
#include "hw/ssi/imx_spi.h"
34
#define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \
22
#include "hw/net/imx_fec.h"
35
GPIO_1_8V_REG_OFFSET) >> 2)
23
+#include "hw/usb/chipidea.h"
36
-#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE)
24
+#include "hw/usb/imx-usb-phy.h"
37
25
#include "exec/memory.h"
38
static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio)
26
#include "cpu.h"
39
{
27
40
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp)
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
}
41
}
61
42
62
+ for (i = 0; i < FSL_IMX6_NUM_USB_PHYS; i++) {
43
memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s,
63
+ snprintf(name, NAME_SIZE, "usbphy%d", i);
44
- TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE);
64
+ sysbus_init_child_obj(obj, name, &s->usbphy[i], sizeof(s->usbphy[i]),
45
+ TYPE_ASPEED_GPIO, 0x800);
65
+ TYPE_IMX_USBPHY);
46
66
+ }
47
sysbus_init_mmio(sbd, &s->iomem);
67
+ for (i = 0; i < FSL_IMX6_NUM_USBS; i++) {
48
}
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
--
49
--
108
2.20.1
50
2.20.1
109
51
110
52
diff view generated by jsdifflib