|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" ]/ ]- @* t8 c: F
#include <linux/init.h>. c& C) s4 x1 E" R
#include <linux/module.h>
0 G* u( c C& p- I5 y1 n#include <linux/kernel.h>
5 d) c3 X5 t0 G0 z+ ^5 k0 o/ z#include <linux/types.h>
" F2 ~& f' [7 c( y#include <linux/gpio.h>
+ a: }& [$ A& f( W7 M, y#include <linux/leds.h>6 a0 P7 `4 L1 w, m: O! y! a
#include <linux/platform_device.h>2 G: L# g6 x, |$ Z4 _! A$ ?, e
0 |2 ?' _* ?# P$ m1 N" t#include <asm/mach-types.h>
4 \5 ]9 Y/ c1 p0 |, S6 K#include <asm/mach/arch.h>. I% `5 C) q! F- G M
#include <mach/da8xx.h>
% j! ?2 X' [2 |* J8 {3 i6 T% |: _#include <mach/mux.h>
: ~, N9 w7 d& @; G$ E$ g" r) s/ t4 H
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" b; u1 ]# Y7 x9 W' `% M# U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! i" q B1 ]3 q* T' I9 {5 ^ T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 r& V; \- Y. T7 `1 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( R: E/ x0 D; g% |6 X/ ]) P& L4 C% ~/ N0 W& W+ u, U
/* assign the tl som board LED-GPIOs*/! D! \4 S x. t) E
static const short da850_evm_tl_user_led_pins[] = { @) t6 O6 ?8 {. d- J" g. t
/* These pins are definition at <mach/mux.h> file */1 v0 U7 V7 z! W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( {8 {+ ?, m( D- }$ ^
-1, E5 K! I5 G, c9 {- O% o {& o0 S
};
. O: s6 k8 T+ j+ L$ }- I
% r1 i$ h2 p4 F$ _static struct gpio_led da850_evm_tl_leds[] = {
- A5 g! t' G3 p2 G1 P {* {# Y: V' U; V+ n+ `6 D
.active_low = 0," E, l' G( l% E( h2 U
.gpio = DA850_USER_LED0,
' o \; X9 D: _; H8 W7 `8 s .name = "user_led0",. ]/ \% a" m' M5 N ~1 s8 |9 _
.default_trigger = "default-on",8 n0 j" l; j, P/ z, ?7 g+ c
},1 s6 ^' d4 E5 I8 n6 [
{" A1 T4 y N7 `4 W6 y2 ?3 |# Y7 L
.active_low = 0,
8 g) W2 e- f3 o/ v4 @& s! w .gpio = DA850_USER_LED1,
0 ?0 \; L q; C- B% c6 t% U .name = "user_led1",
7 c% @. t! e( ^8 R, K# K .default_trigger = "default-on"," \% ^$ k1 D8 z: [, W( i5 `
},
' [/ K4 p2 |+ ?6 a9 t {
) C+ D1 B7 T. E .active_low = 0,
' M1 e- w G0 r .gpio = DA850_USER_LED2,
% t# Q4 R: q+ S9 E! o, l; A .name = "user_led2",
1 }* T# S; C% ?% h+ @$ U .default_trigger = "default-on",7 l$ N N7 ]* \, h
},+ o* F8 |) [& M1 M0 {& k# B
{" f1 x; C9 z7 L+ G6 z9 u
.active_low = 0,, h) }% g6 u- {% @
.gpio = DA850_USER_LED3,, H3 D b) L$ v# R9 l- Q; z5 V
.name = "user_led3",
* u i4 |* \ o: F$ `0 r9 | .default_trigger = "default-on",+ p! L' Y5 O4 Z$ P
},
% Q4 Z7 |9 h6 h% ^8 ^1 y% D}; G! V- t; n" k+ m; z
& |- y2 c. v, `* p( ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% Y N O2 t* b .leds = da850_evm_tl_leds,1 x: B" ^, D) A3 B# u
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: A- Y9 D: W& _1 v+ d
};. m9 e, J3 m7 ~5 q% {' T
2 ]* R$ v3 i+ A2 K7 x/ s( E7 C
static void led_dev_release(struct device *dev)) ~3 ]7 p1 Z/ O8 p' `& j) P' ]- N9 ^
{) \0 w. `) J( D$ K
};5 b1 S- j$ u! ^1 t {* ]
) [, Q% k0 Q8 Q! T& Z' b5 @
static struct platform_device da850_evm_tl_leds_device = {
% M2 ~: s' F* Y* Y7 |6 r& {0 G* \ .name = "leds-gpio",
/ o8 y4 a& P& n; b .id = 1,; U; f: v/ s( A
.dev = {
! S4 Z) r; o! {# [& @ .platform_data = &da850_evm_tl_leds_pdata,
7 G7 I* P2 |' \# z) ` .release = led_dev_release,
# k6 W* c3 Z: W- }/ b$ O }0 T; W' k9 ~1 m! Y$ W6 G6 a4 @
};) K9 d9 J1 Y8 V) c: z* [! P
b8 o) Q2 J% m8 { ~! P
static int __init led_platform_init(void)9 I1 ~5 V; ~2 z5 l4 a9 Z
{
6 u$ ~+ |/ k2 y' L& d int ret;; e8 D( j; U4 n- `3 h! r3 ]9 U
#if 0
0 V/ I/ ^. p! p" \- r* q$ q% E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, o0 y+ r3 V" A' w if (ret)
& W8 ?. G6 R* n9 ^' z' I( ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ ?3 g6 K* @# s4 s* u3 y8 K
"%d\n", ret);
- u+ k# y* W- E0 X1 v8 ?#endif! {- A' f, w' {; B% [
ret = platform_device_register(&da850_evm_tl_leds_device);3 Y2 i, ^9 b# {9 m* ?0 I
if (ret)
5 F, y: i0 M4 V. M+ r1 `/ T pr_warning("Could not register som GPIO expander LEDS");2 u0 h E; c" ?4 B: R# i" j o9 z
else
, j' U* T, L, } printk(KERN_INFO "LED register sucessful!\n");
6 Q/ ]; o* L7 |1 x) s0 B5 D: V( ~% l; q5 Q1 y/ j
return ret;# m- I9 m g" z7 J1 J# ?$ `4 g1 X' V
}( p$ @2 `* W1 Y; \$ u3 o
( m C! }" v+ O, ] sstatic void __exit led_platform_exit(void)
% \' h* {3 B" A{4 x: w1 e& a2 y( f; _5 T
platform_device_unregister(&da850_evm_tl_leds_device);) y9 p8 ~1 o, j. Q& W X5 e
; ]1 D9 Z; O0 x0 g
printk(KERN_INFO "LED unregister!\n");/ k* M$ f# d8 G7 `( i& c
}
0 [& ], O- z" h5 G0 v" `! M7 _3 N' G$ u2 F; T/ F. z( Z
module_init(led_platform_init);3 V: ^7 O" U2 Y: a! R: @1 ?
module_exit(led_platform_exit);
2 c! f* a3 E' u }+ U: [' I+ r( W# b: m3 U
MODULE_DESCRIPTION("Led platform driver");
; u" T1 I6 X4 C$ N( KMODULE_AUTHOR("Tronlong");
! P7 f/ X i$ f9 V; b5 t7 NMODULE_LICENSE("GPL");
" Z9 u9 l# m# Q4 l
+ L8 j* Q& N# s+ I2 T! h |
|