Last active
August 4, 2016 19:45
-
-
Save dhilst/b54054b345afc4239e92f8adde99788e to your computer and use it in GitHub Desktop.
mcp2210.ko: device tree settting up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ { | |
mcp2210: mcp2210 { | |
compatible = "microchip,mcp2210"; | |
#address-cells = <1>; | |
#size-cells = <0>; | |
cs-gpios = <0>; | |
gpio-controller; | |
powerup_chip_settings { | |
pin_mode = [01 00 00 00 00 00 00 00 00]; | |
gpio_value = /bits/ 16 <0x0000>; | |
gpio_direction = /bits/ 16 <0x0040>; /* 0x0040 = 0000 0100 0000 */ | |
other_settings = /bits/ 8 <0x01>; | |
nvram_access_control = /bits/ 8 <0>; | |
password = [00 00 00 00 00 00 00 00]; | |
}; | |
chip_settings { | |
pin_mode = [01 00 00 00 00 00 00 00 00]; | |
gpio_value = /bits/ 16 <0x0000>; | |
gpio_direction = /bits/ 16 <0x0040>; /* 0x0040 = 0000 0100 0000 */ | |
other_settings = /bits/ 8 <0x01>; | |
nvram_access_control = /bits/ 8 <0>; | |
password = [00 00 00 00 00 00 00 00]; | |
}; | |
powerup_spi_settings { | |
/* Powerup spi settings */ | |
bitrate = <12000000>; | |
idle_cs = /bits/ 16 <0x01ff>; | |
active_cs = /bits/ 16 <0x0000>; | |
cs_to_data_delay = /bits/ 16 <10>; | |
last_byte_to_cs_delay = /bits/ 16 <10>; | |
delay_between_bytes = /bits/ 16 <10>; | |
bytes_per_trans = /bits/ 16 <5>; | |
mode = /bits/ 8 <3>; | |
}; | |
spi_settings { | |
/* Powerup spi settings */ | |
bitrate = <12000000>; | |
idle_cs = /bits/ 16 <0x01ff>; | |
active_cs = /bits/ 16 <0x0000>; | |
cs_to_data_delay = /bits/ 16 <10>; | |
last_byte_to_cs_delay = /bits/ 16 <10>; | |
delay_between_bytes = /bits/ 16 <10>; | |
bytes_per_trans = /bits/ 16 <32>; | |
mode = /bits/ 8 <3>; | |
}; | |
usb_settings { | |
/* usb key parameters */ | |
vid = /bits/ 16 <0x04d8>; /* Microchip */ | |
pid = /bits/ 16 <0x00de>; /* USB device ID */ | |
chip_power_option = /bits/ 8 <0x80>; | |
requested_power = /bits/ 8 <0x32>; /* 100mA */ | |
}; | |
pin_configuration { | |
/* board specific configurations */ | |
poll_gpio_usecs = <0>; | |
stale_gpio_usecs = <0>; | |
poll_intr_usecs = <0>; | |
stale_intr_usecs = <0>; | |
3wire_capable = /bits/ 8 <0>; | |
3wire_tx_enable_active_high = /bits/ 8 <0>; | |
3wire_tx_enable_pin = /bits/ 8 <0>; | |
strings_size = <0>; | |
pin@0 { | |
pin = /bits/ 8 <0>; | |
mode = /bits/ 8 <1>; | |
pin_name = "HI-3200"; | |
modalias = "nrf24"; | |
spi_prop { | |
spi,max_speed_hz = <8000000>; | |
spi,min_speed_hz = <8000000>; | |
spi,mode = /bits/ 8 <3>; | |
spi,bits_per_word = /bits/ 8 <8>; | |
spi,cs_to_data_delay = /bits/ 16 <10>; | |
spi,last_byte_to_cs_delay = /bits/ 16 <10>; | |
spi,delay_between_bytes = /bits/ 16 <10>; | |
spi,delay_between_xfers = /bits/ 16 <10>; | |
}; | |
}; | |
pin@1 { | |
pin = /bits/ 8 <1>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@2 { | |
pin = /bits/ 8 <2>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@3 { | |
pin = /bits/ 8 <3>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@4 { | |
pin = /bits/ 8 <4>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@5 { | |
pin = /bits/ 8 <5>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@6 { | |
pin = /bits/ 8 <6>; | |
mode = /bits/ 8 <0>; | |
has_irq = /bits/ 8 <0>; | |
irq = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@7 { | |
pin = /bits/ 8 <7>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
pin@8 { | |
pin = /bits/ 8 <8>; | |
mode = /bits/ 8 <0>; | |
pin_name ="gpio%d"; | |
}; | |
}; | |
}; | |
}; | |
&mcp2210 { | |
nrf24@0 { | |
compatible = "nrf24"; | |
#address-cells = <1>; | |
#size-cells = <0>; | |
reg = <0>; | |
spi-max-frequency = <8000000>; | |
gpio-irq = <&mcp2210 2 0>; | |
gpio-ce = <&mcp2210 1 0>; | |
gpio-led = <&mcp2210 3 0>; | |
}; | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj-m := nrf24.o | |
all: | |
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) | |
clean: | |
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/kernel.h> | |
#include <linux/module.h> | |
#include <linux/spi/spi.h> | |
static int rf_probe(struct spi_device *spi) | |
{ | |
struct device_node *np = spi->dev.of_node; | |
BUG_ON(!spi); | |
if (!np) { | |
dev_err(&spi->dev, "No device tree configuration found"); | |
return -ENODEV; | |
} | |
dev_info(&spi->dev, "probed successfully"); | |
return 0; | |
} | |
static int rf_remove(struct spi_device *spi) | |
{ | |
return 0; | |
} | |
static const struct of_device_id rf_of_ids[] = { | |
{ .compatible = "nrf24" }, | |
{}, | |
}; | |
static struct spi_driver rf_driver = { | |
.driver = { | |
.name = "nrf24", | |
.owner = THIS_MODULE, | |
.of_match_table = rf_of_ids, | |
}, | |
.probe = rf_probe, | |
.remove = rf_remove, | |
}; | |
module_spi_driver(rf_driver); | |
MODULE_LICENSE("GPL"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment