diff --git a/driver/counter.c b/driver/counter.c index 25f7fda..4ed5d3e 100644 --- a/driver/counter.c +++ b/driver/counter.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include /* Meta Information */ MODULE_LICENSE("GPL"); @@ -20,7 +20,7 @@ static struct of_device_id leds_driver_ids[] = { .compatible = "hottis,leds", }, { /* sentinel */ } }; -// MODULE_DEVICE_TABLE(of, my_driver_ids); +// MODULE_DEVICE_TABLE(of, leds_driver_ids); static struct platform_driver leds_driver = { .probe = dt_leds_probe, @@ -31,6 +31,36 @@ static struct platform_driver leds_driver = { }, }; +/* +static int dt_ls7366r_probe(struct spi_device *client); +static void dt_ls7366r_remove(struct spi_device *client); + +static struct of_device_id ls7366r_driver_ids[] = { + { + .compatible = "hottis,ls7366r0", + }, {} +}; +MODULE_DEVICE_TABLE(of, ls7366r_driver_ids); + +static struct spi_device_id ls7366r[] = { + { "ls7366r0", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(spi, ls7366r); + +static struct spi_driver ls7366r_driver = { + .probe = dt_ls7366r_probe, + .remove = dt_ls7366r_remove, + .id_table = ls7366r, + .driver = { + .name = "ls7366r0", + .of_match_table = ls7366r_driver_ids, + }, +}; +*/ + + + /* GPIO variable */ static struct gpio_desc *red_led = NULL; static struct gpio_desc *blue_led = NULL; @@ -42,7 +72,7 @@ static struct gpio_desc *blue_led = NULL; static int dt_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - printk("counter - probing\n"); + printk("counter - led probing\n"); if(!device_property_present(dev, "red-led-gpio")) { printk("counter - Error! Device property 'red-led-gpio' not found!\n"); @@ -73,21 +103,52 @@ static int dt_leds_probe(struct platform_device *pdev) { * @brief This function is called on unloading the driver */ static void dt_leds_remove(struct platform_device *pdev) { - printk("counter - removing\n"); + printk("counter - led removing\n"); gpiod_put(red_led); gpiod_put(blue_led); } + + + +/* +static int dt_ls7366r_probe(struct spi_device *client) { + printk("counter - ls7366r probing\n"); + + int ret = spi_setup(client); + if (ret < 0) { + printk("counter - Error! Failed to set up the SPI bus\n"); + return ret; + } + + return 0; +} + + +static void dt_ls7366r_remove(struct spi_device *client) { + printk("counter - ls7366r removing\n"); +} +*/ + + /** * @brief This function is called, when the module is loaded into the kernel */ static int __init my_init(void) { printk("counter - Loading the drivers...\n"); - if(platform_driver_register(&leds_driver)) { - printk("dt_gpio - Error! Could not load leds driver\n"); + + if (platform_driver_register(&leds_driver)) { + printk("counter - Error! Could not load leds driver\n"); return -1; } + /* + if (spi_register_driver(&ls7366r_driver)) { + printk("counter - Error! Could not load spi driver\n"); + return -1; + } + */ + printk("counter - red led on\n"); gpiod_set_value(red_led, 1); @@ -104,6 +165,9 @@ static void __exit my_exit(void) { gpiod_set_value(red_led, 0); platform_driver_unregister(&leds_driver); + /* + spi_unregister_driver(&ls7366r_driver); + */ } module_init(my_init); diff --git a/driver/counter.dts b/driver/counter.dts index 595ac4f..43c1922 100644 --- a/driver/counter.dts +++ b/driver/counter.dts @@ -14,6 +14,7 @@ }; }; + /* fragment@1 { target = <&spidev0>; __overlay__ { @@ -37,5 +38,6 @@ }; }; }; + */ };