|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 C: D# S: j" h#include <linux/init.h>
2 t1 ~/ y8 r' g#include <linux/module.h>
% r% {) d6 H& B- a% x; [. n# |0 J- d#include <linux/kernel.h>
9 }/ {! X5 f- z/ c$ M6 U#include <linux/types.h>& ]& H: u6 G* }6 A
#include <linux/gpio.h>
- t/ n2 Q8 ~! j- h: p#include <linux/leds.h>
; T5 Z8 i2 V, S#include <linux/platform_device.h>& a, u2 D$ c# T( u" h
" @/ l+ g5 Y; w m2 X0 X#include <asm/mach-types.h>8 n: Q) B8 P# a- j; I
#include <asm/mach/arch.h>! W! x7 @8 x+ u# L( [; {) z; b
#include <mach/da8xx.h>7 \/ N: M3 @9 C* N1 y8 b& R* n4 j
#include <mach/mux.h>2 A* X. I! i! b+ k" a
" N* g$ _! f4 @1 f" }- v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, C1 |0 B H3 U. S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! S- c* p) B) [7 Y6 G* T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' P2 P$ e; U9 _4 ^; G5 D: u3 i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! ?* h$ r+ l6 @* |! f! h
/ z5 F+ j1 N2 o! d
/* assign the tl som board LED-GPIOs*/
8 E, U7 \' C2 ^3 _/ C, A5 astatic const short da850_evm_tl_user_led_pins[] = {
; f! D: M9 \3 M# [ /* These pins are definition at <mach/mux.h> file */
* }6 A4 z/ I9 ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 c! [) d$ b' ^/ E" N8 i: x \4 A
-1
4 P) t4 P! Q7 B9 H! D/ U};/ j3 T0 _/ e% ~8 H
/ M) P6 i X+ F# cstatic struct gpio_led da850_evm_tl_leds[] = {
1 e8 u1 @& @9 a$ L% ^+ |9 t5 o {9 B2 E# N& Z: s1 N; Q) D
.active_low = 0,
: R& P! g6 S D .gpio = DA850_USER_LED0,6 v3 P3 b! e3 q3 p2 t2 P
.name = "user_led0",; s+ }: t! T/ l9 L, x
.default_trigger = "default-on",
$ s! _$ W9 n j, {& d },
+ h$ H a1 \% S7 L: ^+ R0 F {
- n/ x) i( N, A# I' w .active_low = 0,
( X" Q* R. ~- j) a .gpio = DA850_USER_LED1,, `) e E7 ~6 y* l6 W' i7 a
.name = "user_led1",
. `1 w X, Z# F+ n .default_trigger = "default-on",
5 e! U' ~2 a% j0 v6 i4 P },
. F) @( D# n. q {
7 `- J2 o+ M9 F/ @4 M; y' ^. x .active_low = 0,, F& ]* P- c: D+ c: e* I: _9 E+ k
.gpio = DA850_USER_LED2,% n1 @7 j' U/ j0 w4 x/ R. g) z
.name = "user_led2",
+ w" i. { Q# R6 l .default_trigger = "default-on",3 v6 P& R. u8 K+ W* d) v
},
- c1 J& H V/ m6 K b {* ]8 H0 R/ Z/ H% f M
.active_low = 0,
n% o& U! Q4 V) l- |& o3 ~ .gpio = DA850_USER_LED3,
k) B* \4 Q( [; ~1 z! ^ .name = "user_led3", s+ m+ I( Q8 L* H4 e& A* M# h+ P
.default_trigger = "default-on",
) y# {) {* B4 w7 K; u! r },2 @$ |7 y2 Q' R% e& H, ^
};
6 F% Z% L) f) ^4 d; q7 s
, N6 ]5 i# I1 C/ Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) S* I: q) M' p$ S; ? .leds = da850_evm_tl_leds,; r2 H. i' t9 a, I; i s8 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 b) X# ^8 q9 f! P. e) @. M3 t% q};
5 z5 w9 s# D) r' x$ [
2 S. m0 l2 m- c$ Istatic void led_dev_release(struct device *dev)! Q; R: C; b. h
{
$ P" _& K5 m; ] @; O- V( l};- j+ ?* p# q7 y* y
% q: _3 A/ q2 T! S6 z4 ostatic struct platform_device da850_evm_tl_leds_device = {9 O+ @1 @9 c! R- f0 g0 x& n
.name = "leds-gpio",
3 U0 A) B- H4 J0 n" v. ] .id = 1,3 `/ a. q& Q1 F8 |7 I: G
.dev = { d1 B5 c( e' `0 a) N
.platform_data = &da850_evm_tl_leds_pdata," G$ s, `2 b% y
.release = led_dev_release,
* a/ A. H5 L" E+ |3 e1 _8 b }- m7 ~1 T# q) h) ?3 W8 c9 N
};3 q, B6 \7 c9 S o8 I2 K E! X
9 z( s& s0 M5 V8 p
static int __init led_platform_init(void)
6 M& E8 z+ |* B" O1 ?# J{
$ y/ X2 C, @( U9 u0 d/ U& J: w int ret;
& E2 W+ w* I# Z1 ]#if 02 X5 p! i$ J+ K1 L5 R" f6 y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ |4 d* f8 \8 `4 u4 I
if (ret)
$ M3 k! D2 s- j- `- B& y0 L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 n# r9 u; y! N "%d\n", ret);
7 C1 D; `+ L; K8 j$ c#endif0 a, k( p# Z4 n4 x! G
ret = platform_device_register(&da850_evm_tl_leds_device);
2 U/ x1 J) E) `* {: Z0 X* f* J if (ret)) y+ h0 D# z* \) |
pr_warning("Could not register som GPIO expander LEDS");
. Z( x, `1 g7 `0 j( V else
: q8 O v7 p1 B2 {% q4 b5 ?& S printk(KERN_INFO "LED register sucessful!\n");4 c5 m9 j, s8 O! h6 }6 x. G) X0 ]
! I$ e6 \, Q; \9 I) V" M return ret;
4 j) R$ `& r1 Z! J# m9 f4 h}9 {* g; E* [) \# v1 }6 e
+ ^: b/ b$ i7 [9 T5 Y" jstatic void __exit led_platform_exit(void)
; G) \7 S" k) r3 f- `( x1 Y) d{8 X0 P. i2 c9 i2 a( h) D& W& y
platform_device_unregister(&da850_evm_tl_leds_device);. ]; T x0 i4 z) {# c
3 A9 m6 q" O# j$ H+ i1 v- I printk(KERN_INFO "LED unregister!\n");# v4 z5 x+ v( T% F1 ~, @/ C
}
$ g( l0 l) M; X( ^8 ]
2 M- F n7 \* G5 n$ Y6 C% ^6 umodule_init(led_platform_init);6 G* L6 z5 K2 f0 l" W6 @+ V
module_exit(led_platform_exit);% Q/ [) p& b& p: a. _( k0 ~
% i2 m/ s8 g# Z- s
MODULE_DESCRIPTION("Led platform driver");
7 @, {: W3 B$ X8 i9 k. ~7 FMODULE_AUTHOR("Tronlong");
7 t N9 a, i- d4 E1 mMODULE_LICENSE("GPL");9 \; H9 K" j* {' v0 ?8 A) b! h8 `
% A5 g0 n8 ?3 b6 W0 ?& R |
|