// SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2019 Crane Merchandising Systems. All rights reserved. // Copyright (C) 2019 Oleh Kravchenko <[email protected]> #include <linux/delay.h> #include <linux/leds.h> #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/property.h> #include <linux/spi/spi.h> /* * EL15203000 SPI protocol description: * +-----+---------+ * | LED | COMMAND | * +-----+---------+ * | 1 | 1 | * +-----+---------+ * (*) LEDs MCU board expects 20 msec delay per byte. * * LEDs: * +----------+--------------+-------------------------------------------+ * | ID | NAME | DESCRIPTION | * +----------+--------------+-------------------------------------------+ * | 'P' 0x50 | Pipe | Consists from 5 LEDs, controlled by board | * +----------+--------------+-------------------------------------------+ * | 'S' 0x53 | Screen frame | Light tube around the screen | * +----------+--------------+-------------------------------------------+ * | 'V' 0x56 | Vending area | Highlights a cup of coffee | * +----------+--------------+-------------------------------------------+ * * COMMAND: * +----------+-----------------+--------------+--------------+ * | VALUES | PIPE | SCREEN FRAME | VENDING AREA | * +----------+-----------------+--------------+--------------+ * | '0' 0x30 | Off | * +----------+-----------------------------------------------+ * | '1' 0x31 | On | * +----------+-----------------+--------------+--------------+ * | '2' 0x32 | Cascade | Breathing | * +----------+-----------------+--------------+ * | '3' 0x33 | Inverse cascade | * +----------+-----------------+ * | '4' 0x34 | Bounce | * +----------+-----------------+ * | '5' 0x35 | Inverse bounce | * +----------+-----------------+ */ /* EL15203000 default settings */ #define EL_FW_DELAY_USEC … #define EL_PATTERN_DELAY_MSEC … #define EL_PATTERN_LEN … #define EL_PATTERN_HALF_LEN … enum el15203000_command { … }; struct el15203000_led { … }; struct el15203000 { … }; #define to_el15203000_led(d) … static int el15203000_cmd(struct el15203000_led *led, u8 brightness) { … } static int el15203000_set_blocking(struct led_classdev *ldev, enum led_brightness brightness) { … } static int el15203000_pattern_set_S(struct led_classdev *ldev, struct led_pattern *pattern, u32 len, int repeat) { … } static bool is_cascade(const struct led_pattern *pattern, u32 len, bool inv, bool right) { … } static bool is_bounce(const struct led_pattern *pattern, u32 len, bool inv) { … } static int el15203000_pattern_set_P(struct led_classdev *ldev, struct led_pattern *pattern, u32 len, int repeat) { … } static int el15203000_pattern_clear(struct led_classdev *ldev) { … } static int el15203000_probe_dt(struct el15203000 *priv) { … } static int el15203000_probe(struct spi_device *spi) { … } static void el15203000_remove(struct spi_device *spi) { … } static const struct of_device_id el15203000_dt_ids[] = …; MODULE_DEVICE_TABLE(of, el15203000_dt_ids); static struct spi_driver el15203000_driver = …; module_spi_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …; MODULE_ALIAS(…) …;