|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 T' d' i9 T: F+ `4 C
#include <linux/init.h>5 `( E+ a/ g0 _: |3 J7 x: w
#include <linux/module.h>
6 |1 E# u$ U J Y4 u, q: w#include <linux/kernel.h>
0 {/ m' ^9 s+ @% a" {6 u0 \#include <linux/types.h>
* e9 m' R) g: u8 h7 a3 F#include <linux/gpio.h># L0 N, q% K O2 Y
#include <linux/leds.h>, h. \: [% z z' f6 o
#include <linux/platform_device.h>! u. s: F4 `" t0 e/ T( I B1 \% G/ C) N
/ h- s) a' n8 f( W
#include <asm/mach-types.h>3 J8 V- @: ]2 z
#include <asm/mach/arch.h>0 d0 e/ d* d2 p1 \4 \$ W' C0 \
#include <mach/da8xx.h>! X' c# G e7 E6 n! b
#include <mach/mux.h>
$ ^: k+ d' q+ F5 z) _: y
1 J% }2 M7 q. H. p$ S, D( l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 I4 u& `- |# Q, B. A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" h& @( t! @* _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# `& j" O0 t& L8 i0 j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, ~2 R; s v7 J' |( p. H0 U1 d ~3 m0 H! j2 M
/* assign the tl som board LED-GPIOs*/; R$ J% ?7 B: v
static const short da850_evm_tl_user_led_pins[] = {0 }- e% C- j2 k T/ a
/* These pins are definition at <mach/mux.h> file */
' z$ j5 [: C3 L* Q2 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% h/ l5 h3 H9 j) t: A9 o% j
-11 U+ u' u' H |# X" y
};) l$ d4 M2 Y" i8 }! Y& L% C( P- w: ^
; I) Z2 H& b; d( m, z
static struct gpio_led da850_evm_tl_leds[] = {
) n9 K2 v% T1 ~& p {) z* j- u5 s @6 G4 t) G% l4 v. V
.active_low = 0,
: u6 k; ]* W! s, a .gpio = DA850_USER_LED0,4 U( J* Z) L' K" e: @
.name = "user_led0",
2 j8 U) G& Y v7 O0 M5 ? .default_trigger = "default-on",
_) f' C' U \ },
$ h% a8 x0 \; _' o4 M {
7 u" M3 q% M) B& E2 V .active_low = 0,. R3 F) U5 K9 W/ \/ K. V2 s& C( T. {
.gpio = DA850_USER_LED1,
9 `; p$ k" i9 V .name = "user_led1",
3 s% X* Z/ Q P6 \# o M% e4 S7 h .default_trigger = "default-on",
$ f1 ]% x$ ?: U) n1 ?% m' u B },
$ w/ a9 p0 @* p. w g: V. ]- n. i {9 f8 `2 f* ^6 O8 {; A
.active_low = 0,7 a$ ~4 Z: C; u! \
.gpio = DA850_USER_LED2,
# c% w7 {- [6 ^4 W2 c .name = "user_led2",$ o' N6 k' A; L. l7 q9 ^! k3 N
.default_trigger = "default-on",7 v# k: F5 |6 a4 ?* J! v% h
},
; [/ X6 r& v& D: \' v {
1 t: I" r7 V: d& w; C! e .active_low = 0,
- r: k1 q, {1 a. w; F, L' P; {# S. ` .gpio = DA850_USER_LED3,
' r. J! w* f9 a' W8 q0 o .name = "user_led3",4 p! \$ B% R3 D! i
.default_trigger = "default-on",3 q. d2 i( Z% r2 @9 H
},
0 [3 d. C+ f$ a1 B; [( s$ `};5 w4 `. |9 R& p
2 p; q; L0 D# a$ h) O' G" g& w/ \1 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 |# K6 C5 I2 z$ t: R& w; W .leds = da850_evm_tl_leds,8 B0 g/ ?# n# S6 h3 M( D5 q; o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ c7 }2 [: x' f8 G$ ?
};
0 ^3 z5 g) {7 g8 T* M3 L w# e: W$ w
static void led_dev_release(struct device *dev)! W9 `3 E6 ^, B& X N" `
{
: H0 O8 e2 T+ b& ]) X};; i+ r! p" c3 ]7 B9 e
: o: u5 y9 U# C# T: w* lstatic struct platform_device da850_evm_tl_leds_device = {
; w) E# d" e; ]( P3 n .name = "leds-gpio",
; o! {9 ~6 U4 Z! u M+ X' f .id = 1,& u. Z5 a4 e' X) M6 \* D
.dev = {4 ~* K2 \) k/ S# G4 u
.platform_data = &da850_evm_tl_leds_pdata,5 c+ m2 j D9 v5 o! _1 A
.release = led_dev_release,
$ m/ Z9 E# }5 v }) G' F3 x2 |: D
};
# ^* v: B( s8 N4 A# F6 }" K6 ~4 U, l) v @6 k; E1 I) \) v9 w
static int __init led_platform_init(void)
& C9 L, I; G' n9 h{) _4 s0 s( b$ s+ R
int ret;
. I* O' ~0 k" d# g" g+ [' ]8 D#if 08 g: j) Q6 _/ L. B- j- G2 c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. T) \0 X& @/ k2 {5 a- i) { if (ret)
6 c0 [3 G1 s6 `+ \5 F" @2 W* b& x J- h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- V+ m! l3 n f- S' g$ T "%d\n", ret);
8 }- U; T8 G7 B9 j/ W) C5 F#endif- c4 s$ U( F" _, M
ret = platform_device_register(&da850_evm_tl_leds_device);; Y5 p; S5 e) V, H0 x5 C6 G
if (ret)
" z4 X+ x! a+ c; d- L) [ pr_warning("Could not register som GPIO expander LEDS");
3 ?& I& b5 u. J. N, d else6 w5 c- r, {- T: A
printk(KERN_INFO "LED register sucessful!\n");
' i1 J, T3 ?: j7 v x" \1 E" S6 o- k
return ret;' _! Z4 H* Q5 D+ P3 x, E' j5 d, F
}
4 |+ b4 k, m V6 p4 M) K) {( Z7 k' L8 y* Q% S8 n
static void __exit led_platform_exit(void)+ i1 G3 ?6 m. k- B: K
{4 E" i0 G! g/ _ R2 g. d$ f8 r6 ~
platform_device_unregister(&da850_evm_tl_leds_device);
! z) E! _0 a4 V* y; N* C+ ^- X2 x' H6 P4 f3 z. r0 k
printk(KERN_INFO "LED unregister!\n");
9 @% D5 h" U; T" S E8 m: R} C% G4 I9 t- F) c2 \
# q- ^( j3 r: n" {, j
module_init(led_platform_init);) \1 s- K9 O/ G& B
module_exit(led_platform_exit);
9 w: ~. T6 q1 ~/ M# U& o, k, S; V
. }8 k; G) w2 M" Y+ zMODULE_DESCRIPTION("Led platform driver");3 E$ L* M; V5 ?7 `8 P( K- F
MODULE_AUTHOR("Tronlong");
$ y5 c/ v; f- qMODULE_LICENSE("GPL");
" T4 A0 I& O! I; B3 W4 G( z
% s: D- _5 q: r& n |
|