Skip to contentSkip to conversation

dmaengine: add ACPI DMA helpers and use them in dw_dmac

PATCH In review Andy Shevchenko 4 participants 17 messages Apr 9, 2013 – Apr 22, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover dmaengine: add ACPI DMA helpers and use them in dw_dmac

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#1 lore raw

PATCH v2 1/5 dma: acpi-dma: introduce ACPI DMA helpers

There is a new generic API to get a DMA channel for a slave device (commit 9a6cecc8 "dmaengine: add helper function to request a slave DMA channel"). In similar fashion to the DT case (commit aa3da644 "of: Add generic device tree DMA helpers") we introduce helpers to the DMAC drivers which are enumerated by ACPI.

The proposed extension provides the following API calls:
acpi_dma_controller_register(), devm_acpi_dma_controller_register() acpi_dma_controller_free(), devm_acpi_dma_controller_free() acpi_dma_simple_xlate() acpi_dma_request_slave_chan_by_index() acpi_dma_request_slave_chan_by_name()

The first two should be used, for example, at probe() and remove() of the corresponding DMAC driver. At the register stage the DMAC driver supplies a custom xlate() function to translate a struct dma_spec into struct dma_chan.

Accordingly to the ACPI Fixed DMA resource specification the only two pieces of information the slave device has are the channel id and the request line (slave id). Those two are represented by struct dma_spec. The acpi_dma_request_slave_chan_by_index() provides access to the specifix FixedDMA resource by its index. Whereas dma_request_slave_channel() takes a string parameter to identify the DMA resources required by the slave device. To make a slave device driver work with both DeviceTree and ACPI enumeration a simple convention is established: "tx" corresponds to the index 0 and "rx" to the index 1. In case of robust configuration the slave device driver unfortunately needs to call acpi_dma_request_slave_chan_by_index() directly.

Additionally the patch provides "managed" version of the register/free pair i.e. devm_acpi_dma_controller_register() and devm_acpi_dma_controller_free(). Usually, the driver uses only devm_acpi_dma_controller_register().

---
 Documentation/acpi/enumeration.txt |  77 ++++++++++
 drivers/dma/Kconfig                |   4 +
 drivers/dma/Makefile               |   1 +
 drivers/dma/acpi-dma.c             | 279 +++++++++++++++++++++++++++++++++++++
 include/linux/acpi_dma.h           | 116 +++++++++++++++
 5 files changed, 477 insertions(+)
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Documentation/acpi/enumeration.txt +77 -0
index 94a6561..2874c90 100644
@@ -66,6 +66,83 @@ the ACPI device explicitly to acpi_platform_device_ids list defined in
 drivers/acpi/acpi_platform.c. This limitation is only for the platform
 devices, SPI and I2C devices are created automatically as described below.
 
+DMA support
+~~~~~~~~~~~
+DMA controllers enumerated via ACPI should be registered in the system to
+provide generic access to their resources. For example, a driver that would
+like to be accessible to slave devices via generic API call
+dma_request_slave_channel() must register itself at the end of the probe
+function like this:
+
+	err = devm_acpi_dma_controller_register(dev, xlate_func, dw);
+	/* Handle the error if it's not a case of !CONFIG_ACPI */
+
+and implement custom xlate function if needed (usually acpi_dma_simple_xlate()
+is enough) which converts the FixedDMA resource provided by struct
+acpi_dma_spec into the corresponding DMA channel. A piece of code for that case
+could look like:
+
+	#ifdef CONFIG_ACPI
+	struct filter_args {
+		/* Provide necessary information for the filter_func */
+		...
+	};
+
+	static bool filter_func(struct dma_chan *chan, void *param)
+	{
+		/* Choose the proper channel */
+		...
+	}
+
+	static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
+			struct acpi_dma *adma)
+	{
+		dma_cap_mask_t cap;
+		struct filter_args args;
+
+		/* Prepare arguments for filter_func */
+		...
+		return dma_request_channel(cap, filter_func, &args);
+	}
+	#else
+	static struct dma_chan *xlate_func(struct acpi_dma_spec *dma_spec,
+			struct acpi_dma *adma)
+	{
+		return NULL;
+	}
+	#endif
+
+dma_request_slave_channel() will call xlate_func() for each registered DMA
+controller. In the xlate function the proper channel must be chosen based on
+information in struct acpi_dma_spec and the properties of the controller
+provided by struct acpi_dma.
+
+Clients must call dma_request_slave_channel() with the string parameter that
+corresponds to a specific FixedDMA resource. By default "tx" means the first
+entry of the FixedDMA resource array, "rx" means the second entry. The table
+below shows a layout:
+
+	Device (I2C0)
+	{
+		...
+		Method (_CRS, 0, NotSerialized)
+		{
+			Name (DBUF, ResourceTemplate ()
+			{
+				FixedDMA (0x0018, 0x0004, Width32bit, _Y48)
+				FixedDMA (0x0019, 0x0005, Width32bit, )
+			})
+		...
+		}
+	}
+
+So, the FixedDMA with request line 0x0018 is "tx" and next one is "rx" in
+this example.
+
+In robust cases the client unfortunately needs to call
+acpi_dma_request_slave_chan_by_index() directly and therefore choose the
+specific FixedDMA resource by its index.
+
 SPI serial bus support
 ~~~~~~~~~~~~~~~~~~~~~~
 Slave devices behind SPI bus have SpiSerialBus resource attached to them.
