Commit 097924c6 authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'tegra-for-4.15-firmware' of...

Merge tag 'tegra-for-4.15-firmware' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tegra/linux into next/drivers

Pull "firmware: tegra: Changes for v4.15-rc1" from Thierry Reding:

This contains a couple of (non-critical) fixes and improvements for the
BPMP driver as well as support for debugfs.

* tag 'tegra-for-4.15-firmware' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tegra/linux:
  firmware: tegra: Add BPMP debugfs support
  firmware: tegra: Add stubs when BPMP not enabled
  firmware: tegra: Expose tegra_bpmp_mrq_return()
  firmware: tegra: Propagate error code to caller
parents 1c6788e8 f2381f65
obj-$(CONFIG_TEGRA_BPMP) += bpmp.o tegra-bpmp-y = bpmp.o
tegra-bpmp-$(CONFIG_DEBUG_FS) += bpmp-debugfs.o
obj-$(CONFIG_TEGRA_BPMP) += tegra-bpmp.o
obj-$(CONFIG_TEGRA_IVC) += ivc.o obj-$(CONFIG_TEGRA_IVC) += ivc.o
This diff is collapsed.
...@@ -194,16 +194,24 @@ static int tegra_bpmp_wait_master_free(struct tegra_bpmp_channel *channel) ...@@ -194,16 +194,24 @@ static int tegra_bpmp_wait_master_free(struct tegra_bpmp_channel *channel)
} }
static ssize_t __tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, static ssize_t __tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel,
void *data, size_t size) void *data, size_t size, int *ret)
{ {
int err;
if (data && size > 0) if (data && size > 0)
memcpy(data, channel->ib->data, size); memcpy(data, channel->ib->data, size);
return tegra_ivc_read_advance(channel->ivc); err = tegra_ivc_read_advance(channel->ivc);
if (err < 0)
return err;
*ret = channel->ib->code;
return 0;
} }
static ssize_t tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, static ssize_t tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel,
void *data, size_t size) void *data, size_t size, int *ret)
{ {
struct tegra_bpmp *bpmp = channel->bpmp; struct tegra_bpmp *bpmp = channel->bpmp;
unsigned long flags; unsigned long flags;
...@@ -217,7 +225,7 @@ static ssize_t tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, ...@@ -217,7 +225,7 @@ static ssize_t tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel,
} }
spin_lock_irqsave(&bpmp->lock, flags); spin_lock_irqsave(&bpmp->lock, flags);
err = __tegra_bpmp_channel_read(channel, data, size); err = __tegra_bpmp_channel_read(channel, data, size, ret);
clear_bit(index, bpmp->threaded.allocated); clear_bit(index, bpmp->threaded.allocated);
spin_unlock_irqrestore(&bpmp->lock, flags); spin_unlock_irqrestore(&bpmp->lock, flags);
...@@ -337,7 +345,8 @@ int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp, ...@@ -337,7 +345,8 @@ int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
if (err < 0) if (err < 0)
return err; return err;
return __tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size); return __tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size,
&msg->rx.ret);
} }
EXPORT_SYMBOL_GPL(tegra_bpmp_transfer_atomic); EXPORT_SYMBOL_GPL(tegra_bpmp_transfer_atomic);
...@@ -371,7 +380,8 @@ int tegra_bpmp_transfer(struct tegra_bpmp *bpmp, ...@@ -371,7 +380,8 @@ int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
if (err == 0) if (err == 0)
return -ETIMEDOUT; return -ETIMEDOUT;
return tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size); return tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size,
&msg->rx.ret);
} }
EXPORT_SYMBOL_GPL(tegra_bpmp_transfer); EXPORT_SYMBOL_GPL(tegra_bpmp_transfer);
...@@ -387,8 +397,8 @@ static struct tegra_bpmp_mrq *tegra_bpmp_find_mrq(struct tegra_bpmp *bpmp, ...@@ -387,8 +397,8 @@ static struct tegra_bpmp_mrq *tegra_bpmp_find_mrq(struct tegra_bpmp *bpmp,
return NULL; return NULL;
} }
static void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code,
int code, const void *data, size_t size) const void *data, size_t size)
{ {
unsigned long flags = channel->ib->flags; unsigned long flags = channel->ib->flags;
struct tegra_bpmp *bpmp = channel->bpmp; struct tegra_bpmp *bpmp = channel->bpmp;
...@@ -426,6 +436,7 @@ static void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, ...@@ -426,6 +436,7 @@ static void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel,
mbox_client_txdone(bpmp->mbox.channel, 0); mbox_client_txdone(bpmp->mbox.channel, 0);
} }
} }
EXPORT_SYMBOL_GPL(tegra_bpmp_mrq_return);
static void tegra_bpmp_handle_mrq(struct tegra_bpmp *bpmp, static void tegra_bpmp_handle_mrq(struct tegra_bpmp *bpmp,
unsigned int mrq, unsigned int mrq,
...@@ -824,6 +835,10 @@ static int tegra_bpmp_probe(struct platform_device *pdev) ...@@ -824,6 +835,10 @@ static int tegra_bpmp_probe(struct platform_device *pdev)
if (err < 0) if (err < 0)
goto free_mrq; goto free_mrq;
err = tegra_bpmp_init_debugfs(bpmp);
if (err < 0)
dev_err(&pdev->dev, "debugfs initialization failed: %d\n", err);
return 0; return 0;
free_mrq: free_mrq:
......
...@@ -94,10 +94,11 @@ struct tegra_bpmp { ...@@ -94,10 +94,11 @@ struct tegra_bpmp {
struct reset_controller_dev rstc; struct reset_controller_dev rstc;
struct genpd_onecell_data genpd; struct genpd_onecell_data genpd;
};
struct tegra_bpmp *tegra_bpmp_get(struct device *dev); #ifdef CONFIG_DEBUG_FS
void tegra_bpmp_put(struct tegra_bpmp *bpmp); struct dentry *debugfs_mirror;
#endif
};
struct tegra_bpmp_message { struct tegra_bpmp_message {
unsigned int mrq; unsigned int mrq;
...@@ -110,18 +111,60 @@ struct tegra_bpmp_message { ...@@ -110,18 +111,60 @@ struct tegra_bpmp_message {
struct { struct {
void *data; void *data;
size_t size; size_t size;
int ret;
} rx; } rx;
}; };
#if IS_ENABLED(CONFIG_TEGRA_BPMP)
struct tegra_bpmp *tegra_bpmp_get(struct device *dev);
void tegra_bpmp_put(struct tegra_bpmp *bpmp);
int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp, int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
struct tegra_bpmp_message *msg); struct tegra_bpmp_message *msg);
int tegra_bpmp_transfer(struct tegra_bpmp *bpmp, int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
struct tegra_bpmp_message *msg); struct tegra_bpmp_message *msg);
void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code,
const void *data, size_t size);
int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq, int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
tegra_bpmp_mrq_handler_t handler, void *data); tegra_bpmp_mrq_handler_t handler, void *data);
void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq, void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
void *data); void *data);
#else
static inline struct tegra_bpmp *tegra_bpmp_get(struct device *dev)
{
return ERR_PTR(-ENOTSUPP);
}
static inline void tegra_bpmp_put(struct tegra_bpmp *bpmp)
{
}
static inline int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
struct tegra_bpmp_message *msg)
{
return -ENOTSUPP;
}
static inline int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
struct tegra_bpmp_message *msg)
{
return -ENOTSUPP;
}
static inline void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel,
int code, const void *data,
size_t size)
{
}
static inline int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp,
unsigned int mrq,
tegra_bpmp_mrq_handler_t handler,
void *data)
{
return -ENOTSUPP;
}
static inline void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp,
unsigned int mrq, void *data)
{
}
#endif
#if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP) #if IS_ENABLED(CONFIG_CLK_TEGRA_BPMP)
int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp); int tegra_bpmp_init_clocks(struct tegra_bpmp *bpmp);
...@@ -150,4 +193,14 @@ static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp) ...@@ -150,4 +193,14 @@ static inline int tegra_bpmp_init_powergates(struct tegra_bpmp *bpmp)
} }
#endif #endif
#if IS_ENABLED(CONFIG_DEBUG_FS)
int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp);
#else
static inline int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
{
return 0;
}
#endif
#endif /* __SOC_TEGRA_BPMP_H */ #endif /* __SOC_TEGRA_BPMP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment