|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& D& R; O9 U& R0 Z) M/ w% V5 G
#include <linux/init.h>
! [4 k9 B3 g: O; I O; E9 d#include <linux/module.h>1 H( i+ r& ^& d' M
#include <linux/kernel.h>/ s& @1 q% m m# b$ j
#include <linux/types.h>
, w/ H/ H# }# o$ e+ ? l/ }#include <linux/gpio.h>* K. t4 O' U: L% ~
#include <linux/leds.h>9 X0 q& z U+ f% @
#include <linux/platform_device.h>
6 v+ k/ s6 P! S: W; Q& [" H( ?
) w. z# h# T$ `3 [4 K+ e#include <asm/mach-types.h>
6 p( i P8 `; h z#include <asm/mach/arch.h>* {/ y6 _% \3 Z# H/ V9 P
#include <mach/da8xx.h>
2 S: T# }2 q1 }3 b6 }) k, j P#include <mach/mux.h>
* b: v$ T6 Q0 y6 n0 _0 Z4 w
: o7 H7 {0 W& w: g3 J2 v) \: \/ ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 \- o6 @+ b3 G) P4 H+ D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): {! z3 G0 g0 S/ q& b5 i( m5 C$ N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 D6 A& `- W; ~/ `& M1 `7 u, a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- P5 u4 \9 N4 m0 n
/ n+ c/ g' g& ~/ D
/* assign the tl som board LED-GPIOs*/
9 H) e% x0 g) Y; Dstatic const short da850_evm_tl_user_led_pins[] = {& C- P u1 ?$ v) c$ \/ w1 M. x1 A! Q
/* These pins are definition at <mach/mux.h> file */8 i5 n* E8 r4 U. o3 I9 x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ k; y! o3 S0 w, E. j! y c
-1
D% N; b7 [' M" a};( ?% Z$ k! @4 s1 l' R
- l* o! ?, `& A* I% T
static struct gpio_led da850_evm_tl_leds[] = {8 C6 C' ^* P9 G. J; p0 b* t$ m$ m
{+ T; E6 I0 } U. B# r
.active_low = 0," Q- x7 ` B# J4 ~5 r t
.gpio = DA850_USER_LED0,
$ ~4 Q9 ~& G6 v& ~8 u- n .name = "user_led0",' A/ r6 Z6 ~9 D, J6 I/ o" T
.default_trigger = "default-on",# G& a5 W( Y. h: d7 J) @& l4 ~
},6 W5 j" G/ b# J/ k: d! c f
{
) Y4 t7 q" P- h* f3 v. w .active_low = 0,
9 L" o3 ?9 t3 W8 U+ `4 v .gpio = DA850_USER_LED1,: B- O/ u7 A1 ?, {) X. e0 K' d
.name = "user_led1",
4 @6 h! C4 c* z( m. _( i .default_trigger = "default-on",
& O6 |: N, q2 u0 y6 W+ Z% | },
^2 R- O* J y2 S8 _9 O {, b% M1 E5 a0 {
.active_low = 0,6 J/ {9 E( C. F6 `$ @, K
.gpio = DA850_USER_LED2,
4 s$ A$ |, a) p% p3 V/ j# t .name = "user_led2",3 e( w, ?! C$ n+ g- `
.default_trigger = "default-on",
6 U+ r. p# l9 L0 S9 F, j },
. X2 g9 P5 N4 Q7 Y- i {7 L0 g6 I: y I- t
.active_low = 0,$ C& p c8 _- ~7 F' l
.gpio = DA850_USER_LED3,
$ f7 H8 l9 j) ~( b2 B( P; N( W% ]6 N .name = "user_led3",1 z- ~ g( `) n3 U- A/ a6 O
.default_trigger = "default-on",
1 U4 t9 Q9 z( b) F3 g4 r },6 p! Z1 H/ W. l- `2 s
};
$ s" a! `3 T6 p; z$ L7 Q6 p- Z0 s- s
8 e3 k1 M" O. _& c: v8 i8 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* q& Q* y I y; ] .leds = da850_evm_tl_leds,
+ o8 N8 W, I& s3 }5 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
X0 }; h! X6 G0 @2 |3 L};8 b l$ ^* }3 B7 h
. N9 u( f6 S7 @8 S" a4 H
static void led_dev_release(struct device *dev)) @, G- A$ P( y' s# P7 \9 D' _
{; s# Z2 n; k0 E( V6 _
};
3 _6 e# s8 _6 w' R' u+ ?
' I# |! W2 ?' `static struct platform_device da850_evm_tl_leds_device = {
8 M6 ^0 @# ?# X; [ .name = "leds-gpio",
# l! _' g1 G; d6 ^# v) ]. J% i .id = 1,
5 O6 S$ m# H, D( y9 _ .dev = {
( |9 h+ z) s' e .platform_data = &da850_evm_tl_leds_pdata,
6 b; `+ b( k" L8 w1 M .release = led_dev_release,/ \/ q4 W9 y; a3 {6 Y& L7 h( t, `
}: s- _. v' T$ z8 _, W8 S
};
( R% h8 ^( j9 s, G4 j7 M* ~% h) y. }: S: Z& x u! ^
static int __init led_platform_init(void)
( `2 Z3 k( I/ Z: l0 r- J$ Q2 R{; s8 u# v4 ?) d7 m1 Q4 b
int ret;
' p+ g" \7 N9 q, v#if 0
% ]- s6 d$ ]9 n+ Z h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- {" w. g; X) v& x, A8 w2 I
if (ret)
4 c! z D$ X1 b8 d" a: U2 f. Z; H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" y3 v! ^: w3 m* ^9 S3 z4 M
"%d\n", ret);+ N, \& r( a! ^6 L+ B: e- Y1 t3 P
#endif
1 V% e1 ~/ n, a- c) x& y/ p ret = platform_device_register(&da850_evm_tl_leds_device);9 z' M' G( \* [ v* s% ]
if (ret)/ j' }; n* G- z9 D; t( v8 [5 h. M F
pr_warning("Could not register som GPIO expander LEDS");4 R: f; y L% b6 _5 U
else$ z% P- A& M7 { W. k1 _
printk(KERN_INFO "LED register sucessful!\n");" z- R0 a6 k; `8 `
7 P1 R& [- Y7 e1 N9 V: P' S return ret;5 L+ q, f8 O9 j# O
}
! E D* J Q1 h3 U4 N; P
( Z# L! b5 c' ]+ Y; V+ w4 istatic void __exit led_platform_exit(void)
7 x" D* @: R# I' f* b{2 g& @0 S8 D6 N0 ]; V
platform_device_unregister(&da850_evm_tl_leds_device);% D9 A5 ~9 I9 a' b
+ H. R( H9 @) t- q4 j1 Y( F3 p
printk(KERN_INFO "LED unregister!\n");) k" x& G* U: X# S! g
}# l I& {3 H* F6 K8 x' V2 f C; x
_. g1 X! S' W% S }module_init(led_platform_init);
" a2 H6 k+ l8 j* B- h5 L I5 wmodule_exit(led_platform_exit);
1 t: |! l; T8 x. y& G9 b4 _1 V; c: P* L3 Z% ?6 g; |) S, M
MODULE_DESCRIPTION("Led platform driver");/ ]" v; m# ^. h" H2 |
MODULE_AUTHOR("Tronlong");- J E: N3 U' G0 k" m9 V( N
MODULE_LICENSE("GPL");
& L! N& z! n1 |, w' Y0 n) W2 H, a6 ^' A. V; x' g$ Q
|
|