|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& a* [! k I+ T
#include <linux/init.h>
$ ?" ?3 }, N& ^6 Z) T#include <linux/module.h>9 t3 U- ~5 s& n
#include <linux/kernel.h>* D. N1 a7 x2 j7 ^7 u! N
#include <linux/types.h>
8 [5 }2 B8 ^$ H#include <linux/gpio.h>
' e5 f; Z/ p- A7 u! B#include <linux/leds.h>
, r2 ]# x+ r1 V3 w6 Y! w8 A#include <linux/platform_device.h>! T0 ^7 h0 [) ^" G. k% g! ]3 K
5 H8 S% G" x; K4 B$ X/ }
#include <asm/mach-types.h>& e" P) O' Z, B! N1 j
#include <asm/mach/arch.h>
& C& e- G+ a, W; d#include <mach/da8xx.h>
( C6 L# x. ~9 D# _#include <mach/mux.h>
* _0 z( U+ A! n. Q7 }9 j4 a
1 }. A6 y9 Z& t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; n9 R" z& A$ Z x8 c; ^8 P" d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 n; f2 {. }- `' U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% ]! V& y: g/ _ K/ V* }3 K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( I# ]. q {& K
3 |+ \. L( |8 y; _; x! u, y7 `6 O/* assign the tl som board LED-GPIOs*/2 o' k7 T7 n0 H/ S' o
static const short da850_evm_tl_user_led_pins[] = {" W4 y6 H; b9 R) a* O! d
/* These pins are definition at <mach/mux.h> file */- v* g, T% m8 V/ T2 j: M) ]) E1 B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( ^9 |5 Q' R4 N. w
-1
7 ] d! q8 V5 c3 x- m5 H% j};
1 N; p- t9 a. d/ n8 l
+ n9 N; i6 I& D/ Nstatic struct gpio_led da850_evm_tl_leds[] = {$ N4 A' f7 L' {6 ?, E
{
7 @/ `2 F0 S4 \/ n8 X3 B0 g .active_low = 0,
0 j( P) C6 F4 h4 V/ `* P. N# q" {( z .gpio = DA850_USER_LED0,; v9 }5 f! N T# N3 \( ]
.name = "user_led0",6 B' n6 t7 l, `5 w
.default_trigger = "default-on",
! S0 ~ X$ d% k6 O3 S6 @ },% I& |$ V' @5 B2 e, C' n
{
a; x0 R. ]. N" W .active_low = 0,
5 [9 x0 Z2 K6 d4 {2 D .gpio = DA850_USER_LED1,
]0 S. Z% _& Z% h" o& c2 w8 { .name = "user_led1",
/ d6 ?1 W* l/ O& K1 H6 S: }/ h .default_trigger = "default-on",
/ d2 j% [9 T7 L K# O },
- N: ^) M7 O8 C- E; J( D {6 Q( [# h$ U6 q. `6 l& s# ?
.active_low = 0,, H: u1 k% y5 C+ Z. @1 d
.gpio = DA850_USER_LED2,$ V' [. e+ D8 o8 I
.name = "user_led2",
1 d% H6 W# G- k+ ~0 l5 C/ a .default_trigger = "default-on",5 \( u d5 ]% R0 A
},2 g/ S5 ~( x) |1 H6 G) s
{. |- k* S# @; u" X
.active_low = 0," {! N' m/ w- Q, {
.gpio = DA850_USER_LED3,
8 }' J {4 O, _. D6 @6 ?5 N/ s r .name = "user_led3",$ e# J; J4 s$ {0 s2 ~; c
.default_trigger = "default-on",3 \, |1 M( y, M; P! U7 z/ `
},
' c8 E- _0 i: P, i: D- O};
" G3 n5 d/ _' j6 D, \% K9 X+ P: T! {( f; h2 c0 |7 G
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; t* S' @: v! }+ }* t/ s6 O
.leds = da850_evm_tl_leds,
; X; I, v0 X1 B) w9 o; s w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! `6 T' C# S7 v6 \, T};
! i0 \) }8 ~- V- C. d
3 f# R' Y9 \! }0 c8 T( W: \4 u/ ^static void led_dev_release(struct device *dev)
" H T* T/ { v4 i; R, }9 h{
R! b6 c9 F1 Q d$ w% n! \( l};( c* q3 a- {8 m2 V
# T3 \& ]# B5 |; Z* _5 l9 q
static struct platform_device da850_evm_tl_leds_device = {7 X" I" z- r5 `
.name = "leds-gpio"," m* S. G6 ` [
.id = 1,
! P6 ]1 d! W/ E: p .dev = {
: n& Q8 Y/ {/ V2 H .platform_data = &da850_evm_tl_leds_pdata,
5 L. e% s) \* u .release = led_dev_release,; x, d, j' d. e6 l5 x# l9 V
}7 D5 p3 D6 c a
};8 r X7 g6 D) E z7 h
" [: P2 Z' g- Q! u
static int __init led_platform_init(void)
' J* C! Q, v/ c2 x{, B- x: N' N* W4 u+ v
int ret;- z. k& J) K; l( r6 E
#if 0
3 q- [0 q; X, o5 y! |! S% c( f' S9 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 i: ?: m9 r) N: c, }2 i0 \
if (ret)
( H" Y& S( J3 `0 J: W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ i+ U2 y- U. Y$ `+ [8 l% [) v "%d\n", ret);
/ I2 T# Q3 z9 _: e+ E( c1 q$ S#endif! }1 u$ J V ^8 S
ret = platform_device_register(&da850_evm_tl_leds_device);( c: _/ Z! C+ c
if (ret)' O7 x( W6 X' F
pr_warning("Could not register som GPIO expander LEDS");2 X5 t; [. M+ T% v7 r$ X
else1 l3 ~8 T" Y$ t& F* q
printk(KERN_INFO "LED register sucessful!\n");' I, _$ h$ s; r9 J2 T" X
4 V6 r7 ~1 `0 [: X. j
return ret;& b# t2 C4 `' ^4 ~& _: Y
}6 t, g5 i( ?7 u- v1 r5 g
7 M- Z/ a' M, l P6 ? V
static void __exit led_platform_exit(void)
( Z# f% n& u+ e{
8 r f+ a% C" `2 D% n0 q8 o platform_device_unregister(&da850_evm_tl_leds_device);! U4 z! h( k( {0 [
6 E2 }% G2 I: `8 q
printk(KERN_INFO "LED unregister!\n");3 ]' y5 {/ d1 P/ @# `) k
}7 @* i @3 X3 x
5 y6 w$ H U+ p
module_init(led_platform_init);4 O/ f4 V: K+ ]* N9 T) r& H
module_exit(led_platform_exit);
' t8 x. M4 [! \/ ]9 Q8 {/ Q5 J: \! N
MODULE_DESCRIPTION("Led platform driver");" G: T- o5 B1 X; W/ Q% E
MODULE_AUTHOR("Tronlong");
2 ~1 `# Q4 K( p6 i$ d$ ~MODULE_LICENSE("GPL");8 g. ^4 H; D0 }( O/ w
' @+ G: A' ^5 [" W8 c7 [6 c |
|