提交 43b5abe0 编写于 作者: S Sascha Herrmann 提交者: David S. Miller

at86rf230: add irq type configuration option

Add option to at86rf230 platform data to configure the type of the
interrupt used by the driver. The irq polarity of the device will
be configured accordingly.
Signed-off-by: NSascha Herrmann <sascha@ps.nvbi.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8ac2b3c0
...@@ -219,6 +219,9 @@ struct at86rf230_local { ...@@ -219,6 +219,9 @@ struct at86rf230_local {
#define IRQ_PLL_UNL (1 << 1) #define IRQ_PLL_UNL (1 << 1)
#define IRQ_PLL_LOCK (1 << 0) #define IRQ_PLL_LOCK (1 << 0)
#define IRQ_ACTIVE_HIGH 0
#define IRQ_ACTIVE_LOW 1
#define STATE_P_ON 0x00 /* BUSY */ #define STATE_P_ON 0x00 /* BUSY */
#define STATE_BUSY_RX 0x01 #define STATE_BUSY_RX 0x01
#define STATE_BUSY_TX 0x02 #define STATE_BUSY_TX 0x02
...@@ -726,11 +729,16 @@ static irqreturn_t at86rf230_isr(int irq, void *data) ...@@ -726,11 +729,16 @@ static irqreturn_t at86rf230_isr(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int at86rf230_irq_polarity(struct at86rf230_local *lp, int pol)
{
return at86rf230_write_subreg(lp, SR_IRQ_POLARITY, pol);
}
static int at86rf230_hw_init(struct at86rf230_local *lp) static int at86rf230_hw_init(struct at86rf230_local *lp)
{ {
struct at86rf230_platform_data *pdata = lp->spi->dev.platform_data;
int rc, irq_pol;
u8 status; u8 status;
int rc;
rc = at86rf230_read_subreg(lp, SR_TRX_STATUS, &status); rc = at86rf230_read_subreg(lp, SR_TRX_STATUS, &status);
if (rc) if (rc)
...@@ -748,6 +756,16 @@ static int at86rf230_hw_init(struct at86rf230_local *lp) ...@@ -748,6 +756,16 @@ static int at86rf230_hw_init(struct at86rf230_local *lp)
dev_info(&lp->spi->dev, "Status: %02x\n", status); dev_info(&lp->spi->dev, "Status: %02x\n", status);
} }
/* configure irq polarity, defaults to high active */
if (pdata->irq_type & (IRQF_TRIGGER_FALLING | IRQF_TRIGGER_LOW))
irq_pol = IRQ_ACTIVE_LOW;
else
irq_pol = IRQ_ACTIVE_HIGH;
rc = at86rf230_irq_polarity(lp, irq_pol);
if (rc)
return rc;
rc = at86rf230_write_subreg(lp, SR_IRQ_MASK, 0xff); /* IRQ_TRX_UR | rc = at86rf230_write_subreg(lp, SR_IRQ_MASK, 0xff); /* IRQ_TRX_UR |
* IRQ_CCA_ED | * IRQ_CCA_ED |
* IRQ_TRX_END | * IRQ_TRX_END |
...@@ -798,37 +816,36 @@ static int at86rf230_hw_init(struct at86rf230_local *lp) ...@@ -798,37 +816,36 @@ static int at86rf230_hw_init(struct at86rf230_local *lp)
return 0; return 0;
} }
static int at86rf230_fill_data(struct spi_device *spi) static void at86rf230_fill_data(struct spi_device *spi)
{ {
struct at86rf230_local *lp = spi_get_drvdata(spi); struct at86rf230_local *lp = spi_get_drvdata(spi);
struct at86rf230_platform_data *pdata = spi->dev.platform_data; struct at86rf230_platform_data *pdata = spi->dev.platform_data;
if (!pdata) {
dev_err(&spi->dev, "no platform_data\n");
return -EINVAL;
}
lp->rstn = pdata->rstn; lp->rstn = pdata->rstn;
lp->slp_tr = pdata->slp_tr; lp->slp_tr = pdata->slp_tr;
lp->dig2 = pdata->dig2; lp->dig2 = pdata->dig2;
return 0;
} }
static int at86rf230_probe(struct spi_device *spi) static int at86rf230_probe(struct spi_device *spi)
{ {
struct at86rf230_platform_data *pdata;
struct ieee802154_dev *dev; struct ieee802154_dev *dev;
struct at86rf230_local *lp; struct at86rf230_local *lp;
u8 man_id_0, man_id_1; u8 man_id_0, man_id_1;
int rc; int rc, supported = 0;
const char *chip; const char *chip;
int supported = 0;
if (!spi->irq) { if (!spi->irq) {
dev_err(&spi->dev, "no IRQ specified\n"); dev_err(&spi->dev, "no IRQ specified\n");
return -EINVAL; return -EINVAL;
} }
pdata = spi->dev.platform_data;
if (!pdata) {
dev_err(&spi->dev, "no platform_data\n");
return -EINVAL;
}
dev = ieee802154_alloc_device(sizeof(*lp), &at86rf230_ops); dev = ieee802154_alloc_device(sizeof(*lp), &at86rf230_ops);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
...@@ -851,9 +868,7 @@ static int at86rf230_probe(struct spi_device *spi) ...@@ -851,9 +868,7 @@ static int at86rf230_probe(struct spi_device *spi)
spi_set_drvdata(spi, lp); spi_set_drvdata(spi, lp);
rc = at86rf230_fill_data(spi); at86rf230_fill_data(spi);
if (rc)
goto err_fill;
rc = gpio_request(lp->rstn, "rstn"); rc = gpio_request(lp->rstn, "rstn");
if (rc) if (rc)
...@@ -928,7 +943,8 @@ static int at86rf230_probe(struct spi_device *spi) ...@@ -928,7 +943,8 @@ static int at86rf230_probe(struct spi_device *spi)
if (rc) if (rc)
goto err_gpio_dir; goto err_gpio_dir;
rc = request_irq(spi->irq, at86rf230_isr, IRQF_SHARED, rc = request_irq(spi->irq, at86rf230_isr,
IRQF_SHARED | pdata->irq_type,
dev_name(&spi->dev), lp); dev_name(&spi->dev), lp);
if (rc) if (rc)
goto err_gpio_dir; goto err_gpio_dir;
...@@ -948,7 +964,6 @@ static int at86rf230_probe(struct spi_device *spi) ...@@ -948,7 +964,6 @@ static int at86rf230_probe(struct spi_device *spi)
err_slp_tr: err_slp_tr:
gpio_free(lp->rstn); gpio_free(lp->rstn);
err_rstn: err_rstn:
err_fill:
spi_set_drvdata(spi, NULL); spi_set_drvdata(spi, NULL);
mutex_destroy(&lp->bmux); mutex_destroy(&lp->bmux);
ieee802154_free_device(lp->dev); ieee802154_free_device(lp->dev);
......
...@@ -26,6 +26,20 @@ struct at86rf230_platform_data { ...@@ -26,6 +26,20 @@ struct at86rf230_platform_data {
int rstn; int rstn;
int slp_tr; int slp_tr;
int dig2; int dig2;
/* Setting the irq_type will configure the driver to request
* the platform irq trigger type according to the given value
* and configure the interrupt polarity of the device to the
* corresponding polarity.
*
* Allowed values are: IRQF_TRIGGER_RISING, IRQF_TRIGGER_FALLING,
* IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW
*
* Setting it to 0, the driver does not touch the trigger type
* configuration of the interrupt and sets the interrupt polarity
* of the device to high active (the default value).
*/
int irq_type;
}; };
#endif #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册