|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ {, P/ s9 I* \5 W9 S X#include <linux/init.h>+ J% `( D' l: f8 b$ }9 a3 l3 k6 z: U
#include <linux/module.h>
5 @+ H( b6 Q& l; z#include <linux/kernel.h>1 M+ C# T! a( |2 q
#include <linux/types.h>
! O( R/ M+ ~% I#include <linux/gpio.h>: u% z: C. j5 S6 g3 _8 t, O
#include <linux/leds.h>
. ^" \# m: ^% L6 B2 E#include <linux/platform_device.h>0 z, {5 |& c+ n8 k/ ~
* t z, N$ m8 {7 }4 `+ T8 p4 b#include <asm/mach-types.h>+ l6 v2 F- f* g( C2 j
#include <asm/mach/arch.h>
& y- ~/ I1 G& @1 ^ A$ |#include <mach/da8xx.h>" c/ n2 Z* V3 H8 ^: @, ^ r3 m
#include <mach/mux.h>3 b1 y+ f( D" ~0 [) b& @
" X! `* t6 S9 Q0 l6 \$ G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% f4 t! e, l& W( N! z* G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ k5 P, J+ _" ?4 J# W0 V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): f* }/ K- U8 F+ e: Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' F) D% o4 \0 a$ i5 s# j3 p+ A4 [" s) I
& |& C4 f5 B* {9 T/* assign the tl som board LED-GPIOs*/
* D$ B+ k2 p. L1 gstatic const short da850_evm_tl_user_led_pins[] = {
& ~( ?- a9 b# Z /* These pins are definition at <mach/mux.h> file */1 N0 ?" [0 q& g$ V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 L7 |: v% @7 J; M' ~ -1
1 y2 l8 Y' y |; M# H! m" \$ Q};- C, h z) ]) V. X
+ }+ K t2 _! tstatic struct gpio_led da850_evm_tl_leds[] = {
: w+ h. E: o' I( s! U+ I; Q {
& K. j* Q( m, i: m4 Z5 X .active_low = 0,5 y$ x+ u# H1 |, r
.gpio = DA850_USER_LED0,3 I7 d3 w: Z3 d/ b5 V
.name = "user_led0",5 P U0 `, ]. ^1 U: {( S
.default_trigger = "default-on",7 f; \6 |) l# X7 q+ ]# I( b5 F
},
" l0 u1 b' x, U6 g) J) V. W {$ E2 S: z4 {# K3 J& S3 Y( K
.active_low = 0,
3 W. O) |: g; h* l; o .gpio = DA850_USER_LED1,
/ o( R9 o. C7 `) N" Q .name = "user_led1",
) Y, o0 K$ ]$ o4 { .default_trigger = "default-on",8 S5 R9 H; m( s/ r3 I
},, b3 Y$ n* x6 \' P3 \
{
) }! ]( b/ Z0 A5 H! m .active_low = 0,. k' H2 P- [- Q
.gpio = DA850_USER_LED2,/ `, ?" |( m. L' J. K- k+ @
.name = "user_led2",) ^/ V% F% t" l- ^0 P
.default_trigger = "default-on",
2 J+ K, l) | U# P- k$ b( ` },8 w* {$ z5 r! e( W3 ^
{
% D6 M7 h* d1 ^( h9 V .active_low = 0,! I1 T% B( \- n' L2 w5 E
.gpio = DA850_USER_LED3,
$ P- k- E4 M5 g: b7 i& N* |$ N .name = "user_led3",
, w3 \ o/ ]9 \8 ` .default_trigger = "default-on",, Z3 r) S+ v( _* v0 @2 Q$ w, N4 A
},' A/ y5 `7 x9 } b2 C- K" z, u
};; l' p" t% |2 }/ ?0 M7 M6 v R
* t3 s; e% _$ }$ @8 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 S% G% R- m1 n& d' r: X' L, s
.leds = da850_evm_tl_leds,
& D, }" z( l# i3 N; l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- X3 r7 u' N) u/ x% C" f};
5 |3 `" d. A- O; i8 ]. b' {: w7 w: D$ d0 n7 V( U
static void led_dev_release(struct device *dev)9 j- k' s9 s% c! h& r+ B
{
7 ?# }- T0 k$ k* R7 B$ [; m0 o! e};" x5 S. c4 @6 S( d: I5 |
8 A/ P2 ~/ d( T1 z' estatic struct platform_device da850_evm_tl_leds_device = {
& c2 A( G+ o" V; \' [# N1 j .name = "leds-gpio",
- U E2 `2 I# \* M .id = 1,
7 `) P v# v* X9 g4 s .dev = {
. I4 Q& i A" K2 U% d1 L .platform_data = &da850_evm_tl_leds_pdata,/ j. T, l5 I7 v8 ~1 D
.release = led_dev_release,
8 t2 N* M2 u& o: E& \: E1 T% y }
- F% u" F4 n6 i+ p* c' h( t' R};6 E$ m" y" w% t" a8 |9 \* v5 _# E5 C) C
6 m, m2 n& o4 c! y& W' a( \static int __init led_platform_init(void) k8 B, `; I$ b, d; {# M
{
8 a/ |, [! V0 o! m* u int ret;
) l# V0 c! c1 x% E* T#if 0, t' D3 ^# z% \$ J. S% O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ e; W8 W2 D& Z* D% ^1 S if (ret)! b* K; [! I9 r% z1 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* _0 D, \3 i9 f. q "%d\n", ret);* E6 l) A: h1 D4 l
#endif& ?: S6 c8 u) @* `
ret = platform_device_register(&da850_evm_tl_leds_device);8 {6 @/ I: j0 D$ r/ Z3 [2 V& ?2 u
if (ret)4 W: S$ B' T& B4 H8 O+ }' v
pr_warning("Could not register som GPIO expander LEDS");
( I$ l* c [8 ^6 c else
7 N% H$ ]! S7 [% C printk(KERN_INFO "LED register sucessful!\n");/ Q+ G6 ]8 Y1 ]3 p: F/ ]) o
5 c0 D- k' z% B1 I/ B5 x return ret;
: ?/ w" ?9 r1 l" i}
: m' h3 m4 G* S4 Y5 k. d
& ` U i, }" Z6 jstatic void __exit led_platform_exit(void)
$ ]) d% Z; f# @ {' y$ \/ Y{
- ]7 D0 y3 n0 O" M+ n* p- e platform_device_unregister(&da850_evm_tl_leds_device);
: \. R# C/ u6 }& F# I* i. `
% W$ N/ s b( I5 O3 r1 L) o1 i printk(KERN_INFO "LED unregister!\n");2 @/ w. G; r2 H' g* Y; U% k
}
) y; Q& e5 t2 f6 M8 J) S7 e6 z' T: N. m# H# t4 n* N
module_init(led_platform_init);7 \' H: H' Z( T4 h0 ^- M7 |% t' |
module_exit(led_platform_exit);
& E; r$ v0 E% i: b" _3 w0 [9 l) B% K& ^2 k& M
MODULE_DESCRIPTION("Led platform driver");* {; I9 ^$ f$ t$ I: c; C; g1 m
MODULE_AUTHOR("Tronlong");
; a6 n! S; s; |/ FMODULE_LICENSE("GPL");& g" t( s8 ~4 v5 l) i
0 w& x6 e7 s) X- k( |: ] V
|
|