|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( C% G3 w( {6 P+ p
#include <linux/init.h>; X% s6 W7 Q( \ p
#include <linux/module.h>2 x# w6 }5 v8 |/ R3 z( R% `: x
#include <linux/kernel.h>6 {* W# B. E2 i& \
#include <linux/types.h>( A7 _. V5 J" y* |- m" Y P% M) N, c! _
#include <linux/gpio.h>5 h4 P. t2 R2 @3 H
#include <linux/leds.h>
X. k- r# A- D4 [, h#include <linux/platform_device.h>3 J8 w) t+ w p- T" S1 ~& \2 l' P
& h$ W- i1 J! j @7 k- n' G
#include <asm/mach-types.h>3 T# n. X& N9 i" j; d- ?3 H$ d& y
#include <asm/mach/arch.h>
5 S" F/ I$ A/ q#include <mach/da8xx.h> E# j) B2 ^/ ^2 u9 y! b
#include <mach/mux.h>
& \5 ?+ F5 ~% j5 P* ^* q
2 W. N) }0 [8 ~( W$ p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ ^2 `# D( K! D/ v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ @: I, u# \' z! x& H5 O: |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& X6 G! j3 _; U9 i7 R, \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& ~6 J9 \2 ]. u
/ }( E1 \/ U# ]6 o g- B, g: _/* assign the tl som board LED-GPIOs*/1 a6 _5 m6 V4 E S0 j" A. y1 q) C
static const short da850_evm_tl_user_led_pins[] = {
$ _: I0 u8 ~! T5 q& n+ Z) i /* These pins are definition at <mach/mux.h> file */! O* s/ ?2 s w5 p3 s, Z; F' l9 u
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- `9 H+ m8 v4 ~: C0 d
-1
; {6 O! T6 Z+ [};1 b# x8 p( g: m3 q5 ]' c
0 S/ e# {5 ]7 Z; R. _3 l( istatic struct gpio_led da850_evm_tl_leds[] = {
( {/ b$ u: [+ E; M! `; I {
7 e5 F- m' S) H .active_low = 0,
' E; {, A, L; X" n4 f" R .gpio = DA850_USER_LED0,
; ^! _6 E6 k/ }2 t! z" G7 y .name = "user_led0",
! f3 \% Q+ w) J5 _' R5 V4 n .default_trigger = "default-on",
M2 U& G5 Z& W( S) U },! I; D, ]4 B- J1 Y) m1 q! o7 Q
{: C5 m* h# }5 v3 Q, K
.active_low = 0,
4 C9 V8 v6 m+ @, l. `: f .gpio = DA850_USER_LED1,
0 |, @9 }( T% p0 c; J .name = "user_led1",, h. U& C s% d) G: b5 f
.default_trigger = "default-on",& [% F2 d* {! r/ t* q; X) n
},
2 q$ E, y* J* a {
9 p+ n, y3 w" F) C- g, X; d2 t .active_low = 0,
" h/ o* a+ ~9 V7 X g0 } .gpio = DA850_USER_LED2,/ q& r( j9 Q( P: y4 f; d! q
.name = "user_led2",
8 f* U1 {; j) Z: Q' h( ? ] .default_trigger = "default-on",) u0 T: Z9 I: z" n& n: O
},
" n' J: l. ]1 M0 m4 m3 @6 [% |$ d {
' [8 ^" b- p8 O# p .active_low = 0,
9 Q! a1 q G9 F+ k4 H, ` .gpio = DA850_USER_LED3,
+ ]: F3 }7 I7 r .name = "user_led3",% U. _. U* u8 D
.default_trigger = "default-on",# w$ ]/ e( B6 T& O
},3 b1 t+ `& {: J! N
};# h3 I2 A, n$ x# m
7 Y+ q$ K9 ^. B# k% X% q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# g( q3 P# Q$ z .leds = da850_evm_tl_leds,
# @9 E! \3 n/ M5 g: [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," j6 h% F" E, q6 W' o
};. \' b4 P# S; T5 Z& ?" f
" G9 {9 p+ o8 ~static void led_dev_release(struct device *dev)
# f) ^' V) |) |+ X/ j9 G1 u1 {9 M{
% a$ c2 ^2 {5 v5 Z& i7 e) J};
0 D; Y5 @: B% R" a
5 x& {4 O0 b$ C/ M, H7 k" g( z' D+ cstatic struct platform_device da850_evm_tl_leds_device = {
7 `" [& S, V% _* l" I3 O .name = "leds-gpio",
2 c8 Z9 t, A( d! `% V .id = 1,& _ J1 c9 q& {0 H' ]
.dev = {) C6 x. }: Y( i" [: s: _- n4 O
.platform_data = &da850_evm_tl_leds_pdata, w& K, V, [1 a9 L
.release = led_dev_release,0 Z9 ]4 B3 P8 ]3 V! }' ]
}
5 g. ]1 l4 ]( M/ S5 m# E};
2 T! }. y6 I5 \% r" U
" ~4 M/ E& q S1 N! y% |' Fstatic int __init led_platform_init(void)& g$ c4 m$ _& B( Z- y3 N
{
$ X9 r3 e: J% M5 K% J8 K3 B int ret;
7 `/ ~- \ Q+ {/ L#if 0" o! s7 {2 t; F5 ^4 X' ?4 O9 Y$ Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 s9 M- \/ p' Q6 k" ?5 w
if (ret)
: t+ W. p1 `8 `6 m" M4 {& P6 l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' ?) Q/ r# _" w9 s K& i "%d\n", ret);
- m" _3 m) z- Y! J2 u+ y#endif
! m2 [4 n) e# [0 I ret = platform_device_register(&da850_evm_tl_leds_device);
5 {: w- t3 [% m- M% n if (ret)" z& y* n {, \
pr_warning("Could not register som GPIO expander LEDS");
6 ?+ r; g/ g" r3 {, [; b else
% V7 H! J' _3 w7 F& M: A/ s4 O printk(KERN_INFO "LED register sucessful!\n");
8 X; `* \ U- w; p6 ]; s! q) W: D3 b e( D
return ret;
9 J% l/ ^( k& [% I} @1 E- _8 x( I+ a# o
+ I. D6 [- Q, b3 L9 ]3 @
static void __exit led_platform_exit(void)
l" | h+ E5 B% L! `- t{2 I3 D1 q+ h/ a; z) M
platform_device_unregister(&da850_evm_tl_leds_device);9 c6 l- c- N( U; I
: v! K& y9 [/ _, y
printk(KERN_INFO "LED unregister!\n");. y0 Z5 A& t( |; b' e
}
! O* E5 V1 }* Y2 _( ]# ?: b- b. q
( F2 u( O' [" x, I. M. kmodule_init(led_platform_init);$ @. A& y9 i0 @3 F. A
module_exit(led_platform_exit);
- r1 j6 o' Z0 a- a3 M! G( W$ [3 ]7 K* A" s: J
MODULE_DESCRIPTION("Led platform driver"); g- E' [9 t9 I6 b. `8 M+ X3 \
MODULE_AUTHOR("Tronlong");
: S6 ~1 H0 c! l K6 S5 OMODULE_LICENSE("GPL");
. S. R1 e. [$ ~. E3 ]: q9 m7 Y$ O' p: F* e( c4 [- V
|
|