|
20 | 20 | #include <linux/module.h>
|
21 | 21 | #include <linux/regmap.h>
|
22 | 22 | #include <linux/ieee802154.h>
|
| 23 | +#include <linux/irq.h> |
23 | 24 | #include <net/cfg802154.h>
|
24 | 25 | #include <net/mac802154.h>
|
25 | 26 |
|
@@ -992,6 +993,7 @@ static irqreturn_t mrf24j40_isr(int irq, void *data)
|
992 | 993 |
|
993 | 994 | static int mrf24j40_hw_init(struct mrf24j40 *devrec)
|
994 | 995 | {
|
| 996 | + u32 irq_type; |
995 | 997 | int ret;
|
996 | 998 |
|
997 | 999 | /* Initialize the device.
|
@@ -1083,6 +1085,25 @@ static int mrf24j40_hw_init(struct mrf24j40 *devrec)
|
1083 | 1085 | regmap_write(devrec->regmap_long, REG_RFCON3, 0x28);
|
1084 | 1086 | }
|
1085 | 1087 |
|
| 1088 | + irq_type = irq_get_trigger_type(devrec->spi->irq); |
| 1089 | + if (irq_type == IRQ_TYPE_EDGE_RISING || |
| 1090 | + irq_type == IRQ_TYPE_EDGE_FALLING) |
| 1091 | + dev_warn(&devrec->spi->dev, |
| 1092 | + "Using edge triggered irq's are not recommended, because it can cause races and result in a non-functional driver!\n"); |
| 1093 | + switch (irq_type) { |
| 1094 | + case IRQ_TYPE_EDGE_RISING: |
| 1095 | + case IRQ_TYPE_LEVEL_HIGH: |
| 1096 | + /* set interrupt polarity to rising */ |
| 1097 | + ret = regmap_update_bits(devrec->regmap_long, REG_SLPCON0, |
| 1098 | + 0x02, 0x02); |
| 1099 | + if (ret) |
| 1100 | + goto err_ret; |
| 1101 | + break; |
| 1102 | + default: |
| 1103 | + /* default is falling edge */ |
| 1104 | + break; |
| 1105 | + } |
| 1106 | + |
1086 | 1107 | return 0;
|
1087 | 1108 |
|
1088 | 1109 | err_ret:
|
@@ -1182,7 +1203,7 @@ static void mrf24j40_phy_setup(struct mrf24j40 *devrec)
|
1182 | 1203 |
|
1183 | 1204 | static int mrf24j40_probe(struct spi_device *spi)
|
1184 | 1205 | {
|
1185 |
| - int ret = -ENOMEM; |
| 1206 | + int ret = -ENOMEM, irq_type; |
1186 | 1207 | struct ieee802154_hw *hw;
|
1187 | 1208 | struct mrf24j40 *devrec;
|
1188 | 1209 |
|
@@ -1242,9 +1263,13 @@ static int mrf24j40_probe(struct spi_device *spi)
|
1242 | 1263 |
|
1243 | 1264 | mrf24j40_phy_setup(devrec);
|
1244 | 1265 |
|
| 1266 | + /* request IRQF_TRIGGER_LOW as fallback default */ |
| 1267 | + irq_type = irq_get_trigger_type(spi->irq); |
| 1268 | + if (!irq_type) |
| 1269 | + irq_type = IRQF_TRIGGER_LOW; |
| 1270 | + |
1245 | 1271 | ret = devm_request_irq(&spi->dev, spi->irq, mrf24j40_isr,
|
1246 |
| - IRQF_TRIGGER_LOW, dev_name(&spi->dev), |
1247 |
| - devrec); |
| 1272 | + irq_type, dev_name(&spi->dev), devrec); |
1248 | 1273 | if (ret) {
|
1249 | 1274 | dev_err(printdev(devrec), "Unable to get IRQ");
|
1250 | 1275 | goto err_register_device;
|
|
0 commit comments