|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 O0 L: o) V, y( {( O2 V#include <linux/init.h>
; Y) E& C/ K& O( [#include <linux/module.h>
}% H; O5 @! \7 e+ m- X0 j#include <linux/kernel.h>
9 V% ?' {8 U4 d5 M3 c5 z#include <linux/types.h>6 H* B% r7 J( i$ d3 P
#include <linux/gpio.h>
6 ^ k( w0 O* G# J* z% a#include <linux/leds.h>
! P6 ~# m# l9 ~. U6 p# c#include <linux/platform_device.h>" C* h" J M( i- c/ t R9 c5 J
; j+ ], R: {; _#include <asm/mach-types.h>% @& X5 }! I4 E8 A5 M ^1 O0 `; p
#include <asm/mach/arch.h>
! i8 z' Q; x, c; U% D#include <mach/da8xx.h>: l. @4 [0 v7 N; Z$ {( B1 F
#include <mach/mux.h>$ `0 X. Z0 ?% P7 L
7 P, R* T) M2 N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! c) w: Z3 @" _7 E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 c0 J1 r8 ]( m @6 e0 X5 A$ ^5 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; m' U& A( J$ ~7 E, Z' A3 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- j: }: a+ V8 }! m: B" G: U: O
4 o( Q: {- O/ |6 m/ \7 T/* assign the tl som board LED-GPIOs*// }0 R- Y6 {: {% L0 C! _3 I4 r
static const short da850_evm_tl_user_led_pins[] = {
2 ~) V+ W2 R! s9 I9 V /* These pins are definition at <mach/mux.h> file */+ C1 w/ |& Z) F# }3 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 _ a7 D u" I/ [% I' c6 [ -12 i+ D5 m5 F# z( I- f
};" m& x- I6 o# _ T" ]5 w' f# B
6 w1 r; C- o( |2 ^static struct gpio_led da850_evm_tl_leds[] = {6 F" z% g1 b( g7 c1 v$ D6 P
{, h2 E% f: D# d, B8 E5 x
.active_low = 0,& }. n5 j" x4 M. X
.gpio = DA850_USER_LED0,
; I7 K, S- x8 S2 k) n z+ n .name = "user_led0",/ g- p; x6 A4 J7 I5 \( o5 i5 Q
.default_trigger = "default-on",
9 N; F( A' {1 d7 i& @& {/ Z }, w, M# J0 J% p( t, d
{4 A" F7 X# c6 c7 u
.active_low = 0,
; n7 y0 K8 G. x .gpio = DA850_USER_LED1,
! t c% k- h7 \4 j! o' G .name = "user_led1",
* R. J, `. ^( ` .default_trigger = "default-on",9 D5 m8 l0 [0 Y
},
* C' v% L" I8 u, ]$ A {; O" y" d' A8 k4 |5 d1 X
.active_low = 0,4 m6 o+ R9 `& f& V( n
.gpio = DA850_USER_LED2,
4 g0 G/ H1 ]% n7 ~: u .name = "user_led2",9 Q& V, C3 {0 c F
.default_trigger = "default-on",, n' J! a& J/ ~- K
},% U; R( t5 G5 |* Z
{6 Q1 ~6 o3 P9 X6 {
.active_low = 0,5 `4 z) V: S8 ]; N7 t/ {
.gpio = DA850_USER_LED3,- E4 D g; O( A
.name = "user_led3",
( b! @5 [) Q' X/ Y3 }( n$ h0 r .default_trigger = "default-on",
; S1 @2 {% ^% t& W },
8 M- D! i! ~. a i7 q};$ e% Y' C' j3 h- e/ F7 s4 ^
, G& x7 y3 j3 w) U3 |/ T( J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" I' i/ t' n) o3 m
.leds = da850_evm_tl_leds,; U& q' K, t9 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: M: U7 x- r- z& m3 F# C# U) |
};
4 F4 j B1 X9 Y, `- U0 I
5 a) z( R6 [/ R$ b! L; ]1 T6 g, estatic void led_dev_release(struct device *dev)/ t1 o* s1 V2 K8 b
{
! C' x, C& T' F8 k: H t};2 D9 m* @# y5 c4 ]$ G
; D: K6 q4 r6 N) E+ X/ u6 s( Sstatic struct platform_device da850_evm_tl_leds_device = {
1 n+ v7 }) Z S& G .name = "leds-gpio",( y* W( W4 d7 ` i9 a8 N* L' W ] d
.id = 1,
5 s8 D# r; e' ?4 S( \ .dev = {: a H* c0 W) M* j4 o
.platform_data = &da850_evm_tl_leds_pdata,2 X# e+ S4 j( ~' b) V0 I) Q% \
.release = led_dev_release,4 b( a. _% K6 s9 { q
}
2 G8 y1 b) B# ?5 l5 f};9 _, t/ }$ t' o& J9 M7 d- n
' {/ `/ _2 U" X+ i- c& o% N0 }' t
static int __init led_platform_init(void)
+ v% B' h. O8 g{
) J# f( H1 c$ n+ x- J1 N int ret;
; o) a6 |* e) k% ~#if 0
! _( G7 j3 W' E G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' K7 V3 h& O) C6 P" j- `6 V
if (ret)
' C1 m7 `5 \8 S+ L; k# s2 z6 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' d9 l6 b y1 G. ~) n( [, R
"%d\n", ret);1 z* @$ l- _4 n
#endif
& C' U* y! ^! U ret = platform_device_register(&da850_evm_tl_leds_device);" V, `. t- m1 S6 E+ l& K) o
if (ret)2 K, V `- J4 J! S/ G# D
pr_warning("Could not register som GPIO expander LEDS");
- B% z" d; X: f% f else
6 w+ g! b- |( x2 f" v: n printk(KERN_INFO "LED register sucessful!\n");4 _9 t/ T4 R$ C K) h
! |( B. U7 ^% h- U" c
return ret;: g. ~+ A% y6 v
}
9 F! \/ y+ h5 X) G& r! u7 L$ H: m
6 _2 F% ` r8 Q7 Y- c: [$ y3 ostatic void __exit led_platform_exit(void)
: Z* Z' ?5 k* J+ z* Z; m p3 b{; R: T D/ N' {' @- H Q8 j$ I
platform_device_unregister(&da850_evm_tl_leds_device);
2 v. z0 X! O5 Z6 l& U( m9 j" g$ ~! R- m- l
printk(KERN_INFO "LED unregister!\n");
: @6 y" B3 ^! s9 j/ K7 S; X6 D}4 [( X2 t4 N4 g5 n- R7 S
5 v9 J& e f2 {( Y1 B' zmodule_init(led_platform_init);
$ L6 l- @1 {) k ^. a. v; imodule_exit(led_platform_exit);
T4 J" p+ s1 j1 j) ^4 ]+ U0 g4 g0 ?) d; O- u- Y- d5 Q, m. V8 B
MODULE_DESCRIPTION("Led platform driver");: d4 P' c' s% B8 @
MODULE_AUTHOR("Tronlong");
7 [9 ~. w* Q8 ?MODULE_LICENSE("GPL");
9 B! ]9 _% ?4 [& w. L1 }: k8 V7 s% q( ]
|
|