Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ieee802154-for-net-next-2025-03-10' of git://git.kernel.org/pub/scm/linux/kernel/git/wpan/wpan-next

Stefan Schmidt says:

====================
pull-request: ieee802154-next 2025-03-10

An update from ieee802154 for your *net-next* tree:

Andy Shevchenko reworked the ca8210 driver to use the gpiod API and fixed
a few problems of the driver along the way.

* tag 'ieee802154-for-net-next-2025-03-10' of git://git.kernel.org/pub/scm/linux/kernel/git/wpan/wpan-next:
dt-bindings: ieee802154: ca8210: Update polarity of the reset pin
ieee802154: ca8210: Switch to using gpiod API
ieee802154: ca8210: Get platform data via dev_get_platdata()
ieee802154: ca8210: Use proper setters and getters for bitwise types
====================

Link: https://patch.msgid.link/20250310185752.2683890-1-stefan@datenfreihafen.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+41 -48
+1 -1
Documentation/devicetree/bindings/net/ieee802154/ca8210.txt
··· 20 20 reg = <0>; 21 21 spi-max-frequency = <3000000>; 22 22 spi-cpol; 23 - reset-gpio = <&gpio1 1 GPIO_ACTIVE_HIGH>; 23 + reset-gpio = <&gpio1 1 GPIO_ACTIVE_LOW>; 24 24 irq-gpio = <&gpio1 2 GPIO_ACTIVE_HIGH>; 25 25 extclock-enable; 26 26 extclock-freq = 16000000;
+9
drivers/gpio/gpiolib-of.c
··· 203 203 */ 204 204 { "qi,lb60", "rb-gpios", true }, 205 205 #endif 206 + #if IS_ENABLED(CONFIG_IEEE802154_CA8210) 207 + /* 208 + * According to the datasheet, the NRST pin 27 is an active-low 209 + * signal. However, the device tree schema and admittedly 210 + * the out-of-tree implementations have been used for a long 211 + * time incorrectly by describing reset GPIO as active-high. 212 + */ 213 + { "cascoda,ca8210", "reset-gpio", false }, 214 + #endif 206 215 #if IS_ENABLED(CONFIG_PCI_LANTIQ) 207 216 /* 208 217 * According to the PCI specification, the RST# pin is an
+31 -47
drivers/net/ieee802154/ca8210.c
··· 52 52 #include <linux/debugfs.h> 53 53 #include <linux/delay.h> 54 54 #include <linux/gpio/consumer.h> 55 - #include <linux/gpio.h> 56 55 #include <linux/ieee802154.h> 57 56 #include <linux/io.h> 58 57 #include <linux/kfifo.h> 59 58 #include <linux/of.h> 60 - #include <linux/of_gpio.h> 61 59 #include <linux/module.h> 62 60 #include <linux/mutex.h> 63 61 #include <linux/poll.h> ··· 348 350 * @extclockenable: true if the external clock is to be enabled 349 351 * @extclockfreq: frequency of the external clock 350 352 * @extclockgpio: ca8210 output gpio of the external clock 351 - * @gpio_reset: gpio number of ca8210 reset line 352 - * @gpio_irq: gpio number of ca8210 interrupt line 353 + * @reset_gpio: ca8210 reset GPIO descriptor 354 + * @irq_gpio: ca8210 interrupt GPIO descriptor 353 355 * @irq_id: identifier for the ca8210 irq 354 356 * 355 357 */ ··· 357 359 bool extclockenable; 358 360 unsigned int extclockfreq; 359 361 unsigned int extclockgpio; 360 - int gpio_reset; 361 - int gpio_irq; 362 + struct gpio_desc *reset_gpio; 363 + struct gpio_desc *irq_gpio; 362 364 int irq_id; 363 365 }; 364 366 ··· 625 627 */ 626 628 static void ca8210_reset_send(struct spi_device *spi, unsigned int ms) 627 629 { 628 - struct ca8210_platform_data *pdata = spi->dev.platform_data; 630 + struct device *dev = &spi->dev; 631 + struct ca8210_platform_data *pdata = dev_get_platdata(dev); 629 632 struct ca8210_priv *priv = spi_get_drvdata(spi); 630 633 long status; 631 634 632 - gpio_set_value(pdata->gpio_reset, 0); 635 + gpiod_set_value(pdata->reset_gpio, 1); 633 636 reinit_completion(&priv->ca8210_is_awake); 634 637 msleep(ms); 635 - gpio_set_value(pdata->gpio_reset, 1); 638 + gpiod_set_value(pdata->reset_gpio, 0); 636 639 priv->promiscuous = false; 637 640 638 641 /* Wait until wakeup indication seen */ ··· 1445 1446 command.pdata.data_req.src_addr_mode = src_addr_mode; 1446 1447 command.pdata.data_req.dst.mode = dst_address_mode; 1447 1448 if (dst_address_mode != MAC_MODE_NO_ADDR) { 1448 - command.pdata.data_req.dst.pan_id[0] = LS_BYTE(dst_pan_id); 1449 - command.pdata.data_req.dst.pan_id[1] = MS_BYTE(dst_pan_id); 1449 + put_unaligned_le16(dst_pan_id, command.pdata.data_req.dst.pan_id); 1450 1450 if (dst_address_mode == MAC_MODE_SHORT_ADDR) { 1451 1451 command.pdata.data_req.dst.address[0] = LS_BYTE( 1452 1452 dst_addr->short_address ··· 1793 1795 } 1794 1796 hdr.source.mode = data_ind[0]; 1795 1797 dev_dbg(&priv->spi->dev, "srcAddrMode: %#03x\n", hdr.source.mode); 1796 - hdr.source.pan_id = *(u16 *)&data_ind[1]; 1798 + hdr.source.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[1])); 1797 1799 dev_dbg(&priv->spi->dev, "srcPanId: %#06x\n", hdr.source.pan_id); 1798 1800 memcpy(&hdr.source.extended_addr, &data_ind[3], 8); 1799 1801 hdr.dest.mode = data_ind[11]; 1800 1802 dev_dbg(&priv->spi->dev, "dstAddrMode: %#03x\n", hdr.dest.mode); 1801 - hdr.dest.pan_id = *(u16 *)&data_ind[12]; 1803 + hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12])); 1802 1804 dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id); 1803 1805 memcpy(&hdr.dest.extended_addr, &data_ind[14], 8); 1804 1806 ··· 1925 1927 status = mcps_data_request( 1926 1928 header.source.mode, 1927 1929 header.dest.mode, 1928 - header.dest.pan_id, 1930 + le16_to_cpu(header.dest.pan_id), 1929 1931 (union macaddr *)&header.dest.extended_addr, 1930 1932 skb->len - mac_len, 1931 1933 &skb->data[mac_len], ··· 2735 2737 */ 2736 2738 static int ca8210_register_ext_clock(struct spi_device *spi) 2737 2739 { 2740 + struct device *dev = &spi->dev; 2741 + struct ca8210_platform_data *pdata = dev_get_platdata(dev); 2738 2742 struct device_node *np = spi->dev.of_node; 2739 2743 struct ca8210_priv *priv = spi_get_drvdata(spi); 2740 - struct ca8210_platform_data *pdata = spi->dev.platform_data; 2741 2744 2742 2745 if (!np) 2743 2746 return -EFAULT; ··· 2784 2785 */ 2785 2786 static int ca8210_reset_init(struct spi_device *spi) 2786 2787 { 2787 - int ret; 2788 - struct ca8210_platform_data *pdata = spi->dev.platform_data; 2788 + struct device *dev = &spi->dev; 2789 + struct ca8210_platform_data *pdata = dev_get_platdata(dev); 2789 2790 2790 - pdata->gpio_reset = of_get_named_gpio( 2791 - spi->dev.of_node, 2792 - "reset-gpio", 2793 - 0 2794 - ); 2795 - 2796 - ret = gpio_direction_output(pdata->gpio_reset, 1); 2797 - if (ret < 0) { 2798 - dev_crit( 2799 - &spi->dev, 2800 - "Reset GPIO %d did not set to output mode\n", 2801 - pdata->gpio_reset 2802 - ); 2791 + pdata->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); 2792 + if (IS_ERR(pdata->reset_gpio)) { 2793 + dev_crit(dev, "Reset GPIO did not set to output mode\n"); 2794 + return PTR_ERR(pdata->reset_gpio); 2803 2795 } 2804 2796 2805 - return ret; 2797 + return 0; 2806 2798 } 2807 2799 2808 2800 /** ··· 2804 2814 */ 2805 2815 static int ca8210_interrupt_init(struct spi_device *spi) 2806 2816 { 2817 + struct device *dev = &spi->dev; 2818 + struct ca8210_platform_data *pdata = dev_get_platdata(dev); 2807 2819 int ret; 2808 - struct ca8210_platform_data *pdata = spi->dev.platform_data; 2809 2820 2810 - pdata->gpio_irq = of_get_named_gpio( 2811 - spi->dev.of_node, 2812 - "irq-gpio", 2813 - 0 2814 - ); 2821 + pdata->irq_gpio = devm_gpiod_get(dev, "irq", GPIOD_IN); 2822 + if (IS_ERR(pdata->irq_gpio)) { 2823 + dev_crit(dev, "Could not retrieve IRQ GPIO\n"); 2824 + return PTR_ERR(pdata->irq_gpio); 2825 + } 2815 2826 2816 - pdata->irq_id = gpio_to_irq(pdata->gpio_irq); 2827 + pdata->irq_id = gpiod_to_irq(pdata->irq_gpio); 2817 2828 if (pdata->irq_id < 0) { 2818 - dev_crit( 2819 - &spi->dev, 2820 - "Could not get irq for gpio pin %d\n", 2821 - pdata->gpio_irq 2822 - ); 2823 - gpio_free(pdata->gpio_irq); 2829 + dev_crit(dev, "Could not get irq for IRQ GPIO\n"); 2824 2830 return pdata->irq_id; 2825 2831 } 2826 2832 ··· 2827 2841 "ca8210-irq", 2828 2842 spi_get_drvdata(spi) 2829 2843 ); 2830 - if (ret) { 2844 + if (ret) 2831 2845 dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id); 2832 - gpio_free(pdata->gpio_irq); 2833 - } 2834 2846 2835 2847 return ret; 2836 2848 }