[ANNOUNCE] 4.19.307-rt133

2024-03-03 Thread Daniel Wagner
Hello RT-list!

I'm pleased to announce the 4.19.307-rt133 stable release. This is
just an update to the stable release 4.19.307. No RT specific changes.

You can get this release via the git tree at:

  git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git

  branch: v4.19-rt
  Head SHA1: 4790d0210f1929d981659cd4e7ecfb34e0a6889c

Or to build 4.19.307-rt133 directly, the following patches should be applied:

  https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.19.tar.xz

  https://www.kernel.org/pub/linux/kernel/v4.x/patch-4.19.307.xz

  
https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patch-4.19.307-rt133.patch.xz

Signing key fingerprint:

  5BF6 7BC5 0826 72CA BB45  ACAE 587C 5ECA 5D0A 306C

All keys used for the above files and repositories can be found on the
following git repository:

   git://git.kernel.org/pub/scm/docs/kernel/pgpkeys.git

Enjoy!
Daniel



Re: [PATCH net-next v2] tcp: Add skb addr and sock addr to arguments of tracepoint tcp_probe.

2024-03-03 Thread Jason Xing
On Mon, Mar 4, 2024 at 11:46 AM fuyuanli  wrote:
>
> It is useful to expose skb addr and sock addr to user in tracepoint
> tcp_probe, so that we can get more information while monitoring
> receiving of tcp data, by ebpf or other ways.
>
> For example, we need to identify a packet by seq and end_seq when
> calculate transmit latency between lay 2 and lay 4 by ebpf, but which is
> not available in tcp_probe, so we can only use kprobe hooking
> tcp_rcv_esatblised to get them. But we can use tcp_probe directly if skb
> addr and sock addr are available, which is more efficient.
>
> Signed-off-by: fuyuanli 
> Link: 
> https://lore.kernel.org/netdev/20240229052813.GA23899@didi-ThinkCentre-M920t-N000/

Reviewed-by: Jason Xing 



Re: [PATCH net-next v2 3/3] tun: AF_XDP Tx zero-copy support

