|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 D9 W, w# y6 j% B* O#include <linux/init.h>
, v7 v8 w( Y; x& r6 ^5 K#include <linux/module.h>/ ?$ |- @9 ]; h7 R- U
#include <linux/kernel.h>
- O& U+ k$ m7 Y- s: a# I2 ^#include <linux/types.h>1 ?* D( T; D; B) _% {8 U
#include <linux/gpio.h>
+ o) M0 E, d$ n2 {9 z! {#include <linux/leds.h># m/ v! _, G# d- r, Y
#include <linux/platform_device.h>: l2 X3 R5 j6 ^& v
# l4 _, `* L7 m' }
#include <asm/mach-types.h>
6 S/ x! a# r7 E* d' u#include <asm/mach/arch.h>
& n+ K8 [( X: [6 ?! \' @#include <mach/da8xx.h>, H5 a4 t/ N( W, a" m# v5 K4 U* g
#include <mach/mux.h>
4 z& s1 c# v6 N# t# Z6 r: @- G) u% o2 r2 q- K! b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ _% L0 Q+ L* I' y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 ?3 A( Z, A1 Y' I$ o, F! h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: j# l# X. ]1 |) C$ }& N#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ `7 x, _1 i6 N6 f- A/ T# x1 v
2 E& r6 f: E3 ]( `1 d% h8 T( `
/* assign the tl som board LED-GPIOs*/7 W& j) h1 k/ @4 P' m4 w% z- b4 X
static const short da850_evm_tl_user_led_pins[] = {
; x! m( E G, I /* These pins are definition at <mach/mux.h> file */+ f8 ]; H/ h2 V; [' Y, c, _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 Y4 G% G& R: F9 p& Y -1% f; h; y% G# ]2 F! |
};
; s5 n) E& d2 J, n$ P2 Y7 g. \& _! L; O3 T2 k* ^
static struct gpio_led da850_evm_tl_leds[] = {
5 C/ b( U2 t( [& Q+ m# N {) K0 H1 r5 H6 N
.active_low = 0,
* y7 f4 o5 y6 n .gpio = DA850_USER_LED0,8 t' a7 X% m/ A" m! W$ H. O
.name = "user_led0",
' h2 h/ I: M9 ]2 z! y .default_trigger = "default-on",
- U" n* ?9 L% V. k# `9 H: j4 _2 r },
; X4 R' p7 z- i! a# B2 Y: x {3 O) n$ r$ k% @8 V
.active_low = 0,
, b4 |! m2 Y- l4 k/ ~ .gpio = DA850_USER_LED1,- M2 Q1 y% @% |) |0 X' s+ r
.name = "user_led1",- N9 @$ L! g, F$ c
.default_trigger = "default-on",
2 [5 m9 k; S, F: ~3 a/ e2 c9 m: b },
2 i* _3 q1 t, W+ `) N& i {
' D& ?) \: u3 g( Q .active_low = 0,9 e. j" c+ Z3 b2 P# R
.gpio = DA850_USER_LED2,
$ ]; Z4 u( y/ F7 \5 J .name = "user_led2",
2 W8 F# J( x9 F .default_trigger = "default-on",
$ |8 R7 L5 U% j0 V" h3 R }," x5 k( s! o! z- o) g
{
0 B. b5 o/ R1 t% C .active_low = 0,4 q2 [9 N; w% f, M" ]' Z
.gpio = DA850_USER_LED3,; h0 h9 }& u4 I2 R
.name = "user_led3",
5 ^7 G. h g: C r .default_trigger = "default-on",+ k6 D3 W2 r0 {9 d6 I; e/ u2 {& E9 ^
},/ c1 B( Q# e5 X$ C7 K' s. Y
};
0 [) e2 d6 O1 ^( b+ @, K9 u
) E0 I6 F6 j. }+ R. h1 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- }( g# P6 T0 A: ?! x0 J) Q6 g .leds = da850_evm_tl_leds,
/ h% w1 ^% V0 C b" c. c. m5 v .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 Y" s1 p3 w8 l& n};6 ]! U8 u8 w! q
% Z! }! k9 v3 @+ r
static void led_dev_release(struct device *dev)
& J- k$ S: K0 m1 {0 w y{
/ o3 y" I& z I};$ o& E9 ]$ J! x+ ~1 B# J
4 Q1 F5 `+ O5 r4 Z) h
static struct platform_device da850_evm_tl_leds_device = {. K6 G9 A" M9 q
.name = "leds-gpio", v$ a% A+ C4 o6 I! b9 _
.id = 1,- O# e8 w; S0 G. h
.dev = {# i; F* f- L. l& _6 i
.platform_data = &da850_evm_tl_leds_pdata,& N8 O3 y! {$ a( W6 m1 O2 t
.release = led_dev_release,9 W- G# e' ~9 J& ^
}
" E' e" s+ m- i1 y9 d+ {};
' e& L) V# z% S8 t7 k; y9 d) E& J! y: ~
static int __init led_platform_init(void)$ `/ B7 y5 f8 f$ s
{2 k1 }' O+ z; n# g. o7 ]
int ret;
K( W5 B$ ?# f, j8 y' F#if 0/ ?, o' c3 F4 Z4 v7 [! E5 E2 P O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 h8 O. d9 ^7 f/ W* G D. M U6 t1 n0 O" {
if (ret)
$ h4 f6 Z- \/ {& C! ~; ~8 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ d n- R W2 W$ I' h0 f& S. F "%d\n", ret);6 z2 m. @, ^. R- m/ @
#endif( U# z( O3 S' k+ G9 \
ret = platform_device_register(&da850_evm_tl_leds_device);
G$ B6 L8 j3 c2 p7 s if (ret)0 H8 C" z4 N+ I8 D3 [& j
pr_warning("Could not register som GPIO expander LEDS");2 r" M! N0 C {/ l% Y
else& ~3 I: I, C9 C" q7 A: r* p! }
printk(KERN_INFO "LED register sucessful!\n");$ o$ u& B9 }# S5 E* P
+ q+ J5 Z4 x, G' L# H return ret;
# ]+ e0 J; T9 f3 T}
) A: D. p( P* C1 a, u. L$ S6 z+ o/ K5 ?. g
static void __exit led_platform_exit(void)% S. o0 Z' e% S" L3 ]! d
{9 ` ?% z* q/ z& Y6 X
platform_device_unregister(&da850_evm_tl_leds_device);+ s7 o& j, j8 }6 S* y
& Z% B- ^$ c: z printk(KERN_INFO "LED unregister!\n");8 V& D! I7 _+ n! Q
}0 B$ G/ T) B6 D$ S" \* h5 Z8 L
+ O& t# l5 x0 a9 x( I! `7 L$ a/ ymodule_init(led_platform_init);, }$ G. W: E# x
module_exit(led_platform_exit);4 w0 C2 G7 A' s
$ u' ^; [9 P$ C5 k& r' x4 p% ` B' pMODULE_DESCRIPTION("Led platform driver");
5 _2 s! P, I* F6 [$ E/ |' o4 uMODULE_AUTHOR("Tronlong");# J/ G k. n. @$ ^% l
MODULE_LICENSE("GPL");+ T* t+ C F1 E4 A
* k8 s. R( R& a1 y- E, B0 [ |
|