|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ J2 ~! J% h% I" [2 {5 ^9 l9 U6 w#include <linux/init.h>, L6 x! ?6 t+ u! l
#include <linux/module.h>
2 J# d; P. w! N* E( ?9 B#include <linux/kernel.h>
6 V% _- m4 L! H( F% e2 K#include <linux/types.h>: C x( ~* ?1 _) a
#include <linux/gpio.h>
0 j+ m3 u3 N8 `; T# c7 f: ~0 }#include <linux/leds.h>; w. m1 { q" D6 V
#include <linux/platform_device.h>
, R/ J. k4 q8 E+ B1 ?- U0 ^4 T3 @9 m) J9 f8 H
#include <asm/mach-types.h>/ L! A* j# P& z
#include <asm/mach/arch.h>& N7 \, D* S3 j# m7 p* X
#include <mach/da8xx.h>
1 W5 r4 Z$ m6 L# u- M; n#include <mach/mux.h>
3 j0 ]) o. H0 l1 }' ]7 b0 p7 m$ l K1 I7 k/ Y* F1 o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 Y3 p, O8 [" h: J) J7 f- i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) g( K3 n( H& C- v' S8 p; d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' X# \* k3 x2 S. X8 u+ @+ T# A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 ~2 b! }* ~/ A3 U
% I. C4 N- X+ H! ?) T: Y7 q i! h
/* assign the tl som board LED-GPIOs*/' ?0 |$ k6 p2 M, t+ {4 z
static const short da850_evm_tl_user_led_pins[] = {
! T6 r; f) a, d4 {$ L /* These pins are definition at <mach/mux.h> file */$ ]8 L) v4 T, f w' s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% P$ I c$ G1 t; R" W9 K -1
! t% y/ X( [7 l3 A/ J+ C, v};1 t2 @3 E8 p2 l0 L7 ?
5 l: } O: d- F8 U- q9 R5 Y* Ystatic struct gpio_led da850_evm_tl_leds[] = {/ C5 ]- A$ t. m+ A
{7 J' N% R5 I1 D2 r
.active_low = 0,
1 Y6 e. @& x4 H9 b$ z) [ .gpio = DA850_USER_LED0,
: M; u3 d7 o9 ?8 Y .name = "user_led0",
$ X! O1 A) T5 ]$ ^$ r+ p: S .default_trigger = "default-on",7 I+ L" z, f) m
},
4 r+ `, J$ ?5 H! z, M {9 Z( I# |) C+ z/ {) L9 X% {
.active_low = 0,$ z8 W& V% }* z
.gpio = DA850_USER_LED1,
$ E/ d$ F2 N- e" C- R9 I$ o .name = "user_led1",
, }; r9 s& j0 B* a .default_trigger = "default-on",
: I! p; m" w7 L/ P9 b. \, | },
; a; ?9 e! j0 S8 o% h {# ]( T2 T3 Z6 s3 _ G) N+ I' Q
.active_low = 0,3 q2 a4 X/ C" D1 d
.gpio = DA850_USER_LED2,
& y! d$ }( ?$ h Y" }1 W .name = "user_led2",4 R# f! f' p1 g3 U. b
.default_trigger = "default-on",
, l; z3 W5 [3 O/ E },( N' Y% C0 G/ Q& ?; I! W6 K
{
' }$ T6 v# k' w/ ^+ \$ F. E .active_low = 0,, J Z' g' \$ h8 r& C/ I" @, Q
.gpio = DA850_USER_LED3,
+ ~$ p, S6 r3 g2 O3 b6 h .name = "user_led3",4 ^3 j8 o+ y0 t$ j
.default_trigger = "default-on",
3 L2 U: I0 N) _ },7 E* T( g: h# x% _4 Q
};$ @% A3 ]% n+ d) B3 y7 m" F
' g1 f# L# A- U3 x. [! Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' s$ u* Q6 G/ ^* r" F& Z
.leds = da850_evm_tl_leds,0 g% H5 N& P0 ]) t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 L3 \* c5 P# D/ u2 Y8 ^};! ^" A Z" g, e( s( }9 C
4 \( e" @0 y: B3 e
static void led_dev_release(struct device *dev)
L7 [$ ?9 X) _6 Q+ g* u{
u$ I- O3 a& a1 R, k+ a$ x};- h2 ]; G9 B' P1 [& w
; a& G$ O) l% P& @! J
static struct platform_device da850_evm_tl_leds_device = {4 V1 S, B" a2 ?2 W& |$ d/ x' ^6 y
.name = "leds-gpio",% e1 O- r" ^# K+ ?; T$ z
.id = 1,
2 E" ~( F3 N9 K6 u* C) @. Z9 @ .dev = {3 w7 W0 t+ |& w
.platform_data = &da850_evm_tl_leds_pdata,
6 N3 x2 o- Z1 _' _! l+ c/ x* E .release = led_dev_release,, M! [$ K" a% z$ A3 l
}/ F ?' p# Z1 R- {, g8 [0 Y
};; Q0 ~; b& _9 U0 o$ f
Y, ?( F9 r8 d2 |0 V/ S0 p8 {* H
static int __init led_platform_init(void)- {3 Y2 }% \$ y; L6 _: f% `1 E
{7 ]2 I" q* x1 P8 k3 A- M4 t8 F% v
int ret;
A% e: {+ _. I/ C; C; v. |: ~4 F& w#if 0
6 R4 Y% [3 J- K f# [- } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 @ O+ A, M4 T. _, X. Y
if (ret)
+ r" p; F1 O% |3 W& Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 j4 T5 K! O, P; I9 D; b
"%d\n", ret);6 n5 R, m- @2 |4 j7 o4 L
#endif
7 Z5 C$ A8 P% i2 ]9 @7 V ret = platform_device_register(&da850_evm_tl_leds_device);
3 c4 `! h6 a0 x4 ? if (ret)7 ~3 z2 W' v1 a% D2 I; ?0 g
pr_warning("Could not register som GPIO expander LEDS");: h8 u" c0 l) g1 ?! f+ g) b0 L
else
: ^+ z" m3 s `+ p printk(KERN_INFO "LED register sucessful!\n");
- v. k# D% P; K
3 l6 x5 _$ n1 |( V' b/ j return ret;
6 j [: D1 S b. W5 y4 l, `7 m}8 i5 T% |) x8 U% p2 y
- t9 R( Z& j: D9 u) o
static void __exit led_platform_exit(void)7 D) j& S y& X: H( R/ A
{
9 `$ o* ]7 ^& d6 M: ^ platform_device_unregister(&da850_evm_tl_leds_device);; H; W, R1 u8 {# U" h H. \4 r/ s. t% R
5 ]2 g2 E0 C' u; Z; U& ?3 Q: _ printk(KERN_INFO "LED unregister!\n");6 I7 w* I2 W Z/ p8 R
}
: e# j- l) Y* {5 @, S0 X& V' J/ G" P- D0 F9 d6 M
module_init(led_platform_init);! i+ S: }9 W' D5 k* G4 g! d$ s
module_exit(led_platform_exit);
, t1 Y1 P; N% B% y' R" \' s! g( t8 c3 c$ I7 s' W3 B
MODULE_DESCRIPTION("Led platform driver");
! E/ x$ o- }2 D# I1 h/ e6 e/ g- HMODULE_AUTHOR("Tronlong"); r. A& T8 ^4 ~( V
MODULE_LICENSE("GPL");
6 C! Z" X2 T$ S% z% n8 h4 }7 G5 i0 \+ G. s" t9 J
|
|