|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! L: k! {0 o. I
#include <linux/init.h>3 a7 }1 a9 @% |7 w/ D
#include <linux/module.h>1 q/ k) H0 _4 T2 K5 I$ j
#include <linux/kernel.h>5 }5 H" c- n- [9 p: M" M) q( k/ C! h
#include <linux/types.h>: y* H8 q. y# w. v( v
#include <linux/gpio.h>3 r: G; w6 _: B! p- ~
#include <linux/leds.h>
# P+ i: y& @: Z* z#include <linux/platform_device.h>
0 y1 x- G! W% c7 `2 N* o( r2 W) e: v( H: j; @+ T2 E
#include <asm/mach-types.h>
# s. t: g% `! j; T( ?#include <asm/mach/arch.h>& D! G A I' w1 h2 `) }" b4 Q* C
#include <mach/da8xx.h>( h2 n% [ n N+ T: j4 V, l- g( `
#include <mach/mux.h>
" k$ b6 _' o0 z3 |; H5 d% a7 S# t. ~- \- S" F+ o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- w* S w4 _2 D$ \8 y! e0 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 f' J0 [2 W R# R+ i) T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 T$ ~8 r0 W. b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& o3 ` w1 H4 h9 V
3 d! \) g. Q3 D9 ~8 Z6 ^/* assign the tl som board LED-GPIOs*/2 s* Z" |2 B* h8 H [
static const short da850_evm_tl_user_led_pins[] = {
/ @/ E) m3 s3 o! R2 [. V /* These pins are definition at <mach/mux.h> file */$ [* U0 [1 V* V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# G q! _; t( u! ?" { -1
5 k) W& @* u' a};
4 u4 E' ^/ @7 M# {7 e B6 d) I9 F% v2 E6 i; l. u4 h. P8 o
static struct gpio_led da850_evm_tl_leds[] = {
' Z+ s- T, Z: `3 o; N$ Q% { {
( O$ [5 q% p4 Y; L+ c( l5 m% Z .active_low = 0,
) Y7 H8 m# A; o1 `+ n) B0 T% v" z .gpio = DA850_USER_LED0,2 `% A8 I% B: d4 L$ b4 b0 k
.name = "user_led0", s* d# H/ W6 K/ v4 V o
.default_trigger = "default-on",- t: f& @( o. X' Y3 |# |
},% \6 u3 l/ E- C+ [6 w/ ?- `
{
( G7 s* @! Q$ U8 e! [) u3 P# v" R4 @ .active_low = 0, h q1 b `/ J4 H) b2 z
.gpio = DA850_USER_LED1,# k+ \3 }. v9 `0 v4 Z: x
.name = "user_led1",, D4 ]6 C) w" d* z1 t: K4 _
.default_trigger = "default-on",
6 d1 u7 o2 A, G1 D7 K8 \2 k# Z) I5 [ },
8 W% T; s. o, f' q1 I {! U$ |7 V/ F+ ]: q
.active_low = 0,
" ]1 k Q2 C7 [! g/ Z8 {! S .gpio = DA850_USER_LED2,
3 w; m- z1 e0 f; @& r9 q .name = "user_led2",
5 Q4 T' \* q: ] .default_trigger = "default-on",
2 ~8 T3 ~; K: P },
5 `% K9 v! G" g2 u& l E {* Y$ Q g$ O8 B9 h9 e
.active_low = 0,
9 Y, g! _ y) R( b; z8 t, N. O .gpio = DA850_USER_LED3,
! `, k- ^7 f- a& Z7 A, B .name = "user_led3",
( D4 @9 g0 A# h8 }- R( ~1 P .default_trigger = "default-on",
2 o% S! t, O) Z r },! z; s+ n' \! \% P2 K7 O
}; P7 F6 C5 v% a
0 i% B2 z& ^5 Z* {- }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- `$ X% S& W2 H8 ^' N .leds = da850_evm_tl_leds,
) R$ F( ~% g j7 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 q* b5 G' B6 C" v
};* L* T8 m! s/ X0 C! `
9 w* T6 t7 B% D1 ^static void led_dev_release(struct device *dev)
; I/ J9 F. \5 s( [4 o3 N{
# E; v5 ]6 _& t; @5 p% A. \3 c};" F4 d- `6 m( f" z
: |4 \+ R& f* K6 }2 h: m0 d* ?static struct platform_device da850_evm_tl_leds_device = {
1 X1 {" C. @! n( L! l .name = "leds-gpio",
, K4 q3 y9 W' ?- @; K2 | .id = 1,
: N$ B9 ?4 g( G! F& V .dev = {6 @6 u: V% P T5 v
.platform_data = &da850_evm_tl_leds_pdata,! b; t2 _1 _9 _" c- c8 ]0 j
.release = led_dev_release,+ ^" V' N0 A1 O
}
y* ]' w; m- H/ `};7 [8 g: y7 Q( ]5 Y
" d& B6 P: v$ \5 J8 ^9 |1 f3 L+ q
static int __init led_platform_init(void)4 E7 z- Y8 x1 r! W1 p* ?# h6 x
{ J% X1 W4 `0 H7 A! ~; x" @3 e
int ret;
+ [" U; k$ V( _" y! s5 N#if 0% j r0 ~7 k3 ?, b! m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; s$ u% [2 ]8 Z
if (ret)
; d% G7 Y$ c3 i; `( {2 j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- h- R2 s5 Y% I/ r R
"%d\n", ret);0 R6 v2 I2 ?( `) V; O0 X y* m m- Y
#endif
/ J6 J; y2 O# V) d2 [! w ret = platform_device_register(&da850_evm_tl_leds_device);
) B9 d9 `1 q3 t! a if (ret), g( H K$ X& e% k0 A; w
pr_warning("Could not register som GPIO expander LEDS");6 s" ]& q! A% v# {
else- h! ?; o% S4 I5 W
printk(KERN_INFO "LED register sucessful!\n");- R R) L7 y7 H/ \) m/ }
3 O6 M/ f& z4 t
return ret;
4 m* J- i/ z5 z6 m" h}
7 W( f' c2 ], f6 U# E( v
: i0 `5 s" h" W$ y: Ystatic void __exit led_platform_exit(void)
+ H3 i3 w2 X$ H5 r! v, K! L, S d8 A{
0 t/ O1 u( S) @3 K! c5 _# ]# f) O platform_device_unregister(&da850_evm_tl_leds_device);
# p. g: R3 H, J8 r# D5 I% k/ Q* ?
3 }6 \- Z& o( W: u3 v printk(KERN_INFO "LED unregister!\n");
" d B+ ?" G# i- _6 }9 G}& _9 |9 y$ ?# R2 u7 e: o$ P, m
8 s0 U' U: n+ K: q+ C' J
module_init(led_platform_init);$ T. s) C7 r$ y( U
module_exit(led_platform_exit);
9 X8 ?- u* h: a# k/ V& F- E5 W, B3 [8 X+ L& S$ ^4 J
MODULE_DESCRIPTION("Led platform driver");
. s$ M# ^, N# S, Z8 h1 P8 EMODULE_AUTHOR("Tronlong");
6 \* a: ?- O; D; `3 sMODULE_LICENSE("GPL");
9 D( h8 S! |+ C+ `/ c* U3 M3 \( D4 w8 T( ?8 C
|
|