All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Sagar Dharia <sdharia@codeaurora.org>
Cc: gregkh@linuxfoundation.org, bp@suse.de, poeschel@lemonage.de,
	treding@nvidia.com, broonie@kernel.org,
	gong.chen@linux.intel.com, andreas.noever@gmail.com,
	alan@linux.intel.com, mathieu.poirier@linaro.org,
	daniel@ffwll.ch, jkosina@suse.cz, sharon.dvir1@mail.huji.ac.il,
	joe@perches.com, davem@davemloft.net, james.hogan@imgtec.com,
	michael.opdenacker@free-electrons.com,
	daniel.thompson@linaro.org, robh+dt@kernel.org,
	pawel.moll@arm.com, ijc+devicetree@hellion.org.uk,
	galak@codeaurora.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, kheitke@audience.com,
	mlocke@codeaurora.org, agross@codeaurora.org,
	sheetal.tigadoli@gmail.com, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus
Date: Thu, 28 Apr 2016 12:11:11 +0100	[thread overview]
Message-ID: <20160428111110.GD21145@leverpostej> (raw)
In-Reply-To: <1461801489-16254-3-git-send-email-sdharia@codeaurora.org>

On Wed, Apr 27, 2016 at 05:58:05PM -0600, Sagar Dharia wrote:
> OF helper routine scans the SLIMbus DeviceTree, allocates resources,
> and creates slim_devices according to the hierarchy.
> 
> Signed-off-by: Sagar Dharia <sdharia@codeaurora.org>
> ---
>  Documentation/devicetree/bindings/slimbus/bus.txt | 55 ++++++++++++++++++++++
>  drivers/slimbus/slim-core.c                       | 57 +++++++++++++++++++++++
>  2 files changed, 112 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/slimbus/bus.txt
> 
> diff --git a/Documentation/devicetree/bindings/slimbus/bus.txt b/Documentation/devicetree/bindings/slimbus/bus.txt
> new file mode 100644
> index 0000000..c5bb54a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/slimbus/bus.txt
> @@ -0,0 +1,55 @@
> +SLIM(Serial Low Power Interchip Media Bus) bus
> +
> +SLIMbus is a 2-wire bus, and is used to communicate with peripheral
> +components like audio-codec.
> +
> +Controller is a normal device using binding for whatever bus it is
> +on (e.g. platform bus).
> +Required property for SLIMbus controller node:
> +- compatible	- name of SLIMbus controller following generic names
> +		recommended practice.
> +- #address-cells - should be 4 (number of cells required to define
> +		4 fields of the enumeration address for the SLIMbus
> +		slave device)
> +- #size-cells	- should be 0
> +
> +No other properties are required in the SLIMbus controller bus node.
> +
> +Child nodes:
> +Every SLIMbus controller node can contain zero or more child nodes
> +representing slave devices on the bus. Every SLIMbus slave device is
> +uniquely determined by the enumeration address containing 4 fields:
> +Manufacturer ID, Product code, Device index, and Instance value for
> +the device.
> +If child node is not present and it is instantiated after device
> +discovery (slave device reporting itself present),
> +its name will be in this format: "217:60:1:0"

Per the below code, this naming detail is Linux-specific, and should go
from the binding.

> +However, the device may need additional non-standard way to power it
> +up so that it can start functioning. In that case, child node will
> +need to be present as slave of the slimbus-controller device.
> +The compatible property will be necessary so that corresponding
> +driver can probe and execute the required procedure to make it
> +functional.
> +

I imagine there may be other properties in some cases for more than
just power management, so it may be better to say:

	In some cases it may be necessary to describe non-probeable
	details such as non-standard ways of powering up a device. In
	such cases, child nodes for those devices will be present as
	slaves of the slimbus-controller, as detailed below.

> +Required property for SLIMbus child node if it is present:
> +- reg		- enumeration address fields of the device
> +
> +- compatible	- name of SLIMbus child node using practice typically
> +		followed by discoverable buses:
> +		"<manufacturer>,<product-model>", "slim"

What's the point in the "slim" fallback? That seems to imply nothing
useful, and other busses don't do that.


> +
> +SLIMbus example for Qualcomm's slimbus manager component:
> +
> +	slim@28080000 {
> +		compatible = "qcom,slim-msm";
> +		reg = <0x28080000 0x2000>,
> +		interrupts = <0 33 0>;
> +		clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>;
> +		clock-names = "iface_clk", "core_clk";
> +
> +		codec@0217.0060.01.00 {
> +			compatible = "qcom,wcdv1", "slim";
> +			reg = <0x217 0x60 0x1 0x0>;
> +		};
> +	};

I'm not familiar with SLIMbus, but other than the above comments this
binding looks ok to me.