2024-03-03 Thread Jason Wang
On Wed, Feb 28, 2024 at 7:06 PM Yunjian Wang  wrote:
>
> This patch set allows TUN to support the AF_XDP Tx zero-copy feature,
> which can significantly reduce CPU utilization for XDP programs.
>
> Since commit fc72d1d54dd9 ("tuntap: XDP transmission"), the pointer
> ring has been utilized to queue different types of pointers by encoding
> the type into the lower bits. Therefore, we introduce a new flag,
> TUN_XDP_DESC_FLAG(0x2UL), which allows us to enqueue XDP descriptors
> and differentiate them from XDP buffers and sk_buffs. Additionally, a
> spin lock is added for enabling and disabling operations on the xsk pool.
>
> The performance testing was performed on a Intel E5-2620 2.40GHz machine.
> Traffic were generated/send through TUN(testpmd txonly with AF_XDP)
> to VM (testpmd rxonly in guest).
>
> +--+-+-+-+
> |  |   copy  |zero-copy| speedup |
> +--+-+-+-+
> | UDP  |   Mpps  |   Mpps  |%|
> | 64   |   2.5   |   4.0   |   60%   |
> | 512  |   2.1   |   3.6   |   71%   |
> | 1024 |   1.9   |   3.3   |   73%   |
> +--+-+-+-+
>
> Signed-off-by: Yunjian Wang 
> ---
>  drivers/net/tun.c  | 177 +++--
>  drivers/vhost/net.c|   4 +
>  include/linux/if_tun.h |  32 
>  3 files changed, 208 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index bc80fc1d576e..7f4ff50b532c 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -63,6 +63,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -86,6 +87,7 @@ static void tun_default_link_ksettings(struct net_device 
> *dev,
>struct ethtool_link_ksettings *cmd);
>
>  #define TUN_RX_PAD (NET_IP_ALIGN + NET_SKB_PAD)
> +#define TUN_XDP_BATCH 64
>
>  /* TUN device flags */
>
> @@ -146,6 +148,9 @@ struct tun_file {
> struct tun_struct *detached;
> struct ptr_ring tx_ring;
> struct xdp_rxq_info xdp_rxq;
> +   struct xsk_buff_pool *xsk_pool;
> +   spinlock_t pool_lock;   /* Protects xsk pool enable/disable */
> +   u32 nb_descs;
>  };
>
>  struct tun_page {
> @@ -614,6 +619,8 @@ void tun_ptr_free(void *ptr)
> struct xdp_frame *xdpf = tun_ptr_to_xdp(ptr);
>
> xdp_return_frame(xdpf);
> +   } else if (tun_is_xdp_desc_frame(ptr)) {
> +   return;
> } else {
> __skb_array_destroy_skb(ptr);
> }
> @@ -631,6 +638,37 @@ static void tun_queue_purge(struct tun_file *tfile)
> skb_queue_purge(&tfile->sk.sk_error_queue);
>  }
>
> +static void tun_set_xsk_pool(struct tun_file *tfile, struct xsk_buff_pool 
> *pool)
> +{
> +   if (!pool)
> +   return;
> +
> +   spin_lock(&tfile->pool_lock);
> +   xsk_pool_set_rxq_info(pool, &tfile->xdp_rxq);
> +   tfile->xsk_pool = pool;
> +   spin_unlock(&tfile->pool_lock);
> +}
> +
> +static void tun_clean_xsk_pool(struct tun_file *tfile)
> +{
> +   spin_lock(&tfile->pool_lock);
> +   if (tfile->xsk_pool) {
> +   void *ptr;
> +
> +   while ((ptr = ptr_ring_consume(&tfile->tx_ring)) != NULL)
> +   tun_ptr_free(ptr);
> +
> +   if (tfile->nb_descs) {
> +   xsk_tx_completed(tfile->xsk_pool, tfile->nb_descs);
> +   if (xsk_uses_need_wakeup(tfile->xsk_pool))
> +   xsk_set_tx_need_wakeup(tfile->xsk_pool);
> +   tfile->nb_descs = 0;
> +   }
> +   tfile->xsk_pool = NULL;
> +   }
> +   spin_unlock(&tfile->pool_lock);
> +}
> +
>  static void __tun_detach(struct tun_file *tfile, bool clean)
>  {
> struct tun_file *ntfile;
> @@ -648,6 +686,11 @@ static void __tun_detach(struct tun_file *tfile, bool 
> clean)
> u16 index = tfile->queue_index;
> BUG_ON(index >= tun->numqueues);
>
> +   ntfile = rtnl_dereference(tun->tfiles[tun->numqueues - 1]);
> +   /* Stop xsk zc xmit */
> +   tun_clean_xsk_pool(tfile);
> +   tun_clean_xsk_pool(ntfile);
> +
> rcu_assign_pointer(tun->tfiles[index],
>tun->tfiles[tun->numqueues - 1]);
> ntfile = rtnl_dereference(tun->tfiles[index]);
> @@ -668,6 +711,7 @@ static void __tun_detach(struct tun_file *tfile, bool 
> clean)
> tun_flow_delete_by_queue(tun, tun->numqueues + 1);
> /* Drop read queue */
> tun_queue_purge(tfile);
> +   tun_set_xsk_pool(ntfile, xsk_get_pool_from_qid(tun->dev, 
> index));
> tun_set_real_num_queues(tun);
> } else if (tfile->detached && clean) {
> tun = tun_enable_queue(tfile);
> @@ -801,6 +845,7 @@ static int tun_attach(struct tun_struct *tun, struct file 
> *fi

[PATCH net-next v2] tcp: Add skb addr and sock addr to arguments of tracepoint tcp_probe.

2024-03-03 Thread fuyuanli
It is useful to expose skb addr and sock addr to user in tracepoint
tcp_probe, so that we can get more information while monitoring
receiving of tcp data, by ebpf or other ways.

For example, we need to identify a packet by seq and end_seq when
calculate transmit latency between lay 2 and lay 4 by ebpf, but which is
not available in tcp_probe, so we can only use kprobe hooking
tcp_rcv_esatblised to get them. But we can use tcp_probe directly if skb
addr and sock addr are available, which is more efficient.

Signed-off-by: fuyuanli 
Link: 
https://lore.kernel.org/netdev/20240229052813.GA23899@didi-ThinkCentre-M920t-N000/
---
v2:
1) Add printing about those two addresses.
2) Target "net-next" in the title of patch.
---
 include/trace/events/tcp.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 7b1ddffa3dfc..efb651683781 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -258,6 +258,8 @@ TRACE_EVENT(tcp_probe,
__field(__u32, srtt)
__field(__u32, rcv_wnd)
__field(__u64, sock_cookie)
+   __field(const void *, skbaddr)
+   __field(const void *, skaddr)
),
 
