Introduce framework for SLIMbus device drivers
Subsystems (4)
v5 cover Introduce framework for SLIMbus device drivers
SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by MIPI (Mobile Industry Processor Interface) alliance. SLIMbus is a 2-wire implementation, which is used to communicate with peripheral components like audio-codec.
SLIMbus uses Time-Division-Multiplexing to accommodate multiple data channels, and control channel. Control channel has messages to do device-enumeration, messages to send/receive control-data to/from slimbus devices, messages for port/channel management, and messages to do bandwidth allocation.
Framework is introduced to support multiple instances of the bus (1 controller per bus), and multiple slave devices per controller. SPI and I2C frameworks, and comments from last time when I submitted the patches were referred-to while working on this framework.
These patchsets introduce device-management, OF helpers, and messaging APIs, controller driver for Qualcomm's slimbus controller, and clock-pause feature for entering/exiting low-power mode for SLIMbus. Framework patches to do channel, port and bandwidth management are work-in-progress and will be sent out once these initial patches are accepted.
These patchsets were tested on Qualcomm Snapdragon processor board using the controller driver, and a test slave device.
Changes from V4 to V5:
* Addressed inline-code review comments from Mark Brown and Rob Herring.
* Comments to document usage of workqueue while sending device-up/down notifications to slave drivers.
* Introduced module_slimbus_driver macro for ease of registering and de-registering slimbus client driver.
* Modified framework and controller remove functionality and tested bind/unbind for slimbus controller and slimbus device drivers.
* Modified Device Tree compatible string to follow format from other discoverable buses, and clarified documentation about when node definition and compatible fields should be used.
* Clock-pause initiated by the framework when controller is being removed to make sure there are no ongoing transfers.
Sagar Dharia (6):
SLIMbus: Device management on SLIMbus
of/slimbus: OF helper for SLIMbus
slimbus: Add messaging APIs to slimbus framework
slim: qcom: Add Qualcomm Slimbus controller driver
slimbus: Add support for 'clock-pause' feature
slim: qcom: Add runtime-pm support using clock-pause feature
Documentation/devicetree/bindings/slimbus/bus.txt | 55 ++ .../devicetree/bindings/slimbus/slim-qcom-ctrl.txt | 45 ++ Documentation/slimbus/summary | 109 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/slimbus/Kconfig | 20 + drivers/slimbus/Makefile | 5 + drivers/slimbus/slim-core.c | 806 +++++++++++++++++++++ drivers/slimbus/slim-messaging.c | 433 +++++++++++ drivers/slimbus/slim-qcom-ctrl.c | 683 +++++++++++++++++ drivers/slimbus/slim-qcom.h | 64 ++ drivers/slimbus/slim-sched.c | 126 ++++ include/linux/mod_devicetable.h | 13 + include/linux/slimbus.h | 685 +++++++++++++++++ 14 files changed, 3047 insertions(+) create mode 100644 Documentation/devicetree/bindings/slimbus/bus.txt create mode 100644 Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt create mode 100644 Documentation/slimbus/summary create mode 100644 drivers/slimbus/Kconfig create mode 100644 drivers/slimbus/Makefile create mode 100644 drivers/slimbus/slim-core.c create mode 100644 drivers/slimbus/slim-messaging.c create mode 100644 drivers/slimbus/slim-qcom-ctrl.c create mode 100644 drivers/slimbus/slim-qcom.h create mode 100644 drivers/slimbus/slim-sched.c create mode 100644 include/linux/slimbus.h
Signature · 1 line
1.8.2.1
PATCH v5 1/6 SLIMbus: Device management on SLIMbus
SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by MIPI (Mobile Industry Processor Interface) alliance. SLIMbus is a 2-wire implementation, which is used to communicate with peripheral components like audio-codec.
SLIMbus uses Time-Division-Multiplexing to accommodate multiple data channels, and control channel. Control channel has messages to do device-enumeration, messages to send/receive control-data to/from slimbus devices, messages for port/channel management, and messages to do bandwidth allocation.
The framework supports multiple instances of the bus (1 controller per bus), and multiple slave devices per controller.
This patch does device enumeration, logical address assignment, informing device when the device reports present/absent etc. Reporting present may need the driver to do the needful (e.g. turning on voltage regulators powering the device). So probe is called if the device is added to board-info list for a controller. Additionally device is probed when it reports present if that device doesn't need any such steps mentioned above.
--- Documentation/slimbus/summary | 109 +++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/slimbus/Kconfig | 11 + drivers/slimbus/Makefile | 4 + drivers/slimbus/slim-core.c | 684 ++++++++++++++++++++++++++++++++++++++++ include/linux/mod_devicetable.h | 13 + include/linux/slimbus.h | 394 +++++++++++++++++++++++ 8 files changed, 1218 insertions(+) create mode 100644 Documentation/slimbus/summary create mode 100644 drivers/slimbus/Kconfig create mode 100644 drivers/slimbus/Makefile create mode 100644 drivers/slimbus/slim-core.c create mode 100644 include/linux/slimbus.h
Documentation/slimbus/summary new file +109 -0
@@ -0,0 +1,109 @@ +Overview of Linux kernel SLIMbus support +======================================== + +What is SLIMbus? +---------------- +SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by +MIPI (Mobile Industry Processor Interface) alliance. The bus uses master/slave +configuration, and is a 2-wire multi-drop implementation (clock, and data). + +Currently, SLIMbus is used to interface between application processors of SoCs +(System-on-Chip) and peripheral components (typically codec).SLIMbus uses +Time-Division-Multiplexing to accommodate multiple data channels, and +a control channel. + +The control channel is used for various control functions such as bus +management, configuration and status updates.These messages can be unicast (e.g. +reading/writing device specific values), or multicast (e.g. data channel +reconfiguration sequence is a broadcast message announced to all devices) + +A data channel is used for data-transfer between 2 Slimbus devices. Data +channel uses dedicated ports on the device. + +Hardware description: +--------------------- +Slimbus specification has different types of device classifications based on +their capabilities. +A manager device is responsible for enumeration, configuration, and dynamic +channel allocation. Every bus has 1 active manager. + +A generic device is a device providing application functionality (e.g. codec). + +Framer device is responsible for clocking the bus, and transmitting frame-sync +and framing information on the bus. + +Each SLIMbus component has an interface device for monitoring physical layer. + +Typically each SoC contains SLIMbus component having 1 manager, 1 framer device, +1 generic device (for data channel support), and 1 interface device. +External peripheral SLIMbus component usually has 1 generic device (for +functionality/data channel support), and an associated interface device. +The generic device's registers are mapped as 'value elements' so that they can +be written/read using Slimbus control channel exchanging control/status type of +information. +In case there are multiple framer devices on the same bus, manager device is +responsible to select the active-framer for clocking the bus. + +Per specification, Slimbus uses "clock gears" to do power management based on +current frequency and bandwidth requirements. There are 10 clock gears and each +gear changes the Slimbus frequency to be twice its previous gear. + +Each device has a 6-byte enumeration-address and the manager assigns every +device with a 1-byte logical address after the devices report presence on the +bus. + +Software description: +--------------------- +There are 2 types of SLIMbus drivers: + +slim_controller represents a 'controller' for SLIMbus. This driver should +implement duties needed by the SoC (manager device, associated +interface device for monitoring the layers and reporting errors, default +framer device). + +slim_device represents the 'generic device/component' for SLIMbus, and a +slim_driver should implement driver for that slim_device. + +Device notifications to the driver: +----------------------------------- +Since SLIMbus devices have mechanisms for reporting their presence, the +framework allows drivers to bind when corresponding devices report their +presence on the bus. +However, it is possible that the driver needs to be probed +first so that it can enable corresponding SLIMbus devie (e.g. power it up and/or +take it out of reset). To support that behavior, the framework allows drivers +to probe first as well (e.g. using standard DeviceTree compatbility field). +This creates the necessity for the driver to know when the device is functional +(i.e. reported present). device_up callback is used for that reason when the +device reports present and is assigned a logical address by the contoller. + +Similarly, SLIMbus devices 'report absent' when they go down. A 'device_down' +callback notifies the driver when the device reports absent and its logical +address assignment is invalidated by the controller. + +Another notification "boot_device" is used to notify the slim_driver when +controller resets the bus. This notification allows the driver to take necessary +steps to boot the device so that it's functional after the bus has been reset. + +Clock-pause: +------------ +SLIMbus mandates that a reconfiguration sequence (known as clock-pause) be +broadcast to all active devices on the bus before the bus can enter low-power +mode. Controller uses this sequence when it decides to enter low-power mode so +that corresponding clocks and/or power-rails can be turned off to save power. +Clock-pause is exited by waking up framer device (if controller driver initiates +exiting low power mode), or by toggling the data line (if a slave device wants +to initiate it). + +Messaging APIs: +--------------- +The framework supports APIs to exchange control-information with a SLIMbus +device. APIs can be synchronous or asynchronous. +From controller's perspective, multiple buffers can be queued to/from +hardware for sending/receiving data using slim_ctrl_buf circular buffer. +The header file <linux/slimbus.h> has more documentation about messaging APIs. + +----------------------------------------------------------------- +<Sections will be added to this document when port/channel bandwidth management +support, multi-xfer APIs are added to the framework> +------------------------------------------------------------------
drivers/Kconfig +2 -0
@@ -182,4 +182,6 @@ source "drivers/thunderbolt/Kconfig" source "drivers/android/Kconfig" +source "drivers/slimbus/Kconfig" + endmenu
drivers/Makefile +1 -0
@@ -74,6 +74,7 @@ obj-$(CONFIG_TARGET_CORE) += target/ obj-$(CONFIG_MTD) += mtd/ obj-$(CONFIG_SPI) += spi/ obj-$(CONFIG_SPMI) += spmi/ +obj-$(CONFIG_SLIMBUS) += slimbus/ obj-y += hsi/ obj-y += net/ obj-$(CONFIG_ATM) += atm/
drivers/slimbus/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# +# SLIMBUS driver configuration +# +menuconfig SLIMBUS + tristate "Slimbus support" + help + Slimbus is standard interface between System-on-Chip and audio codec, + and other peripheral components in typical embedded systems. + + If unsure, choose N. +
drivers/slimbus/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for kernel slimbus framework. +# +obj-$(CONFIG_SLIMBUS) += slim-core.o
drivers/slimbus/slim-core.c new file +684 -0
684 lines not on this page · raw message
include/linux/mod_devicetable.h +13 -0
@@ -427,6 +427,19 @@ struct spi_device_id {kernel_ulong_t driver_data;/* Data private to the driver */ }; +/* SLIMbus */ + +#define SLIMBUS_NAME_SIZE 32 +#define SLIMBUS_MODULE_PREFIX "slim:" + +struct slim_device_id { +__u16 manf_id, prod_code; +__u8 dev_index, instance; + +/* Data private to the driver */ +kernel_ulong_t driver_data; +}; +#define SPMI_NAME_SIZE 32#define SPMI_MODULE_PREFIX "spmi:"
include/linux/slimbus.h new file +394 -0
394 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
drivers/slimbus/slim-core.c line 191
Quoted 13 lines · On Wednesday 27 April 2016 17:58:04 Sagar Dharia wrote:
drivers/slimbus/slim-core.c new file +13
-0+/** +* slim_driver_register: Client driver registration with slimbus +* @drv:Client driver to be associated with client-device. +* This API will register the client driver with the slimbus +* It is called from the driver's module-init function. +*/ +int slim_driver_register (struct slim_driver *drv) +{ + drv->driver.bus = &slimbus_type; + +return driver_register (&drv->driver); +} +EXPORT_SYMBOL_GPL (slim_driver_register);
Please make this use the same trick as platform_driver_register() to implicitly set the .owner field of the driver to THIS_MODULE.
drivers/slimbus/slim-core.c line 233
Quoted 7 lines
drivers/slimbus/slim-core.c new file +7
-0+/** +* slim_add_device: Add a new device without register board info. +* @ctrl: Controller to which this device is to be added to. +* Called when device doesn't have an explicit client-driver to be probed, or +* the client-driver is a module installed dynamically. +*/ +int slim_add_device (struct slim_controller *ctrl,struct slim_device *sbdev)
This looks like an artifact of ancient pre-DT times. I'd say kill it off before someone starts using it.
Quoted 9 lines
drivers/slimbus/slim-core.c new file +9
-0+struct sbi_boardinfo { +struct list_head list; +struct slim_boardinfo board_info; +}; + +static LIST_HEAD (board_list); +static LIST_HEAD (slim_ctrl_list); +static DEFINE_MUTEX (board_lock); +
drivers/slimbus/slim-core.c line 291
Quoted 10 lines
drivers/slimbus/slim-core.c new file +9
-0+/** +* slim_register_board_info: Board-initialization routine. +* @info: List of all devices on all controllers present on the board. +* @n: number of entries. +* API enumerates respective devices on corresponding controller. +* Called from board-init function. +*/ +int slim_register_board_info (struct slim_boardinfo const *info,unsigned n) +{
Same for all of this.
include/linux/mod_devicetable.h struct spi_device_id { · line 441
Quoted 7 lines
include/linux/mod_devicetable.h +7
-0+struct slim_device_id { +__u16 manf_id, prod_code; +__u8 dev_index, instance; + +/* Data private to the driver */ +kernel_ulong_t driver_data; +};
Can you add explicit padding here to avoid having the anonymous two bytes in the middle?
Also, I think a void pointer instead of a kernel_ulong_t makes it more useful, but there are always cases where one or the other fits better.
Arnd
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 6 lines · Arnd Bergmann
Quoted 1 line · On Wednesday 27 April 2016 17:58:04 Sagar Dharia wrote:
+int
slim_add_device(struct slim_controller *ctrl, struct slim_device *sbdev)This looks like an artifact of ancient pre-DT times. I'd say kill it off before someone starts using it.
Not every architecture uses DT, and even on architectures with DT support it isn't always the only firmware. In this specific case it's questionable how many people are going to implement Slimbus at this point but in general insisting that we go DT only doesn't seem great.
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 5 lines · On Thursday 28 April 2016 12:53:37 Mark Brown wrote:
Quoted 3 lines · Arnd Bergmann
Quoted 1 line · On Wednesday 27 April 2016 17:58:04 Sagar Dharia wrote:
+int
slim_add_device(struct slim_controller *ctrl, struct slim_device *sbdev)
Quoted 8 lines
Quoted 2 lines
This looks like an artifact of ancient pre-DT times. I'd say kill it off before someone starts using it.
Not every architecture uses DT, and even on architectures with DT support it isn't always the only firmware. In this specific case it's questionable how many people are going to implement Slimbus at this point but in general insisting that we go DT only doesn't seem great.
Nothing wrong with adding support for manual board files later if we have a good reason for it, but at the moment, this seems completely ARM/ARM64 specific.
I don't foresee mobile phones with ACPI using this subsystem, but even if we got them, it would be a horrible idea to use hardcoded board specific tables in a platform file, and we should insist that whatever firmware is present has a way to describe the slimbus devices.
Arnd
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · On Thursday 28 April 2016 12:53:37 Mark Brown wrote:
Quoted 2 lines · Arnd Bergmann
This looks like an artifact of ancient pre-DT times. I'd say kill it off before someone starts using it.
Quoted 8 lines
Quoted 4 lines
Not every architecture uses DT, and even on architectures with DT support it isn't always the only firmware. In this specific case it's questionable how many people are going to implement Slimbus at this point but in general insisting that we go DT only doesn't seem great.
Nothing wrong with adding support for manual board files later if we have a good reason for it, but at the moment, this seems completely ARM/ARM64 specific.
It's not in theory, but in practice nobody other that Qualcomm is ever likely to release a controller.
Quoted 4 lines
I don't foresee mobile phones with ACPI using this subsystem, but even if we got them, it would be a horrible idea to use hardcoded board specific tables in a platform file, and we should insist that whatever firmware is present has a way to describe the slimbus devices.
Right, in this particular case I don't think it makes a huge difference but what you were talking about was "ancient pre-DT times" rather than something specific to this particular case. That's definitely a thing that people keep thinking and it's good to push back on it since we do have non-DT cases to worry about (some architectures, other firmwares, things like PCI cards with other components on them and so on).
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 7 lines · On Thursday 28 April 2016 15:38:01 Mark Brown wrote:
Quoted 5 lines · Arnd Bergmann
On Thursday 28 April 2016 12:53:37 Mark Brown wrote:
I don't foresee mobile phones with ACPI using this subsystem, but even if we got them, it would be a horrible idea to use hardcoded board specific tables in a platform file, and we should insist that whatever firmware is present has a way to describe the slimbus devices.
Quoted 6 lines
Right, in this particular case I don't think it makes a huge difference but what you were talking about was "ancient pre-DT times" rather than something specific to this particular case. That's definitely a thing that people keep thinking and it's good to push back on it since we do have non-DT cases to worry about (some architectures, other firmwares, things like PCI cards with other components on them and so on).
Ok, I see what you mean. It turns out I made the exact same comment on the first review five years ago (phrased more nicely back then):
http://thread.gmane.org/gmane.linux.documentation/3192/focus=3193
My comment this time was for the particular driver, but I'd still also maintain that a new subsystem in general should not start out by addressing the needs of traditional board files. I don't think we have merge new platform support on any architecture that would need this in the past years and stuff like spi_board_info and i2c_board_info is only really used on really old machines (but not going away any time soon either).
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 3 lines · Arnd Bergmann
My comment this time was for the particular driver, but I'd still also maintain that a new subsystem in general should not start out by addressing the needs of traditional board files.
I certainly wouldn't insist that people add it but equally pushing to remove it too strongly seems like the wrong thing, at least as a general comment rather than a specific one.
Quoted 5 lines
I don't think we have merge new platform support on any architecture that would need this in the past years and stuff like
spi_board_infoandi2c_board_infois only really used on really old machines (but not going away any time soon either).
It's not just platforms that use these things though - there's things like the SolarFlare NICs where the firmware update mechanism essentially involves exposing a SPI flash as part of a PCI device and we just merged an ASoC driver for a video card which was reusing some existing IPs and chips.
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 6 lines · On Thursday 28 April 2016 17:39:20 Mark Brown wrote:
Quoted 5 lines
I don't think we have merge new platform support on any architecture that would need this in the past years and stuff like
spi_board_infoandi2c_board_infois only really used on really old machines (but not going away any time soon either).
Quoted 6 lines
It's not just platforms that use these things though - there's things like the SolarFlare NICs where the firmware update mechanism essentially involves exposing a SPI flash as part of a PCI device and we just merged an ASoC driver for a video card which was reusing some existing IPs and chips.
That's of course fine: you essentially have a discoverable bus there, and if we need something like that, we can always add it later to any subsystem.
In contrast, the interface in the proposed slimbus subsystem seems designed for board files, and is in the best case just dead code that can be removed, or has a risk of being misused e.g. if some device manufacturer decides to use a board file for this instead of describing the slimbus slaves in DT.
Arnd
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 11 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 28 April 2016 17:39:20 Mark Brown wrote:
It's not just platforms that use these things though - there's things like the SolarFlare NICs where the firmware update mechanism essentially involves exposing a SPI flash as part of a PCI device and we just merged an ASoC driver for a video card which was reusing some existing IPs and chips.
That's of course fine: you essentially have a discoverable bus there, and if we need something like that, we can always add it later to any subsystem.
No, the issue with those cases is that there are devices on discoverable buses that instantiate non-discoverable buses as part of the discoverable device so the implementation of the discoverable device is in part essentially a board file.
Quoted 5 lines
In contrast, the interface in the proposed slimbus subsystem seems designed for board files, and is in the best case just dead code that can be removed, or has a risk of being misused e.g. if some device manufacturer decides to use a board file for this instead of describing the slimbus slaves in DT.
Which can be more of a pain than it should be if the code has been written to assume that all the world is DT. That's the most problematic bit of this meme - I've seen people doing things like duplicating IP drivers inside larger devices because they don't think they're allowed to reuse the IP driver. We can fix this sort of thing up when we notice it but we should also try to avoid people making the mistakes in the first place since it saves everyone a lot of effort. With subsystems and to a lesser extent off SoC drivers we need to be careful about just blindly removing non-DT code and writing things so they're hard to use without DT.
Like I say in this case I think the board file stuff is probably never going to get used so it's probably sensible to remove that code but it does need to be thought about.
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
Quoted 31 lines · Mark Brown
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Thursday 28 April 2016 17:39:20 Mark Brown wrote:
It's not just platforms that use these things though - there's things like the SolarFlare NICs where the firmware update mechanism essentially involves exposing a SPI flash as part of a PCI device and we just merged an ASoC driver for a video card which was reusing some existing IPs and chips.
That's of course fine: you essentially have a discoverable bus there, and if we need something like that, we can always add it later to any subsystem.
No, the issue with those cases is that there are devices on discoverable buses that instantiate non-discoverable buses as part of the discoverable device so the implementation of the discoverable device is in part essentially a board file.
Quoted 5 lines
In contrast, the interface in the proposed slimbus subsystem seems designed for board files, and is in the best case just dead code that can be removed, or has a risk of being misused e.g. if some device manufacturer decides to use a board file for this instead of describing the slimbus slaves in DT.
Which can be more of a pain than it should be if the code has been written to assume that all the world is DT. That's the most problematic bit of this meme - I've seen people doing things like duplicating IP drivers inside larger devices because they don't think they're allowed to reuse the IP driver. We can fix this sort of thing up when we notice it but we should also try to avoid people making the mistakes in the first place since it saves everyone a lot of effort. With subsystems and to a lesser extent off SoC drivers we need to be careful about just blindly removing non-DT code and writing things so they're hard to use without DT.
Quoted 3 lines
Like I say in this case I think the board file stuff is probably never going to get used so it's probably sensible to remove that code but it does need to be thought about.
I agree that the board-file stuff isn't going to be used and will remove it.
I will merge patch1 and patch2 and we can later add ACPI support/board-file support if needed.
Thanks for the comments
Sagar
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH V5 1/6] SLIMbus: Device management on SLIMbus
In reply to Sagar DhariaHi Sagar,
I have some comments on it.
On Wed, 27 Apr 2016 17:58:04 -0600
Sagar Dharia <[email protected]> wrote:
[..]
Quoted 30 lines
drivers/slimbus/slim-core.c new file +24
-0@@ -0,0 +1,684 @@ +/* Copyright (c) 2011-2016, 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. +*/ + +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/slab.h> +#include <linux/init.h> +#include <linux/completion.h> +#include <linux/idr.h> +#include <linux/pm_runtime.h> +#include <linux/slimbus.h> + +static DEFINE_MUTEX (slim_lock); +static DEFINE_IDR (ctrl_idr); +
drivers/slimbus/slim-core.c line 34
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+static bool slim_eaddr_equal (struct slim_eaddr *a,struct slim_eaddr *b) +{ +return (a->manf_id == b->manf_id && + a->prod_code == b->prod_code && + a->dev_index == b->dev_index && + a->instance == b->instance); +} + +static const struct slim_device_id * +slim_match (const struct slim_device_id *id,const struct slim_device *slim_dev)
Why does this not return bool? (and the name seems too generic, it can be __slim_device_match() )
Quoted 7 lines
drivers/slimbus/slim-core.c new file +7
-0+{ +while (id->manf_id !=0 || id->prod_code !=0 ) { +if (id->manf_id == slim_dev->e_addr.manf_id && + id->prod_code == slim_dev->e_addr.prod_code && + id->dev_index == slim_dev->e_addr.dev_index) +return id; + id++;
drivers/slimbus/slim-core.c line 51
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+ } +return NULL ; +} + +static int slim_device_match (struct device *dev,struct device_driver *driver) +{ +struct slim_device *slim_dev; +struct slim_driver *drv =to_slim_driver (driver); + + slim_dev =to_slim_device (dev);
You can do this at definition line as slim_driver does.
Quoted 4 lines
drivers/slimbus/slim-core.c new file +4
-0+if (drv->id_table) +return slim_match (drv->id_table, slim_dev) !=NULL ; +return 0 ; +}
drivers/slimbus/slim-core.c line 65
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+ +struct sb_report_wd { +struct work_struct wd; +struct slim_device *sb; +bool report; +}; + +static void slim_report (struct work_struct *work) +{ +struct slim_driver *sbdrv;
It would be better to give a consistent naming rule for local variables. I see "sbdrv", "driver", "drv" etc. I think sbdrv and sbdev are good choice.
Quoted 40 lines
drivers/slimbus/slim-core.c new file +40
-0+ struct sb_report_wd *sbw = container_of(work, struct sb_report_wd, wd); +struct slim_device *sbdev = sbw->sb; + +mutex_lock (&sbdev->report_lock); +if (!sbdev->dev.driver) + goto report_exit; + +/* check if device-up or down needs to be called */ +if ((!sbdev->reported && !sbdev->notified) || + (sbdev->reported && sbdev->notified)) + goto report_exit; + + sbdrv =to_slim_driver (sbdev->dev.driver); + +/** +* address no longer valid, means device reported absent, whereas +* address valid, means device reported present +*/ +if (sbdev->notified && !sbdev->reported) { + sbdev->notified = false; +if (sbdrv->device_down) + sbdrv->device_down (sbdev); + }else if (!sbdev->notified && sbdev->reported) { + sbdev->notified = true; +if (sbdrv->device_up) + sbdrv->device_up (sbdev); + } +report_exit: +mutex_unlock (&sbdev->report_lock); +kfree (sbw); +} + +/** +* Report callbacks(device_up, device_down) are implemented by slimbus-devices. +* The calls are scheduled into a workqueue to avoid holding up controller +* intialization/tear-down. +*/ +static void schedule_slim_report (struct slim_controller *ctrl, +struct slim_device *sb,bool report) +{
drivers/slimbus/slim-core.c line 115
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+struct sb_report_wd *sbw; + +dev_dbg (&ctrl->dev,"report:%d for slave:%s\n" , report, sb->name); + + sbw =kmalloc (sizeof (*sbw),GFP_KERNEL ); +if (!sbw) +return ; + +INIT_WORK (&sbw->wd, slim_report); + sbw->sb = sb;
Wouldn't we check whether the device is under another reporting or not? Maybe we can cancel ongoing workqueue.
drivers/slimbus/slim-core.c line 127
Quoted 12 lines
drivers/slimbus/slim-core.c new file +12
-0+ sbw->report = report; +if (!queue_work (ctrl->wq, &sbw->wd)) { +dev_err (&ctrl->dev,"failed to queue report:%d slave:%s\n" , + report, sb->name); +kfree (sbw); + } +} + +static int slim_device_probe (struct device *dev) +{ +struct slim_device *slim_dev; +struct slim_driver *driver;
"driver" looks generic name. sbdev and sbdrv are much better.
Quoted 7 lines
drivers/slimbus/slim-core.c new file +7
-0+struct slim_controller *ctrl; +int status =0 ; + + slim_dev =to_slim_device (dev); + driver =to_slim_driver (dev->driver); +if (!driver->id_table) +return -ENODEV ;
drivers/slimbus/slim-core.c line 144
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+ + slim_dev->driver = driver; + +if (driver->probe) + status = driver->probe (slim_dev); +if (status) { + slim_dev->driver =NULL ; + }else if (driver->device_up) { + ctrl = slim_dev->ctrl; +schedule_slim_report (ctrl, slim_dev, true);
Here, "crtl" seems a bit redundant.
Quoted 4 lines
drivers/slimbus/slim-core.c new file +4
-0+ } +return status; +} +
[..]
Quoted 32 lines
drivers/slimbus/slim-core.c new file +32
-0+/** +* slim_add_device: Add a new device without register board info. +* @ctrl: Controller to which this device is to be added to. +* Called when device doesn't have an explicit client-driver to be probed, or +* the client-driver is a module installed dynamically. +*/ +int slim_add_device (struct slim_controller *ctrl,struct slim_device *sbdev) +{ + sbdev->dev.bus = &slimbus_type; + sbdev->dev.parent = &ctrl->dev; + sbdev->dev.release = slim_dev_release; + sbdev->dev.driver =NULL ; + sbdev->ctrl = ctrl; + +slim_ctrl_get (ctrl); +if (!sbdev->name) { + sbdev->name =kasprintf (GFP_KERNEL ,"%x:%x:%x:%x" , + sbdev->e_addr.manf_id, + sbdev->e_addr.prod_code, + sbdev->e_addr.dev_index, + sbdev->e_addr.instance); +if (!sbdev->name) +return -ENOMEM ; + } +dev_set_name (&sbdev->dev,"%s" , sbdev->name); +mutex_init (&sbdev->report_lock); + +/* probe slave on this controller */ +return device_register (&sbdev->dev); +} +EXPORT_SYMBOL_GPL (slim_add_device); +
drivers/slimbus/slim-core.c line 268
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+struct sbi_boardinfo { +struct list_head list; +struct slim_boardinfo board_info; +}; + +static LIST_HEAD (board_list); +static LIST_HEAD (slim_ctrl_list); +static DEFINE_MUTEX (board_lock); + +/* If controller is not present, only add to boards list */
This comment would better be placed in slim_register_board_info() since this function doesn't add boards to the list.
Quoted 131 lines
drivers/slimbus/slim-core.c new file +131
-0+static void slim_match_ctrl_to_boardinfo (struct slim_controller *ctrl, +struct slim_boardinfo *bi) +{ +int ret; + +if (ctrl->nr != bi->bus_num) +return ; + + ret =slim_add_device (ctrl, bi->slim_slave); +if (ret !=0 ) +dev_err (ctrl->dev.parent,"can't create new device %s, ret:%d\n" , + bi->slim_slave->name, ret); +} + +/** +* slim_register_board_info: Board-initialization routine. +* @info: List of all devices on all controllers present on the board. +* @n: number of entries. +* API enumerates respective devices on corresponding controller. +* Called from board-init function. +*/ +int slim_register_board_info (struct slim_boardinfo const *info,unsigned n) +{ +struct sbi_boardinfo *bi; +int i; + + bi =kcalloc (n,sizeof (*bi),GFP_KERNEL ); +if (!bi) +return -ENOMEM ; + +for (i =0 ; i < n; i++, bi++, info++) { +struct slim_controller *ctrl; + +memcpy (&bi->board_info, info,sizeof (*info)); +mutex_lock (&board_lock); +list_add_tail (&bi->list, &board_list); +list_for_each_entry (ctrl, &slim_ctrl_list, list) +slim_match_ctrl_to_boardinfo (ctrl, &bi->board_info); +mutex_unlock (&board_lock); + } +return 0 ; +} +EXPORT_SYMBOL_GPL (slim_register_board_info); + +static void slim_ctrl_add_boarddevs (struct slim_controller *ctrl) +{ +struct sbi_boardinfo *bi; + +mutex_lock (&board_lock); +list_add_tail (&ctrl->list, &slim_ctrl_list); +list_for_each_entry (bi, &board_list, list) +slim_match_ctrl_to_boardinfo (ctrl, &bi->board_info); +mutex_unlock (&board_lock); +} + +/** +* slim_register_controller: Controller bring-up and registration. +* @ctrl: Controller to be registered. +* A controller is registered with the framework using this API. +* If devices on a controller were registered before controller, +* this will make sure that they get probed when controller is up +*/ +int slim_register_controller (struct slim_controller *ctrl) +{ +int id, ret =0 ; + +mutex_lock (&slim_lock); + id =idr_alloc (&ctrl_idr, ctrl, ctrl->nr,-1 ,GFP_KERNEL ); +mutex_unlock (&slim_lock); + +if (id <0 ) +return id; + + ctrl->nr = id; + +dev_set_name (&ctrl->dev,"sb-%d" , ctrl->nr); + ctrl->num_dev =0 ; + +if (!ctrl->min_cg) + ctrl->min_cg =SLIM_MIN_CLK_GEAR ; +if (!ctrl->max_cg) + ctrl->max_cg =SLIM_MAX_CLK_GEAR ; + +mutex_init (&ctrl->m_ctrl); + ret =device_register (&ctrl->dev); +if (ret) + goto dev_reg_failed; + +dev_dbg (&ctrl->dev,"Bus [%s] registered:dev:%p\n" , + ctrl->name, &ctrl->dev); + + ctrl->wq =create_singlethread_workqueue (dev_name (&ctrl->dev)); +if (!ctrl->wq) + goto err_workq_failed; + +slim_ctrl_add_boarddevs (ctrl); +return 0 ; + +err_workq_failed: +device_unregister (&ctrl->dev); +dev_reg_failed: +mutex_lock (&slim_lock); +idr_remove (&ctrl_idr, ctrl->nr); +mutex_unlock (&slim_lock); +return ret; +} +EXPORT_SYMBOL_GPL (slim_register_controller); + +/* slim_remove_device: Remove the effect of slim_add_device() */ +void slim_remove_device (struct slim_device *sbdev) +{ +device_unregister (&sbdev->dev); +} +EXPORT_SYMBOL_GPL (slim_remove_device); + +static int slim_ctrl_remove_device (struct device *dev,void *null) +{ +slim_remove_device (to_slim_device (dev)); +return 0 ; +} + +/** +* slim_del_controller: Controller tear-down. +* @ctrl: Controller to tear-down. +*/ +int slim_del_controller (struct slim_controller *ctrl) +{ +struct slim_controller *found; + +/* First make sure that this bus was added */ +mutex_lock (&slim_lock);
drivers/slimbus/slim-core.c line 409
Quoted 10 lines
drivers/slimbus/slim-core.c new file +10
-0+ found =idr_find (&ctrl_idr, ctrl->nr); +mutex_unlock (&slim_lock); +if (found != ctrl) +return -EINVAL ; + +/* Remove all clients */ +device_for_each_child (&ctrl->dev,NULL , slim_ctrl_remove_device); + + +list_del (&ctrl->list);
This list operation should be protected by slim_lock as slim_ctrl_add_boarddevs() does.
drivers/slimbus/slim-core.c line 420
Quoted 11 lines
drivers/slimbus/slim-core.c new file +11
-0+destroy_workqueue (ctrl->wq); + +/* free bus id */ +mutex_lock (&slim_lock); +idr_remove (&ctrl_idr, ctrl->nr); +mutex_unlock (&slim_lock); + +device_unregister (&ctrl->dev); +return 0 ; +} +EXPORT_SYMBOL_GPL (slim_del_controller);
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>
PATCH v5 2/6 of/slimbus: OF helper for SLIMbus
In reply to Sagar DhariaOF helper routine scans the SLIMbus DeviceTree, allocates resources, and creates slim_devices according to the hierarchy.
--- 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
Documentation/devicetree/bindings/slimbus/bus.txt new file +55 -0
@@ -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" + +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. + +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" + +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"; + + [email protected] { + compatible = "qcom,wcdv1", "slim"; + reg = <0x217 0x60 0x1 0x0>; + }; + };
drivers/slimbus/slim-core.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Re: [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus
drivers/slimbus/slim-core.c static LIST_HEAD(board_list); · line 273
Quoted 6 lines · On Wednesday 27 April 2016 17:58:05 Sagar Dharia wrote:
drivers/slimbus/slim-core.c +5
-0+#if IS_ENABLED (CONFIG_OF ) +/* OF helpers for SLIMbus */ +static void of_register_slim_devices (struct slim_controller *ctrl) +{ +struct device_node *node;
The #ifdef seems useless here, what kind of system would not have CONFIG_OF enabled? I'd suggest merging this into patch 1 and removing the conditional
Arnd
Re: [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus
In reply to Sagar DhariaQuoted 32 lines · Sagar Dharia
OF helper routine scans the SLIMbus DeviceTree, allocates resources, and creates
slim_devicesaccording to the hierarchy.Signed-off-by Sagar Dharia <[email protected]>--- 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.txtDocumentation/devicetree/bindings/slimbus/bus.txt new file +16
-0@@ -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.
Documentation/devicetree/bindings/slimbus/bus.txt line 26
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +10
-0+ +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.
Documentation/devicetree/bindings/slimbus/bus.txt line 34
Quoted 7 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +7
-0+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.
Documentation/devicetree/bindings/slimbus/bus.txt line 40
Quoted 6 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +6
-0+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.
Quoted 5 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +5
-0+ +SLIMbus example for Qualcomm's slimbus manager component: + + slim@28080000 { + compatible = "qcom,slim-msm";
Documentation/devicetree/bindings/slimbus/bus.txt line 55
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +10
-0+ reg = <0x28080000 0x2000>, + interrupts = <0 33 0>; + clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>; + clock-names = "iface_clk", "core_clk"; + + [email protected] { + 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.
Quoted 31 lines
drivers/slimbus/slim-core.c +16
-0@@ -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; +
drivers/slimbus/slim-core.c static LIST_HEAD(board_list); · line 293
Quoted 10 lines
drivers/slimbus/slim-core.c +10
-0+ 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.
Rob Herring
maintainerRe: [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus
In reply to Sagar DhariaQuoted 46 lines · Sagar Dharia
OF helper routine scans the SLIMbus DeviceTree, allocates resources, and creates
slim_devicesaccording to the hierarchy.Signed-off-by Sagar Dharia <[email protected]>--- 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.txtDocumentation/devicetree/bindings/slimbus/bus.txt new file +30
-0@@ -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" + +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.
Documentation/devicetree/bindings/slimbus/bus.txt line 40
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +10
-0+The compatible property will be necessary so that corresponding +driver can probe and execute the required procedure to make it +functional. + +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"
Im most cases for compatible strings on discoverable buses, the VID and PID (and perhaps more) are used to form the compatible string. See USB binding for a recent example. This will save you from having to make up strings for every device.
Documentation/devicetree/bindings/slimbus/bus.txt line 51
Quoted 11 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +11
-0+ +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"; + + [email protected] {
unit-addresses should use ',' to separate fields and generally don't have leading zeros.
Quoted 4 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +4
-0+ compatible = "qcom,wcdv1", "slim"; + reg = <0x217 0x60 0x1 0x0>; + }; + };
Re: [PATCH V5 2/6] of/slimbus: OF helper for SLIMbus
Quoted 21 lines · On Tuesday 03 May 2016 11:11:56 Rob Herring wrote:
Quoted 21 lines
Documentation/devicetree/bindings/slimbus/bus.txt new file +21
-0+ +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" + +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. + +Required property for SLIMbus child node if it is present: +- reg - enumeration address fields of the device +
Quoted 8 lines
Documentation/devicetree/bindings/slimbus/bus.txt line 40
Quoted 3 lines
+- compatible - name of SLIMbus child node using practice typically
Documentation/devicetree/bindings/slimbus/bus.txt new file +2
-0+ followed by discoverable buses: + "<manufacturer>,<product-model>", "slim"Im most cases for compatible strings on discoverable buses, the VID and PID (and perhaps more) are used to form the compatible string. See USB binding for a recent example. This will save you from having to make up strings for every device.
Actually it seems like the current binding puts the same manufacturer ID and product ID pair into both address and compatible string. Is that correct?
I would have expected the address to have only index and instance fields and the compatible string match whatever we can detect by looking at that device. This has probably been discussed 5 years ago when the patches were first posted, but I don't remember the outcome.
Arnd
PATCH v5 3/6 slimbus: Add messaging APIs to slimbus framework
In reply to Sagar DhariaSlimbus devices use value-element, and information elements to control device parameters (e.g. value element is used to represent gain for codec, information element is used to represent interrupt status for codec when codec interrupt fires).
Messaging APIs are used to set/get these value and information elements. Slimbus specification uses 8-bit "transaction IDs" for messages where a read-value is anticipated. Framework uses a table of pointers to store those TIDs and responds back to the caller in O(1).
Caller can opt to do synchronous, or asynchronous reads/writes. For asynchronous operations, the callback will be called from atomic context.
TX and RX circular rings are used to allow queuing of multiple transfers per controller. Controller can choose size of these rings based of controller HW implementation. The buffers are coerently mapped so that controller can utilize DMA operations for the transactions without remapping every transaction buffer. Statically allocated rings help to improve performance by avoiding overhead of dynamically allocating transactions on need basis.
--- drivers/slimbus/Makefile | 2 +- drivers/slimbus/slim-core.c | 50 +++++ drivers/slimbus/slim-messaging.c | 395 +++++++++++++++++++++++++++++++++++++++ include/linux/slimbus.h | 224 ++++++++++++++++++++++ 4 files changed, 670 insertions(+), 1 deletion(-) create mode 100644 drivers/slimbus/slim-messaging.c
drivers/slimbus/Makefile +1 -1
@@ -1,4 +1,4 @@ # # Makefile for kernel slimbus framework. # -obj-$(CONFIG_SLIMBUS) += slim-core.o +obj-$(CONFIG_SLIMBUS) += slim-core.o slim-messaging.o
drivers/slimbus/slim-core.c +50 -0
83 lines not on this page · raw message
drivers/slimbus/slim-messaging.c new file +395 -0
395 lines not on this page · raw message
include/linux/slimbus.h +224 -0
264 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Re: [PATCH V5 3/6] slimbus: Add messaging APIs to slimbus framework
drivers/slimbus/slim-core.c int slim_register_controller(struct slim_controller *ctrl) · line 441
Quoted 7 lines · On Wednesday 27 April 2016 17:58:06 Sagar Dharia wrote:
drivers/slimbus/slim-core.c +7
-0+ ctrl->tx.base =dma_alloc_coherent (ctrl->dev.parent, + (ctrl->tx.sl_sz * ctrl->tx.n), + &ctrl->tx.phy,GFP_KERNEL ); +if (!ctrl->tx.base) { + ret = -ENOMEM ; + goto tx_alloc_failed; + }
This looks controller specific, and hints that some parts of the "common" framework should actually be part of the controller driver instead.
In particular, the use of "ctrl->dev.parent" suggests that this should have been allocated by the controller.
include/linux/slimbus.h struct slim_controller { · line 288
Quoted 11 lines
include/linux/slimbus.h +7
-0@@ -162,6 +279,15 @@ struct slim_controller {struct slim_addrt *addrt;u8 num_dev;struct workqueue_struct *wq; +struct slim_val_inf *tid_tbl[SLIM_MAX_TIDS ]; +u8 last_tid; +spinlock_t txn_lock; +struct slim_ctrl_buf tx; +struct slim_ctrl_buf rx; +struct slim_pending *pending_wr; +struct semaphore tx_sem;
Please try to avoid the use of semaphores in new code.
Arnd
PATCH v5 4/6 slim: qcom: Add Qualcomm Slimbus controller driver
In reply to Sagar DhariaThis controller driver programs manager, interface, and framer devices for Qualcomm's slimbus HW block.
Manager component currently implements logical address setting, and messaging interface.
Interface device reports bus synchronization information, and framer device clocks the bus from the time it's woken up, until clock-pause is executed by the manager device.
--- .../devicetree/bindings/slimbus/slim-qcom-ctrl.txt | 45 ++ drivers/slimbus/Kconfig | 9 + drivers/slimbus/Makefile | 1 + drivers/slimbus/slim-qcom-ctrl.c | 563 +++++++++++++++++++++ drivers/slimbus/slim-qcom.h | 63 +++ 5 files changed, 681 insertions(+) create mode 100644 Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt create mode 100644 drivers/slimbus/slim-qcom-ctrl.c create mode 100644 drivers/slimbus/slim-qcom.h
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +45 -0
@@ -0,0 +1,45 @@ +Qualcomm SLIMBUS controller +"qcom,slim-msm": This controller is used if applications processor + driver controls slimbus master component (SoCs 8960, 8064). + This driver is responsible for communicating with slave HW + directly using messaging interface, and doing data channel + management, and power management. + +Required properties: + +- #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 + - reg : Offset and length of the register region(s) for the device + - reg-names : Register region name(s) referenced in reg above + Required register resource entries are: + "slimbus_physical": Physical adderss of controller register blocks + - compatible : should be "qcom,slim-msm" if this is master component driver + - interrupts : Interrupt number used by this controller + - clocks : Interface and core clocks used by this slimbus controller + - clock-names : Required clock-name entries are: + "iface_clk" : Interface clock for this controller + "core_clk" : Interrupt for controller core's BAM + +Optional property: + - reg entry for slew rate : If slew rate control register is provided, this + entry should be used. + - reg-name for slew rate: "slimbus_slew_reg" + +Example: + slim@28080000 { + compatible = "qcom,slim-msm"; + #address-cells = <4>; + #size-cells = <0>; + reg = <0x28080000 0x2000>, <0x80207C 4>; + reg-names = "slimbus_physical", "slimbus_slew_reg"; + interrupts = <0 33 0>; + clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>; + clock-names = "iface_clk", "core_clk"; + + [email protected] { + compatible = "qcom,wcdv1", "slim"; + reg = <0x217 0x60 0x1 0x0>; + }; + };
drivers/slimbus/Kconfig +9 -0
@@ -9,3 +9,12 @@ menuconfig SLIMBUS If unsure, choose N. +if SLIMBUS +config SLIM_QCOM_CTRL + tristate "Qualcomm Slimbus Manager Component" + depends on SLIMBUS + help + Select driver if Qualcomm's Slimbus Manager Component is + programmed using Linux kernel. + +endif
drivers/slimbus/Makefile +1 -0
@@ -2,3 +2,4 @@ # Makefile for kernel slimbus framework. # obj-$(CONFIG_SLIMBUS) += slim-core.o slim-messaging.o +obj-$(CONFIG_SLIM_QCOM_CTRL) += slim-qcom-ctrl.o
drivers/slimbus/slim-qcom-ctrl.c new file +563 -0
563 lines not on this page · raw message
drivers/slimbus/slim-qcom.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Re: [PATCH V5 4/6] slim: qcom: Add Qualcomm Slimbus controller driver
Quoted 26 lines · Sagar Dharia
This controller driver programs manager, interface, and framer devices for Qualcomm's slimbus HW block.
Manager component currently implements logical address setting, and messaging interface.
Interface device reports bus synchronization information, and framer device clocks the bus from the time it's woken up, until clock-pause is executed by the manager device.Signed-off-by Sagar Dharia <[email protected]>--- .../devicetree/bindings/slimbus/slim-qcom-ctrl.txt | 45 ++ drivers/slimbus/Kconfig | 9 + drivers/slimbus/Makefile | 1 + drivers/slimbus/slim-qcom-ctrl.c | 563 +++++++++++++++++++++ drivers/slimbus/slim-qcom.h | 63 +++ 5 files changed, 681 insertions(+) create mode 100644 Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt create mode 100644 drivers/slimbus/slim-qcom-ctrl.c create mode 100644 drivers/slimbus/slim-qcom.hDocumentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +0
-0
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 3
Quoted 3 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +3
-0@@ -0,0 +1,45 @@ +Qualcomm SLIMBUS controller +"qcom,slim-msm": This controller is used if applications processor + driver controls slimbus master component (SoCs 8960, 8064).
I would strongly recommend using a more specific name, e.g. "qcom,8960-slim", so that there's less confusion when some future SoC inevitably has an incompatible SLIMbus controller.
The DT should contain the specific variant to account for any integration quirks, though the device can simply have one string and require a fallback entry for now.
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 6
Quoted 3 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +3
-0+ This driver is responsible for communicating with slave HW + directly using messaging interface, and doing data channel + management, and power management.
Drvier details don't belong in the DT binding, which should describe the device independent of any particular driver.
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 13
Quoted 7 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +7
-0+ +Required properties: + +- #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
Perhaps refer to the generic SLIMbus binding document for these?
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 17
Quoted 4 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +4
-0+ - reg : Offset and length of the register region(s) for the device + - reg-names : Register region name(s) referenced in reg above + Required register resource entries are: + "slimbus_physical": Physical adderss of controller register blocks
That name seems odd. We _always_ use physical addresses. Surely there's some name in a datasheet for the controller, or if there isn't, then we can just not require a name?
Nit: s/adderss/address/
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 18
Quoted 1 line
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +1
-0+ - compatible : should be "qcom,slim-msm" if this is master component driver
As above, olease remove mentions of the driver.
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 28
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +10
-0+ - interrupts : Interrupt number used by this controller + - clocks : Interface and core clocks used by this slimbus controller + - clock-names : Required clock-name entries are: + "iface_clk" : Interface clock for this controller + "core_clk" : Interrupt for controller core's BAM + +Optional property: + - reg entry for slew rate : If slew rate control register is provided, this + entry should be used. + - reg-name for slew rate: "slimbus_slew_reg"
Per the example below, this looks like an element in a separate system controller block, or part of some other controller that's not modelled here.
What is this, exactly?
Quoted 4 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +4
-0+ +Example: + slim@28080000 { + compatible = "qcom,slim-msm";
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 42
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +10
-0+ #address-cells = <4>; + #size-cells = <0>; + reg = <0x28080000 0x2000>, <0x80207C 4>; + reg-names = "slimbus_physical", "slimbus_slew_reg"; + interrupts = <0 33 0>; + clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>; + clock-names = "iface_clk", "core_clk"; + + [email protected] { + compatible = "qcom,wcdv1", "slim";
As mentioned on the generic binding, please drop the "slim" fallback here.
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 45
Quoted 3 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +3
-0+ reg = <0x217 0x60 0x1 0x0>; + }; + };
Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V5 4/6] slim: qcom: Add Qualcomm Slimbus controller driver
Quoted 16 lines · Mark Rutland
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 28
Quoted 10 lines · Sagar Dharia
+ - interrupts : Interrupt number used by this controller
+ - clocks : Interface and core clocks used by this slimbus controller
+ - clock-names : Required clock-name entries are:Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +7
-0+ "iface_clk" : Interface clock for this controller + "core_clk" : Interrupt for controller core's BAM + +Optional property: + - reg entry for slew rate : If slew rate control register is provided, this + entry should be used. + - reg-name for slew rate: "slimbus_slew_reg"Per the example below, this looks like an element in a separate system controller block, or part of some other controller that's not modelled here.
Quoted 1 line
What is this, exactly?
You are right, this entry is outside the controller block, but needs to be programmed by slimbus controller to make sure slew-rate of the clock line is controlled to be within spec.
I will incorporate other comments in the upcoming patch.
Thanks
Sagar
Quoted 27 lines
Quoted 5 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +4
-0+ +Example: + slim@28080000 { + compatible = "qcom,slim-msm";Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 42
Quoted 10 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +10
-0+ #address-cells = <4>; + #size-cells = <0>; + reg = <0x28080000 0x2000>, <0x80207C 4>; + reg-names = "slimbus_physical", "slimbus_slew_reg"; + interrupts = <0 33 0>; + clocks = <&lcc SLIMBUS_SRC>, <&lcc AUDIO_SLIMBUS_CLK>; + clock-names = "iface_clk", "core_clk"; + + [email protected] { + compatible = "qcom,wcdv1", "slim";As mentioned on the generic binding, please drop the "slim" fallback here.
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt line 45
Quoted 3 lines
Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt new file +3
-0+ reg = <0x217 0x60 0x1 0x0>; + }; + };Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v5 5/6 slimbus: Add support for 'clock-pause' feature
In reply to Sagar DhariaPer slimbus specification, a reconfiguration sequence known as 'clock pause' needs to be broadcast over the bus while entering low- power mode. Clock-pause is initiated by the controller driver. To exit clock-pause, controller typically wakes up the framer device. Since wakeup precedure is controller-specific, framework calls it via controller's function pointer to invoke it.
--- drivers/slimbus/Makefile | 2 +- drivers/slimbus/slim-core.c | 15 +++++ drivers/slimbus/slim-messaging.c | 50 ++++++++++++++-- drivers/slimbus/slim-sched.c | 126 +++++++++++++++++++++++++++++++++++++++ include/linux/slimbus.h | 69 ++++++++++++++++++++- 5 files changed, 254 insertions(+), 8 deletions(-) create mode 100644 drivers/slimbus/slim-sched.c
drivers/slimbus/Makefile +1 -1
@@ -1,5 +1,5 @@ # # Makefile for kernel slimbus framework. # -obj-$(CONFIG_SLIMBUS) += slim-core.o slim-messaging.o +obj-$(CONFIG_SLIMBUS) += slim-core.o slim-messaging.o slim-sched.o obj-$(CONFIG_SLIM_QCOM_CTRL) += slim-qcom-ctrl.o
drivers/slimbus/slim-core.c +15 -0
@@ -421,6 +421,8 @@ int slim_register_controller(struct slim_controller *ctrl)mutex_init (&ctrl->m_ctrl);spin_lock_init (&ctrl->tx.lock);spin_lock_init (&ctrl->rx.lock); +mutex_init (&ctrl->sched.m_reconf); +init_completion (&ctrl->sched.pause_comp); ctrl->pending_wr = kcalloc((ctrl->tx.n - 1), sizeof(struct slim_pending),
@@ -512,6 +514,8 @@ int slim_del_controller(struct slim_controller *ctrl)/* Remove all clients */ device_for_each_child (&ctrl->dev,NULL , slim_ctrl_remove_device); +/* Enter clock pause */ +slim_ctrl_clk_pause (ctrl, false,0 );list_del (&ctrl->list);destroy_workqueue (ctrl->wq);
@@ -666,6 +670,14 @@ int slim_assign_laddr(struct slim_controller *ctrl, struct slim_eaddr *e_addr,struct slim_device *slim;struct slim_addrt *temp; + ret =pm_runtime_get_sync (ctrl->dev.parent); + +if (ctrl->sched.clk_state !=SLIM_CLK_ACTIVE ) { +dev_err (&ctrl->dev,"slim ctrl not active,state:%d, ret:%d\n" , + ctrl->sched.clk_state, ret); + goto slimbus_not_active; + } +mutex_lock (&ctrl->m_ctrl);/* already assigned */ if (ctrl_getaddr_entry (ctrl, e_addr, &i) ==0 ) {
@@ -736,6 +748,9 @@ ret_assigned_laddr: }mutex_unlock (&slim->report_lock); } +slimbus_not_active: +pm_runtime_mark_last_busy (ctrl->dev.parent); +pm_runtime_put_autosuspend (ctrl->dev.parent);return ret; }EXPORT_SYMBOL_GPL (slim_assign_laddr);
drivers/slimbus/slim-messaging.c +44 -6
115 lines not on this page · raw message
drivers/slimbus/slim-sched.c new file +126 -0
126 lines not on this page · raw message
include/linux/slimbus.h +68 -1
125 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v5 6/6 slim: qcom: Add runtime-pm support using clock-pause feature
In reply to Sagar DhariaSlimbus HW mandates that clock-pause sequence has to be executed before disabling relevant interface and core clocks. Runtime-PM's autosuspend feature is used here to enter/exit low power mode for Qualcomm's Slimbus controller. Autosuspend feature enables driver to avoid changing power-modes too frequently since entering clock-pause is an expensive sequence
--- drivers/slimbus/slim-qcom-ctrl.c | 128 +++++++++++++++++++++++++++++++++++++-- drivers/slimbus/slim-qcom.h | 1 + 2 files changed, 125 insertions(+), 4 deletions(-)
drivers/slimbus/slim-qcom-ctrl.c +124 -4
@@ -20,6 +20,7 @@#include <linux/clk.h> #include <linux/of.h> #include <linux/slimbus.h> +#include <linux/pm_runtime.h> #include "slim-qcom.h" #define MSM_SLIM_NAME "msm_slim_ctrl"
@@ -216,6 +217,30 @@ rx_ret_irq:return ret; } +static int msm_clk_pause_wakeup (struct slim_controller *ctrl) +{ +struct msm_slim_ctrl *dev =slim_get_ctrldata (ctrl); + +clk_prepare_enable (dev->hclk); +clk_prepare_enable (dev->rclk); +enable_irq (dev->irq); + +writel_relaxed (1 , dev->base +FRM_WAKEUP ); +/* Make sure framer wakeup write goes through before ISR fires */ +mb (); +/** +* HW Workaround: Currently, slave is reporting lost-sync messages +* after slimbus comes out of clock pause. +* Transaction with slave fail before slave reports that message +* Give some time for that report to come +* Slimbus wakes up in clock gear 10 at 24.576MHz. With each superframe +* being 250 usecs, we wait for 5-10 superframes here to ensure +* we get the message +*/ +usleep_range (1250 ,2500 ); +return 0 ; +} +static int msm_xfer_msg (struct slim_controller *ctrl,struct slim_msg_txn *txn,void *pbuf) {
@@ -286,7 +311,6 @@ static int msm_set_laddr(struct slim_controller *ctrl,*/ msg.wbuf = buf; msg.num_bytes =7 ; - ret =slim_processtxn (&dev->ctrl, &txn);if (ret)
@@ -417,6 +441,8 @@ static int msm_slim_probe(struct platform_device *pdev) dev->ctrl.set_laddr = msm_set_laddr; dev->ctrl.xfer_msg = msm_xfer_msg; + dev->ctrl.wakeup = msm_clk_pause_wakeup; + dev->ctrl.tx.n =MSM_TX_MSGS ; dev->ctrl.rx.n =MSM_RX_MSGS ; dev->ctrl.tx.sl_sz =SLIM_MSGQ_BUF_LEN ;
@@ -514,6 +540,12 @@ static int msm_slim_probe(struct platform_device *pdev)*/ mb (); +pm_runtime_use_autosuspend (&pdev->dev); +pm_runtime_set_autosuspend_delay (&pdev->dev,MSM_SLIM_AUTOSUSPEND ); +pm_runtime_set_active (&pdev->dev); +pm_runtime_mark_last_busy (&pdev->dev); +pm_runtime_enable (&pdev->dev); +dev_dbg (dev->dev,"MSM SB controller is up:ver:0x%x!\n" , dev->ver);return 0 ;
@@ -531,14 +563,101 @@ static int msm_slim_remove(struct platform_device *pdev) {struct msm_slim_ctrl *dev =platform_get_drvdata (pdev); -disable_irq (dev->irq); -clk_disable_unprepare (dev->rclk); -clk_disable_unprepare (dev->hclk); +pm_runtime_disable (&pdev->dev);slim_del_controller (&dev->ctrl);destroy_workqueue (dev->rxwq);return 0 ; } +/** +* If PM_RUNTIME is not defined, these 2 functions become helper +* functions to be called from system suspend/resume. +*/ +#ifdef CONFIG_PM +static int msm_slim_runtime_suspend (struct device *device) +{ +struct platform_device *pdev =to_platform_device (device); +struct msm_slim_ctrl *dev =platform_get_drvdata (pdev); +int ret; + +dev_dbg (device,"pm_runtime: suspending...\n" ); + ret =slim_ctrl_clk_pause (&dev->ctrl, false,SLIM_CLK_UNSPECIFIED ); +if (ret) { +dev_err (device,"clk pause not entered:%d" , ret); + }else { +disable_irq (dev->irq); +clk_disable_unprepare (dev->hclk); +clk_disable_unprepare (dev->rclk); + } +return ret; +} + +static int msm_slim_runtime_resume (struct device *device) +{ +struct platform_device *pdev =to_platform_device (device); +struct msm_slim_ctrl *dev =platform_get_drvdata (pdev); +int ret =0 ; + +dev_dbg (device,"pm_runtime: resuming...\n" ); + ret =slim_ctrl_clk_pause (&dev->ctrl, true,0 ); +if (ret) +dev_err (device,"clk pause not exited:%d" , ret); +return ret; +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int msm_slim_suspend (struct device *dev) +{ +int ret =0 ; + +if (!pm_runtime_enabled (dev) || + (!pm_runtime_suspended (dev))) { +dev_dbg (dev,"system suspend" ); + ret =msm_slim_runtime_suspend (dev); + } +if (ret == -EISCONN ) { +/** +* If the clock pause failed due to active channels, there is +* a possibility that some audio stream is active during suspend. +* (e.g. modem usecase during suspend) +* We dont want to return suspend failure in that case so that +* display and relevant components can still go to suspend. +* If there is some other error, then it should prevent +* system level suspend +*/ + ret =0 ; + } +return ret; +} + +static int msm_slim_resume (struct device *dev) +{ +if (!pm_runtime_enabled (dev) || !pm_runtime_suspended (dev)) { +int ret; + +dev_dbg (dev,"system resume" ); + ret =msm_slim_runtime_resume (dev); +if (!ret) { +pm_runtime_mark_last_busy (dev); +pm_request_autosuspend (dev); + } +return ret; + + } +return 0 ; +} +#endif /* CONFIG_PM_SLEEP */ + +static const struct dev_pm_ops msm_slim_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(msm_slim_suspend, msm_slim_resume) +SET_RUNTIME_PM_OPS ( + msm_slim_runtime_suspend, + msm_slim_runtime_resume, +NULL + ) +}; +static const struct of_device_id msm_slim_dt_match[] = { { .compatible ="qcom,slim-msm" ,
@@ -553,6 +672,7 @@ static struct platform_driver msm_slim_driver = { .name = MSM_SLIM_NAME, .owner = THIS_MODULE, .of_match_table = msm_slim_dt_match, + .pm = &msm_slim_dev_pm_ops, }, };module_platform_driver (msm_slim_driver);
drivers/slimbus/slim-qcom.h +1 -0
@@ -23,6 +23,7 @@ ((l) | ((mt) << 5) | ((mc) << 8) | ((dt) << 15) | ((ad) << 16))#define SLIM_ROOT_FREQ 24576000 +#define MSM_SLIM_AUTOSUSPEND 1000/* MAX message size over control channel */ #define SLIM_MSGQ_BUF_LEN 40
Signature · 1 line
1.8.2.1
Hi Sagar,
Quoted 14 lines · On Wed, 27 Apr 2016 17:58:03 -0600 Sagar Dharia <[email protected]> wrote:
SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by MIPI (Mobile Industry Processor Interface) alliance. SLIMbus is a 2-wire implementation, which is used to communicate with peripheral components like audio-codec.
SLIMbus uses Time-Division-Multiplexing to accommodate multiple data channels, and control channel. Control channel has messages to do device-enumeration, messages to send/receive control-data to/from slimbus devices, messages for port/channel management, and messages to do bandwidth allocation.
Framework is introduced to support multiple instances of the bus (1 controller per bus), and multiple slave devices per controller. SPI and I2C frameworks, and comments from last time when I submitted the patches were referred-to while working on this framework.
Quoted 6 lines
These patchsets introduce device-management, OF helpers, and messaging APIs, controller driver for Qualcomm's slimbus controller, and clock-pause feature for entering/exiting low-power mode for SLIMbus. Framework patches to do channel, port and bandwidth management are work-in-progress and will be sent out once these initial patches are accepted.
I'm interested in this framework, especially the channel and port parts since it is needed for device drivers on the slimbus. Would you have any public git repository where I can review the work-in-progress part of the framework?
Thank you,
Quoted 56 lines
These patchsets were tested on Qualcomm Snapdragon processor board using the controller driver, and a test slave device.
Changes from V4 to V5:
* Addressed inline-code review comments from Mark Brown and Rob Herring.
* Comments to document usage of workqueue while sending device-up/down notifications to slave drivers.
* Introducedmodule_slimbus_drivermacro for ease of registering and de-registering slimbus client driver.
* Modified framework and controller remove functionality and tested bind/unbind for slimbus controller and slimbus device drivers.
* Modified Device Tree compatible string to follow format from other discoverable buses, and clarified documentation about when node definition and compatible fields should be used.
* Clock-pause initiated by the framework when controller is being removed to make sure there are no ongoing transfers.Sagar Dharia (6):
SLIMbus: Device management on SLIMbus
of/slimbus: OF helper for SLIMbus
slimbus: Add messaging APIs to slimbus framework
slim: qcom: Add Qualcomm Slimbus controller driver
slimbus: Add support for 'clock-pause' feature
slim: qcom: Add runtime-pm support using clock-pause featureDocumentation/devicetree/bindings/slimbus/bus.txt | 55 ++ .../devicetree/bindings/slimbus/slim-qcom-ctrl.txt | 45 ++ Documentation/slimbus/summary | 109 +++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/slimbus/Kconfig | 20 + drivers/slimbus/Makefile | 5 + drivers/slimbus/slim-core.c | 806 +++++++++++++++++++++ drivers/slimbus/slim-messaging.c | 433 +++++++++++ drivers/slimbus/slim-qcom-ctrl.c | 683 +++++++++++++++++ drivers/slimbus/slim-qcom.h | 64 ++ drivers/slimbus/slim-sched.c | 126 ++++ include/linux/mod_devicetable.h | 13 + include/linux/slimbus.h | 685 +++++++++++++++++ 14 files changed, 3047 insertions(+) create mode 100644 Documentation/devicetree/bindings/slimbus/bus.txt create mode 100644 Documentation/devicetree/bindings/slimbus/slim-qcom-ctrl.txt create mode 100644 Documentation/slimbus/summary create mode 100644 drivers/slimbus/Kconfig create mode 100644 drivers/slimbus/Makefile create mode 100644 drivers/slimbus/slim-core.c create mode 100644 drivers/slimbus/slim-messaging.c create mode 100644 drivers/slimbus/slim-qcom-ctrl.c create mode 100644 drivers/slimbus/slim-qcom.h create mode 100644 drivers/slimbus/slim-sched.c create mode 100644 include/linux/slimbus.hSignature · 1 line
1.8.2.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Hello Sagar,
Quoted 26 lines · On Fri, 3 Jun 2016 18:14:19 +0900 Masami Hiramatsu…
Hi Sagar,
Quoted 14 lines · On Wed, 27 Apr 2016 17:58:03 -0600 Sagar Dharia <[email protected]> wrote:
SLIMbus (Serial Low Power Interchip Media Bus) is a specification developed by MIPI (Mobile Industry Processor Interface) alliance. SLIMbus is a 2-wire implementation, which is used to communicate with peripheral components like audio-codec.
SLIMbus uses Time-Division-Multiplexing to accommodate multiple data channels, and control channel. Control channel has messages to do device-enumeration, messages to send/receive control-data to/from slimbus devices, messages for port/channel management, and messages to do bandwidth allocation.
Framework is introduced to support multiple instances of the bus (1 controller per bus), and multiple slave devices per controller. SPI and I2C frameworks, and comments from last time when I submitted the patches were referred-to while working on this framework.Quoted 6 lines
These patchsets introduce device-management, OF helpers, and messaging APIs, controller driver for Qualcomm's slimbus controller, and clock-pause feature for entering/exiting low-power mode for SLIMbus. Framework patches to do channel, port and bandwidth management are work-in-progress and will be sent out once these initial patches are accepted.
Quoted 4 lines
I'm interested in this framework, especially the channel and port parts since it is needed for device drivers on the slimbus. Would you have any public git repository where I can review the work-in-progress part of the framework?
So, I've found git repositories on codeaurora.org,
https://source.codeaurora.org/
But there are too many repositories and branches to get the correct working source code. Could you help me to find it?
Thank you,
Signature · 1 line
Masami Hiramatsu <[email protected]>