> diff --git a/drivers/slimbus/slim-core.c b/drivers/slimbus/slim-core.c
> index 6024f74..6aaa08f 100644
> --- a/drivers/slimbus/slim-core.c
> +++ b/drivers/slimbus/slim-core.c
> @@ -18,6 +18,7 @@
>  #include <linux/idr.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/slimbus.h>
> +#include <linux/of.h>
>  
>  static DEFINE_MUTEX(slim_lock);
>  static DEFINE_IDR(ctrl_idr);
> @@ -265,6 +266,61 @@ static LIST_HEAD(board_list);
>  static LIST_HEAD(slim_ctrl_list);
>  static DEFINE_MUTEX(board_lock);
>  
> +#if IS_ENABLED(CONFIG_OF)
> +/* OF helpers for SLIMbus */
> +static void of_register_slim_devices(struct slim_controller *ctrl)
> +{
> +	struct device_node *node;
> +
> +	if (!ctrl->dev.of_node)
> +		return;
> +
> +	for_each_child_of_node(ctrl->dev.of_node, node) {
> +		int ret;
> +		u32 ea[4];
> +		struct slim_device *slim;
> +		char *name;
> +
> +		ret = of_property_read_u32_array(node, "reg", ea, 4);
> +		if (ret) {
> +			dev_err(&ctrl->dev, "of_slim: E-addr err:%d\n", ret);
> +			continue;
> +		}
> +		name = kcalloc(SLIMBUS_NAME_SIZE, sizeof(char), GFP_KERNEL);
> +		if (!name)
> +			return;
> +
> +		slim = kzalloc(sizeof(struct slim_device), GFP_KERNEL);

sizeof(*slim) would be nicer here.

Thanks,
Mark.

  parent reply	other threads:[~2016-04-28 11:11 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 23:58 [PATCH V5 0/6] Introduce framework for SLIMbus device drivers Sagar Dharia
2016-04-27 23:58 ` [PATCH V5 1/6] SLIMbus: Device management on SLIMbus Sagar Dharia
2016-04-28 10:00   ` Arnd Bergmann
2016-04-28 11:53     ` Mark Brown
2016-04-28 12:33       ` Arnd Bergmann
2016-04-28 14:38         ` Mark Brown
     [not found]           ` <20160428143801.GO3217-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-04-28 14:59             ` Arnd Bergmann
2016-04-28 14:59               ` Arnd Bergmann
2016-04-28 16:39               ` Mark Brown
2016-04-28 16:49                 ` Arnd Bergmann
2016-04-29 11:17                   ` Mark Brown
2016-04-29 11:17                     ` Mark Brown
2016-05-06 17:35                     ` Sagar Dharia
2016-06-03  9:14   ` Masami Hiramatsu
2016-04-27 23:58 ` [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus Sagar Dharia
2016-04-28  9:54   ` Arnd Bergmann
2016-04-28 11:11   ` Mark Rutland [this message]
2016-05-03 16:11   ` Rob Herring
2016-05-03 19:26     ` Arnd Bergmann
2016-04-27 23:58 ` [PATCH V5 3/6] slimbus: Add messaging APIs to slimbus framework Sagar Dharia
2016-04-28  9:52   ` Arnd Bergmann
2016-04-27 23:58 ` [PATCH V5 4/6] slim: qcom: Add Qualcomm Slimbus controller driver Sagar Dharia
     [not found]   ` <1461801489-16254-5-git-send-email-sdharia-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-04-28 11:28     ` Mark Rutland
2016-04-28 11:28       ` Mark Rutland
2016-05-06 17:28       ` Sagar Dharia
2016-04-27 23:58 ` [PATCH V5 5/6] slimbus: Add support for 'clock-pause' feature Sagar Dharia
2016-04-27 23:58 ` [PATCH V5 6/6] slim: qcom: Add runtime-pm support using clock-pause feature Sagar Dharia
2016-06-03  9:14 ` [PATCH V5 0/6] Introduce framework for SLIMbus device drivers Masami Hiramatsu
2016-06-27  1:30   ` Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160428111110.GD21145@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=agross@codeaurora.org \
    --cc=alan@linux.intel.com \
    --cc=andreas.noever@gmail.com \
    --cc=bp@suse.de \
    --cc=broonie@kernel.org \
    --cc=daniel.thompson@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gong.chen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=james.hogan@imgtec.com \
    --cc=jkosina@suse.cz \
    --cc=joe@perches.com \
    --cc=kheitke@audience.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=michael.opdenacker@free-electrons.com \
    --cc=mlocke@codeaurora.org \
    --cc=pawel.moll@arm.com \
    --cc=poeschel@lemonage.de \
    --cc=robh+dt@kernel.org \
    --cc=sdharia@codeaurora.org \
    --cc=sharon.dvir1@mail.huji.ac.il \
    --cc=sheetal.tigadoli@gmail.com \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.