TP_fast_assign(
@@ -285,14 +287,18 @@ TRACE_EVENT(tcp_probe,
__entry->ssthresh = tcp_current_ssthresh(sk);
__entry->srtt = tp->srtt_us >> 3;
__entry->sock_cookie = sock_gen_cookie(sk);
+
+   __entry->skbaddr = skb;
+   __entry->skaddr = sk;
),
 
-   TP_printk("family=%s src=%pISpc dest=%pISpc mark=%#x data_len=%d 
snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u 
sock_cookie=%llx",
+   TP_printk("family=%s src=%pISpc dest=%pISpc mark=%#x data_len=%d 
snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u 
sock_cookie=%llx skbaddr=%p skaddr=%p",
  show_family_name(__entry->family),
  __entry->saddr, __entry->daddr, __entry->mark,
  __entry->data_len, __entry->snd_nxt, __entry->snd_una,
  __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd,
- __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie)
+ __entry->srtt, __entry->rcv_wnd, __entry->sock_cookie,
+ __entry->skbaddr, __entry->skaddr)
 );
 
 #define TP_STORE_ADDR_PORTS_SKB_V4(__entry, skb)   \
-- 
2.17.1




Re: [RESEND PATCH v5 0/5] input/touchscreen: imagis: add support for IST3032C

2024-03-03 Thread Dmitry Torokhov
On Fri, Mar 01, 2024 at 05:40:59PM +0100, Karel Balej wrote:
> From: Karel Balej 
> 
> Hello,
> 
> this patch series generalizes the Imagis touchscreen driver to support
> other Imagis chips, namely IST3038B and IST3032C.
> 
> The motivation for IST3032C is the samsung,coreprimevelte smartphone
> with which this series has been tested. However, the support for this
> device is not yet in-tree, the effort is happening at [1]. Preliminary
> version of the regulator driver needed to use the touchscreen on this
> phone can be found here [2].
> 
> Note that this is a prerequisite for (at least a part of) this series
> [3] which among other things implements support for touch keys for
> Imagis touchscreens that have it.
> 
> [1] 
> https://lore.kernel.org/all/20240110-pxa1908-lkml-v8-0-fea768a59...@skole.hr/
> [2] 
> https://lore.kernel.org/all/20240211094609.2223-1-kar...@gimli.ms.mff.cuni.cz/
> [3] 
> https://lore.kernel.org/all/20240120-b4-imagis-keys-v2-0-d7fc16f2e...@skole.hr/

Applied the lot, thank you.

-- 
Dmitry



Re: [RFC PATCH v3 4/5] input: add onkey driver for Marvell 88PM886 PMIC

2024-03-03 Thread Dmitry Torokhov
Hi Karel,

On Sun, Mar 03, 2024 at 11:04:25AM +0100, Karel Balej wrote:
> From: Karel Balej 
> 
> Marvell 88PM886 PMIC provides onkey among other things. Add client
> driver to handle it. The driver currently only provides a basic support
> omitting additional functions found in the vendor version, such as long
> onkey and GPIO integration.
> 
> Signed-off-by: Karel Balej 
> ---
> 
> Notes:
> RFC v3:
> - Drop wakeup-source.
> RFC v2:
> - Address Dmitry's feedback:
>   - Sort includes alphabetically.
>   - Drop onkey->irq.
>   - ret -> err in irq_handler and no initialization.
>   - Break long lines and other formatting.
>   - Do not clobber platform_get_irq error.
>   - Do not set device parent manually.
>   - Use input_set_capability.
>   - Use the wakeup-source DT property.
>   - Drop of_match_table.

I only said that you should not be using of_match_ptr(), but you still
need to have of_match_table set and have MODULE_DEVICE_TABLE() for the
proper module loading support.

With that fixed:

Acked-by: Dmitry Torokhov 

Thanks.

-- 
Dmitry



[RFC PATCH v3 5/5] MAINTAINERS: add myself for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Add an entry to MAINTAINERS for the Marvell 88PM886 PMIC MFD, onkey and
regulator drivers.

Signed-off-by: Karel Balej 
---

Notes:
RFC v3:
- Remove onkey bindings file.
RFC v2:
- Only mention 88PM886 in the commit message.
- Add regulator driver.
- Rename the entry.

 MAINTAINERS | 9 +
 1 file changed, 9 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 960512bec428..944f88c92df6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12949,6 +12949,15 @@ F: drivers/net/dsa/mv88e6xxx/
 F: include/linux/dsa/mv88e6xxx.h
 F: include/linux/platform_data/mv88e6xxx.h
 
