|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 S6 }. u* c P2 X/ T, }+ m#include <linux/init.h>
3 _9 {$ J: t, G o, g% l#include <linux/module.h>
: I: U: J8 ? { p* x" W) B#include <linux/kernel.h>5 k+ s( K9 {$ p/ d# ?( U4 ~. ~
#include <linux/types.h>6 Y* C9 R2 `9 b
#include <linux/gpio.h># w" S& N9 R/ H$ J. ?4 a) \
#include <linux/leds.h>
( l, g6 ]- x$ S; C! b5 p* X#include <linux/platform_device.h>% }) q' v$ C- d+ ]& D
3 k, ]5 O) j- @+ p. G#include <asm/mach-types.h>- u8 }9 c& C$ e
#include <asm/mach/arch.h>
8 {% L/ q- q( V#include <mach/da8xx.h>$ p; r+ V+ l, J- V% s
#include <mach/mux.h># @/ H9 C; x8 T/ X
' X6 b8 |9 Z5 W+ L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 _' o) _0 {3 G- _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 ~' o2 f+ |8 s a$ @5 T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- S" A+ N5 X3 ~0 o9 e* G( T/ \4 @#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& m- Z; I! A2 r
2 C0 `, `& p) Q: |" i/* assign the tl som board LED-GPIOs*/
4 V. i0 _5 j; h' Y. Hstatic const short da850_evm_tl_user_led_pins[] = {+ g8 b: w U3 |! p& i4 G% ^. {8 [
/* These pins are definition at <mach/mux.h> file */
+ S1 D* z/ u& w" Y, k8 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 m" | m+ R: o, e! r2 I6 p# z -14 _9 j4 [& ~. e
};
, w& Y" d2 G! L: h" Q- n# ]" [
* r/ ^; ~( }4 ?5 e' q3 r% Bstatic struct gpio_led da850_evm_tl_leds[] = {
3 [2 z9 I8 q5 f0 a( v! [; S- k% Y) o {
. H7 h" k1 z/ i" ~( H5 `, X .active_low = 0,
, r% C# l: @) G2 K( {, c" B3 T .gpio = DA850_USER_LED0,
7 K) ~ |: k: }3 b .name = "user_led0",; O/ i4 N9 F+ l0 g3 d4 z S
.default_trigger = "default-on"," W% ]' _$ w) K. ^! N! d) g/ e
},+ z- i2 ~1 B4 E' X0 N; B1 y
{
|7 ]* @. `% \. `( { .active_low = 0,
7 Z% U" Q* F* t: b .gpio = DA850_USER_LED1,2 I9 x. e+ g8 N- }
.name = "user_led1"," _+ i& }' E g# P1 _
.default_trigger = "default-on",/ v6 g, [0 r9 J
},/ C: \& A4 x. A, Z& O) f
{7 c1 g- K$ o" T9 s/ G' u3 v8 f" f
.active_low = 0,6 F! W d( F$ K% b/ H
.gpio = DA850_USER_LED2,& U' y \# _, T+ l
.name = "user_led2",% K b* O- l! e+ a" H
.default_trigger = "default-on",
3 l1 [9 N& W" X8 L: d },# s- V# D$ F3 j! c ~% G
{
% |: z4 z- N4 b/ _ .active_low = 0,% u6 [4 N4 F% S3 ?7 g% [9 m
.gpio = DA850_USER_LED3,# G8 H# }9 O: i+ u
.name = "user_led3",
1 Y9 H6 q! g2 C* @& G: b# H .default_trigger = "default-on",
3 i1 ]$ m# r/ ^! H },: o5 w7 ^3 Z4 b8 T+ ^! J6 c( E
};$ e2 i" Q) z% k
! p0 n0 D3 J7 V# p8 e& R8 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 o9 ?8 [# I }* L2 @ .leds = da850_evm_tl_leds,
5 Y J% g, a! e* [* L5 y" q1 D, T/ i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 ] ]: W+ k% J2 }7 F8 {- I9 C$ ^
};: h+ F3 G5 a( ?$ V% q
5 n, b0 B5 T: I9 Rstatic void led_dev_release(struct device *dev)
/ z+ r; ], v+ n7 ?{# h6 F, Q# Y8 r" ^7 C& k
};$ q, ` H d( W/ d, t; E ?
& `' u4 J1 ]0 h5 c
static struct platform_device da850_evm_tl_leds_device = {
5 ]4 y' u4 L0 `+ {. t. H8 y .name = "leds-gpio",. T: W; O' R+ Z
.id = 1,1 M; e4 a+ p5 D; c
.dev = {
3 h, `+ f- ^! V/ k .platform_data = &da850_evm_tl_leds_pdata,+ ?5 }7 f* b% H3 y$ q1 x4 r1 h! G
.release = led_dev_release,. G4 A, t- u+ Y4 f
}5 Y9 c9 E% Z [& u
};
! T# r6 }4 [% l8 A! Y; P; E8 l
: J! g; l/ O; ], J8 C& @4 |& P1 Sstatic int __init led_platform_init(void)
1 |& j0 }, J" l{
" }2 e( W, @$ t% I+ \( r0 G int ret;
( b$ X$ T% v/ t X+ s y* f5 _+ _#if 06 `. _/ D g5 o: L1 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# m" ^ ]1 b# J. H9 u/ P& o
if (ret)
% ?- ]( t# ]- `. c. B, R9 `1 V/ N4 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- L) Q4 I2 F/ V& ^1 N "%d\n", ret); g; _8 c8 K! r- X+ \
#endif% T* q5 D4 n5 u0 y( V/ _9 {$ s! G
ret = platform_device_register(&da850_evm_tl_leds_device);, v# R! p3 u }1 e2 M
if (ret)4 K9 F9 B5 f9 Z1 e, Q7 w3 Z5 ]" M% I
pr_warning("Could not register som GPIO expander LEDS");% ^5 F* J9 ?/ E- k( j
else
3 a3 M7 P7 S: S1 x' D' o printk(KERN_INFO "LED register sucessful!\n");
: ?0 S0 u4 W6 D( m- h# |- L0 n
9 o8 K+ a/ ~! u# W: G return ret;
% Q0 R, I; n& f}
5 T( y' l M7 A: F
% d9 U8 ~; P" R Fstatic void __exit led_platform_exit(void)
2 `4 h8 f! u3 Z; ?: P/ p, c{
4 A% H3 ?3 P9 u u platform_device_unregister(&da850_evm_tl_leds_device);4 [, }/ u. v+ G' J: c+ ~ {
# j8 V8 M) h* ^ printk(KERN_INFO "LED unregister!\n");
. r( ^7 O. \4 Q' m' x* m/ X* u2 h}! m) s' o- J9 J5 z2 @6 D7 W
2 L% q- u3 H% m+ M" ?0 j# [) e7 C4 u, `module_init(led_platform_init);
( O$ \1 p2 p! ?1 r) Xmodule_exit(led_platform_exit);1 t: _6 r8 S' b" H
0 F8 P8 n+ ?, J5 a" U
MODULE_DESCRIPTION("Led platform driver");
% P, E9 V! E7 K" c2 JMODULE_AUTHOR("Tronlong");
, [8 V5 [' c B1 @1 U5 g0 `MODULE_LICENSE("GPL");
2 g k* Q e% D2 b2 H5 g5 Z& m' E
|
|