|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 X& A+ C1 m5 `2 Z0 i! d; C, O; o
#include <linux/init.h>$ B/ F# F* n) P6 P& T" m
#include <linux/module.h>8 v! e- L! B! ~1 C$ ?. H3 B
#include <linux/kernel.h>4 Q8 M! q) X/ b" J
#include <linux/types.h>
/ E4 U. x7 R/ y* C J- w#include <linux/gpio.h>
* h$ F- x, R$ a% r* a' D$ b* V#include <linux/leds.h>: F. u1 r( s# ]9 m
#include <linux/platform_device.h>3 a/ t- @ V1 q* s
3 i6 m: s8 l$ \/ c" G3 F' `/ E& U
#include <asm/mach-types.h>
1 B o( W8 ]8 w" z; s4 @#include <asm/mach/arch.h>9 _; X- F o; F+ O4 _
#include <mach/da8xx.h>
: I5 S& V+ F& U#include <mach/mux.h>; D' ^( G+ ?# z% H# Y$ t7 G
$ D/ e! a) C9 c4 d0 e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- D. A4 l/ z$ A# M: Z/ K# L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" T* }( W6 f7 I5 q- O! c! |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! ^9 Y& O- o5 o) R2 q& w4 s% ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 g0 A, e5 Q' ^7 t5 F) K: U% M0 U, r) v. M* q/ \! S
/* assign the tl som board LED-GPIOs*/8 p7 N3 L2 q# A' ?
static const short da850_evm_tl_user_led_pins[] = {
* [4 D, a$ g& t1 z' I# T) o1 W /* These pins are definition at <mach/mux.h> file */ I$ D7 Q; B) W& ~' O
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, S8 q& ?" ]3 P; v5 w* Z q -1% r, d2 L) l$ E4 D
};2 B6 `& A) q1 Z8 M# L' j
* u! P% \; c7 z0 a+ p8 Fstatic struct gpio_led da850_evm_tl_leds[] = {
( v v2 D- t: {& o {
4 W0 r0 J- a% q$ T# d, h .active_low = 0,( j; J: y' N, }. ?! M
.gpio = DA850_USER_LED0,' S) z( c$ V8 b3 }
.name = "user_led0",
9 N# e( r" R4 ^. U/ C .default_trigger = "default-on",9 V$ R5 }- Y! N1 f l q% R
},( R) F$ F+ g7 d: f: U+ G
{; ?1 i+ p: A+ {2 U: \
.active_low = 0,
" q2 t5 k) q _" b .gpio = DA850_USER_LED1,
+ @- \- m" `5 O* ^ .name = "user_led1",& o6 U+ k u3 n& d: w. r/ r7 V
.default_trigger = "default-on"," P& T& v* h. r I) u' L$ h/ }
},& p( _& O/ T W% f% Y$ ^
{
8 k a( V% w- q& s1 K: _ .active_low = 0,
( k% K. Z% o$ g- D4 y, U .gpio = DA850_USER_LED2,
' P: G- g7 g1 i! Y0 M* h) k3 g .name = "user_led2",. E6 c( S/ H7 E* j1 w
.default_trigger = "default-on",
7 J1 R" Q: r' l: l" [0 F* c: W9 ] },- @+ o) P7 S; S* B7 F7 n
{( w! s4 j0 |& ~$ c" `- V( {
.active_low = 0,
R0 B; ~+ f1 ]: S' p .gpio = DA850_USER_LED3,
4 S8 @! P2 n! p' B- p! S/ p# Y7 \1 P/ S .name = "user_led3",( b" Z2 L3 ? L' Y7 p% g
.default_trigger = "default-on",
* j" x" ~( s5 K X },! z2 }* E7 Y3 ]7 m0 R6 }
};
4 x5 R4 S5 N. j' ?! E* L: x! y0 M0 Y7 @" W0 d/ x9 J; R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# k7 c# [/ e/ n' } B* C .leds = da850_evm_tl_leds,
- q1 K2 Z2 o" i! X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ b5 x! V! \1 L};
4 U- G+ X! B1 D2 }
; U' Q: ]2 Q! V; Gstatic void led_dev_release(struct device *dev). y X3 E. b1 q- D! q4 c8 F
{
. G# L9 ^. d! |5 F& E) f};$ ~4 r# ~/ [, b2 L& u/ @3 D
2 p& V6 A3 b, `' c4 x# Ustatic struct platform_device da850_evm_tl_leds_device = {
6 E, P" s4 O" }* T* X6 }) A .name = "leds-gpio",' A! y' g: j, W* k
.id = 1,% ]7 F9 n3 \) G) A
.dev = {
4 y3 f5 _4 D3 A" q: f .platform_data = &da850_evm_tl_leds_pdata,9 I6 ~. N+ w+ l: P& c8 e
.release = led_dev_release,( d% G& N$ c1 t
}
" Z+ T, k: |+ T' h. ?% Z};
) U6 f6 P1 F6 Z' p9 V7 F, g
; k9 y* F5 N3 H" m9 _+ Rstatic int __init led_platform_init(void)
$ `# M; h4 \2 G; _: x{2 c2 v" g- ?. e3 Q* X6 s! {
int ret;
; `9 V' d' X2 U I" k, d3 j#if 0" y/ T) D# }: A/ c, `- l j4 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! {2 j" e' A" ^2 c- N+ s& X if (ret)
1 ]9 i. r: v+ A V pr_warning("da850_evm_tl_leds_init : User LED mux failed :", d: L* O/ }1 d4 l: O' S
"%d\n", ret);% \1 i: J% t" p/ ]4 _3 E+ I7 R
#endif
+ [7 F2 m; ` a! d( J; Y/ B1 ^ ret = platform_device_register(&da850_evm_tl_leds_device);4 k S$ N( J6 i* ^! G l) O
if (ret)
9 p4 U9 u1 N% k1 k. c pr_warning("Could not register som GPIO expander LEDS");
$ ^' ^( ]( ]. n/ X v4 V% h) R else
; j* v2 M3 e& t( R! T4 d; @ printk(KERN_INFO "LED register sucessful!\n");
+ z) a* M. o! p/ y% E' C
1 Q# q% _+ f% B7 \ return ret;
8 j$ C1 y, X$ O}- R: _* L& l! { a# l
/ s! X( ^- A; B% g. vstatic void __exit led_platform_exit(void)5 A* p& d9 T4 k4 x0 d
{
; c! Y& K+ S% x* @- l platform_device_unregister(&da850_evm_tl_leds_device);
* L$ ^/ t- h7 U, r; ?. x7 [: S* p% u+ p* m& ?. w' R
printk(KERN_INFO "LED unregister!\n");; ?5 I" w/ [% y3 E
}6 a& K: B# h. c9 d" Y1 g- S
/ R' F/ A2 e x- fmodule_init(led_platform_init);; r& A) C. `4 V; R" S
module_exit(led_platform_exit);
Z' h2 j, B( o4 l Z6 T: ^5 j( |/ y' T- c0 X
MODULE_DESCRIPTION("Led platform driver");; t, O) I/ Z& I+ e2 Q$ [1 Q" _$ E
MODULE_AUTHOR("Tronlong");$ @8 u/ U' p- W r* U
MODULE_LICENSE("GPL");+ O+ L, z! `5 S8 @" U, F& c
# o" i. W* O6 _. {- C3 R/ v5 T |
|