-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtl8367c_asicdrv_led.c
726 lines (648 loc) · 22.9 KB
/
rtl8367c_asicdrv_led.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
/*
* Copyright (C) 2013 Realtek Semiconductor Corp.
* All Rights Reserved.
*
* This program is the proprietary software of Realtek Semiconductor
* Corporation and/or its licensors, and only be used, duplicated,
* modified or distributed under the authorized license from Realtek.
*
* ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
* THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
*
* $Revision: 76306 $
* $Date: 2017-03-08 15:13:58 +0800 (週三, 08 三月 2017) $
*
* Purpose : RTL8367C switch high-level API for RTL8367C
* Feature : LED related functions
*
*/
#include "rtl8367c_asicdrv_led.h"
/* Function Name:
* rtl8367c_setAsicLedIndicateInfoConfig
* Description:
* Set Leds indicated information mode
* Input:
* ledno - LED group number. There are 1 to 1 led mapping to each port in each led group
* config - Support 16 types configuration
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* The API can set LED indicated information configuration for each LED group with 1 to 1 led mapping to each port.
* Definition LED Statuses Description
* 0000 LED_Off LED pin Tri-State.
* 0001 Dup/Col Collision, Full duplex Indicator. Blinking every 43ms when collision happens. Low for full duplex, and high for half duplex mode.
* 0010 Link/Act Link, Activity Indicator. Low for link established. Link/Act Blinks every 43ms when the corresponding port is transmitting or receiving.
* 0011 Spd1000 1000Mb/s Speed Indicator. Low for 1000Mb/s.
* 0100 Spd100 100Mb/s Speed Indicator. Low for 100Mb/s.
* 0101 Spd10 10Mb/s Speed Indicator. Low for 10Mb/s.
* 0110 Spd1000/Act 1000Mb/s Speed/Activity Indicator. Low for 1000Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
* 0111 Spd100/Act 100Mb/s Speed/Activity Indicator. Low for 100Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
* 1000 Spd10/Act 10Mb/s Speed/Activity Indicator. Low for 10Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
* 1001 Spd100 (10)/Act 10/100Mb/s Speed/Activity Indicator. Low for 10/100Mb/s. Blinks every 43ms when the corresponding port is transmitting or receiving.
* 1010 Fiber Fiber link Indicator. Low for Fiber.
* 1011 Fault Auto-negotiation Fault Indicator. Low for Fault.
* 1100 Link/Rx Link, Activity Indicator. Low for link established. Link/Rx Blinks every 43ms when the corresponding port is transmitting.
* 1101 Link/Tx Link, Activity Indicator. Low for link established. Link/Tx Blinks every 43ms when the corresponding port is receiving.
* 1110 Master Link on Master Indicator. Low for link Master established.
* 1111 LED_Force Force LED output, LED output value reference
*/
ret_t rtl8367c_setAsicLedIndicateInfoConfig(rtk_uint32 ledno, rtk_uint32 config)
{
ret_t retVal;
CONST rtk_uint16 bits[RTL8367C_LEDGROUPNO] = {RTL8367C_LED0_CFG_MASK, RTL8367C_LED1_CFG_MASK, RTL8367C_LED2_CFG_MASK};
if (ledno >= RTL8367C_LEDGROUPNO)
return RT_ERR_OUT_OF_RANGE;
if (config >= LEDCONF_END)
return RT_ERR_OUT_OF_RANGE;
retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_CONFIGURATION, RTL8367C_LED_CONFIG_SEL_OFFSET, 0);
if (retVal != RT_ERR_OK)
return retVal;
return rtl8367c_setAsicRegBits(RTL8367C_REG_LED_CONFIGURATION, bits[ledno], config);
}
/* Function Name:
* rtl8367c_getAsicLedIndicateInfoConfig
* Description:
* Get Leds indicated information mode
* Input:
* ledno - LED group number. There are 1 to 1 led mapping to each port in each led group
* pConfig - Support 16 types configuration
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_getAsicLedIndicateInfoConfig(rtk_uint32 ledno, rtk_uint32 *pConfig)
{
CONST rtk_uint16 bits[RTL8367C_LEDGROUPNO] = {RTL8367C_LED0_CFG_MASK, RTL8367C_LED1_CFG_MASK, RTL8367C_LED2_CFG_MASK};
if (ledno >= RTL8367C_LEDGROUPNO)
return RT_ERR_OUT_OF_RANGE;
/* Get register value */
return rtl8367c_getAsicRegBits(RTL8367C_REG_LED_CONFIGURATION, bits[ledno], pConfig);
}
/* Function Name:
* rtl8367c_setAsicLedGroupMode
* Description:
* Set Led Group mode
* Input:
* mode - LED mode
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_setAsicLedGroupMode(rtk_uint32 mode)
{
ret_t retVal;
/* Invalid input parameter */
if (mode >= RTL8367C_LED_MODE_END)
return RT_ERR_OUT_OF_RANGE;
retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_CONFIGURATION, RTL8367C_LED_CONFIG_SEL_OFFSET, 1);
if (retVal != RT_ERR_OK)
return retVal;
return rtl8367c_setAsicRegBits(RTL8367C_REG_LED_CONFIGURATION, RTL8367C_DATA_LED_MASK, mode);
}
/* Function Name:
* rtl8367c_getAsicLedGroupMode
* Description:
* Get Led Group mode
* Input:
* pMode - LED mode
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* None
*/
ret_t rtl8367c_getAsicLedGroupMode(rtk_uint32 *pMode)
{
ret_t retVal;
rtk_uint32 regData;
retVal = rtl8367c_getAsicRegBit(RTL8367C_REG_LED_CONFIGURATION, RTL8367C_LED_CONFIG_SEL_OFFSET, ®Data);
if (retVal != RT_ERR_OK)
return retVal;
if (regData != 1)
return RT_ERR_FAILED;
return rtl8367c_getAsicRegBits(RTL8367C_REG_LED_CONFIGURATION, RTL8367C_DATA_LED_MASK, pMode);
}
/* Function Name:
* rtl8367c_setAsicForceLeds
* Description:
* Set group LED mode
* Input:
* port - Physical port number (0~7)
* group - LED group number
* mode - LED mode
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_setAsicForceLed(rtk_uint32 port, rtk_uint32 group, rtk_uint32 mode)
{
rtk_uint16 regAddr;
ret_t retVal;
/* Invalid input parameter */
if (port > RTL8367C_PORTIDMAX)
return RT_ERR_PORT_ID;
if (group >= RTL8367C_LEDGROUPNO)
return RT_ERR_OUT_OF_RANGE;
if (mode >= LEDFORCEMODE_END)
return RT_ERR_OUT_OF_RANGE;
/* Set Related Registers */
if (port < 8)
{
regAddr = RTL8367C_LED_FORCE_MODE_BASE + (group << 1);
if ((retVal = rtl8367c_setAsicRegBits(regAddr, 0x3 << (port * 2), mode)) != RT_ERR_OK)
return retVal;
}
else if (port >= 8)
{
regAddr = RTL8367C_REG_CPU_FORCE_LED0_CFG1 + (group << 1);
if ((retVal = rtl8367c_setAsicRegBits(regAddr, 0x3 << ((port - 8) * 2), mode)) != RT_ERR_OK)
return retVal;
}
return RT_ERR_OK;
}
/* Function Name:
* rtl8367c_getAsicForceLed
* Description:
* Get group LED mode
* Input:
* port - Physical port number (0~7)
* group - LED group number
* pMode - LED mode
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_PORT_ID - Invalid port number
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_getAsicForceLed(rtk_uint32 port, rtk_uint32 group, rtk_uint32 *pMode)
{
rtk_uint16 regAddr;
ret_t retVal;
/* Invalid input parameter */
if (port > RTL8367C_PORTIDMAX)
return RT_ERR_PORT_ID;
if (group >= RTL8367C_LEDGROUPNO)
return RT_ERR_INPUT;
/* Get Related Registers */
if (port < 8)
{
regAddr = RTL8367C_LED_FORCE_MODE_BASE + (group << 1);
if ((retVal = rtl8367c_getAsicRegBits(regAddr, 0x3 << (port * 2), pMode)) != RT_ERR_OK)
return retVal;
}
else if (port >= 8)
{
regAddr = RTL8367C_REG_CPU_FORCE_LED0_CFG1 + (group << 1);
if ((retVal = rtl8367c_getAsicRegBits(regAddr, 0x3 << ((port - 8) * 2), pMode)) != RT_ERR_OK)
return retVal;
}
return RT_ERR_OK;
}
/* Function Name:
* rtl8367c_setAsicForceGroupLed
* Description:
* Turn on/off Led of all ports
* Input:
* group - LED group number
* mode - 0b00:normal mode, 0b01:force blink, 0b10:force off, 0b11:force on
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_setAsicForceGroupLed(rtk_uint32 groupmask, rtk_uint32 mode)
{
ret_t retVal;
rtk_uint32 i, bitmask;
CONST rtk_uint16 bits[3] = {0x0004, 0x0010, 0x0040};
/* Invalid input parameter */
if (groupmask > RTL8367C_LEDGROUPMASK)
return RT_ERR_OUT_OF_RANGE;
if (mode >= LEDFORCEMODE_END)
return RT_ERR_OUT_OF_RANGE;
bitmask = 0;
for (i = 0; i < RTL8367C_LEDGROUPNO; i++)
{
if (groupmask & (1 << i))
{
bitmask = bitmask | bits[i];
}
}
retVal = rtl8367c_setAsicRegBits(RTL8367C_LED_FORCE_CTRL, RTL8367C_LED_FORCE_MODE_MASK, bitmask);
retVal = rtl8367c_setAsicRegBits(RTL8367C_LED_FORCE_CTRL, RTL8367C_FORCE_MODE_MASK, mode);
if (LEDFORCEMODE_NORMAL == mode)
retVal = rtl8367c_setAsicRegBits(RTL8367C_LED_FORCE_CTRL, RTL8367C_LED_FORCE_MODE_MASK, 0);
return retVal;
}
/* Function Name:
* rtl8367c_getAsicForceGroupLed
* Description:
* Turn on/off Led of all ports
* Input:
* group - LED group number
* pMode - 0b00:normal mode, 0b01:force blink, 0b10:force off, 0b11:force on
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* None
*/
ret_t rtl8367c_getAsicForceGroupLed(rtk_uint32 *groupmask, rtk_uint32 *pMode)
{
ret_t retVal;
rtk_uint32 i, regData;
CONST rtk_uint16 bits[3] = {0x0004, 0x0010, 0x0040};
/* Get Related Registers */
if ((retVal = rtl8367c_getAsicRegBits(RTL8367C_LED_FORCE_CTRL, RTL8367C_LED_FORCE_MODE_MASK, ®Data)) != RT_ERR_OK)
return retVal;
for (i = 0; i < RTL8367C_LEDGROUPNO; i++)
{
if ((regData & bits[i]) == bits[i])
{
*groupmask = *groupmask | (1 << i);
}
}
return rtl8367c_getAsicRegBits(RTL8367C_LED_FORCE_CTRL, RTL8367C_FORCE_MODE_MASK, pMode);
}
/* Function Name:
* rtl8367c_setAsicLedBlinkRate
* Description:
* Set led blinking rate at mode 0 to mode 3
* Input:
* blinkRate - Support 6 blink rates
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* LED blink rate can be at 43ms, 84ms, 120ms, 170ms, 340ms and 670ms
*/
ret_t rtl8367c_setAsicLedBlinkRate(rtk_uint32 blinkRate)
{
if (blinkRate >= LEDBLINKRATE_END)
return RT_ERR_OUT_OF_RANGE;
return rtl8367c_setAsicRegBits(RTL8367C_REG_LED_MODE, RTL8367C_SEL_LEDRATE_MASK, blinkRate);
}
/* Function Name:
* rtl8367c_getAsicLedBlinkRate
* Description:
* Get led blinking rate at mode 0 to mode 3
* Input:
* pBlinkRate - Support 6 blink rates
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* None
*/
ret_t rtl8367c_getAsicLedBlinkRate(rtk_uint32 *pBlinkRate)
{
return rtl8367c_getAsicRegBits(RTL8367C_REG_LED_MODE, RTL8367C_SEL_LEDRATE_MASK, pBlinkRate);
}
/* Function Name:
* rtl8367c_setAsicLedForceBlinkRate
* Description:
* Set LEd blinking rate for force mode led
* Input:
* blinkRate - Support 6 blink rates
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_setAsicLedForceBlinkRate(rtk_uint32 blinkRate)
{
if (blinkRate >= LEDFORCERATE_END)
return RT_ERR_OUT_OF_RANGE;
return rtl8367c_setAsicRegBits(RTL8367C_REG_LED_MODE, RTL8367C_FORCE_RATE_MASK, blinkRate);
}
/* Function Name:
* rtl8367c_getAsicLedForceBlinkRate
* Description:
* Get LED blinking rate for force mode led
* Input:
* pBlinkRate - Support 6 blink rates
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* Note:
* None
*/
ret_t rtl8367c_getAsicLedForceBlinkRate(rtk_uint32 *pBlinkRate)
{
return rtl8367c_getAsicRegBits(RTL8367C_REG_LED_MODE, RTL8367C_FORCE_RATE_MASK, pBlinkRate);
}
/*
@func ret_t | rtl8367c_setAsicLedGroupEnable | Turn on/off Led of all system ports
@parm rtk_uint32 | group | LED group id.
@parm rtk_uint32 | portmask | LED port mask.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_PORT_ID | Invalid port number.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can turn on/off leds of dedicated port while indicated information configuration of LED group is set to force mode.
*/
ret_t rtl8367c_setAsicLedGroupEnable(rtk_uint32 group, rtk_uint32 portmask)
{
ret_t retVal;
rtk_uint32 regAddr;
rtk_uint32 regDataMask;
if (group >= RTL8367C_LEDGROUPNO)
return RT_ERR_INPUT;
regAddr = RTL8367C_REG_PARA_LED_IO_EN1 + group / 2;
regDataMask = 0xFF << ((group % 2) * 8);
retVal = rtl8367c_setAsicRegBits(regAddr, regDataMask, portmask & 0xff);
if (retVal != RT_ERR_OK)
return retVal;
regAddr = RTL8367C_REG_PARA_LED_IO_EN3;
regDataMask = 0x3 << (group * 2);
retVal = rtl8367c_setAsicRegBits(regAddr, regDataMask, (portmask >> 8) & 0x7);
if (retVal != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_getAsicLedGroupEnable | Get on/off status of Led of all system ports
@parm rtk_uint32 | group | LED group id.
@parm rtk_uint32 | *portmask | LED port mask.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_PORT_ID | Invalid port number.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can turn on/off leds of dedicated port while indicated information configuration of LED group is set to force mode.
*/
ret_t rtl8367c_getAsicLedGroupEnable(rtk_uint32 group, rtk_uint32 *portmask)
{
ret_t retVal;
rtk_uint32 regAddr;
rtk_uint32 regDataMask, regData;
if (group >= RTL8367C_LEDGROUPNO)
return RT_ERR_INPUT;
regAddr = RTL8367C_REG_PARA_LED_IO_EN1 + group / 2;
regDataMask = 0xFF << ((group % 2) * 8);
retVal = rtl8367c_getAsicRegBits(regAddr, regDataMask, portmask);
if (retVal != RT_ERR_OK)
return retVal;
regAddr = RTL8367C_REG_PARA_LED_IO_EN3;
regDataMask = 0x3 << (group * 2);
retVal = rtl8367c_getAsicRegBits(regAddr, regDataMask, ®Data);
if (retVal != RT_ERR_OK)
return retVal;
*portmask = (regData << 8) | *portmask;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_setAsicLedOperationMode | Set LED operation mode
@parm rtk_uint32 | mode | LED mode. 1:scan mode 1, 2:parallel mode, 3:mdx mode (serial mode)
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can turn on/off led serial mode and set signal to active high/low.
*/
ret_t rtl8367c_setAsicLedOperationMode(rtk_uint32 mode)
{
ret_t retVal;
/* Invalid input parameter */
if (mode >= LEDOP_END)
return RT_ERR_INPUT;
switch (mode)
{
case LEDOP_PARALLEL:
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_LED_SELECT_OFFSET, 0)) != RT_ERR_OK)
return retVal;
/*Disable serial CLK mode*/
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_SCAN0_LED_IO_EN1, RTL8367C_LED_SERI_CLK_EN_OFFSET, 0)) != RT_ERR_OK)
return retVal;
/*Disable serial DATA mode*/
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_SCAN0_LED_IO_EN1, RTL8367C_LED_SERI_DATA_EN_OFFSET, 0)) != RT_ERR_OK)
return retVal;
break;
case LEDOP_SERIAL:
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_LED_SELECT_OFFSET, 1)) != RT_ERR_OK)
return retVal;
/*Enable serial CLK mode*/
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_SCAN0_LED_IO_EN1, RTL8367C_LED_SERI_CLK_EN_OFFSET, 1)) != RT_ERR_OK)
return retVal;
/*Enable serial DATA mode*/
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_SCAN0_LED_IO_EN1, RTL8367C_LED_SERI_DATA_EN_OFFSET, 1)) != RT_ERR_OK)
return retVal;
break;
default:
return RT_ERR_INPUT;
break;
}
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_getAsicLedOperationMode | Get LED OP mode setup
@parm rtk_uint32*| mode | LED mode. 1:scan mode 1, 2:parallel mode, 3:mdx mode (serial mode)
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can get LED serial mode setup and get signal active high/low.
*/
ret_t rtl8367c_getAsicLedOperationMode(rtk_uint32 *mode)
{
ret_t retVal;
rtk_uint32 regData;
if ((retVal = rtl8367c_getAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_LED_SELECT_OFFSET, ®Data)) != RT_ERR_OK)
return retVal;
if (regData == 1)
*mode = LEDOP_SERIAL;
else if (regData == 0)
*mode = LEDOP_PARALLEL;
else
return RT_ERR_FAILED;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_setAsicLedSerialModeConfig | Set LED serial mode
@parm rtk_uint32 | active | Active High or Low.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can turn on/off led serial mode and set signal to active high/low.
*/
ret_t rtl8367c_setAsicLedSerialModeConfig(rtk_uint32 active, rtk_uint32 serimode)
{
ret_t retVal;
/* Invalid input parameter */
if (active >= LEDSERACT_MAX)
return RT_ERR_INPUT;
if (serimode >= LEDSER_MAX)
return RT_ERR_INPUT;
/* Set Active High or Low */
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_SERI_LED_ACT_LOW_OFFSET, active)) != RT_ERR_OK)
return retVal;
/*set to 8G mode (not 16G mode)*/
if ((retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_MODE, RTL8367C_DLINK_TIME_OFFSET, serimode)) != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_getAsicLedSerialModeConfig | Get LED serial mode setup
@parm rtk_uint32*| active | Active High or Low.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can get LED serial mode setup and get signal active high/low.
*/
ret_t rtl8367c_getAsicLedSerialModeConfig(rtk_uint32 *active, rtk_uint32 *serimode)
{
ret_t retVal;
if ((retVal = rtl8367c_getAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_SERI_LED_ACT_LOW_OFFSET, active)) != RT_ERR_OK)
return retVal;
/*get to 8G mode (not 16G mode)*/
if ((retVal = rtl8367c_getAsicRegBit(RTL8367C_REG_LED_MODE, RTL8367C_DLINK_TIME_OFFSET, serimode)) != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/*
@func ret_t | rtl8367c_setAsicLedOutputEnable | Set LED output enable
@parm rtk_uint32 | enabled | enable or disalbe.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can turn on/off LED output Enable
*/
ret_t rtl8367c_setAsicLedOutputEnable(rtk_uint32 enabled)
{
ret_t retVal;
rtk_uint32 regdata;
if (enabled == 1)
regdata = 0;
else
regdata = 1;
/* Enable/Disable H/W IGMP/MLD */
retVal = rtl8367c_setAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_LED_IO_DISABLE_OFFSET, regdata);
return retVal;
}
/*
@func ret_t | rtl8367c_getAsicLedOutputEnable | Get LED serial mode setup
@parm rtk_uint32*| active | Active High or Low.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input value.
@comm
The API can get LED serial mode setup and get signal active high/low.
*/
ret_t rtl8367c_getAsicLedOutputEnable(rtk_uint32 *ptr_enabled)
{
ret_t retVal;
rtk_uint32 regdata;
retVal = rtl8367c_getAsicRegBit(RTL8367C_REG_LED_SYS_CONFIG, RTL8367C_LED_IO_DISABLE_OFFSET, ®data);
if (retVal != RT_ERR_OK)
return retVal;
if (regdata == 1)
*ptr_enabled = 0;
else
*ptr_enabled = 1;
return RT_ERR_OK;
}
/* Function Name:
* rtl8367c_setAsicLedSerialOutput
* Description:
* Set serial LED output group and portmask.
* Input:
* output - Serial LED output group
* pmask - Serial LED output portmask
* Output:
* None
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_setAsicLedSerialOutput(rtk_uint32 output, rtk_uint32 pmask)
{
ret_t retVal;
retVal = rtl8367c_setAsicRegBits(RTL8367C_REG_SERIAL_LED_CTRL, RTL8367C_SERIAL_LED_GROUP_NUM_MASK, output);
if (retVal != RT_ERR_OK)
return retVal;
retVal = rtl8367c_setAsicRegBits(RTL8367C_REG_SERIAL_LED_CTRL, RTL8367C_SERIAL_LED_PORT_EN_MASK, pmask);
if (retVal != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}
/* Function Name:
* rtl8367c_getAsicLedSerialOutput
* Description:
* Get serial LED output group and portmask.
* Input:
* None
* Output:
* pOutput - Serial LED output group
* pPmask - Serial LED output portmask
* Return:
* RT_ERR_OK - Success
* RT_ERR_SMI - SMI access error
* RT_ERR_OUT_OF_RANGE - input parameter out of range
* Note:
* None
*/
ret_t rtl8367c_getAsicLedSerialOutput(rtk_uint32 *pOutput, rtk_uint32 *pPmask)
{
ret_t retVal;
if (pOutput == NULL)
return RT_ERR_NULL_POINTER;
if (pPmask == NULL)
return RT_ERR_NULL_POINTER;
retVal = rtl8367c_getAsicRegBits(RTL8367C_REG_SERIAL_LED_CTRL, RTL8367C_SERIAL_LED_GROUP_NUM_MASK, pOutput);
if (retVal != RT_ERR_OK)
return retVal;
retVal = rtl8367c_getAsicRegBits(RTL8367C_REG_SERIAL_LED_CTRL, RTL8367C_SERIAL_LED_PORT_EN_MASK, pPmask);
if (retVal != RT_ERR_OK)
return retVal;
return RT_ERR_OK;
}