|
求大神给下面的程序做注解,请稍详细些,谢谢。) x% q2 _/ k' K: n: E
#include <linux/init.h>
0 O9 U2 [& x; C6 x' a#include <linux/module.h>
5 c$ g5 D; W1 E0 S- b#include <linux/kernel.h>4 z5 ^2 y6 F8 }* f x# s
#include <linux/types.h>7 S+ h& n7 m4 c( V+ `6 c. m5 m
#include <linux/gpio.h>
9 o- p; ~- W5 g0 U) `4 e7 L' {#include <linux/leds.h>
^' D5 y2 l6 H5 {. R7 O#include <linux/platform_device.h>
2 p5 ^" ] E; [! v/ d- l# @
) A' O: ?, ^: D6 `- a#include <asm/mach-types.h>
' i: I5 C( N) o1 l#include <asm/mach/arch.h>' C5 o. v4 s8 H9 i4 w0 O6 p+ Y
#include <mach/da8xx.h>+ \4 D9 C# O' `4 C% w2 y& b
#include <mach/mux.h># v1 k" K6 e1 a5 R
- n. |8 j \% }+ Y8 k( T" V( O2 {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) ^0 x j2 h6 z; [# \ x% a! h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 c4 J, F6 c$ B& d. H3 D8 G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 }8 R! i) t# `: t, P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! t. x2 ~1 y/ c [9 D; y J3 r
; [7 C! I6 t- T/ y/* assign the tl som board LED-GPIOs*/
) B( D* N3 b4 g$ V `! sstatic const short da850_evm_tl_user_led_pins[] = {
: w, [4 r; ^: e2 }/ F: |" p; ], | /* These pins are definition at <mach/mux.h> file */
/ k: B; s4 h1 f+ `, f- a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ O" \3 I7 T% m
-1, ^- I! u& |, o2 f! v, X) C
};+ _3 H: \( i8 w" Q
& p; T r2 Z' p+ D _
static struct gpio_led da850_evm_tl_leds[] = {
" `7 V Z0 f1 z% B7 a- ?1 n {
$ K1 w, P# |; \8 `. N4 A( H .active_low = 0,
$ H$ F2 w( I4 T .gpio = DA850_USER_LED0,5 y( ~' o# Y9 X" U" G' h7 U
.name = "user_led0",& y) T0 [6 I& D, {
.default_trigger = "default-on",
! J9 J( _# {( f% J },8 V5 W/ W/ w) H; h9 E$ K2 I
{6 m4 {- [6 @* E$ D; J7 l- Z
.active_low = 0,
1 y4 \. A5 e4 @( H6 y& o .gpio = DA850_USER_LED1,
, a$ B1 M) h% g$ W .name = "user_led1",* Y' [) h9 z0 |7 @- T; K# J; G# Y* e
.default_trigger = "default-on",+ u/ m* {; Y. _$ f" p
},% W, D# v% C' p- m0 Q
{" N4 M: m2 n0 N6 V8 i8 K: q
.active_low = 0,, ]- h9 R8 L& g1 F
.gpio = DA850_USER_LED2,
1 L# @. {7 R4 z, j; K" p* B/ w .name = "user_led2",$ m7 Y3 r! z3 P/ K5 E+ b
.default_trigger = "default-on",$ Q b) y' Y$ F( q3 m
},
6 s) t( w6 u8 q2 N/ I {) f) U. u1 g" S x0 A0 f* I4 g
.active_low = 0,( `1 T4 u8 G% ^5 S u$ b
.gpio = DA850_USER_LED3,
3 a G, V O" Z: t* F, a .name = "user_led3", c! H4 |2 }7 g. s* u. X4 M
.default_trigger = "default-on",4 d2 u4 z( _1 |: U& W8 b2 x) C! _$ d
},
/ r9 I9 ^% Q9 [" C4 E) U5 z};( x5 L4 {. p" b% h2 Q( k1 G0 Z
3 K+ L: e& z( N" N. I9 c- ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 H1 x0 r9 ]3 V. [: ]) l
.leds = da850_evm_tl_leds,* \) j0 U7 F- p2 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," o3 A% n0 G7 ]+ z! N% O" C
};
4 P$ c4 a) b1 g6 S8 ^
% I. G- G, Y; ?+ R7 b K1 ~6 v3 }9 Cstatic void led_dev_release(struct device *dev)# l3 u( F9 D/ X4 L( r
{
1 N3 U/ U- W* l+ g& O. T& {$ i$ O};
/ W& o& L# M/ ^! C* f+ g# q$ k, t
static struct platform_device da850_evm_tl_leds_device = {6 |- B7 P( F0 _. _
.name = "leds-gpio",* m. V z, ^5 Y& p) q: W
.id = 1,
1 i9 B2 h" l& q .dev = {
, r0 D% p* H) m& y4 g M .platform_data = &da850_evm_tl_leds_pdata,7 S2 P% @: w/ ?% T
.release = led_dev_release,
1 }# X/ V, r1 a/ v& L7 D8 ` }
! N( y: `; |3 u9 H P: i y};9 O: ]- l3 G1 `/ e" l
) n4 m# P* y- L* s. Vstatic int __init led_platform_init(void)+ V" J/ v2 I+ B: c1 t2 v2 z$ E) _
{
- g& v7 v8 C( e int ret;. S# B$ f3 s y3 a# y* b- Z$ X
#if 04 J) a6 c( X* j" k q) _- [+ `* s( f, F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 `$ q1 l! h& y. j
if (ret)
3 W& O4 {1 {4 O0 H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" g: I0 Q, V! ^- b "%d\n", ret);
4 q( _+ h# }0 E2 g#endif7 J. l6 S3 U/ g% h
ret = platform_device_register(&da850_evm_tl_leds_device);! t; _. z' ~" K3 \8 ], ~' q
if (ret)
( ~8 E9 G5 G4 R! [/ k3 g0 u pr_warning("Could not register som GPIO expander LEDS");
' E9 t. k; F8 K# c else: x, p- U/ ~9 A* v
printk(KERN_INFO "LED register sucessful!\n");. V! X2 F4 q: X% _; u
2 k4 ^' l; L4 K return ret;; F* |9 ?/ W% ~% p
}5 h! _8 Q8 k4 h9 |
7 I: o% ^, f* Q- {( estatic void __exit led_platform_exit(void)
$ v. ~1 h0 x% Y% Y: f7 Z{
* {4 n" p( [& ]7 X: P4 X# h platform_device_unregister(&da850_evm_tl_leds_device);% v$ [. `( W1 j- O6 r
4 p) o: ~/ |4 \) d
printk(KERN_INFO "LED unregister!\n");4 `9 ^+ u2 e9 J/ m
}% T7 G( ?* B+ C5 c* h
( ~1 n5 t8 R7 I# c) fmodule_init(led_platform_init);+ B5 j/ K& ~ E& m! y
module_exit(led_platform_exit);
! s$ L/ o3 y, S6 H3 M
& ^* t* y: c! Z6 b& b' ]! cMODULE_DESCRIPTION("Led platform driver");
4 V+ S$ b+ I8 f9 N8 XMODULE_AUTHOR("Tronlong");% p; `3 D" E Y, _) v2 u
MODULE_LICENSE("GPL");. ?7 O4 C- Q7 N
- n, D* L- Y8 Z5 E |
|