|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 m% ^* z A8 I2 g#include <linux/init.h>
4 d" J9 k$ ~7 D0 r9 {+ M8 `#include <linux/module.h>0 ?) F% m3 ]4 ~
#include <linux/kernel.h>8 A% ^/ c) Z: a, G0 t" ?; L
#include <linux/types.h>1 P- p" f& b2 p2 ^9 x9 ]( k) O
#include <linux/gpio.h>5 D- ?6 G; m/ F$ @6 b, s8 w M5 l
#include <linux/leds.h>/ _& Z/ m0 V* C. V7 M/ V; L& A6 l9 z
#include <linux/platform_device.h>
( P8 Q: T/ d6 {2 y/ D
* b) n W- e2 Q8 [' } Q#include <asm/mach-types.h>0 n! y4 V* N* M& y8 N/ b
#include <asm/mach/arch.h>5 X3 A1 _/ p$ K! o7 m
#include <mach/da8xx.h>9 `# A3 A8 \# U# E6 u P
#include <mach/mux.h>
- x* |* Y/ R' K; A
& W8 @7 L/ X; m6 ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 f3 K8 V% q! k3 U/ C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) F% v- m9 E5 c$ K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 s8 O6 b) P7 I3 n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' g7 P8 V- N3 q) l2 y0 e9 z2 F' P
& O! G1 o: I2 E( e( c/* assign the tl som board LED-GPIOs*/* f1 N# D& v i+ @/ B0 g/ [
static const short da850_evm_tl_user_led_pins[] = {
) |9 t4 q; ?! Y: }! r /* These pins are definition at <mach/mux.h> file */
: W3 n6 R3 a) q5 X- [/ G0 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 D0 a- g; Q- \/ w% J -1
; M4 ]. U |, X7 H8 t3 S, R};
( U; U4 p1 X& I, T' s$ y. X2 q6 ]/ q3 @+ b. ~) }* B# c( ^
static struct gpio_led da850_evm_tl_leds[] = {
: x( @9 O2 J( N, ~: G {
2 @+ Q" {! F4 Y" g' s/ y .active_low = 0,- s* w: |! \& S6 B
.gpio = DA850_USER_LED0,9 m: x Z' q' u$ A+ K2 k$ q
.name = "user_led0",
" x! X; U. o5 {. ?8 ~: N8 m+ @ .default_trigger = "default-on",
% x" H" ~; o/ ^ },
, O# C) | P; u9 \9 w( ~# Y) } {! o x; X$ I3 G% |
.active_low = 0,7 q0 b# e. v" _5 B! ~
.gpio = DA850_USER_LED1,, b, g, Z, w' p% z d' c2 f
.name = "user_led1",7 e+ ~8 f4 b# R% F' L p
.default_trigger = "default-on",% b# q4 h" d3 p+ X
},
7 i& H8 M0 N F {9 q4 J1 ]" n& }% I- A1 A
.active_low = 0,' D! \* i3 y% G- y+ _& z/ \
.gpio = DA850_USER_LED2,
- |9 D. Y) T2 b2 \# I4 a .name = "user_led2",
; A1 A l/ o7 A% z0 E .default_trigger = "default-on",0 _; X: F- ?0 h! Z7 |; d( n
},
/ G9 e3 [ P* Z4 R8 y" | {# `5 K9 O, |5 D T
.active_low = 0,6 b' Q) w) g: P. B- m
.gpio = DA850_USER_LED3,
6 t1 e" a9 v& m .name = "user_led3",
2 v5 |8 f# Q1 E% d8 c8 }. V .default_trigger = "default-on"," a) t" c) {: i
},3 @$ K, R# W) M- \
};
& F% s$ ^4 h/ J2 Q3 Z7 s: V$ ]) T5 c$ p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; h$ W$ s* | u/ T5 T3 P( w
.leds = da850_evm_tl_leds,, o3 Z; m/ X1 S( q& }+ ]) l5 y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ U* p' B! \& n# I9 n4 i};
2 k+ o3 A& P- m* w$ d
8 N& o" {4 q/ _9 v8 x9 ]4 Y( wstatic void led_dev_release(struct device *dev)9 x e1 S. L' K1 x/ ^$ l
{1 D. _! A! K, K( s- U
};
% Z( C1 Z7 ]" O# p( X0 P
% e& ?7 `8 X) H6 Vstatic struct platform_device da850_evm_tl_leds_device = {, W/ J( h; R* ?0 _/ {) }
.name = "leds-gpio",
; r# E2 ^- ], L% ^8 ~ .id = 1,/ Y1 s& S2 {9 Z4 d& M7 L/ C/ {: ]
.dev = {
6 Y' w4 D; c0 r .platform_data = &da850_evm_tl_leds_pdata,9 \% w1 G2 ]9 t+ |. z" ?, J% ]7 D# v* ~7 L
.release = led_dev_release,
0 H$ T1 E8 O# j9 P: i7 c2 n/ _1 l$ d }( O/ M) Y7 @4 n7 N" m: v6 q* c" R" N
};
, h$ a2 Y7 f) w" O% X' b$ s6 ^+ h [2 _9 R) M5 m# R
static int __init led_platform_init(void)
6 v4 d' G; c) J$ y- P1 t1 P# C{
* g* |( [% `; Q( v% ]5 d! @) s9 W int ret;3 ^: m7 @* a/ R
#if 0
/ y. w- ]5 \* F: z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! _+ F' p1 `8 J if (ret)
4 \/ u7 U5 J4 {2 N) x9 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 w; p/ M7 d" g- g "%d\n", ret);
$ X3 T% A9 \* K* y$ Z3 J#endif7 ?- p$ {* b# f5 ~* E2 r9 ^# s
ret = platform_device_register(&da850_evm_tl_leds_device);
- q1 N: ]0 W6 p% c if (ret)
7 q/ c% u6 u. k; A# m5 K8 {" l pr_warning("Could not register som GPIO expander LEDS");& A. a9 @8 v) O C& X
else
. } A4 v0 N! B6 _4 C printk(KERN_INFO "LED register sucessful!\n");) S* {. K6 [6 H$ K
! g4 _3 n2 Q) ^ s# { return ret;
1 t* Y& W9 C: |}
7 ^$ m! b0 Y: C T" b) g1 S
& f. E Z% w" l7 j- p' z: cstatic void __exit led_platform_exit(void)
6 m& M d+ \) q% k{
4 b- z! M' L' l) j* X platform_device_unregister(&da850_evm_tl_leds_device);9 e: {# c+ w5 d; |+ S: R
7 d8 M/ n" n3 z0 r
printk(KERN_INFO "LED unregister!\n");
# W1 Z1 C. e! K* P}
0 E; ]1 |( ^ E8 f" N: }/ S* t
8 m' {' T- f4 A$ r+ a% Kmodule_init(led_platform_init);
+ S6 |* o# d! j# M/ M6 z8 imodule_exit(led_platform_exit);* b, q. y- N( H2 z- u
" I- q, c/ b/ _5 d5 N# _MODULE_DESCRIPTION("Led platform driver");
% c- c7 l: P: P0 H" P# W/ @8 nMODULE_AUTHOR("Tronlong");
: n: d" F P$ q) D7 {# z: F9 QMODULE_LICENSE("GPL");
8 Q- O) Y2 L! z8 P: j
" G$ t2 M; b6 v) x' |/ A |
|