diff --git a/arch/arm/configs/amlogic_gki.fragment b/arch/arm/configs/amlogic_gki.fragment index c12c75bf6..05f4bda5a 100644 --- a/arch/arm/configs/amlogic_gki.fragment +++ b/arch/arm/configs/amlogic_gki.fragment @@ -204,17 +204,11 @@ CONFIG_AMLOGIC_GKI_TOOL=m # amlogic-pwm.ko CONFIG_AMLOGIC_PWM_MESON=m -# support led -CONFIG_AMLOGIC_LED=y - -# leds-tlc59116.ko -CONFIG_AMLOGIC_LEDS_TLC59116=m - -# leds_state.ko -CONFIG_AMLOGIC_LEDS_STATE=m - -# leds-aw9523b.ko -CONFIG_AMLOGIC_LEDS_AW9523B=m +# amlogic-led.ko +CONFIG_AMLOGIC_LED=m +CONFIG_AMLOGIC_LEDS_TLC59116=y +CONFIG_AMLOGIC_LEDS_STATE=y +CONFIG_AMLOGIC_LEDS_AW9523B=y # pwm-regulator.ko CONFIG_REGULATOR_PWM=m diff --git a/arch/arm64/configs/amlogic_gki.fragment b/arch/arm64/configs/amlogic_gki.fragment index 021716158..79c4d44e8 100644 --- a/arch/arm64/configs/amlogic_gki.fragment +++ b/arch/arm64/configs/amlogic_gki.fragment @@ -205,17 +205,11 @@ CONFIG_AMLOGIC_GKI_TOOL=m # amlogic-pwm.ko CONFIG_AMLOGIC_PWM_MESON=m -# support led -CONFIG_AMLOGIC_LED=y - -# leds-tlc59116.ko -CONFIG_AMLOGIC_LEDS_TLC59116=m - -# leds_state.ko -CONFIG_AMLOGIC_LEDS_STATE=m - -# leds-aw9523b.ko -CONFIG_AMLOGIC_LEDS_AW9523B=m +# amlogic-led.ko +CONFIG_AMLOGIC_LED=m +CONFIG_AMLOGIC_LEDS_TLC59116=y +CONFIG_AMLOGIC_LEDS_STATE=y +CONFIG_AMLOGIC_LEDS_AW9523B=y # pwm-regulator.ko CONFIG_REGULATOR_PWM=m diff --git a/drivers/led/Kconfig b/drivers/led/Kconfig index d3823bbf8..c17905511 100644 --- a/drivers/led/Kconfig +++ b/drivers/led/Kconfig @@ -1,22 +1,24 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) # # LED drivers configuration # -menuconfig AMLOGIC_LED - bool "Amlogic LED Support" +config AMLOGIC_LED + tristate "Amlogic LED Support" default n help - Say Y here to get to see options for led drivers. + amlogic led support + select y for built-in + select m for ko + select n for disable This option alone does not add any kernel code. - If you say N, all options in this submenu will be skipped and disabled. - if AMLOGIC_LED config AMLOGIC_LEDS_TLC59116 - tristate "LED Support for the TLC59116" + bool "LED Support for the TLC59116" depends on LEDS_CLASS default n help @@ -24,7 +26,7 @@ config AMLOGIC_LEDS_TLC59116 TLC59116. config AMLOGIC_LEDS_AW9523B - tristate "LED Support for the AW9523B" + bool "LED Support for the AW9523B" depends on LEDS_CLASS default n help @@ -32,11 +34,11 @@ config AMLOGIC_LEDS_AW9523B AW9523B. config AMLOGIC_LEDS_STATE - tristate "LED state support" + bool "LED state support" depends on LEDS_CLASS default n help Choose this option if you want to use the LED state - and led function + and led function endif diff --git a/drivers/led/Makefile b/drivers/led/Makefile index 72c294411..122c23153 100644 --- a/drivers/led/Makefile +++ b/drivers/led/Makefile @@ -1,22 +1,13 @@ # SPDX-License-Identifier: (GPL-2.0+ OR MIT) -TLC_MODULE_NAME = amlogic-led-tlc59116 -obj-$(CONFIG_AMLOGIC_LEDS_TLC59116) += $(TLC_MODULE_NAME).o -$(TLC_MODULE_NAME)-y += leds-tlc59116.o -PR_FMT_TLC = $(subst amlogic-,,$(TLC_MODULE_NAME)) -PR_FMT_DEFINE_TLC="-Dpr_fmt(fmt)= \"[$(PR_FMT_TLC)]: \" fmt" -CFLAGS_leds-tlc59116.o += $(PR_FMT_DEFINE_TLC) +MODULE_NAME = amlogic-led -AW_MODULE_NAME = amlogic-led-aw9523b -obj-$(CONFIG_AMLOGIC_LEDS_AW9523B) += $(AW_MODULE_NAME).o -$(AW_MODULE_NAME)-y += leds-aw9523b.o -PR_FMT_AW = $(subst amlogic-,,$(AW_MODULE_NAME)) -PR_FMT_DEFINE_AW="-Dpr_fmt(fmt)= \"[$(PR_FMT_AW)]: \" fmt" -CFLAGS_leds-aw9523b.o += $(PR_FMT_DEFINE_AW) +PR_FMT = $(subst amlogic-,,$(MODULE_NAME)) +PR_FMT_DEFINE="-Dpr_fmt(fmt)= \"[$(PR_FMT)]: \" fmt" +ccflags-y += $(PR_FMT_DEFINE) -STATE_MODULE_NAME = amlogic-led-state -obj-$(CONFIG_AMLOGIC_LEDS_STATE) += $(STATE_MODULE_NAME).o -$(STATE_MODULE_NAME)-y += leds_state.o -PR_FMT_STATE = $(subst amlogic-,,$(STATE_MODULE_NAME)) -PR_FMT_DEFINE_STATE="-Dpr_fmt(fmt)= \"[$(PR_FMT_STATE)]: \" fmt" -CFLAGS_leds_state.o += $(PR_FMT_DEFINE_STATE) +obj-$(CONFIG_AMLOGIC_LED) = $(MODULE_NAME).o +$(MODULE_NAME)-y = main.o +$(MODULE_NAME)-$(CONFIG_AMLOGIC_LEDS_TLC59116) += leds-tlc59116.o +$(MODULE_NAME)-$(CONFIG_AMLOGIC_LEDS_AW9523B) += leds-aw9523b.o +$(MODULE_NAME)-$(CONFIG_AMLOGIC_LEDS_STATE) += leds_state.o \ No newline at end of file diff --git a/drivers/led/leds-aw9523b.c b/drivers/led/leds-aw9523b.c index 0ca697ae1..f5b32fd7e 100644 --- a/drivers/led/leds-aw9523b.c +++ b/drivers/led/leds-aw9523b.c @@ -991,8 +991,12 @@ static struct i2c_driver meson_aw9523_driver = { .id_table = aw9523_i2c_id, }; -module_i2c_driver(meson_aw9523_driver); +int __init led_aw9523_init(void) +{ + return i2c_add_driver(&meson_aw9523_driver); +} -MODULE_AUTHOR("Tiger Hu "); -MODULE_DESCRIPTION("AW9523 LED Driver"); -MODULE_LICENSE("GPL v2"); +void __exit led_aw9523_exit(void) +{ + return i2c_del_driver(&meson_aw9523_driver); +} diff --git a/drivers/led/leds-tlc59116.c b/drivers/led/leds-tlc59116.c index 2be6a2d4e..6000ffaa9 100644 --- a/drivers/led/leds-tlc59116.c +++ b/drivers/led/leds-tlc59116.c @@ -771,7 +771,12 @@ static struct i2c_driver meson_tlc59116_driver = { .id_table = meson_tlc59116_i2c_id, }; -module_i2c_driver(meson_tlc59116_driver); -MODULE_AUTHOR("Bichao Zheng "); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("TLC59116 LED Driver"); +int __init led_tlc59116_init(void) +{ + return i2c_add_driver(&meson_tlc59116_driver); +} + +void __exit led_tlc59116_exit(void) +{ + return i2c_del_driver(&meson_tlc59116_driver); +} diff --git a/drivers/led/leds_state.c b/drivers/led/leds_state.c index a33ca369a..6120c856d 100644 --- a/drivers/led/leds_state.c +++ b/drivers/led/leds_state.c @@ -385,8 +385,12 @@ static struct platform_driver led_state_driver = { }, }; -module_platform_driver(led_state_driver); +int __init led_state_init(void) +{ + return platform_driver_register(&led_state_driver); +} -MODULE_AUTHOR("Bichao Zheng "); -MODULE_DESCRIPTION("LED STATE driver for amlogic"); -MODULE_LICENSE("GPL"); +void __exit led_state_exit(void) +{ + platform_driver_unregister(&led_state_driver); +} diff --git a/drivers/led/main.c b/drivers/led/main.c new file mode 100644 index 000000000..715a6e38a --- /dev/null +++ b/drivers/led/main.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. + */ + +//#define DEBUG +#include +#include +#include "main.h" + +static int __init led_main_init(void) +{ + pr_debug("### %s() start\n", __func__); + call_sub_init(led_tlc59116_init); + call_sub_init(led_aw9523_init); + call_sub_init(led_state_init); + pr_debug("### %s() end\n", __func__); + return 0; +} + +static void __exit led_main_exit(void) +{ + led_state_exit(); + led_aw9523_init(); + led_tlc59116_init(); +} + +module_init(led_main_init); +module_exit(led_main_exit); + +MODULE_LICENSE("GPL v2"); diff --git a/drivers/led/main.h b/drivers/led/main.h new file mode 100644 index 000000000..21ff73d4e --- /dev/null +++ b/drivers/led/main.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ +/* + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. + */ + +#ifndef __LED_MAIN_H_ +#define __LED_MAIN_H_ + +#if IS_ENABLED(CONFIG_AMLOGIC_LEDS_STATE) +int led_state_init(void); +void led_state_exit(void); +#else +static inline void led_state_init(void) +{ + return 0; +} + +static inline int led_state_exit(void) +{ +} +#endif + +#if IS_ENABLED(CONFIG_AMLOGIC_LEDS_AW9523B) +int led_aw9523_init(void); +void led_aw9523_exit(void); +#else +static inline int led_aw9523_init(void) +{ + return 0; +} + +static inline void led_aw9523_exit(void) +{ +} +#endif + +#if IS_ENABLED(CONFIG_AMLOGIC_LEDS_TLC59116) +int led_tlc59116_init(void); +void led_tlc59116_exit(void); +#else +static inline int led_tlc59116_init(void) +{ + return 0; +} + +static inline void led_tlc59116_exit(void) +{ +} +#endif + +#endif /*__LED_MAIN_H_*/