diff --git a/driver/counter.c b/driver/counter.c index ad2de56..25f7fda 100644 --- a/driver/counter.c +++ b/driver/counter.c @@ -5,29 +5,29 @@ #include #include #include +#include /* Meta Information */ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Wolfgang Hottgenroth"); MODULE_DESCRIPTION("A simple LKM to parse the device tree for a specific device and its properties"); -/* Declate the probe and remove functions */ -static int dt_probe(struct platform_device *pdev); -static void dt_remove(struct platform_device *pdev); +static int dt_leds_probe(struct platform_device *pdev); +static void dt_leds_remove(struct platform_device *pdev); -static struct of_device_id my_driver_ids[] = { +static struct of_device_id leds_driver_ids[] = { { - .compatible = "hottis,counter", + .compatible = "hottis,leds", }, { /* sentinel */ } }; // MODULE_DEVICE_TABLE(of, my_driver_ids); -static struct platform_driver my_driver = { - .probe = dt_probe, - .remove = dt_remove, +static struct platform_driver leds_driver = { + .probe = dt_leds_probe, + .remove = dt_leds_remove, .driver = { - .name = "my_device_driver", - .of_match_table = my_driver_ids, + .name = "leds_device_driver", + .of_match_table = leds_driver_ids, }, }; @@ -39,7 +39,7 @@ static struct gpio_desc *blue_led = NULL; /** * @brief This function is called on loading the driver */ -static int dt_probe(struct platform_device *pdev) { +static int dt_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; printk("counter - probing\n"); @@ -72,7 +72,7 @@ static int dt_probe(struct platform_device *pdev) { /** * @brief This function is called on unloading the driver */ -static void dt_remove(struct platform_device *pdev) { +static void dt_leds_remove(struct platform_device *pdev) { printk("counter - removing\n"); gpiod_put(red_led); gpiod_put(blue_led); @@ -82,9 +82,9 @@ static void dt_remove(struct platform_device *pdev) { * @brief This function is called, when the module is loaded into the kernel */ static int __init my_init(void) { - printk("counter - Loading the driver...\n"); - if(platform_driver_register(&my_driver)) { - printk("dt_gpio - Error! Could not load driver\n"); + printk("counter - Loading the drivers...\n"); + if(platform_driver_register(&leds_driver)) { + printk("dt_gpio - Error! Could not load leds driver\n"); return -1; } @@ -98,12 +98,12 @@ static int __init my_init(void) { * @brief This function is called, when the module is removed from the kernel */ static void __exit my_exit(void) { - printk("counter - Unload driver"); + printk("counter - Unload drivers"); printk("counter - red led off\n"); gpiod_set_value(red_led, 0); - platform_driver_unregister(&my_driver); + platform_driver_unregister(&leds_driver); } module_init(my_init); diff --git a/driver/counter.dts b/driver/counter.dts index 442f794..595ac4f 100644 --- a/driver/counter.dts +++ b/driver/counter.dts @@ -6,11 +6,36 @@ target-path = "/"; __overlay__ { status = "okay"; - counter { - compatible = "hottis,counter"; + leds { + compatible = "hottis,leds"; red-led-gpio = <&gpio 26 0>; blue-led-gpio = <&gpio 21 0>; }; }; }; + + fragment@1 { + target = <&spidev0>; + __overlay__ { + status = "disabled"; + }; + }; + + fragment@2 { + target = <&spi0>; + __overlay__ { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + ls7366r: ls7366r0@0 { + compatible = "hottis,counter"; + reg = <0x0>; + spi-max-frequency = <1000000>; + spi-bits-per-word = <8>; + status = "okay"; + }; + }; + }; + };