|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# k, b9 i% z: h6 |# O1 R" L
#include <linux/init.h>( c) w* P5 ~+ N
#include <linux/module.h>5 e/ p$ F. L* n1 G7 H2 d8 s8 J( ~6 k
#include <linux/kernel.h>0 o. @) g, X' b% D
#include <linux/types.h>* t0 H5 f+ v8 N% {/ O
#include <linux/gpio.h>
2 r& H9 |- _3 F- m9 D1 G2 r7 o#include <linux/leds.h>
0 r9 K, k# V- F5 H) X: c#include <linux/platform_device.h>
; G) s4 u( u4 U+ ]- O) G# P# x8 p
#include <asm/mach-types.h>
0 @, Q( X5 O# p' o/ R& G8 g+ W#include <asm/mach/arch.h>
2 \# y) x* Q$ U" X3 X+ k#include <mach/da8xx.h>
( k) x6 j/ ]- j- w# {, Y2 p. T#include <mach/mux.h>+ H; ~( B2 B; E" `" `
! P6 p& B8 P) {& c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) q' \& r* @3 v1 t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 x* S5 O( z1 r$ _1 P" J+ `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 g. W8 s N' J9 A7 p+ Y( l2 l+ Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 ^& ]( W* O) ]
) r; _0 W- x; P% O
/* assign the tl som board LED-GPIOs*/
/ m1 R( _- f2 x/ ^static const short da850_evm_tl_user_led_pins[] = {: z) y3 A3 N; `) r
/* These pins are definition at <mach/mux.h> file */8 F0 x$ D0 c% k1 S. ~; g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( e7 @) o5 s; ~) `
-1! Z/ h+ m/ b! f( k* r
};) ^5 u; h% M( }6 l
3 h0 h. ^" h5 q1 G8 q, m9 O* vstatic struct gpio_led da850_evm_tl_leds[] = {
. v; c- M+ z, {3 c7 V0 x# K6 J8 T {% }( r" j7 F$ s# Q. @3 f- b& k- R
.active_low = 0,9 N* O+ y" @! W
.gpio = DA850_USER_LED0,
1 r. n- b5 q# _+ S( n .name = "user_led0",
, K* t" D0 t4 W9 S7 m3 F. t5 Y .default_trigger = "default-on",: S5 ]! W$ K# ^) i- k4 i% ?" g
},! p2 ]* {% j, A! I9 u$ Y4 n$ }2 [
{
% |. f! j9 y2 K; } P0 ? .active_low = 0,+ M4 z, J, q, f; E- Q
.gpio = DA850_USER_LED1,
. W' L+ h8 ^! B .name = "user_led1",9 z0 |; n5 s3 t
.default_trigger = "default-on"," ^- i# `1 j. B- h2 E' c* Z6 `
},
E/ q* h* ]/ Q" I) \9 H+ I9 V {$ `* t1 Q% A/ X1 z+ F6 M
.active_low = 0,
; t5 @, i+ m+ b1 |1 _8 `% { .gpio = DA850_USER_LED2,
( z# i' n9 }2 U! h# @ .name = "user_led2",$ h1 J& Z! P1 }7 r
.default_trigger = "default-on",
) L( |3 w( s7 f7 T- N h },
; j0 O9 Q$ b0 G3 H {8 Q/ ?7 M- e- H! W1 i
.active_low = 0,
2 b: A4 {8 M G/ o .gpio = DA850_USER_LED3,
- T( T- F; `8 G: N9 K7 H! [ .name = "user_led3",
, D! l- ]4 P2 T# |0 M+ v7 O .default_trigger = "default-on",$ u+ O' N1 o9 ^+ Q9 M* ^& L
},
: a, \( z8 C/ r3 V};+ N3 D* ^7 E2 `) n) q" N' _
. _3 P8 f0 e9 @- ]0 y5 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, p6 X! ~ K+ I/ z7 N
.leds = da850_evm_tl_leds,
; {( H/ f4 j! r3 k2 ]3 {9 l0 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; A% F0 K; ?, V5 J2 k n9 F9 \
};# Z. b0 n8 c: f
( V9 y8 S- a/ b/ `) \2 y0 Y" j8 s; L
static void led_dev_release(struct device *dev)
9 O$ ]% R7 f% ^* n2 l{9 j+ L' }5 P9 ?7 F8 ^" o
};+ q- g+ p! T1 g
3 y% W; {1 t, ?! ~. Tstatic struct platform_device da850_evm_tl_leds_device = {
6 }4 U( g: g' z7 { .name = "leds-gpio",
9 P7 R$ ?4 m( W .id = 1,: e! H, q6 ^* O9 g2 B. o7 V' d
.dev = {
% q+ ^7 e6 n3 K; X. ~2 W .platform_data = &da850_evm_tl_leds_pdata,# f3 q) O7 C8 L: w
.release = led_dev_release,1 R3 i$ s) M W0 Y% E: c% |! @
}
* u8 \+ P+ w9 k+ w" n! F: B};
5 g- d7 t% b$ |: a1 I; C
7 K4 q% Q$ ?9 }; }static int __init led_platform_init(void)
1 \2 g# l; U$ H+ V{
* @, F. r! g6 U9 _- V3 h int ret;& S s% d$ z. F: ` n) F
#if 04 d) _1 J( f; ~4 F0 l g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 _- j; {& t" ]. A+ f if (ret)
- H: Z* ?( l& c% W1 m* N pr_warning("da850_evm_tl_leds_init : User LED mux failed :" @/ {, n. g( }* f
"%d\n", ret);6 G x# |" j4 r8 T
#endif& u5 \' w9 A9 x' {) u) N
ret = platform_device_register(&da850_evm_tl_leds_device);
; U7 X! L7 u! c9 S0 S/ h1 P8 z4 a2 v if (ret)
8 d1 N0 {7 A0 r% s8 U pr_warning("Could not register som GPIO expander LEDS");% `1 c( v4 K E; B6 o1 f5 u
else
- o7 d+ x" r* r$ i6 |; J3 ] printk(KERN_INFO "LED register sucessful!\n");
0 N6 j2 q8 }) [3 E- q9 t/ j8 U3 ]
0 ~/ a9 b( E% v7 V( f return ret;
9 Y1 i: p' N' C _) V+ ~5 v' v}
' I* m/ |% H9 u3 ?0 F, `8 k. l/ g Z# T3 H, g
static void __exit led_platform_exit(void)1 G' s e X- Y: O( r: C
{: C2 g. _! Y' `; e
platform_device_unregister(&da850_evm_tl_leds_device);1 z8 H: I& G0 e" `9 k- @( e
* z* o, ^! Q6 E. b3 y `- ?
printk(KERN_INFO "LED unregister!\n");
$ ^- S) ], l( K2 q9 t}3 C0 H, [% B) N# x, R3 ]+ u
) I: F1 r4 i: I) L. ~1 b% f
module_init(led_platform_init);
1 y) A% n: }! a( N) umodule_exit(led_platform_exit);, T3 w7 F, e. l" b$ J: T
9 X& P" g6 \! R- K6 g+ k9 U9 P- ~MODULE_DESCRIPTION("Led platform driver");7 _9 i" w' B! _4 O: f1 [4 z6 P4 Q
MODULE_AUTHOR("Tronlong");
! |1 L3 [" ]) T* r+ ?9 q) PMODULE_LICENSE("GPL");
; |* [/ {9 c/ [7 x, P8 e
9 p5 i* n: a5 k; Y( v |
|