Unverified Commit 1901300b authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

Merge tag 'ti-driver-soc-for-v5.19' of...

Merge tag 'ti-driver-soc-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux into arm/drivers

TI Driver updates for v5.19

* wkup_m3: io isolation, voltage scaling, vtt regulator and a debug option to stop m3 in suspend.
* tisci: support for polled mode for system suspend, reset driver is now enabled for COMPILE_TEST
* knav, dma.. misc cleanups for IS_ERR, pm_run_time*, and various other fixups.

* tag 'ti-driver-soc-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ti/linux:
  soc: ti: wkup_m3_ipc: Add debug option to halt m3 in suspend
  soc: ti: wkup_m3_ipc: Add support for i2c voltage scaling
  soc: ti: wkup_m3_ipc: Add support for IO Isolation
  soc: ti: knav_qmss_queue: Use IS_ERR instead of IS_ERR_OR_NULL when checking knav_queue_open() result
  soc: ti: pm33xx: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
  firmware: ti_sci: Switch transport to polled mode during system suspend
  soc: ti: wkup_m3_ipc: Add support for toggling VTT regulator
  soc: ti: knav_qmss_queue: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync
  soc: ti: knav_dma: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync
  reset: ti-sci: Allow building under COMPILE_TEST
  soc: ti: ti_sci_pm_domains: Check for null return of devm_kcalloc
  soc: ti: omap_prm: Use of_device_get_match_data()
  soc: ti: pruss: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
  soc: ti: replace usage of found with dedicated list iterator variable
  soc: ti: wkup_m3_ipc: fix platform_get_irq.cocci warning

Link: https://lore.kernel.org/r/20220507163424.pvqnwrxpoo73lmp2@debtless


Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 68edb53a 2a21f9e6
Loading
Loading
Loading
Loading
+55 −6
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
/*
 * Texas Instruments System Control Interface Protocol Driver
 *
 * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/
 * Copyright (C) 2015-2022 Texas Instruments Incorporated - https://www.ti.com/
 *	Nishanth Menon
 */

