Skip to content

Commit 744cd0f

Browse files
Dilip Kotabroonie
authored andcommitted
spi: lantiq: Move interrupt configuration to SoC specific data structure
Moving interrupt configuration to SoC specific data structure helps to add support for newer SoCs on which SPI controller with lesser interrupt lines compared to existing chipsets. Signed-off-by: Dilip Kota <[email protected]> Link: https://lore.kernel.org/r/7eb6d863515245fedfa0296c72082df107367d07.1594957019.git.eswara.kota@linux.intel.com Signed-off-by: Mark Brown <[email protected]>
1 parent 8743d21 commit 744cd0f

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

drivers/spi/spi-lantiq-ssc.c

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@
149149
#define LTQ_SPI_IRNEN_T_XRX BIT(0) /* Receive end interrupt request */
150150
#define LTQ_SPI_IRNEN_ALL 0x1F
151151

152+
struct lantiq_ssc_spi;
153+
152154
struct lantiq_ssc_hwcfg {
155+
int (*cfg_irq)(struct platform_device *pdev, struct lantiq_ssc_spi *spi);
153156
unsigned int irnen_r;
154157
unsigned int irnen_t;
155158
unsigned int irncr;
@@ -799,7 +802,40 @@ static int lantiq_ssc_transfer_one(struct spi_master *master,
799802
return transfer_start(spi, spidev, t);
800803
}
801804

805+
static int lantiq_cfg_irq(struct platform_device *pdev, struct lantiq_ssc_spi *spi)
806+
{
807+
int irq, err;
808+
809+
irq = platform_get_irq_byname(pdev, LTQ_SPI_RX_IRQ_NAME);
810+
if (irq < 0)
811+
return irq;
812+
813+
err = devm_request_irq(&pdev->dev, irq, lantiq_ssc_xmit_interrupt,
814+
0, LTQ_SPI_RX_IRQ_NAME, spi);
815+
if (err)
816+
return err;
817+
818+
irq = platform_get_irq_byname(pdev, LTQ_SPI_TX_IRQ_NAME);
819+
if (irq < 0)
820+
return irq;
821+
822+
err = devm_request_irq(&pdev->dev, irq, lantiq_ssc_xmit_interrupt,
823+
0, LTQ_SPI_TX_IRQ_NAME, spi);
824+
825+
if (err)
826+
return err;
827+
828+
irq = platform_get_irq_byname(pdev, LTQ_SPI_ERR_IRQ_NAME);
829+
if (irq < 0)
830+
return irq;
831+
832+
err = devm_request_irq(&pdev->dev, irq, lantiq_ssc_err_interrupt,
833+
0, LTQ_SPI_ERR_IRQ_NAME, spi);
834+
return err;
835+
}
836+
802837
static const struct lantiq_ssc_hwcfg lantiq_ssc_xway = {
838+
.cfg_irq = lantiq_cfg_irq,
803839
.irnen_r = LTQ_SPI_IRNEN_R_XWAY,
804840
.irnen_t = LTQ_SPI_IRNEN_T_XWAY,
805841
.irnicr = 0xF8,
@@ -809,6 +845,7 @@ static const struct lantiq_ssc_hwcfg lantiq_ssc_xway = {
809845
};
810846

811847
static const struct lantiq_ssc_hwcfg lantiq_ssc_xrx = {
848+
.cfg_irq = lantiq_cfg_irq,
812849
.irnen_r = LTQ_SPI_IRNEN_R_XRX,
813850
.irnen_t = LTQ_SPI_IRNEN_T_XRX,
814851
.irnicr = 0xF8,
@@ -832,9 +869,9 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
832869
struct lantiq_ssc_spi *spi;
833870
const struct lantiq_ssc_hwcfg *hwcfg;
834871
const struct of_device_id *match;
835-
int err, rx_irq, tx_irq, err_irq;
836872
u32 id, supports_dma, revision;
837873
unsigned int num_cs;
874+
int err;
838875

839876
match = of_match_device(lantiq_ssc_match, dev);
840877
if (!match) {
@@ -843,18 +880,6 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
843880
}
844881
hwcfg = match->data;
845882

846-
rx_irq = platform_get_irq_byname(pdev, LTQ_SPI_RX_IRQ_NAME);
847-
if (rx_irq < 0)
848-
return -ENXIO;
849-
850-
tx_irq = platform_get_irq_byname(pdev, LTQ_SPI_TX_IRQ_NAME);
851-
if (tx_irq < 0)
852-
return -ENXIO;
853-
854-
err_irq = platform_get_irq_byname(pdev, LTQ_SPI_ERR_IRQ_NAME);
855-
if (err_irq < 0)
856-
return -ENXIO;
857-
858883
master = spi_alloc_master(dev, sizeof(struct lantiq_ssc_spi));
859884
if (!master)
860885
return -ENOMEM;
@@ -870,18 +895,7 @@ static int lantiq_ssc_probe(struct platform_device *pdev)
870895
goto err_master_put;
871896
}
872897

873-
err = devm_request_irq(dev, rx_irq, lantiq_ssc_xmit_interrupt,
874-
0, LTQ_SPI_RX_IRQ_NAME, spi);
875-
if (err)
876-
goto err_master_put;
877-
878-
err = devm_request_irq(dev, tx_irq, lantiq_ssc_xmit_interrupt,
879-
0, LTQ_SPI_TX_IRQ_NAME, spi);
880-
if (err)
881-
goto err_master_put;
882-
883-
err = devm_request_irq(dev, err_irq, lantiq_ssc_err_interrupt,
884-
0, LTQ_SPI_ERR_IRQ_NAME, spi);
898+
err = hwcfg->cfg_irq(pdev, spi);
885899
if (err)
886900
goto err_master_put;
887901

0 commit comments

Comments
 (0)