17
17
18
18
#include "simatic-ipc-leds-gpio.h"
19
19
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 = {
21
26
.dev_id = "leds-gpio" ,
22
27
.table = {
23
28
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 = {
30
35
},
31
36
};
32
37
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 = {
34
39
.dev_id = NULL , /* Filled during initialization */
35
40
.table = {
36
41
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 = {
39
44
},
40
45
};
41
46
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
+
42
60
static int simatic_ipc_leds_gpio_f7188x_probe (struct platform_device * pdev )
43
61
{
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 );
46
84
}
47
85
48
86
static void simatic_ipc_leds_gpio_f7188x_remove (struct platform_device * pdev )
49
87
{
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 );
52
92
}
53
93
54
94
static struct platform_driver simatic_ipc_led_gpio_driver = {
0 commit comments