|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* `3 g k( b! j& z( p8 X7 g
#include <linux/init.h>
P {) Q3 B& l# ]& U#include <linux/module.h>4 h2 Z4 z& Y. k9 {$ b/ ]" }7 ~" C
#include <linux/kernel.h>8 B N7 R. s8 p0 r7 C3 T) O
#include <linux/types.h>0 ?9 D }( I# ?& f) j
#include <linux/gpio.h>
2 n4 i. ~3 n* T1 V#include <linux/leds.h>
4 |! {, a1 Q$ k2 [6 X: E+ n; d#include <linux/platform_device.h>
' U( e! v* H* u' c9 m8 O. k5 _& ]. S0 u1 B
#include <asm/mach-types.h>
; j5 z6 k) N* [) D4 {- b% @/ Z#include <asm/mach/arch.h>
5 p' m* P. n( }1 c: `& L# w#include <mach/da8xx.h>
& ?* U" T G: S7 R- f#include <mach/mux.h>
5 r1 A( r% V( x7 j) E z% d" s- g3 I& i4 i8 c0 f" c0 r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 ]4 P# y' h6 _; p% h+ `5 i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 Q5 v1 Y+ g6 N L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ b) ^' G/ @$ K0 e# ~# N, A" S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 o, Y+ B; l, B1 M" O" ], Z' Y+ E; \2 k% O# O
/* assign the tl som board LED-GPIOs*/+ [+ j4 h5 e/ J# w0 q L+ q
static const short da850_evm_tl_user_led_pins[] = {
: u# o3 m" p0 X8 u /* These pins are definition at <mach/mux.h> file */
% q% Z% X$ j/ q d/ z& S9 y/ y: \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ E8 j" V$ C5 l4 ~ m
-13 s% _. ?" U2 C3 v; _
};0 r- I w' N4 g& t, |" L
4 q5 A3 w$ h+ m! B: J2 c
static struct gpio_led da850_evm_tl_leds[] = {0 v, [2 x) p- r) m
{
9 R6 M& Y. ^# m5 E$ Y .active_low = 0,2 H5 l/ z) |7 [# k, q' M
.gpio = DA850_USER_LED0,4 I5 v* s- t0 j
.name = "user_led0",
; t& K% a, F) {6 i4 a& k .default_trigger = "default-on",
7 S5 _5 k6 l- a6 t" Q1 x$ \ },( r+ M" U5 b: ]: m- z
{
- @$ J3 [5 b7 c8 T0 j$ q .active_low = 0,
/ p& g2 J6 P R3 Q .gpio = DA850_USER_LED1,6 v8 `. O- s) {$ l8 ? t
.name = "user_led1",: v0 S- z [8 ^1 A1 R" d
.default_trigger = "default-on",8 g; ]( Z6 R j1 \! k. F
},8 G, w, w: C" `& I2 h5 r# O
{$ O/ Q& X9 `8 R. _& K9 {
.active_low = 0," J6 H# ~% b6 U- g
.gpio = DA850_USER_LED2,% |$ _/ C0 U9 T7 b
.name = "user_led2",7 h' u( s* d# i' ~% [# [& w
.default_trigger = "default-on",
, U0 h3 L* b$ H7 T9 {- C },
+ B; [0 E% p$ s! K( _7 }) v( f# U6 h) w6 g {
j7 S) S, V" f .active_low = 0,
- U* A0 v2 J* e5 A7 S .gpio = DA850_USER_LED3,
+ F/ r% l# s: |1 U' x% M) x .name = "user_led3",5 D# S% _* U# B5 X
.default_trigger = "default-on",
' X8 @; g; G' p+ b, U* c },7 r! \' E6 f8 R% n8 U# C, ]2 h) K6 Q
};
) c) p. _# }) X; t! V2 h# r* r/ \' Y7 T) Q& L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 V- Q& ~9 ]( {4 M6 f5 y .leds = da850_evm_tl_leds,: {+ w q9 ?& y* {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 b) |" K( Q% u, |$ T+ U1 w};
) G$ b0 o! i( u# ~( j9 Y
( o" X: ^" v" o( R# a b" A* c' Gstatic void led_dev_release(struct device *dev)
2 t; a7 J8 i5 W# h: m( A! O0 ~, J{
I# u& N. `6 [% \7 W1 j};
; }) \/ T) a5 Y* s+ c" U6 w
/ B, Q5 q+ t8 I1 h- s( vstatic struct platform_device da850_evm_tl_leds_device = {5 [8 ^( o, a. |: g; |8 k: `- K
.name = "leds-gpio",
1 m/ k# Q6 I: q/ \# _5 R .id = 1,/ {7 ~9 e( O% n' R" Z# Y2 `: e* B
.dev = {
- R( H2 \% A0 r1 T4 K- J .platform_data = &da850_evm_tl_leds_pdata,) x# m$ s% H t7 \/ Q. o
.release = led_dev_release,
# c7 D# u* k: ]0 g# m }9 e& w: ?7 L/ \, Z8 M4 c% h
};0 _8 e% k) K! \( \6 I! A: y
% U" R8 g- [7 B h7 S- f0 F n% L
static int __init led_platform_init(void)
1 U4 g \8 c9 m8 v9 k! o2 R{/ T& H& d6 k& V& |% j3 D7 e
int ret;
# T! W7 k1 S: ~ I" Y" V3 C#if 0
: \, a; ?) ^# h: g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 X% p$ U. B- |: Z& q! D
if (ret)& _% ^: K( Z! M' `/ ?$ ~5 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 F2 y- n3 X1 ~6 J% w "%d\n", ret);' u) q2 `9 y( n4 \
#endif6 }% [! h; O' X- m* T: }+ @
ret = platform_device_register(&da850_evm_tl_leds_device);
; \) x, W0 X( M; H+ s if (ret)
/ L7 g5 T/ L1 k/ v* B3 I3 r( l9 { pr_warning("Could not register som GPIO expander LEDS");! u0 ?3 v$ e( F
else
9 W% j; h1 V0 ~3 O printk(KERN_INFO "LED register sucessful!\n");
# R9 w# I) N* c5 W& Z" N l0 l3 @# b. m
return ret;
: |& E- P- d$ J$ o5 V' x# m: [}8 Z3 W$ G ?5 {1 s; {1 L, w. h
$ |) n1 |: t$ R5 t- m$ c$ A' d
static void __exit led_platform_exit(void)
! s4 X. T& p$ ]$ [( b2 i{" @; [ Y1 w$ a. C# _
platform_device_unregister(&da850_evm_tl_leds_device);( _2 O# z6 p0 R' D ?
4 G q# P# V* u8 ?
printk(KERN_INFO "LED unregister!\n");, u; x8 A" T+ ^: V5 I) E
}5 L! |$ s7 `2 F9 s% a# I
7 O; U V' y* c2 y+ N
module_init(led_platform_init);/ V% O, X+ _, n, }; ^
module_exit(led_platform_exit);
' t- l; I" U& |" _5 D! o; V
/ x# v- b- Y# m. }% m Z1 AMODULE_DESCRIPTION("Led platform driver");
* o, ]; K- V0 n" b6 @" S9 P4 z7 iMODULE_AUTHOR("Tronlong");
1 O5 G, a9 X/ N9 o7 I3 hMODULE_LICENSE("GPL");
: R, Q; c5 u6 ]# P/ k
; |6 t! J1 p! |! M; _5 {( a |
|