|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
}6 m3 O1 e X) |& H# S- w#include <linux/init.h>. G) h9 u# c$ G9 B, Z+ M: S
#include <linux/module.h>: v& ~* @# C* @4 j: z/ x- [5 t
#include <linux/kernel.h>
\0 o) W# c( h% ?#include <linux/types.h>: I# o5 Q" F& |" k1 E S: h( D
#include <linux/gpio.h>4 _, k$ b3 Y; v D$ D$ k2 T
#include <linux/leds.h>
) }1 ^; C* s" H( \% i( D1 | B+ v#include <linux/platform_device.h>; _1 E. l1 `+ S# O9 P) M
6 F/ [& K8 Y( o3 c#include <asm/mach-types.h>
) R, p: n9 L2 ]! {5 Y#include <asm/mach/arch.h>% W V; g% i4 E3 P7 R; Y0 R
#include <mach/da8xx.h>
* y- U, e2 V. u#include <mach/mux.h>
& p' C' a. ]3 Z# R( w: I
8 u0 J6 e8 Y w( {% ]+ r' v. j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! F8 T6 k1 L8 S" i* l6 J7 ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 w0 \/ v9 h* @. {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# ?" Q( v% U: G7 \5 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ u7 j2 n! s3 C) l/ E0 e: s
& W4 V# f1 e) Z& e
/* assign the tl som board LED-GPIOs*/$ [( P3 S. s7 e Y' n
static const short da850_evm_tl_user_led_pins[] = {
+ b7 Q" {: c; H" p9 ?) S- H" I5 B /* These pins are definition at <mach/mux.h> file */, u2 n* i9 Z$ ^' j! A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. l- @7 w' P% o3 L b% E/ H! N -1
( o+ k8 g4 Y" s2 a( Q}; n T1 `! Z+ |4 m: X8 Z
' x: M+ e/ z6 b, S; ~8 v, h/ F
static struct gpio_led da850_evm_tl_leds[] = {
2 m# j: W( |) d, c% e+ S) q- H* P {
+ T- X" s" b! |* y) R7 r, ^3 ]; d# ~ .active_low = 0,
, {4 Y+ T1 g/ ]7 } .gpio = DA850_USER_LED0,- q- ]" I7 f9 ^* _0 t% S2 k
.name = "user_led0",
$ P+ m4 a( L4 _: g! u+ y2 T6 ] .default_trigger = "default-on",
. f9 @1 ]! g& O* f: Z7 T+ ] },1 O0 o B* G( g; `2 }, W
{. R: R. e# O3 \% |. N
.active_low = 0,
6 P* Q2 `( T; f, u( ]. T9 \ .gpio = DA850_USER_LED1,8 Q0 \; ?& C# ` Z( P2 p
.name = "user_led1",( ^+ S: d; D+ @: D
.default_trigger = "default-on",& O4 `' s6 A" O* i$ P& _" a
},
; N* _- W1 l8 K {
: j; V+ I+ \- e/ E# d% U$ | .active_low = 0,% I1 X- M; `! Z% P$ A" m
.gpio = DA850_USER_LED2,
) ?$ p+ @2 y+ p% q/ D! L; a .name = "user_led2",+ ^0 k+ c: r! L* v& P
.default_trigger = "default-on",
6 {: T5 X S5 C5 Z },( `, y/ \; U; o7 R N* L/ p( s( V/ N( P
{' y8 w3 @3 F* ]+ {
.active_low = 0,
* q$ v: @4 U5 Z .gpio = DA850_USER_LED3,( R1 p6 j. ^- k W
.name = "user_led3",
: K- q, S+ _* [$ R9 ]- P .default_trigger = "default-on",
( N8 s# d; {2 n },3 p5 k, h: x+ b: C0 @9 h& a, f
};' t' \+ }* f& n2 c- c
2 g! Z0 k0 X, B. Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 { I/ y! f, S& d9 L# R .leds = da850_evm_tl_leds,
' g) j/ i' L5 h2 \' P! X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# H- t( b/ \" }0 X/ Y
};
+ F# L) J; z4 F+ c# }! J, k/ E* t, y q0 S, B+ O4 A
static void led_dev_release(struct device *dev)
* {. a6 `. Y' L D- f/ k; W{" p1 |4 B# P# F1 @- C9 w
};
( l* _/ q" M: j4 U/ C: g. d2 o! e, l [5 D7 A+ ?: u
static struct platform_device da850_evm_tl_leds_device = {/ g/ ?3 Z. n( |( F" ?8 }) S/ t
.name = "leds-gpio",/ q- Q9 f. ?( k; A* w4 i
.id = 1,' {" o4 l7 z5 \' x4 C& l
.dev = {
: ]7 D& {; F9 b8 t; x6 L .platform_data = &da850_evm_tl_leds_pdata,! c4 n" Y3 g0 v" H& W' N$ p
.release = led_dev_release,
) h+ E# m& K1 k( k! Z }
/ n. O* o2 M, L* J};
4 o. e/ E6 }% ~! m& y- m% a) A5 e5 j9 L8 f3 J% d# [
static int __init led_platform_init(void)
2 h5 g0 y! L& u: `( J8 o: Q! j/ Z& K{6 Y& l8 N$ d6 [& ?" R- ^% ^
int ret;; K! V6 v0 a; ^) {
#if 02 H- P; ?) R% t% X& s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 L/ X" a) a- i( n, h
if (ret) ~% F5 u, f1 N; U8 c( N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 @- K5 |. a9 t- p4 n "%d\n", ret);4 t+ u, w+ s: X! e/ c) G
#endif- |& p3 n, N! _$ n; Q, q4 l" t! d
ret = platform_device_register(&da850_evm_tl_leds_device);" w/ H; H |' F4 f Y
if (ret)
8 P" v4 b& p* V pr_warning("Could not register som GPIO expander LEDS");
( q) E" Q- W( ^) B$ w. Z else0 Q" q1 ]8 f# D0 Y* n9 ]
printk(KERN_INFO "LED register sucessful!\n");, X8 m0 I2 K: a6 T
1 c/ m* B1 {6 ]- e return ret;; e- D" ?2 U# O! z; g
}
2 @3 C$ z* m2 k' D" h1 m
" S# G, c$ j. l. Q; D2 R; |" ostatic void __exit led_platform_exit(void)
% A9 e* j- C y( \% g) _{ z# W5 E, K# @3 Q: @ B
platform_device_unregister(&da850_evm_tl_leds_device);
z6 n. Q O. P
1 ]4 _* S) u2 s printk(KERN_INFO "LED unregister!\n");
# b/ r' h4 E# n; g% ~}
# B3 `" ^, C! K5 J8 J4 A& Z+ d9 G, S; i8 Q% I
module_init(led_platform_init);/ j1 d- S: Z3 j+ J: y. B6 b5 H
module_exit(led_platform_exit);% |- ~, s* z' F
1 o! _, g* x2 n0 |7 L- [+ R
MODULE_DESCRIPTION("Led platform driver");& n2 u, ?% E, ?$ S- ^
MODULE_AUTHOR("Tronlong");
/ f9 U* [+ I6 D9 W" v4 d! ]MODULE_LICENSE("GPL");3 d# X1 l$ O T4 s
) k4 G, Y5 c! Y
|
|