+MARVELL 88PM886 PMIC DRIVER
+M: Karel Balej 
+S: Maintained
+F: Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml
+F: drivers/input/misc/88pm886-onkey.c
+F: drivers/mfd/88pm886.c
+F: drivers/regulators/88pm886-regulator.c
+F: include/linux/mfd/88pm886.h
+
 MARVELL ARMADA 3700 PHY DRIVERS
 M: Miquel Raynal 
 S: Maintained
-- 
2.44.0




[RFC PATCH v3 4/5] input: add onkey driver for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Marvell 88PM886 PMIC provides onkey among other things. Add client
driver to handle it. The driver currently only provides a basic support
omitting additional functions found in the vendor version, such as long
onkey and GPIO integration.

Signed-off-by: Karel Balej 
---

Notes:
RFC v3:
- Drop wakeup-source.
RFC v2:
- Address Dmitry's feedback:
  - Sort includes alphabetically.
  - Drop onkey->irq.
  - ret -> err in irq_handler and no initialization.
  - Break long lines and other formatting.
  - Do not clobber platform_get_irq error.
  - Do not set device parent manually.
  - Use input_set_capability.
  - Use the wakeup-source DT property.
  - Drop of_match_table.
  - Use more temporaries.
  - Use dev_err_probe.
- Modify Kconfig description.

 drivers/input/misc/88pm886-onkey.c | 92 ++
 drivers/input/misc/Kconfig |  7 +++
 drivers/input/misc/Makefile|  1 +
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/input/misc/88pm886-onkey.c

diff --git a/drivers/input/misc/88pm886-onkey.c 
b/drivers/input/misc/88pm886-onkey.c
new file mode 100644
index ..2e5df21cd11b
--- /dev/null
+++ b/drivers/input/misc/88pm886-onkey.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+struct pm886_onkey {
+   struct input_dev *idev;
+   struct pm886_chip *chip;
+};
+
+static irqreturn_t pm886_onkey_irq_handler(int irq, void *data)
+{
+   struct pm886_onkey *onkey = data;
+   struct regmap *regmap = onkey->chip->regmaps[PM886_REGMAP_BASE];
+   struct input_dev *idev = onkey->idev;
+   struct device *parent = idev->dev.parent;
+   unsigned int val;
+   int err;
+
+   err = regmap_read(regmap, PM886_REG_STATUS1, &val);
+   if (err) {
+   dev_err(parent, "Failed to read status: %d\n", err);
+   return IRQ_NONE;
+   }
+   val &= PM886_ONKEY_STS1;
+
+   input_report_key(idev, KEY_POWER, val);
+   input_sync(idev);
+
+   return IRQ_HANDLED;
+}
+
+static int pm886_onkey_probe(struct platform_device *pdev)
+{
+   struct pm886_chip *chip = dev_get_drvdata(pdev->dev.parent);
+   struct device *dev = &pdev->dev;
+   struct pm886_onkey *onkey;
+   struct input_dev *idev;
+   int irq, err;
+
+   onkey = devm_kzalloc(dev, sizeof(*onkey), GFP_KERNEL);
+   if (!onkey)
+   return -ENOMEM;
+
+   onkey->chip = chip;
+
+   irq = platform_get_irq(pdev, 0);
+   if (irq < 0)
+   return dev_err_probe(dev, irq, "Failed to get IRQ\n");
+
+   idev = devm_input_allocate_device(dev);
+   if (!idev) {
+   dev_err(dev, "Failed to allocate input device\n");
+   return -ENOMEM;
+   }
+   onkey->idev = idev;
+
+   idev->name = "88pm886-onkey";
+   idev->phys = "88pm886-onkey/input0";
+   idev->id.bustype = BUS_I2C;
+
+   input_set_capability(idev, EV_KEY, KEY_POWER);
+
+   err = devm_request_threaded_irq(dev, irq, NULL, pm886_onkey_irq_handler,
+   IRQF_ONESHOT | IRQF_NO_SUSPEND, "onkey",
+   onkey);
+   if (err)
+   return dev_err_probe(dev, err, "Failed to request IRQ\n");
+
+   err = input_register_device(idev);
+   if (err)
+   return dev_err_probe(dev, err, "Failed to register input 
device\n");
+
+   return 0;
+}
+
+static struct platform_driver pm886_onkey_driver = {
+   .driver = {
+   .name = "88pm886-onkey",
+   },
+   .probe = pm886_onkey_probe,
+};
+module_platform_driver(pm886_onkey_driver);
+
+MODULE_DESCRIPTION("Marvell 88PM886 onkey driver");
+MODULE_AUTHOR("Karel Balej ");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 6ba984d7f0b1..16a079d9f0f2 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -33,6 +33,13 @@ config INPUT_88PM80X_ONKEY
  To compile this driver as a module, choose M here: the module
  will be called 88pm80x_onkey.
 
+config INPUT_88PM886_ONKEY
+   tristate "Marvell 88PM886 onkey support"
+   depends on MFD_88PM886_PMIC
+   help
+ Support the onkey of Marvell 88PM886 PMIC as an input device
+ reporting power button status.
+
 config INPUT_AB8500_PONKEY
tristate "AB8500 Pon (PowerOn) Key"
depends on AB8500_CORE
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 04296a4abe8e..054a6dc1ac27 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_INPUT_88PM860X_ONKEY) += 88pm860x_onkey.o
 obj-$(CONFIG_INPUT_88PM80X_ONKEY)  += 88pm80x_onkey.o
