|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# W& W2 ]0 Z2 L3 N& C/ y- [#include <linux/init.h>
$ s p: M/ {. O* ^! e3 C. m#include <linux/module.h>
+ I$ r! u8 r7 f' C2 F/ Z#include <linux/kernel.h>
( ?4 }4 k0 b# [) o8 d2 j' V#include <linux/types.h>! }3 R5 y. Q- I2 y3 m
#include <linux/gpio.h>' t: K- F2 r/ a H0 y& C( X
#include <linux/leds.h>
: j6 n- I% E( a+ }, c" C/ B1 ~#include <linux/platform_device.h>
: ^# z9 f: Q0 Q$ I9 K1 X* {
/ O0 x& Y" s4 J; }/ w1 ~/ _: I#include <asm/mach-types.h>3 k3 H; Z6 b+ L
#include <asm/mach/arch.h>; [& l& j1 ~4 }6 E& x: A1 p# G; Z
#include <mach/da8xx.h>
% L! }- f6 q& g8 i9 |7 y#include <mach/mux.h>
% M. X1 T r8 w6 v2 P- [! C$ L9 `2 G9 z* P2 |* b' i$ D; k; G/ `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- i6 P: c% p7 U5 l% y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 }/ O9 v) n$ |* F$ l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ J$ u- o$ c8 o, k' D! [+ n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 _. S8 _- P% q9 K# _! N6 Q1 u4 A$ @1 P7 A1 _; @% o# B
/* assign the tl som board LED-GPIOs*/
! S2 K# c9 |5 N7 G5 y- _- k, Cstatic const short da850_evm_tl_user_led_pins[] = {
: r5 i' G+ W$ R& U /* These pins are definition at <mach/mux.h> file */
1 v. Z$ B2 y) [9 q5 a9 `& p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 q3 T3 U* D, A* v
-1
; N9 I5 I' J' a$ x u7 w0 P};" b5 w# c0 c. o6 U
3 T. j4 J, Q7 t% L1 E9 t9 r. astatic struct gpio_led da850_evm_tl_leds[] = {- k" a( M3 ~( B3 \7 M: k
{
! U! j/ S7 U5 ` .active_low = 0,
+ w/ u! R0 A" h .gpio = DA850_USER_LED0,3 ?; q$ U% b1 `- C" F
.name = "user_led0",' u. q/ {+ g- \% i
.default_trigger = "default-on",$ ?0 q3 N4 J _. T8 J
},# j4 ?! k8 @; s. U5 T2 h( w
{
/ z1 f4 T9 w o3 m7 `$ L .active_low = 0,& T$ E2 V4 `$ t) M+ O* _5 A+ e: B5 c
.gpio = DA850_USER_LED1,
% p7 E% \: y+ Y+ U [2 h .name = "user_led1",) ]$ l5 C; W" }% @0 ~! o f
.default_trigger = "default-on",- H! s: ?+ h6 ?9 F
},8 d8 e' R8 L* x- d* T' g
{
2 c5 M0 s5 i; {4 C' ` .active_low = 0,
1 P( w4 w% g) d6 |6 G6 M" m .gpio = DA850_USER_LED2,
( s) C8 L; ? K5 g5 y! r1 \ .name = "user_led2",! H4 A' o1 q# v2 S3 z) g
.default_trigger = "default-on",
1 b+ l' ]; R, W5 c6 P4 N2 P },- c0 i3 v- F0 Y C
{. [- F3 |3 g, G. Q' ?# P; U. J+ X
.active_low = 0,
+ Z% y6 o% n2 C0 _4 Y6 | .gpio = DA850_USER_LED3,0 }; p7 N+ {+ V2 b) j; y, \
.name = "user_led3",: ]) x X) F9 ^' [. t3 c
.default_trigger = "default-on",
1 }( Q6 g2 q$ ? q2 F- B- |, C }, P: J% E9 {" P& c2 N# Q. Q
};
: z; ~) `/ T7 L8 c. T2 s J3 i4 b) T' ]( C. f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 ]- N b' y; O
.leds = da850_evm_tl_leds,
0 @4 C- F3 h" O4 G6 [: \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ `% ~$ G+ P0 e$ Q" d1 w" Q};. m7 ?8 R3 V( @: I/ v: d1 \+ u2 z
8 V* N0 j6 |* A9 p( S) R- Y
static void led_dev_release(struct device *dev)
8 X& l- ]' ?0 E" J- L. ^# f3 S K{
9 C2 _! c$ {. l5 R};
G. T6 x* y' w1 p7 ]$ j3 K2 D3 n5 a( I0 `
static struct platform_device da850_evm_tl_leds_device = {
5 b$ T3 L) r- E, f S# _* h .name = "leds-gpio",
( ~" r2 O, C' r& Z% K1 R .id = 1,+ f* v y' K2 Y+ Y0 W* b
.dev = {
7 q; m; D( o- t .platform_data = &da850_evm_tl_leds_pdata,
" V, z3 Z2 a# p6 I .release = led_dev_release," q: d' U3 @0 b4 j3 W" W1 R
}* J c$ C( ]0 E1 T0 D9 G5 v2 J
};0 J) k+ U( b( | J
" e2 t! d( O! @
static int __init led_platform_init(void)# Y( u1 H e( L8 L' L8 V
{5 E* G3 C+ S2 ~/ P" _
int ret;
, k: V% M8 x1 k. p1 B6 X$ {#if 0
; f5 F6 _. e' K, F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; S0 o. b5 b0 f. q% o% B if (ret)
% ?! j- \4 u. @! ]: o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 [* g( { f R" ?8 [; k
"%d\n", ret);
5 I% V2 u! V. q6 ~; b#endif
2 A0 Z L" u' y+ C8 c$ `+ ` ret = platform_device_register(&da850_evm_tl_leds_device);$ L( a: A$ t- U6 s
if (ret)2 I/ S; R2 H7 M7 x: Q/ C* b
pr_warning("Could not register som GPIO expander LEDS");, y8 C' F) W$ i) j& Y/ E; D, V2 `( R4 p
else
2 H7 R9 o' |0 W6 t) A' k1 V# [ printk(KERN_INFO "LED register sucessful!\n");; U7 U! h! ^) F$ z4 a: a
$ I+ r7 k; E! Y- n( J; Y2 }5 U
return ret;9 D5 k5 T P0 N4 q+ z6 Y
}' g* b! a/ b& @4 s; k
/ y2 `9 I: @, C: P
static void __exit led_platform_exit(void)1 N* D6 m9 t( J" D) O. u4 B
{
/ j) e [ n, i platform_device_unregister(&da850_evm_tl_leds_device);
/ r2 ~! \$ ]# |6 K' h7 r5 q4 _$ K8 |) m0 e
printk(KERN_INFO "LED unregister!\n");# B3 U/ v% O' n2 n3 `
}/ o/ M9 Q2 ?+ Z" {: x$ t
. Q# j. c( H6 u8 M$ U) q
module_init(led_platform_init);
$ j- Z- T$ }9 U( T; `) l5 umodule_exit(led_platform_exit);
6 F$ E7 B4 |9 o/ a5 I% r% C7 z/ k5 }& y# e7 k6 @
MODULE_DESCRIPTION("Led platform driver");
! P2 s7 F7 q% n& o8 ?MODULE_AUTHOR("Tronlong");; R9 X8 O: V7 m: N: G+ J7 N
MODULE_LICENSE("GPL");
7 G, _* Z, @" L. q- E5 i$ Y5 z0 y, e9 ?( K
|
|