|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) Z7 L5 ]0 W5 N' \* E* o
#include <linux/init.h> f+ f+ [% n, Q" y+ M/ f. S
#include <linux/module.h>8 _/ m2 a# F' h& n0 U" J% G2 }# H
#include <linux/kernel.h> ?2 ~$ e/ B* M/ w3 u
#include <linux/types.h>
7 f% Y3 C: d7 x2 Q- v" T& z#include <linux/gpio.h>
0 ^5 A$ Q, k/ P2 R2 _6 w#include <linux/leds.h>
i& g5 b2 }+ u: `, P4 b+ c#include <linux/platform_device.h>) a1 o" q' Y" g9 M: A
, V# D, i, B1 R9 u#include <asm/mach-types.h>
5 S- a! z _2 z. a#include <asm/mach/arch.h>% n3 o: e" S7 {9 m' v
#include <mach/da8xx.h>
, d) ]. e- j: |8 M5 y3 b#include <mach/mux.h>+ z3 o: e6 n7 j% \2 f
f9 n/ c7 l6 k6 ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 A$ B$ [; a) r: a
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 P/ o7 q0 M/ f- s' r T7 j
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 X) G# J5 R# B2 U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, e! h: M R! q
. Y' Q7 v5 r/ e0 B2 N9 r3 h: ^/* assign the tl som board LED-GPIOs*/
, h9 `2 D; Z" P1 e- Bstatic const short da850_evm_tl_user_led_pins[] = {
0 B' Q% k% a# V. ~' E# S1 s. i1 G /* These pins are definition at <mach/mux.h> file */3 I# H: R/ f5 o4 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," ` H) p. y5 J: L ?0 y
-1
9 T; O3 ]" R6 Y3 f1 Z/ P& ^5 h' f};
4 J& H! y; l V9 @
/ ~# E( B2 l M* kstatic struct gpio_led da850_evm_tl_leds[] = {+ \8 Z- j( H0 l( Z) s; l
{
* c6 j( ]) ~- K0 ?- d! q: D .active_low = 0,
# W' a4 A' F+ A2 W' o3 F! I .gpio = DA850_USER_LED0,
! O9 f/ i/ e# w' X% {$ O. @% j, J* W, F .name = "user_led0",
( g7 h7 D% X% _' [, w .default_trigger = "default-on",- u3 c3 E4 h6 ^/ L9 F7 h
},7 h. a" }" [; ]6 ^* H( C, n* E9 Q
{
: P6 P( s( r. N .active_low = 0,
0 s r, t* ~ b- E .gpio = DA850_USER_LED1,7 V: q+ H& F2 q' h) ~/ A; H
.name = "user_led1",
8 O: [) q0 A5 G$ Z .default_trigger = "default-on",
) \( t# u- s w; u },1 }, d* X: ?/ k2 j" g9 Z* k
{5 i( w3 z' l% M5 v7 o. K7 D
.active_low = 0,& ` W+ L2 Q8 G! V
.gpio = DA850_USER_LED2,9 R0 O7 E1 l! t7 H
.name = "user_led2",: B0 f! h, G! ^ X' q% k! ?: |) W
.default_trigger = "default-on",- E( f O# K# l% v k5 f
},
9 R8 L0 b4 ]2 J! |1 T {
/ K% ^) W: Q/ D. { .active_low = 0,
/ W2 D1 [% N3 d) T: m/ w L .gpio = DA850_USER_LED3,& u. q% E8 w0 M( g
.name = "user_led3",
3 m r2 F/ `# _$ ]) e6 X .default_trigger = "default-on",8 g. B9 }/ W1 S: `$ B
},
) h# x3 P1 k9 Z6 v' J};
5 R' ~0 L! Z/ s" R3 ]
. l% J/ k% i8 ^) U' Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 W" W& J5 E- r8 Z# s8 T+ W5 `
.leds = da850_evm_tl_leds,4 S# S+ [, J( J% j$ _) r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: ^8 {0 w8 N( ~- D. t6 H
};
/ V$ U1 V. G% X% S+ C% B% D( G" f9 E& w3 C h. @0 }
static void led_dev_release(struct device *dev)9 I# N& }5 L0 z. P9 ?0 b( A
{
# @" N4 E! [5 h. f};* t# ^* ?5 _/ G7 f/ N) w
( P4 n2 c) q1 R
static struct platform_device da850_evm_tl_leds_device = {
$ a% y3 h/ Y$ k, D" {+ T .name = "leds-gpio",1 e# j0 C0 m; F* {3 l! K4 g
.id = 1,
+ d% v* T) K. U& g% Y .dev = { k' b0 { D- {+ b) g
.platform_data = &da850_evm_tl_leds_pdata,
' t( f* O' s( r8 M .release = led_dev_release,
' \+ r2 j$ D& t9 k C$ t+ } }4 t2 Y/ w5 j: f) Z% C0 v% I7 X8 R+ m0 s3 q
};
5 N) I3 r" y1 {9 I( T1 t1 t; I, b% G. d" U
static int __init led_platform_init(void)5 h( w! t# o5 D% |9 {2 w* T, R
{
/ X- Z) l; d/ E5 q int ret;
9 r- ?8 w5 ]( f5 ?7 g5 [# F#if 0
! l8 T- _. m4 N2 o8 I) ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 s1 v/ q/ R: X/ U# K. j if (ret)
* ?4 J, l" j' M3 { pr_warning("da850_evm_tl_leds_init : User LED mux failed :", j5 g+ ]5 o' S+ Y7 H
"%d\n", ret);
/ @7 U# c$ m* y#endif" X& E- N% y+ P
ret = platform_device_register(&da850_evm_tl_leds_device);
# e8 U! S" z+ ~# o; z if (ret)6 Q$ H- z# ~6 w8 [3 {1 u
pr_warning("Could not register som GPIO expander LEDS");
3 k4 d* a7 Z8 s: J else4 w; ? w% A' t: ]7 y
printk(KERN_INFO "LED register sucessful!\n");( @0 Y V& }7 z8 @# {/ `
" y/ d) t4 o5 {! W, R+ d3 C return ret;
# F3 u# `. a! X6 X- Q; ~}: y& s. D. r$ t; P$ {
0 u+ _; }3 a& C5 u6 Vstatic void __exit led_platform_exit(void), T# T$ g- q5 q0 H% [
{
, q# i { f9 J platform_device_unregister(&da850_evm_tl_leds_device);/ ~- L' B# [8 U9 P! Z. |
( ~! Q! g8 b& k4 U; D/ b
printk(KERN_INFO "LED unregister!\n");2 Z- g/ J' u& f: F4 V8 q
}! I: S& q. ?- R4 F* F+ b$ G
1 W$ L* g ]& o# [5 o
module_init(led_platform_init);+ a5 o( u i1 D. V- d, b
module_exit(led_platform_exit);# u: P6 w/ x/ T" T
6 K. C: S* G2 W' Z! I6 z
MODULE_DESCRIPTION("Led platform driver");
. S- E s6 ?: h: p: Y) ~! yMODULE_AUTHOR("Tronlong");- w: u8 j E# M
MODULE_LICENSE("GPL");
* m5 D1 L0 X/ G% R' x& d( B, f1 M8 G( n7 s7 d8 |
|
|