mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
Merge branch 'at86rf230'
Alexander Aring says: ==================== at86rf230: various fixes and devicetree support this patch series fix some bugs with the at86rf231 chip and cleaup some code. Also add devicetree support for the at86rf230 driver. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
e73087afc5
1 changed files with 70 additions and 16 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
#include <linux/spi/at86rf230.h>
|
#include <linux/spi/at86rf230.h>
|
||||||
#include <linux/skbuff.h>
|
#include <linux/skbuff.h>
|
||||||
|
#include <linux/of_gpio.h>
|
||||||
|
|
||||||
#include <net/mac802154.h>
|
#include <net/mac802154.h>
|
||||||
#include <net/wpan-phy.h>
|
#include <net/wpan-phy.h>
|
||||||
|
@ -574,7 +575,7 @@ at86rf230_start(struct ieee802154_dev *dev)
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = at86rf230_state(dev, STATE_FORCE_TX_ON);
|
rc = at86rf230_state(dev, STATE_TX_ON);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
@ -914,8 +915,8 @@ static void at86rf230_irqwork(struct work_struct *work)
|
||||||
status &= ~IRQ_TRX_UR; /* FIXME: possibly handle ???*/
|
status &= ~IRQ_TRX_UR; /* FIXME: possibly handle ???*/
|
||||||
|
|
||||||
if (status & IRQ_TRX_END) {
|
if (status & IRQ_TRX_END) {
|
||||||
spin_lock_irqsave(&lp->lock, flags);
|
|
||||||
status &= ~IRQ_TRX_END;
|
status &= ~IRQ_TRX_END;
|
||||||
|
spin_lock_irqsave(&lp->lock, flags);
|
||||||
if (lp->is_tx) {
|
if (lp->is_tx) {
|
||||||
lp->is_tx = 0;
|
lp->is_tx = 0;
|
||||||
spin_unlock_irqrestore(&lp->lock, flags);
|
spin_unlock_irqrestore(&lp->lock, flags);
|
||||||
|
@ -1035,6 +1036,40 @@ static int at86rf230_hw_init(struct at86rf230_local *lp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct at86rf230_platform_data *
|
||||||
|
at86rf230_get_pdata(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct at86rf230_platform_data *pdata;
|
||||||
|
const char *irq_type;
|
||||||
|
|
||||||
|
if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node)
|
||||||
|
return spi->dev.platform_data;
|
||||||
|
|
||||||
|
pdata = devm_kzalloc(&spi->dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
|
if (!pdata)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
pdata->rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
|
||||||
|
pdata->slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
|
||||||
|
|
||||||
|
pdata->irq_type = IRQF_TRIGGER_RISING;
|
||||||
|
of_property_read_string(spi->dev.of_node, "irq-type", &irq_type);
|
||||||
|
if (!strcmp(irq_type, "level-high"))
|
||||||
|
pdata->irq_type = IRQF_TRIGGER_HIGH;
|
||||||
|
else if (!strcmp(irq_type, "level-low"))
|
||||||
|
pdata->irq_type = IRQF_TRIGGER_LOW;
|
||||||
|
else if (!strcmp(irq_type, "edge-rising"))
|
||||||
|
pdata->irq_type = IRQF_TRIGGER_RISING;
|
||||||
|
else if (!strcmp(irq_type, "edge-falling"))
|
||||||
|
pdata->irq_type = IRQF_TRIGGER_FALLING;
|
||||||
|
else
|
||||||
|
dev_warn(&spi->dev, "wrong irq-type specified using edge-rising\n");
|
||||||
|
|
||||||
|
spi->dev.platform_data = pdata;
|
||||||
|
done:
|
||||||
|
return pdata;
|
||||||
|
}
|
||||||
|
|
||||||
static int at86rf230_probe(struct spi_device *spi)
|
static int at86rf230_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct at86rf230_platform_data *pdata;
|
struct at86rf230_platform_data *pdata;
|
||||||
|
@ -1053,15 +1088,17 @@ static int at86rf230_probe(struct spi_device *spi)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata = spi->dev.platform_data;
|
pdata = at86rf230_get_pdata(spi);
|
||||||
if (!pdata) {
|
if (!pdata) {
|
||||||
dev_err(&spi->dev, "no platform_data\n");
|
dev_err(&spi->dev, "no platform_data\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = gpio_request(pdata->rstn, "rstn");
|
if (gpio_is_valid(pdata->rstn)) {
|
||||||
if (rc)
|
rc = gpio_request(pdata->rstn, "rstn");
|
||||||
return rc;
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
if (gpio_is_valid(pdata->slp_tr)) {
|
if (gpio_is_valid(pdata->slp_tr)) {
|
||||||
rc = gpio_request(pdata->slp_tr, "slp_tr");
|
rc = gpio_request(pdata->slp_tr, "slp_tr");
|
||||||
|
@ -1069,9 +1106,11 @@ static int at86rf230_probe(struct spi_device *spi)
|
||||||
goto err_slp_tr;
|
goto err_slp_tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = gpio_direction_output(pdata->rstn, 1);
|
if (gpio_is_valid(pdata->rstn)) {
|
||||||
if (rc)
|
rc = gpio_direction_output(pdata->rstn, 1);
|
||||||
goto err_gpio_dir;
|
if (rc)
|
||||||
|
goto err_gpio_dir;
|
||||||
|
}
|
||||||
|
|
||||||
if (gpio_is_valid(pdata->slp_tr)) {
|
if (gpio_is_valid(pdata->slp_tr)) {
|
||||||
rc = gpio_direction_output(pdata->slp_tr, 0);
|
rc = gpio_direction_output(pdata->slp_tr, 0);
|
||||||
|
@ -1080,11 +1119,13 @@ static int at86rf230_probe(struct spi_device *spi)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset */
|
/* Reset */
|
||||||
msleep(1);
|
if (gpio_is_valid(pdata->rstn)) {
|
||||||
gpio_set_value(pdata->rstn, 0);
|
udelay(1);
|
||||||
msleep(1);
|
gpio_set_value(pdata->rstn, 0);
|
||||||
gpio_set_value(pdata->rstn, 1);
|
udelay(1);
|
||||||
msleep(1);
|
gpio_set_value(pdata->rstn, 1);
|
||||||
|
usleep_range(120, 240);
|
||||||
|
}
|
||||||
|
|
||||||
rc = __at86rf230_detect_device(spi, &man_id, &part, &version);
|
rc = __at86rf230_detect_device(spi, &man_id, &part, &version);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
@ -1198,7 +1239,8 @@ err_gpio_dir:
|
||||||
if (gpio_is_valid(pdata->slp_tr))
|
if (gpio_is_valid(pdata->slp_tr))
|
||||||
gpio_free(pdata->slp_tr);
|
gpio_free(pdata->slp_tr);
|
||||||
err_slp_tr:
|
err_slp_tr:
|
||||||
gpio_free(pdata->rstn);
|
if (gpio_is_valid(pdata->rstn))
|
||||||
|
gpio_free(pdata->rstn);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1214,7 +1256,8 @@ static int at86rf230_remove(struct spi_device *spi)
|
||||||
|
|
||||||
if (gpio_is_valid(pdata->slp_tr))
|
if (gpio_is_valid(pdata->slp_tr))
|
||||||
gpio_free(pdata->slp_tr);
|
gpio_free(pdata->slp_tr);
|
||||||
gpio_free(pdata->rstn);
|
if (gpio_is_valid(pdata->rstn))
|
||||||
|
gpio_free(pdata->rstn);
|
||||||
|
|
||||||
mutex_destroy(&lp->bmux);
|
mutex_destroy(&lp->bmux);
|
||||||
ieee802154_free_device(lp->dev);
|
ieee802154_free_device(lp->dev);
|
||||||
|
@ -1223,8 +1266,19 @@ static int at86rf230_remove(struct spi_device *spi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_OF)
|
||||||
|
static struct of_device_id at86rf230_of_match[] = {
|
||||||
|
{ .compatible = "atmel,at86rf230", },
|
||||||
|
{ .compatible = "atmel,at86rf231", },
|
||||||
|
{ .compatible = "atmel,at86rf233", },
|
||||||
|
{ .compatible = "atmel,at86rf212", },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct spi_driver at86rf230_driver = {
|
static struct spi_driver at86rf230_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
|
.of_match_table = of_match_ptr(at86rf230_of_match),
|
||||||
.name = "at86rf230",
|
.name = "at86rf230",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue