|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 \& G' O" ]& l4 U
#include <linux/init.h>
( n: |8 j1 J' I6 e# d#include <linux/module.h>8 w+ [ f( a* e+ l, L+ _& ~$ q* `
#include <linux/kernel.h>
' T7 c: Y/ r! U- Y: J% c! B8 b#include <linux/types.h>1 F7 q0 n7 T( I
#include <linux/gpio.h>
$ a j0 O& w* q#include <linux/leds.h>
5 W2 T+ z) q! C/ V8 }#include <linux/platform_device.h>$ j X* ~" J+ x8 f
+ g: ]/ z' i7 r+ ^. m, A
#include <asm/mach-types.h>1 _1 i" ~' ]2 [7 X. m
#include <asm/mach/arch.h>
: b# |" c( i \#include <mach/da8xx.h>
' D/ G7 Q1 J; |7 V" w+ C$ Y' a#include <mach/mux.h>
' ]4 Y, f4 h! e! N9 n* R
( |. T9 T0 n7 x- H- o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 A$ f3 N" R' a, x, X1 V$ {+ \4 Z! H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& |( F I1 N- t: b& x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% ?3 N3 q4 G y4 {0 g
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" K/ @, G9 P: j" m8 U
7 P0 w$ K$ f, T& A. o/* assign the tl som board LED-GPIOs*/
/ k$ l P. @ c. N X& cstatic const short da850_evm_tl_user_led_pins[] = {
" g, X* [" d. F i N, x /* These pins are definition at <mach/mux.h> file */
/ m7 g) J8 `& p( ^; X) r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 u5 I7 ^7 Q7 b) T) p
-1
( a! n5 W0 @4 [6 _5 u2 Z};9 ?& M& K2 S; p
8 I( O7 \8 k1 O) Cstatic struct gpio_led da850_evm_tl_leds[] = {
2 u' N: X5 _; d/ J- z3 e, l/ s* `& H {1 d/ \' _- N& f2 K8 E8 u( \: x
.active_low = 0,
4 l Z% M- h% T$ S( J" m .gpio = DA850_USER_LED0,1 L; F. g1 z a5 B
.name = "user_led0",' D; p% H9 ?2 S9 F4 Q
.default_trigger = "default-on", d. p& _2 e+ v. w) h) z
},$ \! f2 `; C$ }1 h; K
{
5 b' s7 p6 z6 i' l; a .active_low = 0,
0 b8 J# q/ V6 ` .gpio = DA850_USER_LED1,
. g6 B* O- F- V7 J5 M+ \5 ` .name = "user_led1",
0 E6 Z; B. J2 I .default_trigger = "default-on",
0 `( J L0 C$ i' n5 J, ]+ [ },, I9 Z5 T( F |# H
{* U9 w8 e% F q& _8 c8 H% z
.active_low = 0,
; W! b+ V4 p; A$ Q .gpio = DA850_USER_LED2,
' i* i5 Z: z% j8 m* e1 S; N7 ]+ E .name = "user_led2",$ G; H& l# E3 b9 o7 _! R
.default_trigger = "default-on",! L, `8 Q: }' \
},4 H# c* z6 A9 ]/ d" q
{
$ V: b* z9 b6 W) n+ i) T) m4 f .active_low = 0, Q; U5 E# _ h0 Q- Z! ^/ F4 K
.gpio = DA850_USER_LED3,: k! C. Q K0 r+ L* P+ k% T: _
.name = "user_led3",
* K- y( n3 B3 ~' k, w2 \- B .default_trigger = "default-on",
$ T' g/ t H. {8 m6 s$ Y& w },, ^8 w# \" |* J8 T$ N! H1 @
};
7 N; k( k" L$ C
3 w+ d4 l! `+ n6 u* \+ W% astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- R0 z" q/ c/ [- U7 E( Z .leds = da850_evm_tl_leds,
4 k- c8 b- q5 M3 M5 _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 p$ o; b R1 o) i* N" p" F
};
" g/ d0 q1 Z# `+ u( c/ e
3 `6 f$ D0 R G$ h7 `- o+ \# ~1 Kstatic void led_dev_release(struct device *dev)5 Q. I0 x) B6 o8 l! X/ H* x
{& N: Z% N, r4 l
};! Y N- @: D0 N; c
4 r9 v) O% _, u
static struct platform_device da850_evm_tl_leds_device = {
6 J7 G6 S0 q' I7 Y& |% J .name = "leds-gpio",8 L4 b5 V! A* j' r; G
.id = 1,
. X! v L9 ~" V; H5 D8 n3 Z8 Y .dev = {
7 M' G9 T B; n! g: x+ t7 V .platform_data = &da850_evm_tl_leds_pdata,) \# K/ F+ t$ y$ u/ n+ G! [4 x
.release = led_dev_release,
( \6 g8 j# \; O9 v% o }1 z d9 ^, T4 l2 T$ f
};
7 y) `9 O# s# F' v5 e
. h7 |6 `. i, ]/ j$ Z# S& Nstatic int __init led_platform_init(void)
' j% U1 ?* o. p{
( B0 V! A' n2 m$ g1 u# s int ret;
8 b# b( z7 i& u/ a( y4 c#if 0$ R3 k4 {$ }8 K2 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) G$ |( x2 y1 h! _. D
if (ret)7 g" c8 [1 b7 M3 J: s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& X2 ?' ~" n: F; a6 C+ M% K1 C. B
"%d\n", ret);
8 _7 [. _5 K; p7 c% X% P#endif! x+ b7 `5 v" K/ @. f2 f% }: L! O
ret = platform_device_register(&da850_evm_tl_leds_device);
" W7 E+ J1 a* E2 Q! x: y9 N+ O if (ret)1 O& ^) U" }# o8 i& O
pr_warning("Could not register som GPIO expander LEDS");% Y9 G- t- S& d8 j$ L T
else2 k* L% g+ j9 Y2 c
printk(KERN_INFO "LED register sucessful!\n");
2 N; B7 |8 x4 v3 \ a. M- u) e0 S! z) p% X7 ^2 Z: L
return ret;
6 Y# M- r: t8 N+ ]% B( z$ ~}
8 k- r. C! N9 {" \
$ o6 r6 n7 X0 q* s' [* T% zstatic void __exit led_platform_exit(void)
8 \( r; h9 ~9 B/ B4 G6 T{
+ @9 G9 ]1 [- G, ]' y platform_device_unregister(&da850_evm_tl_leds_device);, {. _( C' f5 K1 W" @ t# z i
3 Y8 J" L' A2 i! s
printk(KERN_INFO "LED unregister!\n");1 H# H- t9 M! w+ ]
}8 y' c h- M c5 t
. T: A5 {% ~: T# s, J( R7 B& }module_init(led_platform_init);; S: ^ Z! k/ l. K A/ c
module_exit(led_platform_exit);% M: c% I9 n* g
* y& v8 b3 e3 o0 K3 i* O8 ^: sMODULE_DESCRIPTION("Led platform driver");
- f) B: o0 i, m* e5 C' N2 ]2 f# J" `" [MODULE_AUTHOR("Tronlong");7 \" z! o$ h* D
MODULE_LICENSE("GPL");
; m$ ?* P7 Q+ S& b2 v
4 P8 L" c6 A4 r' U |
|