net: ipa: introduce ipa_interrupt_init()
Create a new function ipa_interrupt_init() that is called at probe time to allocate and initialize the IPA interrupt data structure. Create ipa_interrupt_exit() as its inverse. This follows the normal IPA driver pattern of *_init() functions doing things that can be done before access to hardware is required. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
e87e4371ed
commit
ad1be80d75
@@ -19,6 +19,7 @@
|
||||
* time only these three are supported.
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
@@ -238,26 +239,15 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt)
|
||||
/* Configure the IPA interrupt framework */
|
||||
int ipa_interrupt_config(struct ipa *ipa)
|
||||
{
|
||||
struct ipa_interrupt *interrupt = ipa->interrupt;
|
||||
struct device *dev = &ipa->pdev->dev;
|
||||
struct ipa_interrupt *interrupt;
|
||||
unsigned int irq = interrupt->irq;
|
||||
const struct reg *reg;
|
||||
unsigned int irq;
|
||||
int ret;
|
||||
|
||||
ret = platform_get_irq_byname(ipa->pdev, "ipa");
|
||||
if (ret <= 0) {
|
||||
dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", ret);
|
||||
return ret ? : -EINVAL;
|
||||
}
|
||||
irq = ret;
|
||||
|
||||
interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
|
||||
if (!interrupt)
|
||||
return -ENOMEM;
|
||||
interrupt->ipa = ipa;
|
||||
interrupt->irq = irq;
|
||||
|
||||
/* Start with all IPA interrupts disabled */
|
||||
/* Disable all IPA interrupt types */
|
||||
reg = ipa_reg(ipa, IPA_IRQ_EN);
|
||||
iowrite32(0, ipa->reg_virt + reg_offset(reg));
|
||||
|
||||
@@ -297,5 +287,32 @@ void ipa_interrupt_deconfig(struct ipa *ipa)
|
||||
|
||||
dev_pm_clear_wake_irq(dev);
|
||||
free_irq(interrupt->irq, interrupt);
|
||||
}
|
||||
|
||||
/* Initialize the IPA interrupt structure */
|
||||
struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ipa_interrupt *interrupt;
|
||||
int irq;
|
||||
|
||||
irq = platform_get_irq_byname(pdev, "ipa");
|
||||
if (irq <= 0) {
|
||||
dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", irq);
|
||||
|
||||
return ERR_PTR(irq ? : -EINVAL);
|
||||
}
|
||||
|
||||
interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
|
||||
if (!interrupt)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
interrupt->irq = irq;
|
||||
|
||||
return interrupt;
|
||||
}
|
||||
|
||||
/* Inverse of ipa_interrupt_init() */
|
||||
void ipa_interrupt_exit(struct ipa_interrupt *interrupt)
|
||||
{
|
||||
kfree(interrupt);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,18 @@ int ipa_interrupt_config(struct ipa *ipa);
|
||||
*/
|
||||
void ipa_interrupt_deconfig(struct ipa *ipa);
|
||||
|
||||
/**
|
||||
* ipa_interrupt_init() - Initialize the IPA interrupt structure
|
||||
* @pdev: IPA platform device pointer
|
||||
*
|
||||
* Return: Pointer to an IPA interrupt structure, or a pointer-coded error
|
||||
*/
|
||||
struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev);
|
||||
|
||||
/**
|
||||
* ipa_interrupt_exit() - Inverse of ipa_interrupt_init()
|
||||
* @interrupt: IPA interrupt structure
|
||||
*/
|
||||
void ipa_interrupt_exit(struct ipa_interrupt *interrupt);
|
||||
|
||||
#endif /* _IPA_INTERRUPT_H_ */
|
||||
|
||||
@@ -803,6 +803,7 @@ out_self:
|
||||
static int ipa_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ipa_interrupt *interrupt;
|
||||
enum ipa_firmware_loader loader;
|
||||
const struct ipa_data *data;
|
||||
struct ipa_power *power;
|
||||
@@ -834,12 +835,21 @@ static int ipa_probe(struct platform_device *pdev)
|
||||
if (loader == IPA_LOADER_DEFER)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
/* The clock and interconnects might not be ready when we're
|
||||
* probed, so might return -EPROBE_DEFER.
|
||||
/* The IPA interrupt might not be ready when we're probed, so this
|
||||
* might return -EPROBE_DEFER.
|
||||
*/
|
||||
interrupt = ipa_interrupt_init(pdev);
|
||||
if (IS_ERR(interrupt))
|
||||
return PTR_ERR(interrupt);
|
||||
|
||||
/* The clock and interconnects might not be ready when we're probed,
|
||||
* so this might return -EPROBE_DEFER.
|
||||
*/
|
||||
power = ipa_power_init(dev, data->power_data);
|
||||
if (IS_ERR(power))
|
||||
return PTR_ERR(power);
|
||||
if (IS_ERR(power)) {
|
||||
ret = PTR_ERR(power);
|
||||
goto err_interrupt_exit;
|
||||
}
|
||||
|
||||
/* No more EPROBE_DEFER. Allocate and initialize the IPA structure */
|
||||
ipa = kzalloc(sizeof(*ipa), GFP_KERNEL);
|
||||
@@ -850,6 +860,7 @@ static int ipa_probe(struct platform_device *pdev)
|
||||
|
||||
ipa->pdev = pdev;
|
||||
dev_set_drvdata(dev, ipa);
|
||||
ipa->interrupt = interrupt;
|
||||
ipa->power = power;
|
||||
ipa->version = data->version;
|
||||
ipa->modem_route_count = data->modem_route_count;
|
||||
@@ -934,6 +945,8 @@ err_kfree_ipa:
|
||||
kfree(ipa);
|
||||
err_power_exit:
|
||||
ipa_power_exit(power);
|
||||
err_interrupt_exit:
|
||||
ipa_interrupt_exit(interrupt);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -941,10 +954,14 @@ err_power_exit:
|
||||
static void ipa_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct ipa *ipa = dev_get_drvdata(&pdev->dev);
|
||||
struct ipa_power *power = ipa->power;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct ipa_interrupt *interrupt;
|
||||
struct ipa_power *power;
|
||||
int ret;
|
||||
|
||||
power = ipa->power;
|
||||
interrupt = ipa->interrupt;
|
||||
|
||||
/* Prevent the modem from triggering a call to ipa_setup(). This
|
||||
* also ensures a modem-initiated setup that's underway completes.
|
||||
*/
|
||||
@@ -986,6 +1003,7 @@ out_power_put:
|
||||
ipa_reg_exit(ipa);
|
||||
kfree(ipa);
|
||||
ipa_power_exit(power);
|
||||
ipa_interrupt_exit(interrupt);
|
||||
|
||||
dev_info(dev, "IPA driver removed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user