Advertisement
danielhilst

0001-nRF24L01P-board-setup-code-for-raspberry-pi.patch

Aug 8th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.66 KB | None | 0 0
  1. From b948e594ca42d3d8c3d070abeb1744f7e1fbf1fc Mon Sep 17 00:00:00 2001
  2. From: Daniel Hilst SellI <danielhilst@gmail.com>
  3. Date: Fri, 8 Aug 2014 16:12:02 -0300
  4. Subject: [PATCH] nRF24L01P board setup code for raspberry pi
  5.  
  6. ---
  7. arch/arm/mach-bcm2708/bcm2708.c | 41 +++++++++++++++++++++--------------------
  8.  include/linux/spi/nRF24L01P.h   | 11 +++++++++++
  9.  2 files changed, 32 insertions(+), 20 deletions(-)
  10.  create mode 100644 include/linux/spi/nRF24L01P.h
  11.  
  12. diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
  13. index 50f4f0a..8e9db7f 100644
  14. --- a/arch/arm/mach-bcm2708/bcm2708.c
  15. +++ b/arch/arm/mach-bcm2708/bcm2708.c
  16. @@ -33,6 +33,8 @@
  17.  #include <linux/module.h>
  18.  #include <linux/spi/spi.h>
  19.  #include <linux/w1-gpio.h>
  20. +#include <linux/spi/nRF24L01P.h>
  21. +#include <linux/gpio.h>
  22.  
  23.  #include <linux/version.h>
  24.  #include <linux/clkdev.h>
  25. @@ -586,23 +588,24 @@ static struct platform_device bcm2708_spi_device = {
  26.     .resource = bcm2708_spi_resources,
  27.  };
  28.  
  29. -#ifdef CONFIG_BCM2708_SPIDEV
  30. -static struct spi_board_info bcm2708_spi_devices[] = {
  31. -   {
  32. -       .modalias = "spidev",
  33. -       .max_speed_hz = 500000,
  34. -       .bus_num = 0,
  35. -       .chip_select = 0,
  36. -       .mode = SPI_MODE_0,
  37. -   }, {
  38. -       .modalias = "spidev",
  39. -       .max_speed_hz = 500000,
  40. -       .bus_num = 0,
  41. -       .chip_select = 1,
  42. -       .mode = SPI_MODE_0,
  43. -   }
  44. +#define NRF24L01P_IRQ_GPIO 24
  45. +#define NRF24L01P_CE_GPIO  25
  46. +
  47. +static struct nRF24L01P_platform_data rf24_config = {
  48. +        .gpio_ce = NRF24L01P_CE_GPIO,
  49. +        .gpio_irq = NRF24L01P_IRQ_GPIO,
  50. +};
  51. +
  52. +static struct spi_board_info bcm2708_spi_rf24[] __initdata = {
  53. +        {
  54. +                .modalias = "nRF24L01P", /* nRF24L01+ */
  55. +                .max_speed_hz = 8000000,
  56. +                .bus_num = 0,
  57. +                .chip_select = 0,
  58. +                .platform_data = &rf24_config,
  59. +                .mode = SPI_MODE_0,
  60. +        },
  61.  };
  62. -#endif
  63.  
  64.  static struct resource bcm2708_bsc0_resources[] = {
  65.     {
  66. @@ -787,10 +790,8 @@ void __init bcm2708_init(void)
  67.     system_rev = boardrev;
  68.     system_serial_low = serial;
  69.  
  70. -#ifdef CONFIG_BCM2708_SPIDEV
  71. -   spi_register_board_info(bcm2708_spi_devices,
  72. -           ARRAY_SIZE(bcm2708_spi_devices));
  73. -#endif
  74. +   spi_register_board_info(bcm2708_spi_rf24,
  75. +           ARRAY_SIZE(bcm2708_spi_rf24));
  76.  }
  77.  
  78.  #define TIMER_PERIOD DIV_ROUND_CLOSEST(STC_FREQ_HZ, HZ)
  79. diff --git a/include/linux/spi/nRF24L01P.h b/include/linux/spi/nRF24L01P.h
  80. new file mode 100644
  81. index 0000000..3be5a9d
  82. --- /dev/null
  83. +++ b/include/linux/spi/nRF24L01P.h
  84. @@ -0,0 +1,11 @@
  85. +#ifndef __LINUX_SPI_NRF24L01P_H
  86. +#define __LINUX_SPI_NRF24L01P_H
  87. +
  88. +/* linux/spi/nRF24L01P */
  89. +
  90. +struct nRF24L01P_platform_data {
  91. +        unsigned int gpio_irq;
  92. +        unsigned int gpio_ce;            /* Chip Enable */
  93. +};
  94. +
  95. +#endif
  96. --
  97. 2.0.3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement