|
17 | 17 | #include <linux/irq.h>
|
18 | 18 | #include <linux/gpio.h>
|
19 | 19 | #include <linux/delay.h>
|
| 20 | +#include <linux/property.h> |
20 | 21 | #include <linux/spi/spi.h>
|
21 |
| -#include <linux/spi/at86rf230.h> |
22 | 22 | #include <linux/regmap.h>
|
23 | 23 | #include <linux/skbuff.h>
|
24 | 24 | #include <linux/of_gpio.h>
|
@@ -1415,32 +1415,6 @@ static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
|
1415 | 1415 | return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
|
1416 | 1416 | }
|
1417 | 1417 |
|
1418 |
| -static int |
1419 |
| -at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr, |
1420 |
| - u8 *xtal_trim) |
1421 |
| -{ |
1422 |
| - struct at86rf230_platform_data *pdata = spi->dev.platform_data; |
1423 |
| - int ret; |
1424 |
| - |
1425 |
| - if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) { |
1426 |
| - if (!pdata) |
1427 |
| - return -ENOENT; |
1428 |
| - |
1429 |
| - *rstn = pdata->rstn; |
1430 |
| - *slp_tr = pdata->slp_tr; |
1431 |
| - *xtal_trim = pdata->xtal_trim; |
1432 |
| - return 0; |
1433 |
| - } |
1434 |
| - |
1435 |
| - *rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0); |
1436 |
| - *slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0); |
1437 |
| - ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim); |
1438 |
| - if (ret < 0 && ret != -EINVAL) |
1439 |
| - return ret; |
1440 |
| - |
1441 |
| - return 0; |
1442 |
| -} |
1443 |
| - |
1444 | 1418 | static int
|
1445 | 1419 | at86rf230_detect_device(struct at86rf230_local *lp)
|
1446 | 1420 | {
|
@@ -1548,26 +1522,32 @@ static int at86rf230_probe(struct spi_device *spi)
|
1548 | 1522 | struct at86rf230_local *lp;
|
1549 | 1523 | unsigned int status;
|
1550 | 1524 | int rc, irq_type, rstn, slp_tr;
|
1551 |
| - u8 xtal_trim = 0; |
| 1525 | + u8 xtal_trim; |
1552 | 1526 |
|
1553 | 1527 | if (!spi->irq) {
|
1554 | 1528 | dev_err(&spi->dev, "no IRQ specified\n");
|
1555 | 1529 | return -EINVAL;
|
1556 | 1530 | }
|
1557 | 1531 |
|
1558 |
| - rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim); |
| 1532 | + rc = device_property_read_u8(&spi->dev, "xtal-trim", &xtal_trim); |
1559 | 1533 | if (rc < 0) {
|
1560 |
| - dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc); |
1561 |
| - return rc; |
| 1534 | + if (rc != -EINVAL) { |
| 1535 | + dev_err(&spi->dev, |
| 1536 | + "failed to parse xtal-trim: %d\n", rc); |
| 1537 | + return rc; |
| 1538 | + } |
| 1539 | + xtal_trim = 0; |
1562 | 1540 | }
|
1563 | 1541 |
|
| 1542 | + rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0); |
1564 | 1543 | if (gpio_is_valid(rstn)) {
|
1565 | 1544 | rc = devm_gpio_request_one(&spi->dev, rstn,
|
1566 | 1545 | GPIOF_OUT_INIT_HIGH, "rstn");
|
1567 | 1546 | if (rc)
|
1568 | 1547 | return rc;
|
1569 | 1548 | }
|
1570 | 1549 |
|
| 1550 | + slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0); |
1571 | 1551 | if (gpio_is_valid(slp_tr)) {
|
1572 | 1552 | rc = devm_gpio_request_one(&spi->dev, slp_tr,
|
1573 | 1553 | GPIOF_OUT_INIT_LOW, "slp_tr");
|
|
0 commit comments