drivers/dma/Kconfig +4 -0
index aeaea32..2ad5ed9 100644
@@ -328,6 +328,10 @@ config DMA_ENGINE
 config DMA_VIRTUAL_CHANNELS
 	tristate
 
+config DMA_ACPI
+	def_bool y
+	depends on ACPI
+
 config DMA_OF
 	def_bool y
 	depends on OF
drivers/dma/Makefile +1 -0
index 488e3ff..268e626 100644
@@ -3,6 +3,7 @@ ccflags-$(CONFIG_DMADEVICES_VDEBUG) += -DVERBOSE_DEBUG
 
 obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
 obj-$(CONFIG_DMA_VIRTUAL_CHANNELS) += virt-dma.o
+obj-$(CONFIG_DMA_ACPI) += acpi-dma.o
 obj-$(CONFIG_DMA_OF) += of-dma.o
 
 obj-$(CONFIG_NET_DMA) += iovlock.o
drivers/dma/acpi-dma.c new file +279 -0

279 lines not on this page · raw message

include/linux/acpi_dma.h new file +116 -0

116 lines not on this page · raw message

Signature · 1 line
1.8.2.rc0.22.gb3600c3
#2 lore raw

PATCH v2 2/5 dmaengine: call acpi_dma_request_slave_channel as well

In reply to Andy Shevchenko

The slave device could be enumerated by ACPI. In that case the dma_request_slave_channel should use the acpi_dma_request_slave_channel() helper.

---
 drivers/dma/dmaengine.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/dma/dmaengine.c +6 -0
index c121b03..93f7992 100644
@@ -62,6 +62,8 @@
 #include <linux/rculist.h>
 #include <linux/idr.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
+#include <linux/acpi_dma.h>
 #include <linux/of_dma.h>
 
 static DEFINE_MUTEX(dma_list_mutex);
@@ -564,6 +566,10 @@ struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name)
 	if (dev->of_node)
 		return of_dma_request_slave_channel(dev->of_node, name);
 
+	/* If device was enumerated by ACPI get slave info from here */
+	if (ACPI_HANDLE(dev))
+		return acpi_dma_request_slave_chan_by_name(dev, name);
+
 	return NULL;
 }
 EXPORT_SYMBOL_GPL(dma_request_slave_channel);
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#3 lore raw

PATCH v2 3/5 dma: acpi-dma: parse CSRT to extract additional resources

In reply to Andy Shevchenko

Since we have CSRT only to get additional DMA controller resources, let's get rid of drivers/acpi/csrt.c and move its logic inside ACPI DMA helpers code.

---
 drivers/acpi/Makefile    |   1 -
 drivers/acpi/csrt.c      | 159 -------------------------------------------
 drivers/acpi/internal.h  |   1 -
 drivers/acpi/scan.c      |   1 -
 drivers/dma/acpi-dma.c   | 172 ++++++++++++++++++++++++++++++++++++++++++++++-
 include/linux/acpi_dma.h |   4 ++
 6 files changed, 173 insertions(+), 165 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
drivers/acpi/Makefile +0 -1
index ecb743b..6050c80 100644
@@ -38,7 +38,6 @@ acpi-y				+= processor_core.o
 acpi-y				+= ec.o
 acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
 acpi-y				+= pci_root.o pci_link.o pci_irq.o
-acpi-y				+= csrt.o
 acpi-$(CONFIG_X86_INTEL_LPSS)	+= acpi_lpss.o
 acpi-y				+= acpi_platform.o
 acpi-y				+= power.o
drivers/acpi/csrt.c deleted +0 -159

159 lines not on this page · raw message

drivers/acpi/internal.h +0 -1
index 6f1afd9..297cbf4 100644
@@ -35,7 +35,6 @@ void acpi_pci_link_init(void);
 void acpi_pci_root_hp_init(void);
 void acpi_platform_init(void);
 int acpi_sysfs_init(void);
-void acpi_csrt_init(void);
 #ifdef CONFIG_ACPI_CONTAINER
 void acpi_container_init(void);
 #else
drivers/acpi/scan.c +0 -1
index d7f3c8b..6742aa1 100644
@@ -2042,7 +2042,6 @@ int __init acpi_scan_init(void)
 	acpi_pci_link_init();
 	acpi_platform_init();
 	acpi_lpss_init();
-	acpi_csrt_init();
 	acpi_container_init();
 	acpi_pci_slot_init();
 	acpi_memory_hotplug_init();
drivers/dma/acpi-dma.c +169 -3

215 lines not on this page · raw message

include/linux/acpi_dma.h +4 -0
index d09deab..fb02980 100644
@@ -37,6 +37,8 @@ struct acpi_dma_spec {
  * @dev:		struct device of this controller
  * @acpi_dma_xlate:	callback function to find a suitable channel
  * @data:		private data used by a callback function
+ * @base_request_line:	first supported request line (CSRT)
+ * @end_request_line:	last supported request line (CSRT)
  */
 struct acpi_dma {
 	struct list_head	dma_controllers;
@@ -44,6 +46,8 @@ struct acpi_dma {
 	struct dma_chan		*(*acpi_dma_xlate)
 				(struct acpi_dma_spec *, struct acpi_dma *);
 	void			*data;
+	unsigned short		base_request_line;
+	unsigned short		end_request_line;
 };
 
 /* Used with acpi_dma_simple_xlate() */
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#4 lore raw

PATCH v2 4/5 dw_dmac: add ACPI support

In reply to Andy Shevchenko

Since we have proper ACPI DMA helpers implemented, the driver may use it. This patch introduces custom filter function together with acpi_device_id table.

---
 drivers/dma/dw_dmac.c      | 68 ++++++++++++++++++++++++++++++++++------------
 drivers/dma/dw_dmac_regs.h |  1 -
 2 files changed, 50 insertions(+), 19 deletions(-)
drivers/dma/dw_dmac.c +50 -18
index e33dc3b..2e5deaa 100644
@@ -25,6 +25,8 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/acpi.h>
+#include <linux/acpi_dma.h>
 
 #include "dw_dmac_regs.h"
 #include "dmaengine.h"
@@ -983,13 +985,6 @@ static inline void convert_burst(u32 *maxburst)
 		*maxburst = 0;
 }
 
-static inline void convert_slave_id(struct dw_dma_chan *dwc)
-{
-	struct dw_dma *dw = to_dw_dma(dwc->chan.device);
-
-	dwc->dma_sconfig.slave_id -= dw->request_line_base;
-}
-
 static int
 set_runtime_config(struct dma_chan *chan, struct dma_slave_config *sconfig)
 {
@@ -1008,7 +1003,6 @@ set_runtime_config(struct dma_chan *chan, struct dma_slave_config *sconfig)
 
 	convert_burst(&dwc->dma_sconfig.src_maxburst);
 	convert_burst(&dwc->dma_sconfig.dst_maxburst);
-	convert_slave_id(dwc);
 
 	return 0;
 }
@@ -1284,6 +1278,46 @@ static struct dma_chan *dw_dma_of_xlate(struct of_phandle_args *dma_spec,
 	return dma_request_channel(cap, dw_dma_of_filter, &fargs);
 }
 
+#ifdef CONFIG_ACPI
+static bool dw_dma_acpi_filter(struct dma_chan *chan, void *param)
+{
+	struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
+	struct acpi_dma_spec *dma_spec = param;
+
+	if (chan->device->dev != dma_spec->dev ||
+	    chan->chan_id != dma_spec->chan_id)
+		return false;
+
+	dwc->request_line = dma_spec->slave_id;
+	dwc->src_master = dwc_get_sms(NULL);
+	dwc->dst_master = dwc_get_dms(NULL);
+
+	return true;
+}
+
+static void dw_dma_acpi_controller_register(struct dw_dma *dw)
+{
+	struct device *dev = dw->dma.dev;
+	struct acpi_dma_filter_info *info;
+	int ret;
+
+	info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+	if (!info)
+		return;
+
+	dma_cap_zero(info->dma_cap);
+	dma_cap_set(DMA_SLAVE, info->dma_cap);
+	info->filter_fn = dw_dma_acpi_filter;
+
+	ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate,
+						info);
+	if (ret)
+		dev_err(dev, "could not register acpi_dma_controller\n");
+}
+#else /* !CONFIG_ACPI */
+static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {}
+#endif /* !CONFIG_ACPI */
+
 /* --------------------- Cyclic DMA API extensions -------------------- */
 
 /**
@@ -1620,7 +1654,6 @@ dw_dma_parse_dt(struct platform_device *pdev)
 
 static int dw_probe(struct platform_device *pdev)
 {
-	const struct platform_device_id *match;
 	struct dw_dma_platform_data *pdata;
 	struct resource		*io;
 	struct dw_dma		*dw;
@@ -1704,11 +1737,6 @@ static int dw_probe(struct platform_device *pdev)
 		memcpy(dw->data_width, pdata->data_width, 4);
 	}
 
-	/* Get the base request line if set */
-	match = platform_get_device_id(pdev);
-	if (match)
-		dw->request_line_base = (unsigned int)match->driver_data;
-
 	/* Calculate all channel mask before DMA setup */
 	dw->all_chan_mask = (1 << nr_channels) - 1;
 
