Skip to contentSkip to conversation

Add support for the System Power Management Interface (SPMI)

RFC PATCH Superseded Josh Cartwright 4 participants 17 messages Aug 9, 2013 – Aug 16, 2013 2 messages not in the archive

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Add support for the System Power Management Interface (SPMI)

The System Power Management Interface (SPMI) is a high-speed, low-latency, bi-directional, two-wire serial bus suitable for real-time control of voltage and frequency scaled multi-core application processors and its power management of auxiliary components. SPMI obsoletes a number of legacy, custom point-to-point interfaces and provides a low pin count, high-speed control bus for up to 4 Master and 16 Slave devices.

SPMI is specified by the MIPI (Mobile Industry Process Interface) Alliance [1].

Introduced in this patchset are the core SPMI bus components, as well an implementation of an SPMI controller, the "PMIC arbiter", which is used on several Qualcomm SoCs to communicate with off-chip Power Management ICs (PMICs). Notably missing from this patchset is an implementation of a spmi device/slave driver, which is still forthcoming. With this patchset in it's current state, it is possible to perform register accesses to a slave via debugfs.

[1]: http://www.mipi.org/specifications/system-power-management-interface

Josh Cartwright (1):
spmi: document the PMIC arbiter SPMI bindings

Kenneth Heitke (2):
spmi: Linux driver framework for SPMI
spmi: Add MSM PMIC Arbiter SPMI controller

 .../devicetree/bindings/spmi/spmi-pmic-arb.txt     |  26 +
 drivers/Kconfig                                    |   2 +
 drivers/Makefile                                   |   1 +
 drivers/of/Kconfig                                 |   6 +
 drivers/of/Makefile                                |   1 +
 drivers/of/of_spmi.c                               |  74 +++
 drivers/spmi/Kconfig                               |  24 +
 drivers/spmi/Makefile                              |   9 +
 drivers/spmi/spmi-dbgfs.c                          | 591 +++++++++++++++++++++
 drivers/spmi/spmi-dbgfs.h                          |  37 ++
 drivers/spmi/spmi-pmic-arb.c                       | 499 +++++++++++++++++
 drivers/spmi/spmi.c                                | 449 ++++++++++++++++
 include/linux/mod_devicetable.h                    |   8 +
 include/linux/of_spmi.h                            |  37 ++
 include/linux/spmi.h                               | 337 ++++++++++++
 15 files changed, 2101 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt
 create mode 100644 drivers/of/of_spmi.c
 create mode 100644 drivers/spmi/Kconfig
 create mode 100644 drivers/spmi/Makefile
 create mode 100644 drivers/spmi/spmi-dbgfs.c
 create mode 100644 drivers/spmi/spmi-dbgfs.h
 create mode 100644 drivers/spmi/spmi-pmic-arb.c
 create mode 100644 drivers/spmi/spmi.c
 create mode 100644 include/linux/of_spmi.h
 create mode 100644 include/linux/spmi.h
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw

RFC PATCH 1/3 spmi: Linux driver framework for SPMI

From: Kenneth Heitke <[email protected]>

System Power Management Interface (SPMI) is a specification developed by the MIPI (Mobile Industry Process Interface) Alliance optimized for the real time control of Power Management ICs (PMIC).

SPMI is a two-wire serial interface that supports up to 4 master devices and up to 16 logical slaves.

The framework supports message APIs, multiple busses (1 controller per bus) and multiple clients/slave devices per controller.

---
 drivers/Kconfig                 |   2 +
 drivers/Makefile                |   1 +
 drivers/of/Kconfig              |   6 +
 drivers/of/Makefile             |   1 +
 drivers/of/of_spmi.c            |  74 +++++
 drivers/spmi/Kconfig            |   9 +
 drivers/spmi/Makefile           |   7 +
 drivers/spmi/spmi-dbgfs.c       | 591 ++++++++++++++++++++++++++++++++++++++++
 drivers/spmi/spmi-dbgfs.h       |  37 +++
 drivers/spmi/spmi.c             | 449 ++++++++++++++++++++++++++++++
 include/linux/mod_devicetable.h |   8 +
 include/linux/of_spmi.h         |  37 +++
 include/linux/spmi.h            | 337 +++++++++++++++++++++++
 13 files changed, 1559 insertions(+)
 create mode 100644 drivers/of/of_spmi.c
 create mode 100644 drivers/spmi/Kconfig
 create mode 100644 drivers/spmi/Makefile
 create mode 100644 drivers/spmi/spmi-dbgfs.c
 create mode 100644 drivers/spmi/spmi-dbgfs.h
 create mode 100644 drivers/spmi/spmi.c
 create mode 100644 include/linux/of_spmi.h
 create mode 100644 include/linux/spmi.h
drivers/Kconfig +2 -0
index aa43b91..2b35420 100644
@@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig"
 
 source "drivers/spi/Kconfig"
 
+source "drivers/spmi/Kconfig"
+
 source "drivers/hsi/Kconfig"
 
 source "drivers/pps/Kconfig"
drivers/Makefile +1 -0
index ab93de8..5c250df 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_ATA)		+= ata/
 obj-$(CONFIG_TARGET_CORE)	+= target/
 obj-$(CONFIG_MTD)		+= mtd/
 obj-$(CONFIG_SPI)		+= spi/
+obj-$(CONFIG_SPMI)		+= spmi/
 obj-y				+= hsi/
 obj-y				+= net/
 obj-$(CONFIG_ATM)		+= atm/