+obj-$(CONFIG_INPUT_88PM886_ONKEY)  += 88pm886-onkey.o
 obj-$(CONFIG_INPUT_AB8500_PONKEY)  

[RFC PATCH v3 1/5] dt-bindings: mfd: add entry for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Marvell 88PM886 is a PMIC with several subdevices such as onkey,
regulators or battery and charger. It comes in at least two revisions,
A0 and A1 -- only A1 is described here at the moment.

Signed-off-by: Karel Balej 
---

Notes:
RFC v3:
- Add wakeup-source property.
- Address Rob's feedback:
  - Move regulators into the MFD file.
  - Remove interrupt-controller and #interrupt-cells properties.
RFC v2:
- Address Rob's feedback:
  - Drop mention of 88PM880.
  - Make sure the file passes bindings check (add the necessary header
and fix `interrupt-cells`).
  - Other small changes.
- Add regulators. Changes with respect to the regulator RFC series:
  - Address Krzysztof's comments:
- Drop unused compatible.
- Fix sub-node pattern.

 .../bindings/mfd/marvell,88pm886-a1.yaml  | 76 +++
 1 file changed, 76 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml

diff --git a/Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml 
b/Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml
new file mode 100644
index ..61ffbf669e90
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml
@@ -0,0 +1,76 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/marvell,88pm886-a1.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Marvell 88PM886 PMIC core
+
+maintainers:
+  - Karel Balej 
+
+description:
+  Marvell 88PM886 is a PMIC providing several functions such as onkey,
+  regulators or battery and charger.
+
+properties:
+  compatible:
+const: marvell,88pm886-a1
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  wakeup-source: true
+
+  regulators:
+type: object
+additionalProperties: false
+patternProperties:
+  "^(ldo(1[0-6]|[1-9])|buck[1-5])$":
+type: object
+$ref: /schemas/regulator/regulator.yaml#
+description: LDO or buck regulator.
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+i2c {
+  #address-cells = <1>;
+  #size-cells = <0>;
+  pmic@30 {
+compatible = "marvell,88pm886-a1";
+reg = <0x30>;
+interrupts = <0 4 IRQ_TYPE_LEVEL_HIGH>;
+interrupt-parent = <&gic>;
+wakeup-source;
+
+regulators {
+  ldo2: ldo2 {
+regulator-min-microvolt = <310>;
+regulator-max-microvolt = <330>;
+};
+
+  ldo15: ldo15 {
+regulator-min-microvolt = <330>;
+regulator-max-microvolt = <330>;
+};
+
+  buck2: buck2 {
+regulator-min-microvolt = <180>;
+regulator-max-microvolt = <180>;
+};
+};
+  };
+};
+...
-- 
2.44.0




[RFC PATCH v3 3/5] regulator: add regulators driver for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Support the LDO and buck regulators of the Marvell 88PM886 PMIC.

Signed-off-by: Karel Balej 
---

Notes:
RFC v3:
- Do not have a variable for each regulator -- define them all in the
  pm886_regulators array.
- Use new regulators regmap index name.
- Use dev_err_probe.
RFC v2:
- Drop of_compatible and related code.
- Drop unused include.
- Remove some abstraction: use only one regmap for all regulators and
  only mention 88PM886 in Kconfig description.
- Reword commit message.

 drivers/regulator/88pm886-regulator.c | 195 ++
 drivers/regulator/Kconfig |   6 +
 drivers/regulator/Makefile|   1 +
 3 files changed, 202 insertions(+)
 create mode 100644 drivers/regulator/88pm886-regulator.c

diff --git a/drivers/regulator/88pm886-regulator.c 
b/drivers/regulator/88pm886-regulator.c
new file mode 100644
index ..73f6ce413dc3
--- /dev/null
+++ b/drivers/regulator/88pm886-regulator.c
@@ -0,0 +1,195 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define PM886_REG_LDO_EN1  0x09
+#define PM886_REG_LDO_EN2  0x0a
+
+#define PM886_REG_BUCK_EN  0x08
+
+#define PM886_REG_LDO1_VOUT0x20
+#define PM886_REG_LDO2_VOUT0x26
+#define PM886_REG_LDO3_VOUT0x2c
+#define PM886_REG_LDO4_VOUT0x32
+#define PM886_REG_LDO5_VOUT0x38
+#define PM886_REG_LDO6_VOUT0x3e
+#define PM886_REG_LDO7_VOUT0x44
+#define PM886_REG_LDO8_VOUT0x4a
+#define PM886_REG_LDO9_VOUT0x50
+#define PM886_REG_LDO10_VOUT   0x56
+#define PM886_REG_LDO11_VOUT   0x5c
+#define PM886_REG_LDO12_VOUT   0x62
+#define PM886_REG_LDO13_VOUT   0x68
+#define PM886_REG_LDO14_VOUT   0x6e
+#define PM886_REG_LDO15_VOUT   0x74
+#define PM886_REG_LDO16_VOUT   0x7a
+
+#define PM886_REG_BUCK1_VOUT   0xa5
+#define PM886_REG_BUCK2_VOUT   0xb3
+#define PM886_REG_BUCK3_VOUT   0xc1
+#define PM886_REG_BUCK4_VOUT   0xcf
+#define PM886_REG_BUCK5_VOUT   0xdd
+
+#define PM886_LDO_VSEL_MASK0x0f
+#define PM886_BUCK_VSEL_MASK   0x7f
+
+struct pm886_regulator {
+   struct regulator_desc desc;
+   int max_uA;
+};
+
+static int pm886_regulator_get_ilim(struct regulator_dev *rdev)
+{
+   struct pm886_regulator *data = rdev_get_drvdata(rdev);
+
+   if (!data) {
+   dev_err(&rdev->dev, "Failed to get regulator data\n");
+   return -EINVAL;
+   }
+   return data->max_uA;
+}
+
+static const struct regulator_ops pm886_ldo_ops = {
+   .list_voltage = regulator_list_voltage_table,
+   .map_voltage = regulator_map_voltage_iterate,
+   .set_voltage_sel = regulator_set_voltage_sel_regmap,
+   .get_voltage_sel = regulator_get_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable = regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .get_current_limit = pm886_regulator_get_ilim,
+};
+
+static const struct regulator_ops pm886_buck_ops = {
+   .list_voltage = regulator_list_voltage_linear_range,
+   .map_voltage = regulator_map_voltage_linear_range,
+   .set_voltage_sel = regulator_set_voltage_sel_regmap,
+   .get_voltage_sel = regulator_get_voltage_sel_regmap,
+   .enable = regulator_enable_regmap,
+   .disable = regulator_disable_regmap,
+   .is_enabled = regulator_is_enabled_regmap,
+   .get_current_limit = pm886_regulator_get_ilim,
+};
+
+static const unsigned int pm886_ldo_volt_table1[] = {
+   170, 180, 190, 250, 280, 290, 310, 330,
+};
+
+static const unsigned int pm886_ldo_volt_table2[] = {
+   120, 125, 170, 180, 185, 190, 250, 260,
+   270, 275, 280, 285, 290, 300, 310, 330,
+};
+
+static const unsigned int pm886_ldo_volt_table3[] = {
+   170, 180, 190, 200, 210, 250, 270, 280,
+};
+
+static const struct linear_range pm886_buck_volt_ranges1[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 79, 12500),
+   REGULATOR_LINEAR_RANGE(160, 80, 84, 5),
+};
+
+static const struct linear_range pm886_buck_volt_ranges2[] = {
+   REGULATOR_LINEAR_RANGE(60, 0, 79, 12500),
+   REGULATOR_LINEAR_RANGE(160, 80, 114, 5),
+};
+
+static struct pm886_regulator pm886_regulators[] = {
+   [PM886_REGULATOR_ID_LDO2] = {
+   .desc = {
+   .name = "LDO2",
+   .id = PM886_REGULATOR_ID_LDO2,
+   .regulators_node = "regulators",
+   .of_match = "ldo2",
+   .ops = &pm886_ldo_ops,
+   .type = REGULATOR_VOLTAGE,
+ 

[RFC PATCH v3 2/5] mfd: add driver for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Marvell 88PM886 is a PMIC which provides various functions such as
onkey, battery, charger and regulators. It is found for instance in the
samsung,coreprimevelte smartphone with which this was tested.

Only implement basic support to allow for the use of regulators and
onkey omitting the currently unused register definitions and I2C
subclients which should thus be added with the subdevice drivers which
need them.

Signed-off-by: Karel Balej 
---

Notes:
RFC v3:
- Drop onkey cell .of_compatible.
- Rename LDO page offset and regmap to REGULATORS.
RFC v2:
- Remove some abstraction.
- Sort includes alphabetically and add linux/of.h.
- Depend on OF, remove of_match_ptr and add MODULE_DEVICE_TABLE.
- Use more temporaries and break long lines.
- Do not initialize ret in probe.
- Use the wakeup-source DT property.
- Rename ret to err.
- Address Lee's comments:
  - Drop patched in presets for base regmap and related defines.
  - Use full sentences in comments.
  - Remove IRQ comment.
  - Define regmap_config member values.
  - Rename data to sys_off_data.
  - Add _PMIC suffix to Kconfig.
  - Use dev_err_probe.
  - Do not store irq_data.
  - s/WHOAMI/CHIP_ID
  - Drop LINUX part of include guard name.
  - Merge in the regulator series modifications in order to have more
devices and modify the commit message accordingly. Changes with
respect to the original regulator series patches:
- ret -> err
- Add temporary for dev in pm88x_initialize_subregmaps.
- Drop of_compatible for the regulators.
- Do not duplicate LDO regmap for bucks.
- Rewrite commit message.

 drivers/mfd/88pm886.c   | 210 
 drivers/mfd/Kconfig |  12 +++
 drivers/mfd/Makefile|   1 +
 include/linux/mfd/88pm886.h |  46 
 4 files changed, 269 insertions(+)
 create mode 100644 drivers/mfd/88pm886.c
 create mode 100644 include/linux/mfd/88pm886.h

diff --git a/drivers/mfd/88pm886.c b/drivers/mfd/88pm886.c
new file mode 100644
index ..c17220e1b7e2
--- /dev/null
+++ b/drivers/mfd/88pm886.c
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define PM886_REG_INT_STATUS1  0x05
+
+#define PM886_REG_INT_ENA_10x0a
+#define PM886_INT_ENA1_ONKEY   BIT(0)
+
+#define PM886_REGMAP_CONF_REG_BITS 8
+#define PM886_REGMAP_CONF_VAL_BITS 8
+#define PM886_REGMAP_CONF_MAX_REG  0xfe
+
+enum pm886_irq_number {
+   PM886_IRQ_ONKEY,
+
+   PM886_MAX_IRQ
+};
+
+static struct regmap_irq pm886_regmap_irqs[] = {
+   REGMAP_IRQ_REG(PM886_IRQ_ONKEY, 0, PM886_INT_ENA1_ONKEY),
+};
+
+static struct regmap_irq_chip pm886_regmap_irq_chip = {
+   .name = "88pm886",
+   .irqs = pm886_regmap_irqs,
+   .num_irqs = ARRAY_SIZE(pm886_regmap_irqs),
+   .num_regs = 4,
+   .status_base = PM886_REG_INT_STATUS1,
+   .ack_base = PM886_REG_INT_STATUS1,
+   .unmask_base = PM886_REG_INT_ENA_1,
+};
+
+static struct resource pm886_onkey_resources[] = {
+   DEFINE_RES_IRQ_NAMED(PM886_IRQ_ONKEY, "88pm886-onkey"),
+};
+
+static struct mfd_cell pm886_devs[] = {
+   {
+   .name = "88pm886-onkey",
+   .num_resources = ARRAY_SIZE(pm886_onkey_resources),
+   .resources = pm886_onkey_resources,
+   },
+   {
+   .name = "88pm886-regulator",
+   .id = PM886_REGULATOR_ID_LDO2,
+   },
+   {
+   .name = "88pm886-regulator",
+   .id = PM886_REGULATOR_ID_LDO15,
+   },
+   {
+   .name = "88pm886-regulator",
+   .id = PM886_REGULATOR_ID_BUCK2,
+   },
+};
+
+static const struct regmap_config pm886_i2c_regmap = {
+   .reg_bits = PM886_REGMAP_CONF_REG_BITS,
+   .val_bits = PM886_REGMAP_CONF_VAL_BITS,
+   .max_register = PM886_REGMAP_CONF_MAX_REG,
+};
+
+static int pm886_power_off_handler(struct sys_off_data *sys_off_data)
+{
+   struct pm886_chip *chip = sys_off_data->cb_data;
+   struct regmap *regmap = chip->regmaps[PM886_REGMAP_BASE];
+   struct device *dev = &chip->client->dev;
+   int err;
+
+   err = regmap_update_bits(regmap, PM886_REG_MISC_CONFIG1, PM886_SW_PDOWN,
+   PM886_SW_PDOWN);
+   if (err) {
+   dev_err(dev, "Failed to power off the device: %d\n", err);
+   return NOTIFY_BAD;
+   }
+   return NOTIFY_DONE;
+}
+
+static int pm886_initialize_subregmaps(struct pm886_chip *chip)
+{
+   struct device *dev = &chip->client->dev;
+   struct i2c_client *page;
+   struct regmap *regmap;
+   int err;
+
+   /* regulators page */
+   page = devm_i2c_new_dummy_device(dev, chip->client->adapter,
+   

[RFC PATCH v3 0/5] initial support for Marvell 88PM886 PMIC

2024-03-03 Thread Karel Balej
From: Karel Balej 

Hello,

the following implements basic support for Marvell's 88PM886 PMIC which
is found for instance as a component of the samsung,coreprimevelte
smartphone which inspired this and also serves as a testing platform.

The code for the MFD is based primarily on this old series [1] with the
addition of poweroff based on the smartphone's downstream kernel tree
[2]. The onkey and regulators drivers are based on the latter. I am not
in possesion of the datasheet.

[1] 
https://lore.kernel.org/all/1434098601-3498-1-git-send-email-yizh...@marvell.com/
[2] https://github.com/CoderCharmander/g361f-kernel

Thank you and kind regards,
K. B.
---
RFC v3:
- Address Rob's feedback:
  - Drop onkey bindings patch.
- Rename PM88X -> PM886 everywhere.
- RFC v2: 
https://lore.kernel.org/all/20240211094609.2223-1-kar...@gimli.ms.mff.cuni.cz/
RFC v2:
- Merge with the regulators series to have multiple devices and thus
  justify the use of the MFD framework.
- Rebase on v6.8-rc3.
- Reorder patches.
- MFD RFC v1: 
https://lore.kernel.org/all/20231217131838.7569-1-kar...@gimli.ms.mff.cuni.cz/
- regulators RFC v1: 
https://lore.kernel.org/all/20231228100208.2932-1-kar...@gimli.ms.mff.cuni.cz/

Karel Balej (5):
  dt-bindings: mfd: add entry for Marvell 88PM886 PMIC
  mfd: add driver for Marvell 88PM886 PMIC
  regulator: add regulators driver for Marvell 88PM886 PMIC
  input: add onkey driver for Marvell 88PM886 PMIC
  MAINTAINERS: add myself for Marvell 88PM886 PMIC

 .../bindings/mfd/marvell,88pm886-a1.yaml  |  76 +++
 MAINTAINERS   |   9 +
 drivers/input/misc/88pm886-onkey.c|  92 
 drivers/input/misc/Kconfig|   7 +
 drivers/input/misc/Makefile   |   1 +
 drivers/mfd/88pm886.c | 210 ++
 drivers/mfd/Kconfig   |  12 +
 drivers/mfd/Makefile  |   1 +
 drivers/regulator/88pm886-regulator.c | 195 
 drivers/regulator/Kconfig |   6 +
 drivers/regulator/Makefile|   1 +
 include/linux/mfd/88pm886.h   |  46 
 12 files changed, 656 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/mfd/marvell,88pm886-a1.yaml
 create mode 100644 drivers/input/misc/88pm886-onkey.c
 create mode 100644 drivers/mfd/88pm886.c
 create mode 100644 drivers/regulator/88pm886-regulator.c
 create mode 100644 include/linux/mfd/88pm886.h

-- 
2.44.0