|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% L! \( V2 @$ F( ]! c
#include <linux/init.h>. y" {( t" D* m" f7 G& t& m4 w3 b5 o
#include <linux/module.h>% }" q9 {( ^8 U2 X$ x z
#include <linux/kernel.h>+ u, d/ v; v! J1 ~
#include <linux/types.h>3 V; B T( O& f k. ?
#include <linux/gpio.h>
( s" y+ s0 v; W8 y) u! c( p#include <linux/leds.h>
8 ` A: _* y+ A, z2 K0 m |3 ]#include <linux/platform_device.h>) t# i. F; J4 A0 X
) u t% d3 r/ k% h6 a; x J# O#include <asm/mach-types.h>
, s5 y/ F* l4 @$ t' ], f#include <asm/mach/arch.h>
1 B; ~$ @6 @, `* {- b#include <mach/da8xx.h>
5 v" c% o4 c- d4 l" c#include <mach/mux.h>7 G* l2 ^6 j2 R3 c$ X
, m6 F1 ^$ C8 M- H2 z. `$ \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: |* @; `( D# d% E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); L5 n8 ^$ f. a( B' ]5 X# x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) [% Y. r5 q9 x+ w, G% I& s0 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# F. v; s/ y6 n7 u7 E! z% i
: Q! k* {; h. K) l' e/* assign the tl som board LED-GPIOs*/
' P, K7 E8 e {0 c" E' lstatic const short da850_evm_tl_user_led_pins[] = {
) m. g1 T0 j9 m- t1 r g8 l; y /* These pins are definition at <mach/mux.h> file */
& h, j. F. D- i# _" H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' L0 |: h( K& x- ?) }7 q5 r
-1; {! n( c: g' M- ]6 \5 V' ?% t$ {
};& l& ]4 g) N2 f/ U: I
% {& ^- t: V" {- ^) m/ E* Jstatic struct gpio_led da850_evm_tl_leds[] = {
2 q( ^ E7 A3 ^" r& F5 b2 {1 h {0 W# v. z' M! r% t! c# H
.active_low = 0,, d3 a+ E4 Q# J
.gpio = DA850_USER_LED0,+ f6 ?8 j8 k' u' v/ J
.name = "user_led0", K7 G4 W! J& F7 y8 E
.default_trigger = "default-on",
, n# G5 Z$ u) c% e6 w5 ` },& X' m$ U: {8 j3 \# V* y' u& B
{) k! k8 \4 o3 C
.active_low = 0,% H2 k0 O- D& M1 j! M# ]! t f; i
.gpio = DA850_USER_LED1,
; c4 M6 o8 d/ a4 R5 _ .name = "user_led1",
# i% \: j9 N/ e" Q& F .default_trigger = "default-on",
! y- J. Y W. _3 c6 z" D/ X },
$ I c. V6 w: ]- [# M. q {& I6 T+ u1 N/ h. b* t+ a8 B
.active_low = 0,
4 n; h* Z$ s" a. i .gpio = DA850_USER_LED2,
" m' l- j. R6 f( g+ S! A+ E; A .name = "user_led2",
/ T$ y. b% y4 @/ p$ T .default_trigger = "default-on",
( v( |4 p4 w" @9 e# p/ K8 z },+ j" o0 I3 {# o" Z- D) k6 I
{
5 q( w( M, @8 G8 ^, R/ b/ D .active_low = 0,- [) V9 Z1 V0 L8 R( {+ r3 O# ~8 d
.gpio = DA850_USER_LED3,
Z3 {- @" s7 f" r, r .name = "user_led3",0 m% F8 x% z/ |" x3 _7 l! x
.default_trigger = "default-on",9 }6 G9 l. y- [- Y/ P& @4 A
},
) z# S* `- ^$ W3 ?};; C2 |; W1 E/ x: D: d3 i. J! V
6 v/ g) o) f/ v4 C9 `* R3 qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ s( z- W" T" M' Z9 m3 I .leds = da850_evm_tl_leds,
7 T; v% _, h" }) W4 q5 ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 {% d4 U q! |5 i1 {, D4 x};* f/ }( Y! r1 R+ g, L
]* X( X5 {2 z9 W% {static void led_dev_release(struct device *dev)
% |7 {4 P8 h$ I' k3 e4 F! n, B{
9 A% k* k8 r, `2 I$ T};: K" O7 S( {6 K1 t& p" N
* G' L# a) T- C- b$ _. D
static struct platform_device da850_evm_tl_leds_device = {
* Z' o' E* G( Y .name = "leds-gpio",
9 A4 o. u, J, e/ h- N .id = 1,
* u- ]8 E ]# x1 _, B$ K .dev = {
: y( W( ~& L! z1 w .platform_data = &da850_evm_tl_leds_pdata,* Z. ~8 u4 h9 |# K" y$ L! p
.release = led_dev_release,
8 d8 i; `6 Q, D) R: K1 g6 l }
: u& ]! K/ J) ]1 ?% [* B2 `}; e. l. N- C( s+ n; I- J
8 l& b! _1 N6 Z8 C; lstatic int __init led_platform_init(void)4 g; w9 u) |% a; t. h
{
0 s8 |/ S; K4 O0 r int ret;
5 H, F+ [. ?" B9 M s/ [9 {#if 0, i! o5 k' ]5 ?- l1 P" n; p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( o) X9 S+ I- U" f if (ret)
6 e/ J8 ]. O2 S5 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! r, w* E+ I+ @5 _$ \
"%d\n", ret);, m+ x( K8 H. C9 o% n9 v
#endif
i9 N9 s- K8 @ ret = platform_device_register(&da850_evm_tl_leds_device);. O6 h3 l4 K$ ?, q( {
if (ret)# ~0 r" R( w. b) G+ `% _: @
pr_warning("Could not register som GPIO expander LEDS");
0 G8 [( `. y6 k) S) s# J else
4 h( K5 z$ @4 o- u4 W( h printk(KERN_INFO "LED register sucessful!\n");
# _ X2 {+ Q7 S1 r4 S
9 a8 a7 E4 t9 r/ g- B return ret;
( [# Y! ]4 Z, a9 {* T}
% ~& m v, K7 q; T6 F6 _+ x
" C) l0 q- m4 a/ {2 w. Xstatic void __exit led_platform_exit(void)6 m( D$ v+ V0 t9 h3 b! Z, @, H
{8 n) @8 s# z. ^& F: d, X
platform_device_unregister(&da850_evm_tl_leds_device);
}, A& d1 ?/ h6 W& s7 {$ \' F6 i0 s2 } L- |
printk(KERN_INFO "LED unregister!\n");/ Q$ {1 `) b/ n0 ?8 Z. P
}
2 F L" j! i: S
% H; B& [/ ]8 t3 |) U! Kmodule_init(led_platform_init);
4 C+ d* V- Y( V& S- }. u6 mmodule_exit(led_platform_exit);
; l9 _( U' g7 ~" f' Z9 W
5 a0 T6 i6 P& b/ a4 o/ g0 qMODULE_DESCRIPTION("Led platform driver");5 h4 f* M! D c7 Q4 ~; B
MODULE_AUTHOR("Tronlong");) \* \. |2 s1 s8 A7 V- p+ \- A8 I
MODULE_LICENSE("GPL");
5 s |6 f! ]. t6 a" {% V4 }* S; F
3 ^* Y' `: t- i; S/ O+ E% N; j0 X |
|