@@ -1833,6 +1861,9 @@ static int dw_probe(struct platform_device *pdev)
 				"could not register of_dma_controller\n");
 	}
 
+	if (ACPI_HANDLE(&pdev->dev))
+		dw_dma_acpi_controller_register(dw);
+
 	return 0;
 }
 
@@ -1904,11 +1935,12 @@ static const struct of_device_id dw_dma_of_id_table[] = {
 MODULE_DEVICE_TABLE(of, dw_dma_of_id_table);
 #endif
 
-static const struct platform_device_id dw_dma_ids[] = {
-	/* Name,	Request Line Base */
-	{ "INTL9C60",	(kernel_ulong_t)16 },
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id dw_dma_acpi_id_table[] = {
+	{ "INTL9C60", 0 },
 	{ }
 };
+#endif
 
 static struct platform_driver dw_driver = {
 	.probe		= dw_probe,
@@ -1918,8 +1950,8 @@ static struct platform_driver dw_driver = {
 		.name	= "dw_dmac",
 		.pm	= &dw_dev_pm_ops,
 		.of_match_table = of_match_ptr(dw_dma_of_id_table),
+		.acpi_match_table = ACPI_PTR(dw_dma_acpi_id_table),
 	},
-	.id_table	= dw_dma_ids,
 };
 
 static int __init dw_init(void)
drivers/dma/dw_dmac_regs.h +0 -1
index 9b0e12e..9d41720 100644
@@ -250,7 +250,6 @@ struct dw_dma {
 	/* hardware configuration */
 	unsigned char		nr_masters;
 	unsigned char		data_width[4];
-	unsigned int		request_line_base;
 
 	struct dw_dma_chan	chan[0];
 };
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#5 lore raw

PATCH v2 5/5 ACPI / LPSS: add support of shared clock

In reply to Andy Shevchenko

From: "Rafael J. Wysocki" <[email protected]>

The DMA controller in Lynxpoint is using the LPSS root clock as a functional clock to work properly. Proposed patch adds support of the shared clock. It also avoids hardcoding the name of the DMA device in clk-lpt.c and the name of the root clock in acpi_lpss.c.

---
 drivers/acpi/acpi_lpss.c               | 26 ++++++++++++++++++++++----
 drivers/clk/x86/clk-lpt.c              | 15 +++++++++++----
 include/linux/platform_data/clk-lpss.h |  5 +++++
 3 files changed, 38 insertions(+), 8 deletions(-)
drivers/acpi/acpi_lpss.c +22 -4
index b1c9542..652fd5c 100644
@@ -35,11 +35,16 @@ ACPI_MODULE_NAME("acpi_lpss");
 
 struct lpss_device_desc {
 	bool clk_required;
-	const char *clk_parent;
+	const char *clkdev_name;
 	bool ltr_required;
 	unsigned int prv_offset;
 };
 
+static struct lpss_device_desc lpss_dma_desc = {
+	.clk_required = true,
+	.clkdev_name = "hclk",
+};
+
 struct lpss_private_data {
 	void __iomem *mmio_base;
 	resource_size_t mmio_size;
@@ -49,7 +54,6 @@ struct lpss_private_data {
 
 static struct lpss_device_desc lpt_dev_desc = {
 	.clk_required = true,
-	.clk_parent = "lpss_clk",
 	.prv_offset = 0x800,
 	.ltr_required = true,
 };
@@ -60,6 +64,9 @@ static struct lpss_device_desc lpt_sdio_dev_desc = {
 };
 
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
+	/* Generic LPSS devices */
+	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+
 	/* Lynxpoint LPSS devices */
 	{ "INT33C0", (unsigned long)&lpt_dev_desc },
 	{ "INT33C1", (unsigned long)&lpt_dev_desc },
@@ -91,16 +98,27 @@ static int register_device_clock(struct acpi_device *adev,
 				 struct lpss_private_data *pdata)
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
+	struct lpss_clk_data *clk_data;
 
 	if (!lpss_clk_dev)
 		lpt_register_clock_device();
 
-	if (!dev_desc->clk_parent || !pdata->mmio_base
+	clk_data = platform_get_drvdata(lpss_clk_dev);
+	if (!clk_data)
+		return -ENODEV;
+
+	if (dev_desc->clkdev_name) {
+		clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name,
+				    dev_name(&adev->dev));
+		return 0;
+	}
+
+	if (!pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
 		return -ENODATA;
 
 	pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev),
-				       dev_desc->clk_parent, 0,
+				       clk_data->name, 0,
 				       pdata->mmio_base + dev_desc->prv_offset,
 				       0, 0, NULL);
 	if (IS_ERR(pdata->clk))
drivers/clk/x86/clk-lpt.c +11 -4
index 5cf4f46..e70fae3f 100644
@@ -15,22 +15,29 @@
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/platform_data/clk-lpss.h>
 #include <linux/platform_device.h>
 
 #define PRV_CLOCK_PARAMS 0x800
 
 static int lpt_clk_probe(struct platform_device *pdev)
 {
+	struct lpss_clk_data *drvdata;
 	struct clk *clk;
 
+	drvdata = devm_kmalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
 	/* LPSS free running clock */
-	clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
-				      100000000);
+	drvdata->name = "lpss_clk";
+	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
+				      CLK_IS_ROOT, 100000000);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	/* Shared DMA clock */
-	clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
+	drvdata->clk = clk;
+	platform_set_drvdata(pdev, drvdata);
 	return 0;
 }
 
include/linux/platform_data/clk-lpss.h +5 -0
index 528e73c..2390199 100644
@@ -13,6 +13,11 @@
 #ifndef __CLK_LPSS_H
 #define __CLK_LPSS_H
 
+struct lpss_clk_data {
+	const char *name;
+	struct clk *clk;
+};
+
 extern int lpt_clk_init(void);
 
 #endif /* __CLK_LPSS_H */
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#6 lore raw

Re: [PATCH v2 5/5] ACPI / LPSS: add support of shared clock

Quoted 1 line · Andy Shevchenko

From: "Rafael J. Wysocki" <[email protected]>

Well, that should be

From: Rafael J. Wysocki <[email protected]>

Quoted 7 lines

The DMA controller in Lynxpoint is using the LPSS root clock as a functional clock to work properly. Proposed patch adds support of the shared clock. It also avoids hardcoding the name of the DMA device in clk-lpt.c and the name of the root clock in acpi_lpss.c.

and accordingly:

Quoted 131 lines
---
 drivers/acpi/acpi_lpss.c               | 26 ++++++++++++++++++++++----
 drivers/clk/x86/clk-lpt.c              | 15 +++++++++++----
 include/linux/platform_data/clk-lpss.h |  5 +++++
 3 files changed, 38 insertions(+), 8 deletions(-)
drivers/acpi/acpi_lpss.c +22 -4
index b1c9542..652fd5c 100644
@@ -35,11 +35,16 @@ ACPI_MODULE_NAME("acpi_lpss");
 
 struct lpss_device_desc {
 	bool clk_required;
-	const char *clk_parent;
+	const char *clkdev_name;
 	bool ltr_required;
 	unsigned int prv_offset;
 };
 
+static struct lpss_device_desc lpss_dma_desc = {
+	.clk_required = true,
+	.clkdev_name = "hclk",
+};
+
 struct lpss_private_data {
 	void __iomem *mmio_base;
 	resource_size_t mmio_size;
@@ -49,7 +54,6 @@ struct lpss_private_data {
 
 static struct lpss_device_desc lpt_dev_desc = {
 	.clk_required = true,
-	.clk_parent = "lpss_clk",
 	.prv_offset = 0x800,
 	.ltr_required = true,
 };
@@ -60,6 +64,9 @@ static struct lpss_device_desc lpt_sdio_dev_desc = {
 };
 
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
+	/* Generic LPSS devices */
+	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+
 	/* Lynxpoint LPSS devices */
 	{ "INT33C0", (unsigned long)&lpt_dev_desc },
 	{ "INT33C1", (unsigned long)&lpt_dev_desc },
@@ -91,16 +98,27 @@ static int register_device_clock(struct acpi_device *adev,
 				 struct lpss_private_data *pdata)
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
+	struct lpss_clk_data *clk_data;
 
 	if (!lpss_clk_dev)
 		lpt_register_clock_device();
 
-	if (!dev_desc->clk_parent || !pdata->mmio_base
+	clk_data = platform_get_drvdata(lpss_clk_dev);
+	if (!clk_data)
+		return -ENODEV;
+
+	if (dev_desc->clkdev_name) {
+		clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name,
+				    dev_name(&adev->dev));
+		return 0;
+	}
+
+	if (!pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
 		return -ENODATA;
 
 	pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev),
-				       dev_desc->clk_parent, 0,
+				       clk_data->name, 0,
 				       pdata->mmio_base + dev_desc->prv_offset,
 				       0, 0, NULL);
 	if (IS_ERR(pdata->clk))
drivers/clk/x86/clk-lpt.c +11 -4
index 5cf4f46..e70fae3f 100644
@@ -15,22 +15,29 @@
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/platform_data/clk-lpss.h>
 #include <linux/platform_device.h>
 
 #define PRV_CLOCK_PARAMS 0x800
 
 static int lpt_clk_probe(struct platform_device *pdev)
 {
+	struct lpss_clk_data *drvdata;
 	struct clk *clk;
 
+	drvdata = devm_kmalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
 	/* LPSS free running clock */
-	clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
-				      100000000);
+	drvdata->name = "lpss_clk";
+	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
+				      CLK_IS_ROOT, 100000000);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	/* Shared DMA clock */
-	clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
+	drvdata->clk = clk;
+	platform_set_drvdata(pdev, drvdata);
 	return 0;
 }
 
