|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 \$ F0 W1 n: J( Z& O
#include <linux/init.h>% D) b. ^' M! Q. `- B7 e
#include <linux/module.h>6 A0 G6 I7 a B3 |7 K
#include <linux/kernel.h>
- Q- x# q' {% f( g" h- ]" e#include <linux/types.h>
9 F1 {# n5 {) Q+ n- m( q#include <linux/gpio.h>
& b+ c! K2 r( U#include <linux/leds.h>
' U2 i* Y7 i% Q! o# \#include <linux/platform_device.h>
1 l8 x4 m& \& c6 |3 F7 g7 q6 l) B5 `& P$ y8 T3 w
#include <asm/mach-types.h>
+ _# A- k5 B. j#include <asm/mach/arch.h>& H! Z2 h/ a' f( p5 X
#include <mach/da8xx.h>
* T( ]% d- b, ~2 O6 l#include <mach/mux.h>! ~) ?. _% S8 Q) F- I
e5 N8 g' L/ O7 u" f1 ~- Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* w8 G' w- U4 @. c6 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& z3 B# {( w) @/ t7 G" ]- s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. S' G8 d6 p* o! M& p* a6 r, S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). v; h, r1 d- j" h9 v
& {; h# E( q% T# S/ W: V+ M/* assign the tl som board LED-GPIOs*/% {9 ~9 C! z( L8 t9 E0 b, k5 h
static const short da850_evm_tl_user_led_pins[] = {9 E9 K, T) V7 C% R
/* These pins are definition at <mach/mux.h> file */' }& P5 B& h6 B1 u3 w# d4 s* B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* @; m! |* p5 m -1: ` w" a; C x0 j7 u2 b
};/ A# H4 z- j! J) n2 Q {
5 k' |9 X5 H/ I0 [static struct gpio_led da850_evm_tl_leds[] = {
M% y Z! C5 [! y5 Z {
4 n9 N( H. n$ i5 A X8 e .active_low = 0,
' c' H. {8 g6 E& ` H; | .gpio = DA850_USER_LED0,9 Y0 ^$ s! g A& T
.name = "user_led0",
3 o) s3 y+ `* j4 U .default_trigger = "default-on",( X" w! G( r: k* J* u
},; B( A$ Y& e) M+ W% R8 i
{
# B# B, f; f/ ` .active_low = 0,5 S5 V( `5 I* q& K8 I. _
.gpio = DA850_USER_LED1,
, u& @ Z/ L% n* ?, B5 P& W' Y .name = "user_led1",, m% v/ B. _: ?$ i5 K" L
.default_trigger = "default-on",
( \, l, l: a' Z3 U v },
/ s) o3 I1 c7 r; n% { {
: k- _+ i7 i& K, d) F .active_low = 0,
" y/ r( v. |+ I+ J# O L .gpio = DA850_USER_LED2,
- I2 b1 |3 U$ K( {' D6 e .name = "user_led2",, W0 l5 n6 `7 x" W
.default_trigger = "default-on",. t1 n" ^( p1 u h
}," l( }2 ~1 y/ r9 C: Y% y
{" v8 Y) U' r5 H9 H! b* h h1 t
.active_low = 0,
0 w& x5 t' t! d .gpio = DA850_USER_LED3,1 i8 y9 K3 q* J5 Q9 ^
.name = "user_led3",
B) l) i- ]- M# P: t2 Q7 V .default_trigger = "default-on",3 w2 V* h- p' j# O: u& K
},
" G# v1 W, {8 Y# [- [0 }};8 C; T$ l* C8 F. j7 y$ a
" w: `% {7 r s+ k6 J" e- x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 @, b' K. e) Y* K7 S) _1 y
.leds = da850_evm_tl_leds,' b0 D' S! u \5 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ o' J1 r; w. q, g1 A};4 H8 o, ~2 h# `) L* @: K0 i
1 F$ L# z( @4 N
static void led_dev_release(struct device *dev)# n8 J( g' s) x* D0 r5 x1 Y
{
; L- E3 k( ]) X; Q% i, O- r& c1 H};
2 L5 u8 r* [. {
+ J1 n' t* C3 {5 p* Gstatic struct platform_device da850_evm_tl_leds_device = {0 D' `- _! T8 O& G' J1 y5 V
.name = "leds-gpio",
3 w1 W3 [9 [ o1 T3 _) [- S .id = 1,% I0 u' z# U, x8 v- P$ _# B7 r/ z3 W
.dev = {
" ~ I( _9 h7 D( s( f, i .platform_data = &da850_evm_tl_leds_pdata, e2 ?- a W# w4 ^$ ~
.release = led_dev_release,
) D& q7 ?+ _. u }
0 X& @ N9 E3 S; Y" C# J};1 P% N* W$ w+ S
9 b4 j) q- Q# U
static int __init led_platform_init(void)
) N3 z4 s3 F; f* Q{+ U _% ~& Y# B$ _
int ret;
7 D8 A8 H+ z- Z#if 0
: L9 Y1 O% I$ J+ ^( t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 o( A+ c! t; K! w; m8 k6 T if (ret)/ a" k) g3 b& W! x k2 k! ]: k. C5 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
i) Z6 q2 p+ F "%d\n", ret);
( b) p: @8 f) x4 j# }0 k) R' v#endif
9 m0 O: z+ b6 ? ret = platform_device_register(&da850_evm_tl_leds_device);
% ^9 D; j3 [9 {/ n- w7 [4 t6 ~+ C if (ret)! ^9 Z6 ~9 v# \) ]
pr_warning("Could not register som GPIO expander LEDS");) B+ H; L, \. C, q
else) \2 o- @0 j* O/ g) m7 h
printk(KERN_INFO "LED register sucessful!\n"); X6 b7 ] y$ } d
7 Y9 r) o* g# ^( d% h$ E return ret;
8 Y8 ~0 I. u5 P) u. y! n5 ?( c}
9 i7 T, `9 l' t" {3 v B8 m4 x3 ]+ I4 i& w! C3 r' w
static void __exit led_platform_exit(void)- ~3 A+ _: }+ o V- Q4 Q# T5 l5 U
{3 S; K( ^0 H" A5 B2 ?1 ~
platform_device_unregister(&da850_evm_tl_leds_device);
. Q- c) }/ {8 q
: s) g/ P+ A4 K printk(KERN_INFO "LED unregister!\n");
2 v2 L6 g" q& m}) {/ @9 @, L/ S! u# v+ q' b
# y7 s3 U4 w4 J, ^ v3 @
module_init(led_platform_init);
' n4 ^& `5 k8 I \8 L& y6 Q: b6 ~module_exit(led_platform_exit);2 W; z7 t7 Q# G. A( O
3 u, j4 b6 H) t) N0 [. yMODULE_DESCRIPTION("Led platform driver");0 y6 n/ d N) ]- `# N6 Y# p# E: q
MODULE_AUTHOR("Tronlong");$ ]& I, `4 S1 q2 h7 @
MODULE_LICENSE("GPL");6 o/ Z4 R5 s2 S0 { ^
. I c `# d6 Q4 c2 O+ {" h* B
|
|