Skip to contentSkip to conversation

hw/misc: Add code to emulate PFUZE3000 PMIC

PATCH In review Andrey Smirnov 2 participants 5 messages Dec 14, 2017 – Dec 17, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/misc: Add code to emulate PFUZE3000 PMIC

Add trivial code to emulate PFUZE3000 PMIC.

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

Thanks,
Andrey Smirnov

 hw/misc/Makefile.objs       |   2 +
 hw/misc/pfuze3000.c         | 212 ++++++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/pfuze3000.h |  48 ++++++++++
 3 files changed, 262 insertions(+)
 create mode 100644 hw/misc/pfuze3000.c
 create mode 100644 include/hw/misc/pfuze3000.h
hw/misc/Makefile.objs +2 -0
index 4599288e55..72dcd953bb 100644
@@ -64,3 +64,5 @@ obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
 obj-$(CONFIG_AUX) += auxbus.o
 obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
 obj-y += mmio_interface.o
+
+obj-y += pfuze3000.o
hw/misc/pfuze3000.c new file +212 -0

212 lines not on this page · raw message

include/hw/misc/pfuze3000.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw
Quoted 11 lines · Andrey Smirnov

Add trivial code to emulate PFUZE3000 PMIC.

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

Yes, it ought to have a CONFIG_something symbol and be enabled via the whatever.mak for whatever guest architecture needs this device.

Is there a board which needs this device? We usually only add devices together with whatever's using them.

Quoted 6 lines
hw/misc/pfuze3000.c new file +0 -0
new file mode 100644
index 0000000000..f414b7c0ba

hw/misc/pfuze3000.c line 10

Quoted 10 lines
hw/misc/pfuze3000.c new file +10 -0
@@ -0,0 +1,212 @@
+/*
+ *
+ * Copyright (c) 2017, Impinj, Inc.
+ *
+ * Author: Andrey Smirnov <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.

The .h file is "v2 or later", but the .c file is "v2 or v3". Is that an intentional difference? Generally we go with "v2 or later".

Quoted 4 lines
hw/misc/pfuze3000.c new file +4 -0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.

hw/misc/pfuze3000.c line 65

Quoted 10 lines
hw/misc/pfuze3000.c new file +9 -0
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
+static void pfuze3000_reset(DeviceState *ds)
+{
+    PFuze3000State *s = PFUZE3000(ds);
+
+    s->reg = PFUZE100_INVAL;

This function needs to reset all the device state
(all the fields that the guest can modify).

Code looks OK otherwise.

thanks
-- PMM

#2 lore raw
Quoted 13 lines · Peter Maydell
Quoted 11 lines · Andrey Smirnov

Add trivial code to emulate PFUZE3000 PMIC.

---

Integrating this into a build system via "obj-y" might not be the best way. Does this code need a dedicated CONFIG_ symbol?

Quoted 7 lines

Yes, it ought to have a CONFIG_something symbol and be enabled via the whatever.mak for whatever guest architecture needs this device.

Is there a board which needs this device? We usually only add devices together with whatever's using them.

It's a pretty popular PMIC used on majority on i.MX reference designs, but I am not sure how many of those boards truly need it in QEMU. I ended up having to implement this code for a custom i.MX7 board that used one of PFUZE3000's output as a power supply for USB. I am not sure if I'm ever going to submit patches for that mystery board upstream. Looking at imx6qdl-sabresd.dtsi, in Linux source tree I think this emulation code would also be needed for USB emulation on i.MX6 SabreSD board, but I haven't verified it in practice.

Is this enough of a case to justify the patch's inclusion, or should I go back and find a board QEMU supports that actually needs this (either answer is perfectly fine with me)?

Quoted 11 lines
Quoted 11 lines
hw/misc/pfuze3000.c new file +5 -0
new file mode 100644
index 0000000000..f414b7c0ba
@@ -0,0 +1,212 @@
+/*
+ *
+ * Copyright (c) 2017, Impinj, Inc.
+ *
+ * Author: Andrey Smirnov <[email protected]>
Quoted 9 lines

hw/misc/pfuze3000.c line 10

Quoted 5 lines
hw/misc/pfuze3000.c new file +5 -0
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 or
+ * (at your option) version 3 of the License.

The .h file is "v2 or later", but the .c file is "v2 or v3". Is that an intentional difference? Generally we go with "v2 or later".

Nope, just me not paying attention. Will change in v2.

Quoted 9 lines
Quoted 8 lines
hw/misc/pfuze3000.c new file +8 -0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
Quoted 9 lines

hw/misc/pfuze3000.c line 188

Quoted 5 lines
hw/misc/pfuze3000.c new file +5 -0
+static void pfuze3000_reset(DeviceState *ds)
+{
+    PFuze3000State *s = PFUZE3000(ds);
+
+    s->reg = PFUZE100_INVAL;

This function needs to reset all the device state
(all the fields that the guest can modify).

Good point, will change in v2.

Thanks,
Andrey Smirnov

#3 lore raw
Quoted 13 lines · Andrey Smirnov
Quoted 2 lines · Peter Maydell

Is there a board which needs this device? We usually only add devices together with whatever's using them.

It's a pretty popular PMIC used on majority on i.MX reference designs, but I am not sure how many of those boards truly need it in QEMU. I ended up having to implement this code for a custom i.MX7 board that used one of PFUZE3000's output as a power supply for USB. I am not sure if I'm ever going to submit patches for that mystery board upstream. Looking at imx6qdl-sabresd.dtsi, in Linux source tree I think this emulation code would also be needed for USB emulation on i.MX6 SabreSD board, but I haven't verified it in practice.

Quoted 3 lines

Is this enough of a case to justify the patch's inclusion, or should I go back and find a board QEMU supports that actually needs this (either answer is perfectly fine with me)?

I think what I'd like to see is some board model in QEMU actually creating this device. (I assume it's not intended as a "user creates it with -device" pluggable device.) Otherwise it's just dead code from upstream's point of view.

thanks
-- PMM

#4 lore raw
Quoted 14 lines · Peter Maydell
Quoted 13 lines · Andrey Smirnov
Quoted 2 lines · Peter Maydell

Is there a board which needs this device? We usually only add devices together with whatever's using them.

It's a pretty popular PMIC used on majority on i.MX reference designs, but I am not sure how many of those boards truly need it in QEMU. I ended up having to implement this code for a custom i.MX7 board that used one of PFUZE3000's output as a power supply for USB. I am not sure if I'm ever going to submit patches for that mystery board upstream. Looking at imx6qdl-sabresd.dtsi, in Linux source tree I think this emulation code would also be needed for USB emulation on i.MX6 SabreSD board, but I haven't verified it in practice.

Quoted 9 lines
Quoted 3 lines

Is this enough of a case to justify the patch's inclusion, or should I go back and find a board QEMU supports that actually needs this (either answer is perfectly fine with me)?

I think what I'd like to see is some board model in QEMU actually creating this device. (I assume it's not intended as a "user creates it with -device" pluggable device.) Otherwise it's just dead code from upstream's point of view.

Your assumption is correct and fair enough, I'll see if I can find a place upstream it can be put it.

Thanks,
Andrey Smirnov