|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' _# I' L# Z' R h2 y0 F#include <linux/init.h>
: p. B- C+ j% [& k8 \#include <linux/module.h>4 @+ Z! ~6 x3 u) w
#include <linux/kernel.h>9 k% R k- Z& C& i& B, V" Q$ h5 W# G
#include <linux/types.h>- a3 U. |1 L8 N2 W+ q2 E
#include <linux/gpio.h>
: J+ H* o8 v6 [. v8 y; b5 A2 \7 P#include <linux/leds.h>
9 B1 \4 g/ J3 k+ y. I, b& }#include <linux/platform_device.h>
1 M" m* W3 L: M% M% a. ~, ?
G/ v- @% d5 W9 I) q#include <asm/mach-types.h>
" e) i/ @4 f( h* q. Z2 h#include <asm/mach/arch.h>- I" N( [ B1 M: C8 `% ~5 `
#include <mach/da8xx.h>$ E/ @8 ]5 G; `+ n
#include <mach/mux.h>
# M& [( Y7 x* v+ f7 I$ ~5 H" ?8 I W- S" d5 C& t3 ]/ ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 s5 O3 R7 u$ Y7 i: l/ E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 Z2 y6 D) r6 Y. f9 I2 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% Y( M d3 L0 q9 W( h
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" C4 M& r* T1 @
, z% ?4 U1 e r D! i; c: s8 Z/* assign the tl som board LED-GPIOs*/
( T7 x+ N' C1 Z" x& Hstatic const short da850_evm_tl_user_led_pins[] = {
5 t' u9 v# E9 X* n& ] /* These pins are definition at <mach/mux.h> file */
% d, d: d$ S: q8 C. F6 b; K' ]6 d; l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 {/ b2 Y, K" ~, I9 r
-1+ j3 f; S5 @( y* G5 q
};
2 ~" s7 \" F$ D) c: L+ f3 A C
5 a. }- g3 S1 t+ @7 V, u2 b" Ostatic struct gpio_led da850_evm_tl_leds[] = {% R2 S3 j2 [* |) s
{) y, q5 T; y1 `3 g. p% {. s) G( L
.active_low = 0,
/ T- R% O: j9 `7 f6 A1 C .gpio = DA850_USER_LED0,
7 I1 f9 Z- }" @* O* r1 I5 c .name = "user_led0",2 D& ~" U" |' u2 M4 Q/ @
.default_trigger = "default-on",
: N# |; L4 n; t! p },2 M$ @' @5 f, N' n" E9 ]# k! U
{ H1 s, M; v$ y* @
.active_low = 0,
# a% R& b- J$ V% b8 I .gpio = DA850_USER_LED1," X( W7 A, W6 l# w7 f! K* o9 F
.name = "user_led1",
7 {/ F) D$ f1 M1 U( E .default_trigger = "default-on",* Z. [- g, H7 s7 S. T
}," }6 u! N0 b/ n- k% K; ?' K/ f
{
2 {0 d! N a9 \: F) N) e, o9 s$ ` .active_low = 0,
; j! t, x$ O, W6 }# n: M .gpio = DA850_USER_LED2,
1 }- r( ^# K8 } .name = "user_led2",9 }* l$ t! b/ t. {* W
.default_trigger = "default-on",
6 |0 Z, ?% Y; D9 E% c },) i* V+ l; m4 n( o& r- W
{
# E, {& ^4 g! ~9 \* S8 C .active_low = 0,
$ g0 h* A, M2 y6 {% A* { .gpio = DA850_USER_LED3,! a+ E+ S4 c7 U* @
.name = "user_led3",! y$ |) ?' `! ^9 f
.default_trigger = "default-on",
/ ?5 \$ k* V* \/ z' s5 P3 ` },
" t& _+ z" X5 ?, M};; O. I* Z# }( @; w
- t$ Y0 m/ H* H! O, E' i& Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( ]9 B1 r# C3 l% r .leds = da850_evm_tl_leds,
4 t8 Y; I" C4 a% U7 s( G" o5 g" x$ i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ \8 H& O* Q2 r0 \6 H, S
};
, ~: ~( D* f$ @1 w8 N
: i& ?' y$ a/ p! [8 Bstatic void led_dev_release(struct device *dev)0 i+ ~4 l# N. M D" j# s) Q% ]
{* u6 L" |! u7 y% m* I8 `
};
" t8 V% |: `* E% ?
7 e$ E# s$ k3 x estatic struct platform_device da850_evm_tl_leds_device = {
3 d2 @. G5 a6 u% l" e1 ~ .name = "leds-gpio",
" J" y3 n' |) ^ .id = 1,
5 D' S3 D r! i; [2 v .dev = {% {) n1 v6 U; X) l
.platform_data = &da850_evm_tl_leds_pdata,
7 F& u3 H, q5 ]0 ? t1 Y, |' K .release = led_dev_release,
# X: k$ _+ r" p2 l }
o" E3 Q- J4 |};* u& g: J, ?3 B: b* p+ J* V& _3 |
: ?3 p$ Y1 T& m+ E5 }
static int __init led_platform_init(void)
+ a) a9 i4 c/ K6 S+ P; C7 I( Y; S{
9 K# p0 }' @; H( ?- L- I; f int ret;- |+ o( ^: {' y5 j3 Z ^
#if 0* z D+ o3 h! a: D/ p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( W/ V4 G* h/ B$ A if (ret)
+ O' ~/ e' J9 H: a# { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& Z) i2 z# E M0 y1 `
"%d\n", ret);/ {3 p8 U0 s: D$ f
#endif& f p8 I' ]) H2 J' L
ret = platform_device_register(&da850_evm_tl_leds_device);
) r9 ` K" Q& n5 o/ ] if (ret)4 b( c. Y/ |4 t( v
pr_warning("Could not register som GPIO expander LEDS");0 [" y- `# z/ v' e; E! z) l
else* b+ v+ {; Y, s
printk(KERN_INFO "LED register sucessful!\n");
- m7 F7 |4 y9 z
( |5 S) w3 \- ?% M2 t! j3 a* v return ret;
% G( [, k" F* T" ^% c z: l# f: N}" I7 D- } W6 z
; U: S' w' {3 I
static void __exit led_platform_exit(void)
; e. k1 B/ G" K3 X% L* Z{
- L$ j6 A2 @4 G platform_device_unregister(&da850_evm_tl_leds_device);7 [% \/ S# ~" b6 p8 w6 }, k Z
3 F; `& k/ Z0 d" h
printk(KERN_INFO "LED unregister!\n");- |5 }$ D6 |# B6 R% @5 G/ }
}# l3 z. ~2 M; O& |* f4 G" ^
8 y/ C/ q- ~6 Y Cmodule_init(led_platform_init);; l/ k2 U+ U+ M" q
module_exit(led_platform_exit);: G0 r: a, u% O& L/ \& X
/ F3 ~4 r2 W/ n! X8 k( \ d
MODULE_DESCRIPTION("Led platform driver");' s# U+ T4 x! d
MODULE_AUTHOR("Tronlong");, |) o$ r0 l8 a( _( G; H! g
MODULE_LICENSE("GPL");& L* g F" v' R9 {5 N
/ W# d- |" M& w) u/ p
|
|