mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 08:34:20 +08:00
gpio: Support no-irq stmpe mode
Adds support for boards which have an STMPE GPIO device without the interrupt pin connected. This means that no interrupt can be received but the GPIO pins can still be driven and read. Cc: Grant Likely <grant.likely@secretlab.ca> Acked-by: Viresh Kumar <viresh.kumar@st.com> Tested-by: Michel Jaouen <michel.jaouen@stericsson.com> Signed-off-by: Chris Blair <chris.blair@stericsson.com> Acked-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
e31f9b8264
commit
38040c858c
@ -307,13 +307,11 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
|
|||||||
struct stmpe_gpio_platform_data *pdata;
|
struct stmpe_gpio_platform_data *pdata;
|
||||||
struct stmpe_gpio *stmpe_gpio;
|
struct stmpe_gpio *stmpe_gpio;
|
||||||
int ret;
|
int ret;
|
||||||
int irq;
|
int irq = 0;
|
||||||
|
|
||||||
pdata = stmpe->pdata->gpio;
|
pdata = stmpe->pdata->gpio;
|
||||||
|
|
||||||
irq = platform_get_irq(pdev, 0);
|
irq = platform_get_irq(pdev, 0);
|
||||||
if (irq < 0)
|
|
||||||
return irq;
|
|
||||||
|
|
||||||
stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL);
|
stmpe_gpio = kzalloc(sizeof(struct stmpe_gpio), GFP_KERNEL);
|
||||||
if (!stmpe_gpio)
|
if (!stmpe_gpio)
|
||||||
@ -330,22 +328,29 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
|
|||||||
stmpe_gpio->chip.dev = &pdev->dev;
|
stmpe_gpio->chip.dev = &pdev->dev;
|
||||||
stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1;
|
stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1;
|
||||||
|
|
||||||
|
if (irq >= 0)
|
||||||
stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0);
|
stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0);
|
||||||
|
else
|
||||||
|
dev_info(&pdev->dev,
|
||||||
|
"device configured in no-irq mode; "
|
||||||
|
"irqs are not available\n");
|
||||||
|
|
||||||
ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO);
|
ret = stmpe_enable(stmpe, STMPE_BLOCK_GPIO);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
|
if (irq >= 0) {
|
||||||
ret = stmpe_gpio_irq_init(stmpe_gpio);
|
ret = stmpe_gpio_irq_init(stmpe_gpio);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_disable;
|
goto out_disable;
|
||||||
|
|
||||||
ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq, IRQF_ONESHOT,
|
ret = request_threaded_irq(irq, NULL, stmpe_gpio_irq,
|
||||||
"stmpe-gpio", stmpe_gpio);
|
IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
|
dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
|
||||||
goto out_removeirq;
|
goto out_removeirq;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = gpiochip_add(&stmpe_gpio->chip);
|
ret = gpiochip_add(&stmpe_gpio->chip);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -361,8 +366,10 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_freeirq:
|
out_freeirq:
|
||||||
|
if (irq >= 0)
|
||||||
free_irq(irq, stmpe_gpio);
|
free_irq(irq, stmpe_gpio);
|
||||||
out_removeirq:
|
out_removeirq:
|
||||||
|
if (irq >= 0)
|
||||||
stmpe_gpio_irq_remove(stmpe_gpio);
|
stmpe_gpio_irq_remove(stmpe_gpio);
|
||||||
out_disable:
|
out_disable:
|
||||||
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
|
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
|
||||||
@ -391,8 +398,10 @@ static int __devexit stmpe_gpio_remove(struct platform_device *pdev)
|
|||||||
|
|
||||||
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
|
stmpe_disable(stmpe, STMPE_BLOCK_GPIO);
|
||||||
|
|
||||||
|
if (irq >= 0) {
|
||||||
free_irq(irq, stmpe_gpio);
|
free_irq(irq, stmpe_gpio);
|
||||||
stmpe_gpio_irq_remove(stmpe_gpio);
|
stmpe_gpio_irq_remove(stmpe_gpio);
|
||||||
|
}
|
||||||
platform_set_drvdata(pdev, NULL);
|
platform_set_drvdata(pdev, NULL);
|
||||||
kfree(stmpe_gpio);
|
kfree(stmpe_gpio);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user