include/linux/platform_data/clk-lpss.h +5 -0
index 528e73c..2390199 100644
@@ -13,6 +13,11 @@
 #ifndef __CLK_LPSS_H
 #define __CLK_LPSS_H
 
+struct lpss_clk_data {
+	const char *name;
+	struct clk *clk;
+};
+
 extern int lpt_clk_init(void);
 
 #endif /* __CLK_LPSS_H */
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#7 lore raw

PATCH v2 5/5 ACPI / LPSS: add support of shared clock

From: "Rafael J. Wysocki" <[email protected]>

The DMA controller in Lynxpoint is using the LPSS root clock as a functional clock to work properly. Proposed patch adds support of the shared clock. It also avoids hardcoding the name of the DMA device in clk-lpt.c and the name of the root clock in acpi_lpss.c.

---
 drivers/acpi/acpi_lpss.c               | 26 ++++++++++++++++++++++----
 drivers/clk/x86/clk-lpt.c              | 15 +++++++++++----
 include/linux/platform_data/clk-lpss.h |  5 +++++
 3 files changed, 38 insertions(+), 8 deletions(-)
drivers/acpi/acpi_lpss.c +22 -4
index b1c9542..652fd5c 100644
@@ -35,11 +35,16 @@ ACPI_MODULE_NAME("acpi_lpss");
 
 struct lpss_device_desc {
 	bool clk_required;
-	const char *clk_parent;
+	const char *clkdev_name;
 	bool ltr_required;
 	unsigned int prv_offset;
 };
 
+static struct lpss_device_desc lpss_dma_desc = {
+	.clk_required = true,
+	.clkdev_name = "hclk",
+};
+
 struct lpss_private_data {
 	void __iomem *mmio_base;
 	resource_size_t mmio_size;
@@ -49,7 +54,6 @@ struct lpss_private_data {
 
 static struct lpss_device_desc lpt_dev_desc = {
 	.clk_required = true,
-	.clk_parent = "lpss_clk",
 	.prv_offset = 0x800,
 	.ltr_required = true,
 };
@@ -60,6 +64,9 @@ static struct lpss_device_desc lpt_sdio_dev_desc = {
 };
 
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
+	/* Generic LPSS devices */
+	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+
 	/* Lynxpoint LPSS devices */
 	{ "INT33C0", (unsigned long)&lpt_dev_desc },
 	{ "INT33C1", (unsigned long)&lpt_dev_desc },
@@ -91,16 +98,27 @@ static int register_device_clock(struct acpi_device *adev,
 				 struct lpss_private_data *pdata)
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
+	struct lpss_clk_data *clk_data;
 
 	if (!lpss_clk_dev)
 		lpt_register_clock_device();
 
-	if (!dev_desc->clk_parent || !pdata->mmio_base
+	clk_data = platform_get_drvdata(lpss_clk_dev);
+	if (!clk_data)
+		return -ENODEV;
+
+	if (dev_desc->clkdev_name) {
+		clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name,
+				    dev_name(&adev->dev));
+		return 0;
+	}
+
+	if (!pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
 		return -ENODATA;
 
 	pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev),
-				       dev_desc->clk_parent, 0,
+				       clk_data->name, 0,
 				       pdata->mmio_base + dev_desc->prv_offset,
 				       0, 0, NULL);
 	if (IS_ERR(pdata->clk))
drivers/clk/x86/clk-lpt.c +11 -4
index 5cf4f46..e70fae3f 100644
@@ -15,22 +15,29 @@
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/platform_data/clk-lpss.h>
 #include <linux/platform_device.h>
 
 #define PRV_CLOCK_PARAMS 0x800
 
 static int lpt_clk_probe(struct platform_device *pdev)
 {
+	struct lpss_clk_data *drvdata;
 	struct clk *clk;
 
+	drvdata = devm_kmalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
 	/* LPSS free running clock */
-	clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
-				      100000000);
+	drvdata->name = "lpss_clk";
+	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
+				      CLK_IS_ROOT, 100000000);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	/* Shared DMA clock */
-	clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
+	drvdata->clk = clk;
+	platform_set_drvdata(pdev, drvdata);
 	return 0;
 }
 
include/linux/platform_data/clk-lpss.h +5 -0
index 528e73c..2390199 100644
@@ -13,6 +13,11 @@
 #ifndef __CLK_LPSS_H
 #define __CLK_LPSS_H
 
+struct lpss_clk_data {
+	const char *name;
+	struct clk *clk;
+};
+
 extern int lpt_clk_init(void);
 
 #endif /* __CLK_LPSS_H */
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#8 lore raw
In reply to Andy Shevchenko
Quoted 9 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Vinod, any comments on the series? Could you consider merging these for 3.10?

Quoted 30 lines

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#9 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

--
~Vinod

Quoted 38 lines

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#10 lore raw

Will do tomorrow. Thanks!

Quoted 52 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

--
~Vinod

Quoted 35 lines

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Quoted 3 lines

--
1.8.2.rc0.22.gb3600c3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw
In reply to Vinod Koul
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

