|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. B' ^& w1 m+ Z
#include <linux/init.h>
/ O' q- ?3 U8 q9 e) Y, b( m#include <linux/module.h>/ ~2 ]2 C; o( Q2 C
#include <linux/kernel.h>2 f! N" K( ~2 t g/ q
#include <linux/types.h>
) i* D; Z0 w5 u7 o, L/ O#include <linux/gpio.h>: ], u. r5 r2 _6 z
#include <linux/leds.h>
9 \! X( d8 y- b) r#include <linux/platform_device.h>! I! t; D- m' n7 C$ o- C' r, K
* d# g* }* i1 ] L d1 e9 w
#include <asm/mach-types.h>' q3 @! I3 G. q
#include <asm/mach/arch.h>
$ d& L" o8 G* D#include <mach/da8xx.h>
' e! t6 ]7 b, l' f" e#include <mach/mux.h>
0 q- M# H4 b$ p0 D: V6 B" n" j5 |0 m. Z) A: s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, s% w4 J3 m# F) Q( i r, J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 {% w- v7 i; E) W$ v6 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: `/ T! W) \* V: ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ b$ G. b G9 V! m
! k) E3 E$ A. E$ Y
/* assign the tl som board LED-GPIOs*/
2 V: h9 q t% [) bstatic const short da850_evm_tl_user_led_pins[] = {
' M7 O0 M( s: }7 z /* These pins are definition at <mach/mux.h> file */
! z2 T, _7 B) H/ v7 _& V1 W# r. h' h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 a. z2 y: h. g$ |+ f L
-1
0 N( u; c5 K9 h1 S S; }9 J/ k};
" H n p( O( ~( b. h" j: H2 l" Q
' b( w. { {( U$ @/ ^& istatic struct gpio_led da850_evm_tl_leds[] = {! X: Z7 U& W4 ~# u; q; ^. `' ?
{3 O! t: {4 J2 t) Y1 ]9 X
.active_low = 0,- {( l) g3 d/ W$ F, [; {+ {& f i
.gpio = DA850_USER_LED0,& t4 W: _6 F+ Z" p5 X/ M, j
.name = "user_led0",- W7 S7 U* w1 u% v i: m0 Q* W: c4 b3 A
.default_trigger = "default-on",
1 A, G: K) ~4 }) x6 f" }$ Y$ s },$ V6 o; Q4 I3 J; b, v0 R
{
' f, I# T X. q& q .active_low = 0," X7 q4 E* L( \$ N* Z& H
.gpio = DA850_USER_LED1,
h5 \+ C* N) D7 z3 { .name = "user_led1",6 b+ x; P. b5 K- Q+ _$ {
.default_trigger = "default-on",
3 Q+ M* m0 z/ c5 D, I },
* }- A6 V8 h. w9 F+ ] {
1 d; N8 i' ^! Y, a l- n, x .active_low = 0,4 a/ }' N9 b& c+ A8 m+ B- B
.gpio = DA850_USER_LED2,6 ]4 G' ]+ B0 q5 ]8 m# r
.name = "user_led2",& d" U8 {+ Z4 _5 `/ e; x3 j4 V
.default_trigger = "default-on",) O/ Y3 h5 ?4 L' G2 c
},( P8 |6 [$ k- U$ S; l2 U
{
5 z8 D X( G: O .active_low = 0,$ D: I$ P l9 v8 d4 P
.gpio = DA850_USER_LED3,* Z3 J: W5 w* b1 P. I4 g5 f' h1 t
.name = "user_led3",
4 b3 {" Q* ~* T9 H7 G' M4 N& l .default_trigger = "default-on",, n0 r! k. e6 G8 J( @ p
},. D3 X$ `/ F4 r ^% k$ G
};
5 y" p/ {* O" \9 u$ t) r* T/ r0 p ?* _! F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 p! t2 |) }9 r$ a
.leds = da850_evm_tl_leds,
6 I/ {( f0 |. ~6 D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 {% r/ ?9 s& s0 g( f
};
3 u3 _9 C6 H" s n( s% r* N5 G: _2 W
/ t2 c; {/ f$ y# d M x8 C; Cstatic void led_dev_release(struct device *dev)
- G2 N4 |" V* E# y; @! e" a# P1 B{( ]: z) ^ V" g5 V3 b) |' K
};
! A- R+ C' W* T) x! }$ r9 l
( F0 ]& o* l1 T+ ?+ @* |& N. j$ b5 R, j& ystatic struct platform_device da850_evm_tl_leds_device = {1 Q/ u- z0 j8 C( d- O; r% {
.name = "leds-gpio",
* R/ u: s! b# h$ p& J .id = 1,
$ C6 x& X' x8 w5 z8 O0 I& k .dev = {
q' R3 @) ?7 v A8 I+ U7 l .platform_data = &da850_evm_tl_leds_pdata,
: |$ F% A. V1 L .release = led_dev_release,
) z2 Z' m& b2 P- C }. u4 Z- L/ @$ R$ t4 Q# E
};& V+ f$ x0 R0 E" L: L- H/ A
3 o, H2 R, v( Y
static int __init led_platform_init(void)
/ v9 J2 q. V* T{3 [" N) Y. J" `6 ?- w
int ret;
! K X" f4 j+ s: U( b# W% g#if 0
6 m+ ?& W' l/ u$ [$ h# H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# U" G" S2 V4 z6 R
if (ret) }/ ]/ G6 o, Q3 p+ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, k% O/ G! O6 G# j* l. o3 m, X* j/ g "%d\n", ret);
% h- b1 H) X1 ^! u- ~1 K2 F#endif
( d1 n7 I/ a0 i ^ ret = platform_device_register(&da850_evm_tl_leds_device);
, d# d( b3 C: E8 @ if (ret)
/ Q0 o! y4 P- s& z: T8 H pr_warning("Could not register som GPIO expander LEDS");
5 F# o8 ?6 A# ]1 p$ J else$ S3 Z8 }6 f! Q/ g0 c6 s r
printk(KERN_INFO "LED register sucessful!\n");
4 ^5 m3 ^! f) v& O
( B5 T, K* ^$ ` Y return ret;6 E. U7 E7 i4 @4 s- |
}
- n# Q; g+ B* A9 P7 Z+ P7 X$ j, L" Y3 H, F* A! V% Y% ~( b/ n
static void __exit led_platform_exit(void)4 P, U) |7 y" a
{8 M5 c0 \) Y) p4 D6 d8 V! R* S8 T' @: D
platform_device_unregister(&da850_evm_tl_leds_device);6 ]9 Q, F5 ]# K0 n
: a; {" N( w. p% ~/ C9 A7 j
printk(KERN_INFO "LED unregister!\n");
8 H: B7 M) t! B: l- `& d3 x% N2 ?}
% n" C/ Y4 L3 X* b9 ]9 g
) m* W6 {5 z/ _: [/ A" ]module_init(led_platform_init);/ [+ U, V* D# v% B9 v/ }! B/ l( {
module_exit(led_platform_exit);
& L" O: f/ s3 p3 V$ W0 f. R$ Q0 l0 o; }5 N& o
MODULE_DESCRIPTION("Led platform driver");
( |6 k# t$ m' T q4 V7 z0 _MODULE_AUTHOR("Tronlong");
* z6 z0 s( d* _" w3 AMODULE_LICENSE("GPL");
! e3 P, y! {1 ]- }% [2 y+ h2 [% J4 Z2 d+ q
|
|