|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& c1 s# K8 v0 n" C+ U; R4 I% c#include <linux/init.h>
; }* }2 C9 x& R+ ]$ t#include <linux/module.h>, b; M) y3 [. E: M- X
#include <linux/kernel.h>
8 C/ I& R* [1 {% T7 e6 H# o s: P#include <linux/types.h>9 u! p5 M1 v" F$ @& v; a
#include <linux/gpio.h>
4 L, ~" G# `( w# ?- }5 B/ u#include <linux/leds.h>; Y0 H1 a V1 o* ?
#include <linux/platform_device.h>
H) z2 J5 Y% x9 `3 L) R, h- h* c/ q3 |
1 `+ I- Q! _: F8 w9 M& Y* q5 e#include <asm/mach-types.h>! E& G( L$ R3 w% x5 t# R6 z$ @: c' t
#include <asm/mach/arch.h>
1 y6 \5 p; i6 j; T9 x8 v# t2 b2 E#include <mach/da8xx.h>' I* ]$ x" t0 s) S8 D5 o6 y# s
#include <mach/mux.h>' a8 b; W7 Y( x: N
+ L" |+ O. v3 A/ }5 O- `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) n! u: E0 f9 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 t s2 e; S% ?0 J/ \0 }7 o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): A7 Z, p, y2 H* g; `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: N/ e7 G# l) ?, e1 ^" U5 ~% I- Y* {0 ^: d' n
/* assign the tl som board LED-GPIOs*/
+ t( q1 S1 j# x' d7 R# e2 lstatic const short da850_evm_tl_user_led_pins[] = {
6 K* K5 O; t- L$ J5 i /* These pins are definition at <mach/mux.h> file */, A' R% {1 h' ?2 {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 A$ w7 w* J2 a" u
-1/ @, b- G F/ Z; t' _
};
: S& k) ~' Q9 X; L# P X' a; i9 B" L* ^' l# o
static struct gpio_led da850_evm_tl_leds[] = {+ _. _0 j3 B. S! ?* _! A
{* a% n, `8 H/ W$ ~2 J
.active_low = 0,
, T! F; `3 C7 q$ T9 r4 I .gpio = DA850_USER_LED0,; z2 ` ^5 h& i
.name = "user_led0",
) \5 B, F# _ Q; r( B' v0 o/ z. h .default_trigger = "default-on",& s$ F2 _4 k) ?8 P' d7 T9 {
},$ p. \& ?6 U. B+ ?1 D
{
/ P4 k7 d9 g" r5 M4 h6 a .active_low = 0,
6 p* y2 ?* T5 p7 `9 z7 e .gpio = DA850_USER_LED1,) w+ Q& L; x; R2 ?% L( P: _
.name = "user_led1",
6 k( w/ ]- k4 _( L .default_trigger = "default-on",6 {5 }' E: s- H1 V; w+ Q. y- a
},; E0 m) ]9 H& E; w5 N
{! f* N1 A0 L; {7 G" b
.active_low = 0,
; g0 S' ]+ a9 b .gpio = DA850_USER_LED2,
- F9 b c0 a. k- X( u' C1 E2 u .name = "user_led2",8 T! n; Y) M! h0 _; b
.default_trigger = "default-on",
4 k4 O5 p5 b( s) k# m/ r5 A- s3 c },) \$ t1 C% y& i+ b0 B' a" r- B( }
{# X$ t- ~- v3 Q! V2 g5 X, d9 }) c. X
.active_low = 0,
; z( Q% l' J) R3 B .gpio = DA850_USER_LED3,4 ] i# R% Z& c, h- A
.name = "user_led3",; Y& Z4 b6 j) Y: Y$ F2 j
.default_trigger = "default-on", U1 m& {1 {( R- n7 Y6 j
},
1 z5 `7 _. n6 |2 l$ y};
% f4 w& k6 {6 j4 P. q' T7 R5 F" g k: a& Z( N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 u1 a) `7 \. p* r& \ .leds = da850_evm_tl_leds,1 L8 q& L& k; }' y8 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," \' K) s5 d4 s2 g/ f: p
};2 a1 ?8 p& s& l
) U1 J* v/ p# Y7 l3 hstatic void led_dev_release(struct device *dev)6 l6 V+ B! D H7 S# B9 z
{
2 z' [2 ^7 R9 \2 x' P: \6 U};
& y# k' T# }& K6 R6 |$ E3 J; j; P' l6 _ o
static struct platform_device da850_evm_tl_leds_device = {
: U2 u7 Q. w' T, H .name = "leds-gpio",3 e2 m2 ^5 p: t9 n! K! _
.id = 1,7 m# V7 I$ l/ T$ C) J ?
.dev = {
4 Y. h4 O- d! W6 D4 U' h# @ .platform_data = &da850_evm_tl_leds_pdata,
# q) \- k: K3 A" G .release = led_dev_release,
! {/ F6 G' L; q2 e+ ^; Z }
5 m5 m# k9 Z" s, g};' `& |) a9 y, t1 B
4 V9 c! ?9 Z; \. A7 w8 J' t
static int __init led_platform_init(void)
! x7 j& ]9 X% l1 ^; J: K{
* Z2 U; K8 [4 E, ]5 T int ret;4 d' I3 r& {) V( x( O0 s
#if 0! ]& l$ [ s. H% e, \. l& f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; v$ A+ O' c0 r' U% I9 k3 a if (ret)- i( _) p$ A! Z0 V; L, d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". J5 T0 I! |) ~! R
"%d\n", ret);
4 C: w; |. k+ u. V#endif6 K2 E* r/ |6 `2 e" Z
ret = platform_device_register(&da850_evm_tl_leds_device);, y) C. ~# v" b/ U
if (ret)
a& M: g' q! Q/ G R4 ~; `) K pr_warning("Could not register som GPIO expander LEDS");' ?$ T5 ?6 n& y- H1 \- H. X- u
else) R" I- |0 T+ e. c4 l
printk(KERN_INFO "LED register sucessful!\n");
! M7 x P* R2 [6 K& j3 ]' `' a: o0 m- n% B* x
return ret;
9 n9 \) R1 P$ k0 u% @9 j}4 A1 v# K" x; ?. u
( F, _$ f+ e8 D3 I7 _
static void __exit led_platform_exit(void)
1 v% I* S9 b# n3 h1 _) l- b{
8 @. P; {; N6 G }+ b$ b' u+ V6 s3 N platform_device_unregister(&da850_evm_tl_leds_device);3 T- ?+ Y, b- i/ h
5 t8 D* L* y8 W# V) ` printk(KERN_INFO "LED unregister!\n");
r2 p& g# L( q# i* R+ Q}
6 D& |) M; s) d7 J0 a6 w( d, D2 k3 S/ f8 \! `
module_init(led_platform_init);
" Z2 G2 g6 h! F9 xmodule_exit(led_platform_exit);
' U. Q. A$ ^9 C
* \5 U6 G9 ]& A1 W h# K8 S2 g6 B: XMODULE_DESCRIPTION("Led platform driver");
- e8 }4 o6 ]3 AMODULE_AUTHOR("Tronlong");
3 v" o! w) j9 y2 n. qMODULE_LICENSE("GPL");9 t3 P$ O/ N, k2 i
8 k# e$ u! u! r$ U8 z; R+ U |
|