|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& n$ P# e& d( s4 |7 h
#include <linux/init.h>
7 |1 w4 c1 G- V, d6 O#include <linux/module.h>
! P1 _% {7 Y, \4 E; P#include <linux/kernel.h>2 M4 f: b- `5 y4 V
#include <linux/types.h>% z6 u5 e: ^5 k. ?* \5 [/ B5 L
#include <linux/gpio.h>
# S7 `/ Q- ?# t3 o3 E- \#include <linux/leds.h>
4 b! X6 ~* n) n. Q: @: |#include <linux/platform_device.h>) m2 g. p# v4 y% _' O- S
* o% j$ z; j. k' n
#include <asm/mach-types.h>
1 G8 y" N6 ?9 u% v#include <asm/mach/arch.h>
7 Z8 W$ c% {! C( i8 F0 c. Z r#include <mach/da8xx.h>
9 s# C4 X: ]. b4 E5 O#include <mach/mux.h>" I3 k) f, Q$ z7 B, x5 p
. S; h8 H4 P/ J/ K# d3 l5 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 p7 s7 L/ p; Y& Y0 q" H( g& G+ w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! w+ W9 E) h4 d' l$ L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 C+ U1 s) }. G8 M# Q' j3 {5 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 i- T8 ], N- N/ `
. X8 E; g! }& L' i! G7 X( }& s/* assign the tl som board LED-GPIOs*/% I, s) o( a1 J0 j: ?3 O
static const short da850_evm_tl_user_led_pins[] = {
. ? ?! |; W# N: N% W$ a /* These pins are definition at <mach/mux.h> file */
4 _3 Q) W: o2 E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' r8 N5 \5 F, I9 _) I -13 Y2 D0 _! o' K
};
" O d5 H& ]1 T# y
( E6 ^0 Z* P6 g: s5 Ostatic struct gpio_led da850_evm_tl_leds[] = {
0 u4 O4 t4 i% L, P! r" k k {
4 R$ a; P7 K5 w8 M% U8 y2 y- m .active_low = 0,9 E9 Q4 J; [7 d2 \& h4 c* G `4 J
.gpio = DA850_USER_LED0,
2 B: P; N8 b3 e3 _: }, } .name = "user_led0",5 h8 E7 H8 S9 H' J
.default_trigger = "default-on",
% ^4 Y% f/ Q: l* n. p1 [' ?4 s( Y },6 K& z. n3 q! n: B& |6 P
{
: G& d% ^7 t6 B/ i2 o, o2 _ .active_low = 0,
$ }" }% L8 V/ U; T' ^# R9 F .gpio = DA850_USER_LED1,
: t! n7 k, e% j .name = "user_led1",
m, x5 _! c& c& J+ `; o .default_trigger = "default-on",9 t. q' `) p- }$ [3 H
},& V4 T8 W; G7 }# y; e% I
{, y& L+ Y5 U8 z+ D: s5 T$ z
.active_low = 0,
& g0 b7 g; ]; M6 z0 `+ ]- X) y7 w .gpio = DA850_USER_LED2,
2 |1 R# t$ L* F2 ~ .name = "user_led2",4 ]6 V3 \% b e5 r/ p; Y
.default_trigger = "default-on",
; P% X; A8 Y" ~6 p% x% t },
, i6 l) m, J l {% e, c, M" y& w/ i# c) U) g
.active_low = 0,
) _& x |- U4 N. A$ A* a .gpio = DA850_USER_LED3,9 B. p8 a) o b: E9 ^3 ^
.name = "user_led3",
6 S$ f1 o+ f9 s/ J+ n6 [ .default_trigger = "default-on",8 s V. I) u$ @ @( B8 u
},
: C3 o. O3 m; a- P& u' C};
3 R* F7 C) Q' o5 A( l
. Z: g; F. b- F, ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) I' [' i g+ D% p8 n .leds = da850_evm_tl_leds,2 J0 R( Q& M9 ~$ T; \) i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ q1 N0 d! }4 c0 Y3 x
};
$ l# H% {1 v' k1 Z3 ]/ w6 X! e2 |+ n1 o6 t1 M
static void led_dev_release(struct device *dev)
: s' Z" _! i, h$ a! |: ^ B{
7 u! z; L0 {% C! D# r- y};
& n+ Y0 h3 K/ t# M. i8 ^) @- d* r. Q! G
static struct platform_device da850_evm_tl_leds_device = {# g1 ?( E- O; Q, H" }. q
.name = "leds-gpio",
/ H" V3 P8 g* R$ |6 A0 O* R5 k1 a3 V .id = 1,+ a* L/ k( H/ b1 n+ u
.dev = {
5 P9 ^; o' W' h .platform_data = &da850_evm_tl_leds_pdata,) H; x6 s. B" A
.release = led_dev_release,2 x+ d* y6 A( R% Y
}
0 Q9 Q& g& t4 \" _" l9 \; z f};- G: E' P; t- ]; F+ X' O& X
7 U& S6 F* `' q! N& z A* e1 i/ |7 `
static int __init led_platform_init(void)1 P+ F. i' u! _8 G/ E
{* S/ f7 C8 m5 j9 d' f4 @
int ret;
# f" P0 L- _, n S- J) |#if 0
6 Y- U1 I& r3 P z( U8 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 b1 ], |, e' j) D; `7 d( l
if (ret)& @& F. Q w: G' c ]& M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 f, `; ~ d" p6 b$ g
"%d\n", ret);
; ^$ C5 c7 b& S1 }, G+ q, n#endif
# f! O4 O" L# l( P ret = platform_device_register(&da850_evm_tl_leds_device);* X& u! d% ~& }1 M) G/ L6 Z( W! ]
if (ret)
5 n4 g- N; o! r: h, p5 O pr_warning("Could not register som GPIO expander LEDS");
! B- R5 S/ @) G+ s9 r" y, { else- T( T+ M3 z$ Q7 C3 w2 R
printk(KERN_INFO "LED register sucessful!\n");
" a% n& }$ p$ W: ]* k E7 e
{* |" q. r& A) y% \$ E4 Z# P$ i N return ret;
) t. W# k# c$ @0 }0 S* j. e/ a0 C( ]}
/ e0 A. V, I( }4 n
4 F! O, h6 g( d' d# o/ estatic void __exit led_platform_exit(void)
/ z. v% ^6 `* j9 M{7 C; m3 ?7 I% e9 v# b* \
platform_device_unregister(&da850_evm_tl_leds_device);
, u! F- G/ L& f8 S( a/ I+ m$ L7 E. [+ }0 ]1 m$ n. n
printk(KERN_INFO "LED unregister!\n");+ D8 v ^( j( i) Y8 Y) a8 U5 V
}/ F# @! N5 ?3 N0 O. P8 Z8 b
/ T8 N3 O+ t4 u4 X4 U% l
module_init(led_platform_init);: |% o: H8 r. E- F! |
module_exit(led_platform_exit); Z" d0 Q7 `& N
- K: F5 N3 L1 |* X4 R0 ~
MODULE_DESCRIPTION("Led platform driver");
: B& t9 Z9 O5 e' ZMODULE_AUTHOR("Tronlong");
& O$ \' R) Q5 ?6 T/ vMODULE_LICENSE("GPL");6 b2 I, _% k% L
; a! J) f A/ m$ \6 T
|
|