drivers/of/Kconfig +6 -0
index 80e5c13..916b0c1 100644
@@ -76,6 +76,12 @@ config OF_PCI_IRQ
 	help
 	  OpenFirmware PCI IRQ routing helpers
 
+config OF_SPMI
+	def_tristate SPMI
+	depends on SPMI
+	help
+	  OpenFirmware SPMI bus accessors
+
 config OF_MTD
 	depends on MTD
 	def_bool y
drivers/of/Makefile +1 -0
index 1f9c0c4..5486614 100644
@@ -9,4 +9,5 @@ obj-$(CONFIG_OF_SELFTEST) += selftest.o
 obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
 obj-$(CONFIG_OF_PCI)	+= of_pci.o
 obj-$(CONFIG_OF_PCI_IRQ)  += of_pci_irq.o
+obj-$(CONFIG_OF_SPMI)	+= of_spmi.o
 obj-$(CONFIG_OF_MTD)	+= of_mtd.o
drivers/of/of_spmi.c new file +74 -0

74 lines not on this page · raw message

drivers/spmi/Kconfig new file +9 -0
new file mode 100644
index 0000000..a03835f
@@ -0,0 +1,9 @@
+#
+# SPMI driver configuration
+#
+menuconfig SPMI
+	bool "SPMI support"
+	help
+	  SPMI (System Power Management Interface) is a two-wire
+	  serial interface between baseband and application processors
+	  and Power Management Integrated Circuits (PMIC).
drivers/spmi/Makefile new file +7 -0
new file mode 100644
index 0000000..ef96afd
@@ -0,0 +1,7 @@
+#
+# Makefile for kernel SPMI framework.
+#
+obj-$(CONFIG_SPMI)	+= spmi-core.o
+
+spmi-core-y			+= spmi.o
+spmi-core-$(CONFIG_DEBUG_FS)	+= spmi-dbgfs.o
drivers/spmi/spmi-dbgfs.c new file +591 -0

591 lines not on this page · raw message

drivers/spmi/spmi-dbgfs.h new file +37 -0
new file mode 100644
index 0000000..896bb5a
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef _SPMI_DBGFS_H
+#define _SPMI_DBGFS_H
+
+#include <linux/spmi.h>
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS
+
+extern void __init spmi_dfs_init(void);
+extern void __exit spmi_dfs_exit(void);
+extern void spmi_dfs_add_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_del_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_add_device(struct spmi_device *sdev);
+extern void spmi_dfs_del_device(struct spmi_device *sdev);
+
+#else
+
+static inline void __init spmi_dfs_init(void) { }
+static inline void __exit spmi_dfs_exit(void) { }
+static inline void spmi_dfs_add_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_del_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_add_device(struct spmi_device *sdev) { }
+static inline void spmi_dfs_del_device(struct spmi_device *sdev) { }
+#endif
+
+#endif /* _SPMI_DBGFS_H */
drivers/spmi/spmi.c new file +449 -0

449 lines not on this page · raw message

include/linux/mod_devicetable.h +8 -0
index 45e9214..677e474 100644
@@ -432,6 +432,14 @@ struct spi_device_id {
 	kernel_ulong_t driver_data;	/* Data private to the driver */
 };
 