Actually those two (at least 5/5) can't be applied on top of slave-dma. The patches requires slave-dma and linux-pm together. I heard it's usually achieved by creating a specific branch in one subsystem (linux-pm in our case) for another.

Rafael, what could we do here?

Quoted 40 lines

--
~Vinod

Quoted 38 lines

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 1 line
1.8.2.rc0.22.gb3600c3
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#12 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

Quoted 6 lines

Actually those two (at least 5/5) can't be applied on top of slave-dma. The patches requires slave-dma and linux-pm together. I heard it's usually achieved by creating a specific branch in one subsystem (linux-pm in our case) for another.

Rafael, what could we do here?

I suppose Vinod can pull from my acpi-lpss (which is guaranteed not to be rebased at this point) and apply the series on top of that.

Thanks,
Rafael

Quoted 36 lines
Quoted 34 lines
Quoted 34 lines

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#13 lore raw
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Andy Shevchenko
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

Actually those two (at least 5/5) can't be applied on top of slave-dma. The patches requires slave-dma and linux-pm together. I heard it's usually achieved by creating a specific branch in one subsystem (linux-pm in our case) for another.

Quoted 4 lines
Quoted 1 line

Rafael, what could we do here?

I suppose Vinod can pull from my acpi-lpss (which is guaranteed not to be rebased at this point) and apply the series on top of that.

Or I can wait for rc1 and apply afterwards...?

Quoted 44 lines

Thanks,
Rafael

Quoted 36 lines
Quoted 34 lines
Quoted 34 lines

Since v1:
- address one Vinod's comment
- replace 5/6 & 6/6 by 5/5 from Rafael
- tested on Intel Lynxpoint system

Andy Shevchenko (4):
dma: acpi-dma: introduce ACPI DMA helpers
dmaengine: call acpi_dma_request_slave_channel as well
dma: acpi-dma: parse CSRT to extract additional resources
dw_dmac: add ACPI support

Rafael J. Wysocki (1):
ACPI / LPSS: add support of shared clock

 Documentation/acpi/enumeration.txt     |  77 ++++++
 drivers/acpi/Makefile                  |   1 -
 drivers/acpi/acpi_lpss.c               |  26 +-
 drivers/acpi/csrt.c                    | 159 ------------
 drivers/acpi/internal.h                |   1 -
 drivers/acpi/scan.c                    |   1 -
 drivers/clk/x86/clk-lpt.c              |  15 +-
 drivers/dma/Kconfig                    |   4 +
 drivers/dma/Makefile                   |   1 +
 drivers/dma/acpi-dma.c                 | 445 +++++++++++++++++++++++++++++++++
 drivers/dma/dmaengine.c                |   6 +
 drivers/dma/dw_dmac.c                  |  68 +++--
 drivers/dma/dw_dmac_regs.h             |   1 -
 include/linux/acpi_dma.h               | 120 +++++++++
 include/linux/platform_data/clk-lpss.h |   5 +
 15 files changed, 741 insertions(+), 189 deletions(-)
 delete mode 100644 drivers/acpi/csrt.c
 create mode 100644 drivers/dma/acpi-dma.c
 create mode 100644 include/linux/acpi_dma.h
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#14 lore raw
Quoted 16 lines · Vinod Koul
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Andy Shevchenko
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

Actually those two (at least 5/5) can't be applied on top of slave-dma. The patches requires slave-dma and linux-pm together. I heard it's usually achieved by creating a specific branch in one subsystem (linux-pm in our case) for another.

Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Rafael, what could we do here?

I suppose Vinod can pull from my acpi-lpss (which is guaranteed not to be rebased at this point) and apply the series on top of that.

Or I can wait for rc1 and apply afterwards...?

Mika and I have no objections to go this way.

--
With Best Regards,
Andy Shevchenko

#15 lore raw
Quoted 17 lines · Andy Shevchenko
Quoted 16 lines · Vinod Koul
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Andy Shevchenko
Quoted 7 lines · Vinod Koul
Quoted 4 lines · Andy Shevchenko

There is a patch series which introduces ACPI DMA helpers in similar way like we have for DeviceTree.

In addition it applies this to the first user, namely dw_dmac driver.

Applied w/o 3 & 5.2 they failed, can you pls rebase and resend

Actually those two (at least 5/5) can't be applied on top of slave-dma. The patches requires slave-dma and linux-pm together. I heard it's usually achieved by creating a specific branch in one subsystem (linux-pm in our case) for another.

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Rafael, what could we do here?

I suppose Vinod can pull from my acpi-lpss (which is guaranteed not to be rebased at this point) and apply the series on top of that.

Or I can wait for rc1 and apply afterwards...?

Mika and I have no objections to go this way.

That'd be fine by me too.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#16 lore raw

PATCH v2 5/5 ACPI / LPSS: register clock device for Lynxpoint DMA properly

In reply to Vinod Koul

From: "Rafael J. Wysocki" <[email protected]>