@@ -12,6 +12,7 @@
#include <linux/debugfs.h>
#include <linux/export.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mailbox_client.h>
#include <linux/module.h>
@@ -96,6 +97,7 @@ struct ti_sci_desc {
 * @node:	list head
 * @host_id:	Host ID
 * @users:	Number of users of this instance
 * @is_suspending: Flag set to indicate in suspend path.
 */
struct ti_sci_info {
	struct device *dev;
@@ -114,7 +116,7 @@ struct ti_sci_info {
	u8 host_id;
	/* protected by ti_sci_list_mutex */
	int users;

	bool is_suspending;
};

#define cl_to_ti_sci_info(c)	container_of(c, struct ti_sci_info, cl)
@@ -349,6 +351,8 @@ static struct ti_sci_xfer *ti_sci_get_one_xfer(struct ti_sci_info *info,

	hdr = (struct ti_sci_msg_hdr *)xfer->tx_message.buf;
	xfer->tx_message.len = tx_message_size;
	xfer->tx_message.chan_rx = info->chan_rx;
	xfer->tx_message.timeout_rx_ms = info->desc->max_rx_timeout_ms;
	xfer->rx_len = (u8)rx_message_size;

	reinit_completion(&xfer->done);
@@ -406,6 +410,7 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,
	int ret;
	int timeout;
	struct device *dev = info->dev;
	bool done_state = true;

	ret = mbox_send_message(info->chan_tx, &xfer->tx_message);
	if (ret < 0)
@@ -413,13 +418,27 @@ static inline int ti_sci_do_xfer(struct ti_sci_info *info,

	ret = 0;

	if (!info->is_suspending) {
		/* And we wait for the response. */
		timeout = msecs_to_jiffies(info->desc->max_rx_timeout_ms);
	if (!wait_for_completion_timeout(&xfer->done, timeout)) {
		if (!wait_for_completion_timeout(&xfer->done, timeout))
			ret = -ETIMEDOUT;
	} else {
		/*
		 * If we are suspending, we cannot use wait_for_completion_timeout
		 * during noirq phase, so we must manually poll the completion.
		 */
		ret = read_poll_timeout_atomic(try_wait_for_completion, done_state,
					       true, 1,
					       info->desc->max_rx_timeout_ms * 1000,
					       false, &xfer->done);
	}

	if (ret == -ETIMEDOUT || !done_state) {
		dev_err(dev, "Mbox timedout in resp(caller: %pS)\n",
			(void *)_RET_IP_);
		ret = -ETIMEDOUT;
	}

	/*
	 * NOTE: we might prefer not to need the mailbox ticker to manage the
	 * transfer queueing since the protocol layer queues things by itself.
@@ -3264,6 +3283,35 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
	return NOTIFY_BAD;
}

static void ti_sci_set_is_suspending(struct ti_sci_info *info, bool is_suspending)
{
	info->is_suspending = is_suspending;
}

static int ti_sci_suspend(struct device *dev)
{
	struct ti_sci_info *info = dev_get_drvdata(dev);
	/*
	 * We must switch operation to polled mode now as drivers and the genpd
	 * layer may make late TI SCI calls to change clock and device states
	 * from the noirq phase of suspend.
	 */
	ti_sci_set_is_suspending(info, true);

	return 0;
}

static int ti_sci_resume(struct device *dev)
{
	struct ti_sci_info *info = dev_get_drvdata(dev);

	ti_sci_set_is_suspending(info, false);

	return 0;
}

static DEFINE_SIMPLE_DEV_PM_OPS(ti_sci_pm_ops, ti_sci_suspend, ti_sci_resume);

/* Description for K2G */
static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
	.default_host_id = 2,
@@ -3472,6 +3520,7 @@ static struct platform_driver ti_sci_driver = {
	.driver = {
		   .name = "ti-sci",
		   .of_match_table = of_match_ptr(ti_sci_of_match),
		   .pm = &ti_sci_pm_ops,
	},
};
module_platform_driver(ti_sci_driver);
+1 −1
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ config RESET_SUNXI

config RESET_TI_SCI
	tristate "TI System Control Interface (TI-SCI) reset driver"
	depends on TI_SCI_PROTOCOL
	depends on TI_SCI_PROTOCOL || COMPILE_TEST
	help
	  This enables the reset driver support over TI System Control Interface
	  available on some new TI's SoCs. If you wish to use reset resources
+13 −16
Original line number Diff line number Diff line
@@ -415,9 +415,8 @@ static int of_channel_match_helper(struct device_node *np, const char *name,
void *knav_dma_open_channel(struct device *dev, const char *name,
					struct knav_dma_cfg *config)
{
	struct knav_dma_chan *chan;
	struct knav_dma_device *dma;
	bool found = false;
	struct knav_dma_device *dma = NULL, *iter1;
	struct knav_dma_chan *chan = NULL, *iter2;
	int chan_num = -1;
	const char *instance;

@@ -444,33 +443,32 @@ void *knav_dma_open_channel(struct device *dev, const char *name,
	}

	/* Look for correct dma instance */
	list_for_each_entry(dma, &kdev->list, list) {
		if (!strcmp(dma->name, instance)) {
			found = true;
	list_for_each_entry(iter1, &kdev->list, list) {
		if (!strcmp(iter1->name, instance)) {
			dma = iter1;
			break;
		}
	}
	if (!found) {
	if (!dma) {
		dev_err(kdev->dev, "No DMA instance with name %s\n", instance);
		return (void *)-EINVAL;
	}

	/* Look for correct dma channel from dma instance */
	found = false;
	list_for_each_entry(chan, &dma->chan_list, list) {
	list_for_each_entry(iter2, &dma->chan_list, list) {
		if (config->direction == DMA_MEM_TO_DEV) {
			if (chan->channel == chan_num) {
				found = true;
			if (iter2->channel == chan_num) {
				chan = iter2;
				break;
			}
		} else {
			if (chan->flow == chan_num) {
				found = true;
			if (iter2->flow == chan_num) {
				chan = iter2;
				break;
			}
		}
	}
	if (!found) {
	if (!chan) {
		dev_err(kdev->dev, "channel %d is not in DMA %s\n",
				chan_num, instance);
		return (void *)-EINVAL;
@@ -747,9 +745,8 @@ static int knav_dma_probe(struct platform_device *pdev)
	INIT_LIST_HEAD(&kdev->list);

	pm_runtime_enable(kdev->dev);
	ret = pm_runtime_get_sync(kdev->dev);
	ret = pm_runtime_resume_and_get(kdev->dev);
	if (ret < 0) {
		pm_runtime_put_noidle(kdev->dev);
		dev_err(kdev->dev, "unable to enable pktdma, err %d\n", ret);
		goto err_pm_disable;
	}
+9 −12
Original line number Diff line number Diff line
@@ -758,10 +758,9 @@ void *knav_pool_create(const char *name,
					int num_desc, int region_id)
{
	struct knav_region *reg_itr, *region = NULL;
	struct knav_pool *pool, *pi;
	struct knav_pool *pool, *pi = NULL, *iter;
	struct list_head *node;
	unsigned last_offset;
	bool slot_found;
	int ret;

	if (!kdev)
@@ -790,7 +789,7 @@ void *knav_pool_create(const char *name,
	}

	pool->queue = knav_queue_open(name, KNAV_QUEUE_GP, 0);
	if (IS_ERR_OR_NULL(pool->queue)) {
	if (IS_ERR(pool->queue)) {
		dev_err(kdev->dev,
			"failed to open queue for pool(%s), error %ld\n",
			name, PTR_ERR(pool->queue));
@@ -816,18 +815,17 @@ void *knav_pool_create(const char *name,
	 * the request
	 */
	last_offset = 0;
	slot_found = false;
	node = &region->pools;
	list_for_each_entry(pi, &region->pools, region_inst) {
		if ((pi->region_offset - last_offset) >= num_desc) {
			slot_found = true;
	list_for_each_entry(iter, &region->pools, region_inst) {
		if ((iter->region_offset - last_offset) >= num_desc) {
			pi = iter;
			break;
		}
		last_offset = pi->region_offset + pi->num_desc;
		last_offset = iter->region_offset + iter->num_desc;
	}
	node = &pi->region_inst;

	if (slot_found) {
	if (pi) {
		node = &pi->region_inst;
		pool->region = region;
		pool->num_desc = num_desc;
		pool->region_offset = last_offset;
@@ -1785,9 +1783,8 @@ static int knav_queue_probe(struct platform_device *pdev)
	INIT_LIST_HEAD(&kdev->pdsps);

	pm_runtime_enable(&pdev->dev);
	ret = pm_runtime_get_sync(&pdev->dev);
	ret = pm_runtime_resume_and_get(&pdev->dev);
	if (ret < 0) {
		pm_runtime_put_noidle(&pdev->dev);
		dev_err(dev, "Failed to enable QMSS\n");
		return ret;
	}
+2 −5
Original line number Diff line number Diff line
@@ -941,23 +941,20 @@ static int omap_prm_probe(struct platform_device *pdev)
	struct resource *res;
	const struct omap_prm_data *data;
	struct omap_prm *prm;
	const struct of_device_id *match;
	int ret;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res)
		return -ENODEV;

	match = of_match_device(omap_prm_id_table, &pdev->dev);
	if (!match)
	data = of_device_get_match_data(&pdev->dev);
	if (!data)
		return -ENOTSUPP;

	prm = devm_kzalloc(&pdev->dev, sizeof(*prm), GFP_KERNEL);
	if (!prm)
		return -ENOMEM;

	data = match->data;

	while (data->base != res->start) {
		if (!data->base)
			return -EINVAL;
Loading