|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 f) T. R- c& B# h9 g- W#include <linux/init.h>
; i1 r- M% ?% l% \, P#include <linux/module.h>6 V# q2 k; J' ]$ r: }- L
#include <linux/kernel.h>8 O# T, g7 Q" o$ P: t% ?- c8 j
#include <linux/types.h>
! \) {% C; z% ]: P4 _% Q#include <linux/gpio.h>
9 F) w5 l7 h- ~+ d8 i- Y! u#include <linux/leds.h>
5 b6 I( O" c) ~ e#include <linux/platform_device.h>
5 f1 G6 y+ |: p% S) F- U6 u3 a
% F/ k+ C( g( v" R#include <asm/mach-types.h>
9 y# Z' u6 V0 l: \. V( s#include <asm/mach/arch.h>- i& J- h, N! r3 G- C' e/ ~/ P3 E
#include <mach/da8xx.h>9 N( }3 b; O G+ ~- [3 c7 ~) P
#include <mach/mux.h>
5 i3 t& e) e5 n" E4 Z3 ?" t8 Y5 R; _' K7 w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 {0 f6 y- [. U' W0 n5 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, i0 `3 ~9 A& ~) R/ z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' {& Z& U c1 C6 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 J0 }+ r8 R: w" W& f, j1 X7 P( G$ L: e6 Q8 x+ t
/* assign the tl som board LED-GPIOs*/
: O6 L8 z& a; astatic const short da850_evm_tl_user_led_pins[] = {$ h: E+ G( u( B( U* J
/* These pins are definition at <mach/mux.h> file */
0 g4 r* S3 Z! P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 a/ ]5 X% n8 ?3 P* O -13 N9 r2 P. F: _$ O
};
1 G6 \9 D) {# m: y; N% ~7 \* ` ?. [) u$ R* t
static struct gpio_led da850_evm_tl_leds[] = {
! \: r/ m6 p$ g3 C- S- K {
8 E t( z- o; a# L; a .active_low = 0,
- R7 U& P) c; s+ r5 Z; u3 g# z .gpio = DA850_USER_LED0,/ L1 }3 {" F1 I
.name = "user_led0",
) E; D! o3 Q6 i& _& W# O! H .default_trigger = "default-on",
8 T# J: s) t# ~5 I },
, Q% e* Z9 F/ j! W {- \8 ~4 ?& z9 U1 O- q- i* Z; Q6 g5 ~
.active_low = 0,* E# i" o8 c0 O+ u2 j/ Y! K, s- g
.gpio = DA850_USER_LED1,
- R" j/ r' J( v: D1 T/ Y .name = "user_led1",! t7 g9 `8 T3 ]9 |
.default_trigger = "default-on",
( [3 L9 x, J6 z& {3 H4 Q( d2 v' j3 U },4 N0 ~" @" T2 B( r5 B
{0 T6 w2 x5 F. z8 o$ f0 }% N
.active_low = 0,
8 o5 q$ B9 c1 x" @) X: v# f! k .gpio = DA850_USER_LED2,5 g# U% i7 p9 q& {* U
.name = "user_led2"," x& E3 a0 x8 l; i, o$ z9 e: v
.default_trigger = "default-on",7 {, d% {% `0 P% W1 j, L
},
+ ~0 N! @% ?6 C! @8 a6 L9 w {0 d; } k1 E* j* j
.active_low = 0," O$ G2 b( U8 U( M
.gpio = DA850_USER_LED3,
% e# j' M+ j+ Z/ {* c .name = "user_led3",
9 H1 g/ @9 i3 E( ~( s .default_trigger = "default-on",7 a9 G( `0 y1 f
},
$ I7 [( ~8 q- ]- f% p: u/ ~( S};" S9 v6 G0 ]6 C. c' ~8 M" d
3 }9 S3 R( q8 S. Z$ `! i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& ?7 S3 B" B* q% l
.leds = da850_evm_tl_leds,
8 R/ s! S2 d% n a+ G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; S# P; u" g9 I" z};
. e. {) X' p6 Y! P% H5 o/ X/ \7 G. p* S
static void led_dev_release(struct device *dev)
7 Z6 ^' d+ Z P1 H! w{
* V+ @ m" G: b4 G" m" E};
1 h: P+ Z. e: J) D1 d9 E# M' a2 j; }! x# f
static struct platform_device da850_evm_tl_leds_device = {. y, N! R u, b: q' L- {5 r3 ?
.name = "leds-gpio",
6 ^- d: N. L6 B .id = 1,; ^; g2 Y( p& ^8 q8 W5 |0 Q
.dev = {! l) k5 {; k+ E& _2 a; K: O
.platform_data = &da850_evm_tl_leds_pdata,
8 L& A" X5 O9 c0 [ .release = led_dev_release,+ w; u, ~, z8 P1 n0 T: z' P/ y
}. y3 f& J5 g( \% V. G6 b/ {
};9 V' ]2 P9 n3 ?
( `6 O1 g$ {+ p, p8 pstatic int __init led_platform_init(void)
( a& f! a1 `; E, p9 L( q{
' e; b; p3 D' T int ret;
m8 _! L3 I' ` z#if 0/ P9 O2 w: v w7 c6 ^8 H, C5 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# N* _( J8 i! o: \: w5 C if (ret)7 v1 A7 d+ v* T7 I( C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 N0 R" \5 g* @/ t* c1 A4 s "%d\n", ret);
, ]" J" K! R# s: D0 t+ S#endif
! M1 R, N" E S8 {, v ret = platform_device_register(&da850_evm_tl_leds_device);, D# ^2 @9 x" E( u: x0 s' m5 U! E- a+ O
if (ret)
. R" r1 u! D2 l, h: I pr_warning("Could not register som GPIO expander LEDS");( v* S. `$ U6 Y. W: k/ C; C9 t
else
/ s. @7 w x8 W" H% d( e printk(KERN_INFO "LED register sucessful!\n");
: E3 u- F; B7 Q- Y1 f/ O1 H
1 W% r: y$ j" V$ |( J" z/ f+ O return ret;# i) B5 P l; I; C1 x* ?: O
}5 ~* {. u3 J) x) m' ]
! C# e4 G; f% Y- k a6 ustatic void __exit led_platform_exit(void)
6 S( G; ^. ~1 s4 G" g{
5 S8 c$ `9 \, T platform_device_unregister(&da850_evm_tl_leds_device);
. C9 r# R8 R7 `+ `& N
1 ~. e! N! m9 Y printk(KERN_INFO "LED unregister!\n");
0 t( M/ `3 U1 o& |+ y0 ]}8 E4 B4 q% \& B1 z1 V2 v5 S# g* q
/ w: Q( {- s! n$ \4 e' h
module_init(led_platform_init);
. G/ j9 y. N8 h' f' i9 O. O- {module_exit(led_platform_exit);" A1 s/ h8 t: m( X" W
3 Z( j' r( m7 o2 t" c% |
MODULE_DESCRIPTION("Led platform driver");
$ D" P3 T Q4 Z" b7 ]: u- b- C8 [4 UMODULE_AUTHOR("Tronlong");
+ \( z3 K( ?( I" O- u# eMODULE_LICENSE("GPL");: b8 t/ L! u" G' T7 _: u& B
" w. ]( f2 ~6 L: F
|
|