1717
1818#include "simatic-ipc-leds-gpio.h"
1919
20- static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
20+ struct simatic_ipc_led_tables {
21+ struct gpiod_lookup_table * led_lookup_table ;
22+ struct gpiod_lookup_table * led_lookup_table_extra ;
23+ };
24+
25+ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_227g = {
2126 .dev_id = "leds-gpio" ,
2227 .table = {
2328 GPIO_LOOKUP_IDX ("gpio-f7188x-2" , 0 , NULL , 0 , GPIO_ACTIVE_LOW ),
@@ -30,7 +35,7 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
3035 },
3136};
3237
33- static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = {
38+ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra_227g = {
3439 .dev_id = NULL , /* Filled during initialization */
3540 .table = {
3641 GPIO_LOOKUP_IDX ("gpio-f7188x-3" , 6 , NULL , 6 , GPIO_ACTIVE_HIGH ),
@@ -39,16 +44,51 @@ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_extra = {
3944 },
4045};
4146
47+ static struct gpiod_lookup_table simatic_ipc_led_gpio_table_bx_59a = {
48+ .dev_id = "leds-gpio" ,
49+ .table = {
50+ GPIO_LOOKUP_IDX ("gpio-f7188x-2" , 0 , NULL , 0 , GPIO_ACTIVE_LOW ),
51+ GPIO_LOOKUP_IDX ("gpio-f7188x-2" , 3 , NULL , 1 , GPIO_ACTIVE_LOW ),
52+ GPIO_LOOKUP_IDX ("gpio-f7188x-5" , 3 , NULL , 2 , GPIO_ACTIVE_LOW ),
53+ GPIO_LOOKUP_IDX ("gpio-f7188x-5" , 2 , NULL , 3 , GPIO_ACTIVE_LOW ),
54+ GPIO_LOOKUP_IDX ("gpio-f7188x-7" , 7 , NULL , 4 , GPIO_ACTIVE_LOW ),
55+ GPIO_LOOKUP_IDX ("gpio-f7188x-7" , 4 , NULL , 5 , GPIO_ACTIVE_LOW ),
56+ {} /* Terminating entry */
57+ }
58+ };
59+
4260static int simatic_ipc_leds_gpio_f7188x_probe (struct platform_device * pdev )
4361{
44- return simatic_ipc_leds_gpio_probe (pdev , & simatic_ipc_led_gpio_table ,
45- & simatic_ipc_led_gpio_table_extra );
62+ const struct simatic_ipc_platform * plat = dev_get_platdata (& pdev -> dev );
63+ struct simatic_ipc_led_tables * led_tables ;
64+
65+ led_tables = devm_kzalloc (& pdev -> dev , sizeof (* led_tables ), GFP_KERNEL );
66+ if (!led_tables )
67+ return - ENOMEM ;
68+
69+ switch (plat -> devmode ) {
70+ case SIMATIC_IPC_DEVICE_227G :
71+ led_tables -> led_lookup_table = & simatic_ipc_led_gpio_table_227g ;
72+ led_tables -> led_lookup_table_extra = & simatic_ipc_led_gpio_table_extra_227g ;
73+ break ;
74+ case SIMATIC_IPC_DEVICE_BX_59A :
75+ led_tables -> led_lookup_table = & simatic_ipc_led_gpio_table_bx_59a ;
76+ break ;
77+ default :
78+ return - ENODEV ;
79+ }
80+
81+ platform_set_drvdata (pdev , led_tables );
82+ return simatic_ipc_leds_gpio_probe (pdev , led_tables -> led_lookup_table ,
83+ led_tables -> led_lookup_table_extra );
4684}
4785
4886static void simatic_ipc_leds_gpio_f7188x_remove (struct platform_device * pdev )
4987{
50- simatic_ipc_leds_gpio_remove (pdev , & simatic_ipc_led_gpio_table ,
51- & simatic_ipc_led_gpio_table_extra );
88+ struct simatic_ipc_led_tables * led_tables = platform_get_drvdata (pdev );
89+
90+ simatic_ipc_leds_gpio_remove (pdev , led_tables -> led_lookup_table ,
91+ led_tables -> led_lookup_table_extra );
5292}
5393
5494static struct platform_driver simatic_ipc_led_gpio_driver = {
0 commit comments