From: Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Geert Uytterhoeven
<geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Subject: [PATCH V2 3/8] spi: rspi: Add support for more than one interrupt
Date: Sun, 12 Jan 2014 11:27:39 +0100 [thread overview]
Message-ID: <1389522464-1569-4-git-send-email-geert@linux-m68k.org> (raw)
In-Reply-To: <1389522464-1569-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
From: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Add support for up to 3 interrupts, based on the SDK reference code.
This is needed for RZ/A1H.
Minimum 1 and maximum 3 interrupts can be passed via platform device
resources.
Signed-off-by: Geert Uytterhoeven <geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
---
v2:
- s/irq[]/irqs[]/
- s/numirq/num_irqs/
- Use unsigned int for loop counters that cannot be negative
- Merge the platform_get_irq() and devm_request_irq() loops
- Do not update copyright header in further untouched rspi.h
drivers/spi/spi-rspi.c | 52 +++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index eded530763ca..45da760281f9 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -1,7 +1,7 @@
/*
* SH RSPI driver
*
- * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012, 2013 Renesas Solutions Corp.
*
* Based on spi-sh.c:
* Copyright (C) 2011 Renesas Solutions Corp.
@@ -176,6 +176,7 @@
#define SPBFCR_RXTRG_MASK 0x07 /* Receive Buffer Data Triggering Number */
#define DUMMY_DATA 0x00
+#define MAX_NUM_IRQ 3
struct rspi_data {
void __iomem *addr;
@@ -187,12 +188,13 @@ struct rspi_data {
spinlock_t lock;
struct clk *clk;
u8 spsr;
+ int irqs[MAX_NUM_IRQ];
+ unsigned int num_irqs;
const struct spi_ops *ops;
/* for dmaengine */
struct dma_chan *chan_tx;
struct dma_chan *chan_rx;
- int irq;
unsigned dma_width_16bit:1;
unsigned dma_callbacked:1;
@@ -470,7 +472,7 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
struct scatterlist sg;
const void *buf = NULL;
struct dma_async_tx_descriptor *desc;
- unsigned len;
+ unsigned int len, i;
int ret = 0;
if (rspi->dma_width_16bit) {
@@ -508,7 +510,8 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
* DMAC needs SPTIE, but if SPTIE is set, this IRQ routine will be
* called. So, this driver disables the IRQ while DMA transfer.
*/
- disable_irq(rspi->irq);
+ for (i = 0; i < rspi->num_irqs; i++)
+ disable_irq(rspi->irqs[i]);
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD, RSPI_SPCR);
rspi_enable_irq(rspi, SPCR_SPTIE);
@@ -527,7 +530,8 @@ static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
ret = -ETIMEDOUT;
rspi_disable_irq(rspi, SPCR_SPTIE);
- enable_irq(rspi->irq);
+ for (i = 0; i < rspi->num_irqs; i++)
+ enable_irq(rspi->irqs[i]);
end:
rspi_dma_unmap_sg(&sg, rspi->chan_tx, DMA_TO_DEVICE);
@@ -636,7 +640,7 @@ static int rspi_receive_dma(struct rspi_data *rspi, struct spi_transfer *t)
struct scatterlist sg, sg_dummy;
void *dummy = NULL, *rx_buf = NULL;
struct dma_async_tx_descriptor *desc, *desc_dummy;
- unsigned len;
+ unsigned int len, i;
int ret = 0;
if (rspi->dma_width_16bit) {
@@ -694,7 +698,8 @@ static int rspi_receive_dma(struct rspi_data *rspi, struct spi_transfer *t)
* DMAC needs SPTIE, but if SPTIE is set, this IRQ routine will be
* called. So, this driver disables the IRQ while DMA transfer.
*/
- disable_irq(rspi->irq);
+ for (i = 0; i < rspi->num_irqs; i++)
+ disable_irq(rspi->irqs[i]);
rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD, RSPI_SPCR);
rspi_enable_irq(rspi, SPCR_SPTIE | SPCR_SPRIE);
@@ -717,7 +722,8 @@ static int rspi_receive_dma(struct rspi_data *rspi, struct spi_transfer *t)
ret = -ETIMEDOUT;
rspi_disable_irq(rspi, SPCR_SPTIE | SPCR_SPRIE);
- enable_irq(rspi->irq);
+ for (i = 0; i < rspi->num_irqs; i++)
+ enable_irq(rspi->irqs[i]);
end:
rspi_dma_unmap_sg(&sg, rspi->chan_rx, DMA_FROM_DEVICE);
@@ -928,6 +934,7 @@ static int rspi_probe(struct platform_device *pdev)
struct spi_master *master;
struct rspi_data *rspi;
int ret, irq;
+ unsigned int i;
char clk_name[16];
const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
const struct spi_ops *ops;
@@ -940,12 +947,6 @@ static int rspi_probe(struct platform_device *pdev)
return -ENODEV;
}
- irq = platform_get_irq(pdev, 0);
- if (irq < 0) {
- dev_err(&pdev->dev, "platform_get_irq error\n");
- return -ENODEV;
- }
-
master = spi_alloc_master(&pdev->dev, sizeof(struct rspi_data));
if (master == NULL) {
dev_err(&pdev->dev, "spi_alloc_master error.\n");
@@ -988,14 +989,25 @@ static int rspi_probe(struct platform_device *pdev)
master->transfer = rspi_transfer;
master->cleanup = rspi_cleanup;
- ret = devm_request_irq(&pdev->dev, irq, rspi_irq, 0,
- dev_name(&pdev->dev), rspi);
- if (ret < 0) {
- dev_err(&pdev->dev, "request_irq error\n");
- goto error1;
+ for (i = 0; i < MAX_NUM_IRQ; i++) {
+ irq = platform_get_irq(pdev, i);
+ if (irq < 0) {
+ if (rspi->num_irqs)
+ break;
+ dev_err(&pdev->dev, "platform_get_irq error\n");
+ ret = -ENODEV;
+ goto error1;
+ }
+ ret = devm_request_irq(&pdev->dev, irq, rspi_irq, 0,
+ dev_name(&pdev->dev), rspi);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "request_irq %d error\n", irq);
+ goto error1;
+ }
+ rspi->irqs[i] = irq;
+ rspi->num_irqs++;
}
- rspi->irq = irq;
ret = rspi_request_dma(rspi, pdev);
if (ret < 0) {
dev_err(&pdev->dev, "rspi_request_dma failed.\n");
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-01-12 10:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-12 10:27 [PATCH V2 0/8] spi: rspi: Add support for RZ/A1H Geert Uytterhoeven
[not found] ` <1389522464-1569-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-12 10:27 ` [PATCH V2 1/8] spi: rspi: Add more RSPI register documentation Geert Uytterhoeven
2014-01-13 12:10 ` Mark Brown
2014-01-12 10:27 ` [PATCH V2 2/8] spi: rspi: Add more QSPI " Geert Uytterhoeven
[not found] ` <1389522464-1569-3-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:10 ` Mark Brown
2014-01-12 10:27 ` Geert Uytterhoeven [this message]
[not found] ` <1389522464-1569-4-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:16 ` [PATCH V2 3/8] spi: rspi: Add support for more than one interrupt Mark Brown
2014-01-12 10:27 ` [PATCH V2 4/8] spi: rspi: Add support for 8-bit Data Register access Geert Uytterhoeven
[not found] ` <1389522464-1569-5-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:29 ` Mark Brown
[not found] ` <20140113122912.GT29039-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-01-13 13:29 ` Geert Uytterhoeven
[not found] ` <CAMuHMdViLJD9O4gnovR6x7RTWor9GYPBZuzP5X7JmVw5g=o4kw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-13 15:55 ` Mark Brown
2014-01-13 19:05 ` Geert Uytterhoeven
2014-01-12 10:27 ` [PATCH V2 7/8] spi: rspi: Add support for specifying CPHA/CPOL Geert Uytterhoeven
2014-01-13 17:23 ` Mark Brown
2014-01-12 10:27 ` [PATCH V2 8/8] spi: rspi: Add support for loopback mode Geert Uytterhoeven
2014-01-12 10:27 ` [PATCH V2 5/8] spi: rspi: Add support for no TX only mode Geert Uytterhoeven
2014-01-12 10:27 ` [PATCH V2 6/8] spi: rspi: Add support for missing SPCR2 register Geert Uytterhoeven
[not found] ` <1389522464-1569-7-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-13 12:36 ` Sergei Shtylyov
[not found] ` <52D3DDDB.309-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-01-19 11:39 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389522464-1569-4-git-send-email-geert@linux-m68k.org \
--to=geert-td1emuhucqxl1znqvxdv9g@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=geert+renesas-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
--cc=linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).