+#define SPMI_NAME_SIZE	32
+#define SPMI_MODULE_PREFIX "spmi:"
+
+struct spmi_device_id {
+	char name[SPMI_NAME_SIZE];
+	kernel_ulong_t driver_data;	/* Data private to the driver */
+};
+
 /* dmi */
 enum dmi_field {
 	DMI_NONE,
include/linux/of_spmi.h new file +37 -0
new file mode 100644
index 0000000..6965d7d
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef _LINUX_OF_SPMI
+#define _LINUX_OF_SPMI
+
+struct spmi_controller;
+
+#ifdef CONFIG_OF_SPMI
+/**
+ * of_spmi_register_devices() - Register devices in the SPMI Device Tree
+ * @ctrl: spmi_controller which devices should be registered to.
+ *
+ * This routine scans the SPMI Device Tree, allocating resources and
+ * creating spmi_devices according to the SPMI bus Device Tree
+ * hierarchy. Details of this hierarchy can be found in
+ * Documentation/devicetree/bindings/spmi. This routine is normally
+ * called from the probe routine of the driver registering as a
+ * spmi_controller.
+ */
+int of_spmi_register_devices(struct spmi_controller *ctrl);
+#else
+static int of_spmi_register_devices(struct spmi_controller *ctrl)
+{
+	return -ENXIO;
+}
+#endif /* CONFIG_OF_SPMI */
+
+#endif
include/linux/spmi.h new file +337 -0

337 lines not on this page · raw message

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 5 lines · Josh Cartwright
drivers/of/of_spmi.c new file +2 -0
@@ -0,0 +1,74 @@
+/* Copyright (c) 2012,2013 The Linux Foundation. All rights reserved.
+ *

drivers/of/of_spmi.c line 12

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) "%s: " fmt, __func__

As you never make a pr_* call in this file, this line isn't needed.

Quoted 4 lines
drivers/of/of_spmi.c new file +3 -0
+++ b/drivers/spmi/spmi-dbgfs.c
@@ -0,0 +1,591 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *

drivers/of/of_spmi.c line 12

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) "%s:%d: " fmt, __func__, __LINE__

__func__ and __LINE__? Is that really needed, what will it help with? Seems like extra noise, especially as you only have a few pr_* calls in this file:

Quoted 4 lines
drivers/of/of_spmi.c new file +4 -0
+static int
+spmi_read_data(struct spmi_device *sdev, uint8_t *buf, int offset, int cnt)
+{
+	int ret = 0;

drivers/of/of_spmi.c line 26

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+	int len;
+	uint16_t addr;
+
+	while (cnt > 0) {
+		addr = offset & 0xFFFF;
+		len = min(cnt, MAX_REG_PER_TRANSACTION);
+
+		ret = spmi_ext_register_readl(sdev, addr, buf, len);
+		if (ret < 0) {
+			pr_err("SPMI read failed, err = %d\n", ret);

Should be using dev_err() instead.

Quoted 13 lines
drivers/of/of_spmi.c new file +13 -0
+/**
+ * spmi_write_data: writes data across the SPMI bus
+ * @ctrl: The SPMI controller
+ * @buf: data to be written.
+ * @offset: SPMI address offset to start writing to.
+ * @cnt: The number of bytes to write.
+ *
+ * Returns 0 on success, otherwise returns error code from SPMI driver.
+ */
+static int
+spmi_write_data(struct spmi_device *sdev, uint8_t *buf, int offset, int cnt)
+{
+	int ret = 0;

drivers/of/of_spmi.c line 49

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+	int len;
+	uint16_t addr;
+
+	while (cnt > 0) {
+		addr = offset & 0xFFFF;
+		len = min(cnt, MAX_REG_PER_TRANSACTION);
+
+		ret = spmi_ext_register_writel(sdev, addr, buf, len);
+		if (ret < 0) {
+			pr_err("SPMI write failed, err = %d\n", ret);

Same, dev_err() please.

Quoted 12 lines
drivers/of/of_spmi.c new file +12 -0
+static ssize_t spmi_device_dfs_reg_write(struct file *file,
+					 const char __user *buf,
+					 size_t count, loff_t *ppos)
+{
+	int bytes_read;
+	int data;
+	int pos = 0;
+	int cnt = 0;
+	u8  *values;
+	size_t ret = 0;
+
+	struct spmi_trans *trans = file->private_data;

drivers/of/of_spmi.c line 71

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+	u32 offset = trans->offset;
+
+	/* Make a copy of the user data */
+	char *kbuf = kmalloc(count + 1, GFP_KERNEL);
+	if (!kbuf)
+		return -ENOMEM;
+
+	ret = copy_from_user(kbuf, buf, count);
+	if (ret == count) {
+		pr_err("failed to copy data from user\n");

No need for a message here at all, you will get a message in the function if something happened wrong.

Also, shouldn't it just be a simple:

	if (copy_from_user()) {

test?

Quoted 15 lines
drivers/of/of_spmi.c new file +15 -0
+		ret = -EFAULT;
+		goto free_buf;
+	}
+
+	count -= ret;
+	*ppos += count;
+	kbuf[count] = '\0';
+
+	/* Override the text buffer with the raw data */
+	values = kbuf;
+
+	/* Parse the data in the buffer.  It should be a string of numbers */
+	while (sscanf(kbuf + pos, "%i%n", &data, &bytes_read) == 1) {
+		pos += bytes_read;
+		values[cnt++] = data & 0xff;

drivers/of/of_spmi.c line 96

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+	}
+
+	if (!cnt)
+		goto free_buf;
+
+	/* Perform the SPMI write(s) */
+	ret = spmi_write_data(trans->sdev, values, offset, cnt);
+
+	if (ret) {
+		pr_err("SPMI write failed, err = %zu\n", ret);

dev_err() please.

Quoted 9 lines
drivers/of/of_spmi.c new file +9 -0
+static ssize_t spmi_device_dfs_reg_read(struct file *file, char __user *buf,
+					size_t count, loff_t *ppos)
+{
+	struct spmi_trans *trans = file->private_data;
+	struct spmi_log_buffer *log = trans->log;
+	size_t ret;
+	size_t len;
+
+	/* Is the the log buffer empty */

drivers/of/of_spmi.c line 115

Quoted 10 lines
drivers/of/of_spmi.c new file +10 -0
+	if (log->rpos >= log->wpos) {
+		if (get_log_data(trans) <= 0)
+			return 0;
+	}
+
+	len = min(count, (size_t) log->wpos - log->rpos);
+
+	ret = copy_to_user(buf, &log->data[log->rpos], len);
+	if (ret == len) {
+		pr_err("error copy SPMI register values to user\n");

Same comments as above.

drivers/of/of_spmi.c line 118

Quoted 3 lines
drivers/of/of_spmi.c new file +3 -0
+void __exit spmi_dfs_exit(void)
+{
+	pr_debug("de-initializing spmi debugfs ...");

Not needed, use the in-kernel trace functionality if you really want to know this.

drivers/of/of_spmi.c line 126

Quoted 8 lines
drivers/of/of_spmi.c new file +8 -0
+	debugfs_remove_recursive(spmi_debug_root);
+}
+
+void __init spmi_dfs_init(void)
+{
+	struct dentry *help;
+
+	pr_debug("creating SPMI debugfs file-system\n");

Same as above, not needed.

So, with those changes, pr_fmt() isn't needed at all :)

Quoted 11 lines
drivers/spmi/spmi-dbgfs.h new file +8 -0
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

drivers/spmi/spmi-dbgfs.h line 18

Quoted 10 lines
drivers/spmi/spmi-dbgfs.h new file +10 -0
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifndef _SPMI_DBGFS_H
+#define _SPMI_DBGFS_H
+
+#include <linux/spmi.h>
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Quoted 27 lines
drivers/spmi/spmi-dbgfs.h new file +19 -0
+
+extern void __init spmi_dfs_init(void);
+extern void __exit spmi_dfs_exit(void);
+extern void spmi_dfs_add_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_del_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_add_device(struct spmi_device *sdev);
+extern void spmi_dfs_del_device(struct spmi_device *sdev);
+
+#else
+
+static inline void __init spmi_dfs_init(void) { }
+static inline void __exit spmi_dfs_exit(void) { }
+static inline void spmi_dfs_add_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_del_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_add_device(struct spmi_device *sdev) { }
+static inline void spmi_dfs_del_device(struct spmi_device *sdev) { }
+#endif
+
+#endif /* _SPMI_DBGFS_H */
drivers/spmi/spmi.c new file +2 -0
new file mode 100644
index 0000000..3bbcc63
@@ -0,0 +1,449 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *

drivers/spmi/spmi.c line 12

Quoted 10 lines
drivers/spmi/spmi.c new file +10 -0
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) "%s: " fmt, __func__

Again, not needed for this file, because:

drivers/spmi/spmi.c line 364

Quoted 5 lines
drivers/spmi/spmi.c new file +5 -0
+int spmi_add_controller(struct spmi_controller *ctrl)
+{
+	int id;
+
+	pr_debug("adding controller for bus %d (0x%p)\n", ctrl->nr, ctrl);

dev_dbg() if you really need/want it.

drivers/spmi/spmi.c line 367

Quoted 3 lines
drivers/spmi/spmi.c new file +3 -0
+
+	if (((int)ctrl->nr) < 0) {
+		pr_err("invalid bus identifier %d\n", ctrl->nr);

dev_err() please.

drivers/spmi/spmi.c line 380

Quoted 13 lines
drivers/spmi/spmi.c new file +13 -0
+		return -EINVAL;
+	}
+
+	idr_preload(GFP_KERNEL);
+	mutex_lock(&board_lock);
+	id = idr_alloc(&ctrl_idr, ctrl, ctrl->nr, ctrl->nr + 1, GFP_NOWAIT);
+	mutex_unlock(&board_lock);
+	idr_preload_end();
+
+	if (id < 0) {
+		pr_err(
+		   "idr_alloc(start:%d end:%d):%d at spmi_add_controller()\n",
+		   ctrl->nr, ctrl->nr, id);

dev_err() please.

And then the pr_fmt() line can be removed.

thanks,

greg k-h

#3 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Hey Greg-

Thanks for the comments.

Quoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · Josh Cartwright
drivers/of/of_spmi.c new file +6 -0
@@ -0,0 +1,74 @@
+/* Copyright (c) 2012,2013 The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
Quoted 8 lines

drivers/of/of_spmi.c line 12

Quoted 6 lines
drivers/of/of_spmi.c new file +6 -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.
+ */
+#define pr_fmt(fmt) "%s: " fmt, __func__

As you never make a pr_* call in this file, this line isn't needed.

I'll clean these up for v2.

Quoted 8 lines
Quoted 8 lines
drivers/of/of_spmi.c new file +8 -0
+static int
+spmi_read_data(struct spmi_device *sdev, uint8_t *buf, int offset, int cnt)
+{
+	int ret = 0;
+	int len;
+	uint16_t addr;
+
+	while (cnt > 0) {
Quoted 8 lines

drivers/of/of_spmi.c line 26

Quoted 6 lines
drivers/of/of_spmi.c new file +6 -0
+		addr = offset & 0xFFFF;
+		len = min(cnt, MAX_REG_PER_TRANSACTION);
+
+		ret = spmi_ext_register_readl(sdev, addr, buf, len);
+		if (ret < 0) {
+			pr_err("SPMI read failed, err = %d\n", ret);

Should be using dev_err() instead.

These too.

[..]

Quoted 13 lines

drivers/of/of_spmi.c line 35

Quoted 9 lines
drivers/of/of_spmi.c new file +9 -0
+
+	/* Make a copy of the user data */
+	char *kbuf = kmalloc(count + 1, GFP_KERNEL);
+	if (!kbuf)
+		return -ENOMEM;
+
+	ret = copy_from_user(kbuf, buf, count);
+	if (ret == count) {
+		pr_err("failed to copy data from user\n");

No need for a message here at all, you will get a message in the function if something happened wrong.

Quoted 3 lines

Also, shouldn't it just be a simple:

	if (copy_from_user()) {

test?

Indeed, thanks.

[..]

Quoted 6 lines

drivers/of/of_spmi.c line 38

Quoted 3 lines
drivers/of/of_spmi.c new file +3 -0
+void __exit spmi_dfs_exit(void)
+{
+	pr_debug("de-initializing spmi debugfs ...");

Not needed, use the in-kernel trace functionality if you really want to know this.

Will kill these.

Quoted 17 lines
Quoted 17 lines
drivers/spmi/spmi-dbgfs.h new file +14 -0
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef _SPMI_DBGFS_H
+#define _SPMI_DBGFS_H
+
Quoted 8 lines

drivers/spmi/spmi-dbgfs.h line 18

Quoted 4 lines
drivers/spmi/spmi-dbgfs.h new file +4 -0
+#include <linux/spmi.h>
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Not sure I follow you, but it may be because this is a bit misleading.

Currently CONFIG_DEBUG_FS is being extended to also mean "do you want the SPMI core to create device entries?". It would probably make more sense to have a CONFIG_SPMI_DEBUG option which is def_bool DEBUG_FS, as other busses have.

The #ifdef here would then be #ifdef CONFIG_SPMI_DEBUG, as well as in the Makefile:

  spmi-core-$(CONFIG_SPMI_DEBUG) += spmi-dbgfs.o
Quoted 11 lines
Quoted 11 lines
drivers/spmi/spmi-dbgfs.h new file +11 -0
+
+extern void __init spmi_dfs_init(void);
+extern void __exit spmi_dfs_exit(void);
+extern void spmi_dfs_add_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_del_controller(struct spmi_controller *ctrl);
+extern void spmi_dfs_add_device(struct spmi_device *sdev);
+extern void spmi_dfs_del_device(struct spmi_device *sdev);
+
+#else
+
+static inline void __init spmi_dfs_init(void) { }
Quoted 8 lines

drivers/spmi/spmi-dbgfs.h line 37

Quoted 8 lines
drivers/spmi/spmi-dbgfs.h new file +8 -0
+static inline void __exit spmi_dfs_exit(void) { }
+static inline void spmi_dfs_add_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_del_controller(struct spmi_controller *ctrl) { }
+static inline void spmi_dfs_add_device(struct spmi_device *sdev) { }
+static inline void spmi_dfs_del_device(struct spmi_device *sdev) { }
+#endif
+
+#endif /* _SPMI_DBGFS_H */

Thanks,
Josh

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#4 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 9 lines · Josh Cartwright
Quoted 4 lines

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Not sure I follow you, but it may be because this is a bit misleading.

Currently CONFIG_DEBUG_FS is being extended to also mean "do you want the SPMI core to create device entries?". It would probably make more

debugfs -^

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#5 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

In reply to Josh Cartwright
Quoted 13 lines · Josh Cartwright
Quoted 5 lines
Quoted 1 line

+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Not sure I follow you, but it may be because this is a bit misleading.

Currently CONFIG_DEBUG_FS is being extended to also mean "do you want the SPMI core to create device entries?". It would probably make more sense to have a CONFIG_SPMI_DEBUG option which is def_bool DEBUG_FS, as other busses have.

Quoted 4 lines

The #ifdef here would then be #ifdef CONFIG_SPMI_DEBUG, as well as in the Makefile:

  spmi-core-$(CONFIG_SPMI_DEBUG) += spmi-dbgfs.o

If debugfs is enabled why wouldn't you want debugfs entries for your devices? Don't assume a user is going to be able to rebuild their kernel just for debugging stuff (hint, they usually aren't), so having these present, if they don't cause any performance issues, is usually best to always have around.

thanks,

greg k-h

#6 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Josh Cartwright
Quoted 5 lines
Quoted 1 line

+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Not sure I follow you, but it may be because this is a bit misleading.

Currently CONFIG_DEBUG_FS is being extended to also mean "do you want the SPMI core to create device entries?". It would probably make more sense to have a CONFIG_SPMI_DEBUG option which is def_bool DEBUG_FS, as other busses have.

The #ifdef here would then be #ifdef CONFIG_SPMI_DEBUG, as well as in the Makefile:

Quoted 7 lines
Quoted 1 line
  spmi-core-$(CONFIG_SPMI_DEBUG) += spmi-dbgfs.o

If debugfs is enabled why wouldn't you want debugfs entries for your devices? Don't assume a user is going to be able to rebuild their kernel just for debugging stuff (hint, they usually aren't), so having these present, if they don't cause any performance issues, is usually best to always have around.

Okay, that makes sense.

So, backing up a step, you're original comment was regarding the CONFIG_DEBUG_FS conditional in spmi-dbgfs.h:

Quoted 17 lines · Greg Kroah-Hartman
Quoted 17 lines
drivers/spmi/spmi-dbgfs.h new file +14 -0
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef _SPMI_DBGFS_H
+#define _SPMI_DBGFS_H
+
Quoted 8 lines

drivers/spmi/spmi-dbgfs.h line 18

Quoted 4 lines
drivers/spmi/spmi-dbgfs.h new file +4 -0
+#include <linux/spmi.h>
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

The reason why this is done is because the spmi debugfs support code is is only built-in when CONFIG_DEBUG_FS is set.

Would you rather it always be built-in (well, whenever SPMI support is included), and rely on the debugfs_* shims to handle the !CONFIG_DEBUG_FS case?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#7 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 58 lines · Josh Cartwright
Quoted 17 lines · Greg Kroah-Hartman
Quoted 16 lines · Josh Cartwright
Quoted 5 lines
Quoted 1 line

+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Not sure I follow you, but it may be because this is a bit misleading.

Currently CONFIG_DEBUG_FS is being extended to also mean "do you want the SPMI core to create device entries?". It would probably make more sense to have a CONFIG_SPMI_DEBUG option which is def_bool DEBUG_FS, as other busses have.

The #ifdef here would then be #ifdef CONFIG_SPMI_DEBUG, as well as in the Makefile:

Quoted 7 lines
Quoted 1 line
  spmi-core-$(CONFIG_SPMI_DEBUG) += spmi-dbgfs.o

If debugfs is enabled why wouldn't you want debugfs entries for your devices? Don't assume a user is going to be able to rebuild their kernel just for debugging stuff (hint, they usually aren't), so having these present, if they don't cause any performance issues, is usually best to always have around.

Okay, that makes sense.

So, backing up a step, you're original comment was regarding the CONFIG_DEBUG_FS conditional in spmi-dbgfs.h:

Quoted 17 lines · Greg Kroah-Hartman
Quoted 17 lines
drivers/spmi/spmi-dbgfs.h new file +14 -0
@@ -0,0 +1,37 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#ifndef _SPMI_DBGFS_H
+#define _SPMI_DBGFS_H
+
Quoted 8 lines

drivers/spmi/spmi-dbgfs.h line 18

Quoted 4 lines
drivers/spmi/spmi-dbgfs.h new file +4 -0
+#include <linux/spmi.h>
+#include <linux/debugfs.h>
+
+#ifdef CONFIG_DEBUG_FS

Why? If debugfs isn't enabled, the functions should just compile away with the debugfs_() calls, so no need to do this type of thing here, right?

Quoted 6 lines

The reason why this is done is because the spmi debugfs support code is is only built-in when CONFIG_DEBUG_FS is set.

Would you rather it always be built-in (well, whenever SPMI support is included), and rely on the debugfs_* shims to handle the !CONFIG_DEBUG_FS case?

Yes, that makes the logic in your driver simpler, and easier to review. The compiler will just compile away almost all of the logic if debugfs isn't present, so there shouldn't be any big size difference.

thanks,

greg k-h

#8 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

In reply to Josh Cartwright
Quoted 30 lines · Josh Cartwright

+++ b/drivers/spmi/spmi.c

drivers/spmi/spmi.c new file +28 -0
@@ -0,0 +1,449 @@
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) "%s: " fmt, __func__
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/idr.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/spmi.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+
+#include "spmi-dbgfs.h"
+
+static DEFINE_MUTEX(board_lock);
+static DEFINE_IDR(ctrl_idr);

drivers/spmi/spmi.c line 38

Quoted 10 lines
drivers/spmi/spmi.c new file +10 -0
+
+static void spmi_dev_release(struct device *dev)
+{
+	struct spmi_device *spmidev = to_spmi_device(dev);
+	kfree(spmidev);
+}
+
+static struct device_type spmi_dev_type = {
+	.release	= spmi_dev_release,
+};

I give a lot of people crap when they get things wrong with the driver model, so it's only fair to call out when it's done correctly.

Nice job here, thanks for getting this right.

drivers/spmi/spmi.c line 43

Quoted 4 lines
drivers/spmi/spmi.c new file +4 -0
+static void spmi_ctrl_release(struct device *dev)
+{
+	struct spmi_controller *ctrl = to_spmi_controller(dev);
+	complete(&ctrl->dev_released);

When is this memory going to be freed?

Ah, you think it will be when you remove the device later on:

Quoted 16 lines
drivers/spmi/spmi.c new file +16 -0
+int spmi_del_controller(struct spmi_controller *ctrl)
+{
+	struct spmi_controller *found;
+
+	if (!ctrl)
+		return -EINVAL;
+
+	/* Check that the ctrl has been added */
+	mutex_lock(&board_lock);
+	found = idr_find(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	if (found != ctrl)
+		return -EINVAL;
+
+	spmi_dfs_del_controller(ctrl);

drivers/spmi/spmi.c line 419

Quoted 10 lines
drivers/spmi/spmi.c new file +10 -0
+
+	/* Remove all the clients associated with this controller */
+	mutex_lock(&board_lock);
+	bus_for_each_dev(&spmi_bus_type, NULL, ctrl, spmi_ctrl_remove_device);
+	idr_remove(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	init_completion(&ctrl->dev_released);
+	device_unregister(&ctrl->dev);
+	wait_for_completion(&ctrl->dev_released);

But you just leaked memory, right?

You should never have to wait for this to happen, why did you need to add this? Why not just a simple call to kfree() in the release function?

thanks,

greg k-h

#9 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Josh Cartwright

+++ b/drivers/spmi/spmi.c

(quoted diff) +0 -0
@@ -0,0 +1,449 @@

[..]

Quoted 38 lines

drivers/spmi/spmi.c line 43

Quoted 4 lines
drivers/spmi/spmi.c new file +4 -0
+static void spmi_ctrl_release(struct device *dev)
+{
+	struct spmi_controller *ctrl = to_spmi_controller(dev);
+	complete(&ctrl->dev_released);

When is this memory going to be freed?

Ah, you think it will be when you remove the device later on:

Quoted 16 lines
drivers/spmi/spmi.c new file +16 -0
+int spmi_del_controller(struct spmi_controller *ctrl)
+{
+	struct spmi_controller *found;
+
+	if (!ctrl)
+		return -EINVAL;
+
+	/* Check that the ctrl has been added */
+	mutex_lock(&board_lock);
+	found = idr_find(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	if (found != ctrl)
+		return -EINVAL;
+
+	spmi_dfs_del_controller(ctrl);

drivers/spmi/spmi.c line 419

Quoted 10 lines
drivers/spmi/spmi.c new file +10 -0
+
+	/* Remove all the clients associated with this controller */
+	mutex_lock(&board_lock);
+	bus_for_each_dev(&spmi_bus_type, NULL, ctrl, spmi_ctrl_remove_device);
+	idr_remove(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	init_completion(&ctrl->dev_released);
+	device_unregister(&ctrl->dev);
+	wait_for_completion(&ctrl->dev_released);

But you just leaked memory, right?

Quoted 3 lines

You should never have to wait for this to happen, why did you need to add this? Why not just a simple call to kfree() in the release function?

Unfortunately, the reason why this was necessary may be lost to history. :(

I'll do some testing with the completion removed and a simple kfree() in the release and see if there is any fallout.

Thanks,
Josh

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#10 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

Quoted 43 lines · Josh Cartwright
Quoted 3 lines · Greg Kroah-Hartman
Quoted 2 lines · Josh Cartwright

+++ b/drivers/spmi/spmi.c

(quoted diff) +0 -0
@@ -0,0 +1,449 @@

[..]

Quoted 38 lines

drivers/spmi/spmi.c line 43

Quoted 4 lines
drivers/spmi/spmi.c new file +4 -0
+static void spmi_ctrl_release(struct device *dev)
+{
+	struct spmi_controller *ctrl = to_spmi_controller(dev);
+	complete(&ctrl->dev_released);

When is this memory going to be freed?

Ah, you think it will be when you remove the device later on:

Quoted 16 lines
drivers/spmi/spmi.c new file +16 -0
+int spmi_del_controller(struct spmi_controller *ctrl)
+{
+	struct spmi_controller *found;
+
+	if (!ctrl)
+		return -EINVAL;
+
+	/* Check that the ctrl has been added */
+	mutex_lock(&board_lock);
+	found = idr_find(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	if (found != ctrl)
+		return -EINVAL;
+
+	spmi_dfs_del_controller(ctrl);

drivers/spmi/spmi.c line 419

Quoted 10 lines
drivers/spmi/spmi.c new file +10 -0
+
+	/* Remove all the clients associated with this controller */
+	mutex_lock(&board_lock);
+	bus_for_each_dev(&spmi_bus_type, NULL, ctrl, spmi_ctrl_remove_device);
+	idr_remove(&ctrl_idr, ctrl->nr);
+	mutex_unlock(&board_lock);
+
+	init_completion(&ctrl->dev_released);
+	device_unregister(&ctrl->dev);
+	wait_for_completion(&ctrl->dev_released);

But you just leaked memory, right?

Quoted 8 lines
Quoted 3 lines

You should never have to wait for this to happen, why did you need to add this? Why not just a simple call to kfree() in the release function?

Unfortunately, the reason why this was necessary may be lost to history. :(

I'll do some testing with the completion removed and a simple kfree() in the release and see if there is any fallout.

There will be, you need to fix up the calling logic and the driver to prevent memory that it thinks it still has access to, from going away (that was my hint for the other patch you sent.)

thanks,

greg k-h

#11 lore raw

Re: [PATCH RFC 1/3] spmi: Linux driver framework for SPMI

In reply to Josh Cartwright
Quoted 30 lines · Josh Cartwright

From: Kenneth Heitke <[email protected]>

System Power Management Interface (SPMI) is a specification developed by the MIPI (Mobile Industry Process Interface) Alliance optimized for the real time control of Power Management ICs (PMIC).

SPMI is a two-wire serial interface that supports up to 4 master devices and up to 16 logical slaves.

The framework supports message APIs, multiple busses (1 controller per bus) and multiple clients/slave devices per controller.

---

drivers/Kconfig                 |   2 +
drivers/Makefile                |   1 +
drivers/of/Kconfig              |   6 +
drivers/of/Makefile             |   1 +
drivers/of/of_spmi.c            |  74 +++++
drivers/spmi/Kconfig            |   9 +
drivers/spmi/Makefile           |   7 +
drivers/spmi/spmi-dbgfs.c       | 591 ++++++++++++++++++++++++++++++++++++++++
drivers/spmi/spmi-dbgfs.h       |  37 +++
drivers/spmi/spmi.c             | 449 ++++++++++++++++++++++++++++++
include/linux/mod_devicetable.h |   8 +
include/linux/of_spmi.h         |  37 +++
include/linux/spmi.h            | 337 +++++++++++++++++++++++
13 files changed, 1559 insertions(+)
Quoted 8 lines

create mode 100644 drivers/of/of_spmi.c
create mode 100644 drivers/spmi/Kconfig
create mode 100644 drivers/spmi/Makefile
create mode 100644 drivers/spmi/spmi-dbgfs.c
create mode 100644 drivers/spmi/spmi-dbgfs.h
create mode 100644 drivers/spmi/spmi.c
create mode 100644 include/linux/of_spmi.h
create mode 100644 include/linux/spmi.h

Looks like you are missing a patch for the general OF binding for SPMI

- k

Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#12 lore raw

RFC PATCH 2/3 spmi: Add MSM PMIC Arbiter SPMI controller

In reply to Josh Cartwright

From: Kenneth Heitke <[email protected]>

Qualcomm's PMIC Arbiter SPMI controller functions as a bus master and is used to communication with one or more PMIC (slave) devices on the SPMI bus. The PMIC Arbiter is actually a hardware wrapper around the SPMI controller that provides concurrent and autonomous PMIC access to various entities that need to communicate with the PMIC.

The SPMI controller hardware handles all of the SPMI bus activity (bus arbitration, sequence start condition, transmission of frames, etc). This software driver uses the PMIC Arbiter register interface to initiate command sequences on the SPMI bus. The status register is read to determine when the command sequence has completed and whether or not it completed successfully.

---
 drivers/spmi/Kconfig         |  15 ++
 drivers/spmi/Makefile        |   2 +
 drivers/spmi/spmi-pmic-arb.c | 499 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 516 insertions(+)
 create mode 100644 drivers/spmi/spmi-pmic-arb.c
drivers/spmi/Kconfig +15 -0
index a03835f..056891d 100644
@@ -7,3 +7,18 @@ menuconfig SPMI
 	  SPMI (System Power Management Interface) is a two-wire
 	  serial interface between baseband and application processors
 	  and Power Management Integrated Circuits (PMIC).
+
+if SPMI
+
+config SPMI_MSM_PMIC_ARB
+	tristate "Qualcomm MSM SPMI Controller (PMIC Arbiter)"
+	depends on ARCH_MSM
+	help
+	  If you say yes to this option, support will be included for the
+	  built-in SPMI PMIC Arbiter interface on Qualcomm MSM family
+	  processors.
+
+	  This is required for communicating with Qualcomm PMICs and
+	  other devices that have the SPMI interface.
+
+endif
drivers/spmi/Makefile +2 -0
index ef96afd..f83ea87 100644
@@ -5,3 +5,5 @@ obj-$(CONFIG_SPMI)	+= spmi-core.o
 
 spmi-core-y			+= spmi.o
 spmi-core-$(CONFIG_DEBUG_FS)	+= spmi-dbgfs.o
+
+obj-$(CONFIG_SPMI_MSM_PMIC_ARB)	+= spmi-pmic-arb.o
drivers/spmi/spmi-pmic-arb.c new file +499 -0

499 lines not on this page · raw message

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#13 lore raw

Re: [PATCH RFC 2/3] spmi: Add MSM PMIC Arbiter SPMI controller

drivers/spmi/spmi-pmic-arb.c line 113

Quoted 4 lines · Josh Cartwright
drivers/spmi/spmi-pmic-arb.c new file +4 -0
+struct spmi_pmic_arb_dev {
+	struct spmi_controller	controller;
+	struct device		*dev;
+	struct device		*slave;

This is problematic.

Why do you have the driver "own" the controller? What is dev for, there's already a struct device within the controller. Same for slave, what is it?

You have 3 struct devices here, which one controls the lifecycle of the object (hint, I know the answer, but I think it's wrong...)

thanks,

greg k-h

A message that is not in the archive (sent off-list or not yet received): b639088d50df93caaef8fe7e09c12953b1153ce8.1376596224.git.joshc@codeaurora.org

A message that is not in the archive (sent off-list or not yet received): [email protected]

#16 lore raw

Re: [PATCH RFC 3/3] spmi: document the PMIC arbiter SPMI bindings

Hey Kumar-

Thanks for the review.

Quoted 9 lines · Kumar Gala
Quoted 5 lines · Josh Cartwright

---
.../devicetree/bindings/spmi/spmi-pmic-arb.txt | 26 ++++++++++++++++++++++

1 file changed, 26 insertions(+)

create mode 100644 Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt

As this is a qcom specific binding, I think the file name should be msm-spmi-pmic-arb.txt or something like that.

Agreed. It might be nice to use a vendor prefix in the name too. How's qcom,msm-pmic-arb.txt sound?

Quoted 9 lines

Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt line 1

Quoted 7 lines
Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt new file +1 -0
new file mode 100644
index 0000000..1c14bf4
@@ -0,0 +1,26 @@
+Qualcomm SPMI Controller (PMIC Arbiter)

We should get in the habit of trying to have at least one sentence about what the device is or does.

Certainly.

Quoted 11 lines

Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt line 10

Quoted 9 lines
Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt new file +9 -0
+
+Required properties:
+- compatible : should be "qcom,spmi-pmic-arb".
+- reg-names  : should be "core", "intr", "cnfg"
+- reg : offset and length of the PMIC Arbiter Core register map.
+- reg : offset and length of the PMIC Arbiter Interrupt controller register map.
+- reg : offset and length of the PMIC Arbiter Configuration register map.
+- #address-cells : must be set to 1
+- #size-cells : must be set to 0

Hmm, you aren't describe anything about child nodes.

Indeed. I'll put together a generic SPMI binding document as you had suggested before and reference it in this binding.

Josh

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
#17 lore raw

Re: [PATCH RFC 3/3] spmi: document the PMIC arbiter SPMI bindings

Quoted 13 lines · Josh Cartwright

Hey Kumar-

Thanks for the review.

Quoted 8 lines · Kumar Gala
Quoted 5 lines · Josh Cartwright

---
.../devicetree/bindings/spmi/spmi-pmic-arb.txt | 26 ++++++++++++++++++++++

1 file changed, 26 insertions(+)

create mode 100644 Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt

Quoted 3 lines
Quoted 1 line

As this is a qcom specific binding, I think the file name should be msm-spmi-pmic-arb.txt or something like that.

Agreed. It might be nice to use a vendor prefix in the name too. How's qcom,msm-pmic-arb.txt sound?

Sounds good, as I see we have other examples of having a comma in file names for bindings.

- k

Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#18 lore raw

Re: [PATCH RFC 3/3] spmi: document the PMIC arbiter SPMI bindings

Quoted 16 lines · Kumar Gala
Quoted 13 lines · Josh Cartwright

Hey Kumar-

Thanks for the review.

Quoted 8 lines · Kumar Gala
Quoted 5 lines · Josh Cartwright

---
.../devicetree/bindings/spmi/spmi-pmic-arb.txt | 26 ++++++++++++++++++++++

1 file changed, 26 insertions(+)

create mode 100644 Documentation/devicetree/bindings/spmi/spmi-pmic-arb.txt

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

As this is a qcom specific binding, I think the file name should be msm-spmi-pmic-arb.txt or something like that.

Agreed. It might be nice to use a vendor prefix in the name too. How's qcom,msm-pmic-arb.txt sound?

Sounds good, as I see we have other examples of having a comma in file names for bindings.

The rule I've applied for bindings I created is use the complete compatible value for the file name. Where multiple are supported (e.g. SoC versions), just use the first one. Then, the filename is pretty unambiguous, both from a point of view of ls and from choosing a name.