The DMA controller in Lynxpoint is enumerated as a regular ACPI device now. To work properly it is using the LPSS root clock as a functional clock. That's why we have to register the clock device accordingly to the ACPI ID of the DMA controller. The acpi_lpss.c module is responsible to do the job.

This patch also removes hardcoded name of the DMA device in clk-lpt.c and the name of the root clock in acpi_lpss.c.

---
Since 5/5 v2.1:
- fix a typo (devm_kzalloc)
- amend commit message to clarify what is done and why.

 drivers/acpi/acpi_lpss.c               | 26 ++++++++++++++++++++++----
 drivers/clk/x86/clk-lpt.c              | 15 +++++++++++----
 include/linux/platform_data/clk-lpss.h |  5 +++++
 3 files changed, 38 insertions(+), 8 deletions(-)
drivers/acpi/acpi_lpss.c +22 -4
index b1c9542..652fd5c 100644
@@ -35,11 +35,16 @@ ACPI_MODULE_NAME("acpi_lpss");
 
 struct lpss_device_desc {
 	bool clk_required;
-	const char *clk_parent;
+	const char *clkdev_name;
 	bool ltr_required;
 	unsigned int prv_offset;
 };
 
+static struct lpss_device_desc lpss_dma_desc = {
+	.clk_required = true,
+	.clkdev_name = "hclk",
+};
+
 struct lpss_private_data {
 	void __iomem *mmio_base;
 	resource_size_t mmio_size;
@@ -49,7 +54,6 @@ struct lpss_private_data {
 
 static struct lpss_device_desc lpt_dev_desc = {
 	.clk_required = true,
-	.clk_parent = "lpss_clk",
 	.prv_offset = 0x800,
 	.ltr_required = true,
 };
@@ -60,6 +64,9 @@ static struct lpss_device_desc lpt_sdio_dev_desc = {
 };
 
 static const struct acpi_device_id acpi_lpss_device_ids[] = {
+	/* Generic LPSS devices */
+	{ "INTL9C60", (unsigned long)&lpss_dma_desc },
+
 	/* Lynxpoint LPSS devices */
 	{ "INT33C0", (unsigned long)&lpt_dev_desc },
 	{ "INT33C1", (unsigned long)&lpt_dev_desc },
@@ -91,16 +98,27 @@ static int register_device_clock(struct acpi_device *adev,
 				 struct lpss_private_data *pdata)
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
+	struct lpss_clk_data *clk_data;
 
 	if (!lpss_clk_dev)
 		lpt_register_clock_device();
 
-	if (!dev_desc->clk_parent || !pdata->mmio_base
+	clk_data = platform_get_drvdata(lpss_clk_dev);
+	if (!clk_data)
+		return -ENODEV;
+
+	if (dev_desc->clkdev_name) {
+		clk_register_clkdev(clk_data->clk, dev_desc->clkdev_name,
+				    dev_name(&adev->dev));
+		return 0;
+	}
+
+	if (!pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
 		return -ENODATA;
 
 	pdata->clk = clk_register_gate(NULL, dev_name(&adev->dev),
-				       dev_desc->clk_parent, 0,
+				       clk_data->name, 0,
 				       pdata->mmio_base + dev_desc->prv_offset,
 				       0, 0, NULL);
 	if (IS_ERR(pdata->clk))
drivers/clk/x86/clk-lpt.c +11 -4
index 5cf4f46..4f45eee 100644
@@ -15,22 +15,29 @@
 #include <linux/clk-provider.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/platform_data/clk-lpss.h>
 #include <linux/platform_device.h>
 
 #define PRV_CLOCK_PARAMS 0x800
 
 static int lpt_clk_probe(struct platform_device *pdev)
 {
+	struct lpss_clk_data *drvdata;
 	struct clk *clk;
 
+	drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
+	if (!drvdata)
+		return -ENOMEM;
+
 	/* LPSS free running clock */
-	clk = clk_register_fixed_rate(&pdev->dev, "lpss_clk", NULL, CLK_IS_ROOT,
-				      100000000);
+	drvdata->name = "lpss_clk";
+	clk = clk_register_fixed_rate(&pdev->dev, drvdata->name, NULL,
+				      CLK_IS_ROOT, 100000000);
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
-	/* Shared DMA clock */
-	clk_register_clkdev(clk, "hclk", "INTL9C60.0.auto");
+	drvdata->clk = clk;
+	platform_set_drvdata(pdev, drvdata);
 	return 0;
 }
 
include/linux/platform_data/clk-lpss.h +5 -0
index 528e73c..2390199 100644
@@ -13,6 +13,11 @@
 #ifndef __CLK_LPSS_H
 #define __CLK_LPSS_H
 
+struct lpss_clk_data {
+	const char *name;
+	struct clk *clk;
+};
+
 extern int lpt_clk_init(void);
 
 #endif /* __CLK_LPSS_H */
Signature · 1 line
1.8.2.rc0.22.gb3600c3