|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* Q+ `5 D" \5 {2 l) y% Z& r) G: W: a/ \
#include <linux/init.h>. {) @$ t' y1 l
#include <linux/module.h>
: F! E; o+ h" k r8 g#include <linux/kernel.h>! M; a/ G8 {) v# |0 y* O4 s
#include <linux/types.h>1 Z+ |% M& F( n. Q; H" S, F/ ^* I
#include <linux/gpio.h>
+ m5 N/ d6 v- L. h( ?/ y- t6 J" e#include <linux/leds.h>
7 v4 C3 B8 m, ?#include <linux/platform_device.h>4 A; N; Z9 A$ { H
, H4 v* s9 D, G1 ^* G0 E4 W
#include <asm/mach-types.h>8 T# v, `8 s; P5 e+ @
#include <asm/mach/arch.h>) d7 ]3 O$ Z9 s, \5 R" N
#include <mach/da8xx.h>
2 A/ K, K* P3 c8 E#include <mach/mux.h>: V, }% m4 O7 V& n0 U2 ]6 F
4 P4 u5 Q$ F8 q1 c: ~" P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' e; l$ _' ~0 j; j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 }4 ~+ w; a2 I0 B* Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* ~/ O4 Z! F# | _# M6 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 F; f0 y8 Y* W: o2 S, v, C W @- Y
/* assign the tl som board LED-GPIOs*/; r/ L7 D* K+ d1 l& H1 T( c4 z
static const short da850_evm_tl_user_led_pins[] = {
8 J9 z) P8 V. ?& Z+ R: z /* These pins are definition at <mach/mux.h> file */
, G! n. N; ?: I& J- W5 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& S! ]$ H# m# ~) s2 i* F$ n -18 w: B; T8 l6 u1 s, \8 U6 [0 u
};
2 z3 Y" E4 }6 Q' b8 H$ [. W- g8 w& a4 u0 m* c4 P. J- g
static struct gpio_led da850_evm_tl_leds[] = {3 ]) {5 \, _" O5 u7 T
{
, ^! _: X8 \8 E. Z. z1 [' { .active_low = 0,5 p8 I5 P/ Q6 Q7 d/ w5 {
.gpio = DA850_USER_LED0,
% C( Y0 Q k8 f. R z1 ~0 a$ Q .name = "user_led0",2 A3 M9 @- @3 d: c/ v4 Z4 K I, ?
.default_trigger = "default-on",
. w/ b4 X# V1 z4 B- } },
% ~- h6 O/ B& i) T# n7 N {% |9 F0 i: K1 A
.active_low = 0,
' P( {: [! {: i0 x+ s a; H/ @% C .gpio = DA850_USER_LED1,
; y: q* |9 q3 o+ I" m .name = "user_led1", u$ M9 y0 G8 v9 ^4 K! ~1 X
.default_trigger = "default-on",; I8 A: Y P. _/ U% y2 p
},
( l. P: _6 U5 o {9 D1 Z+ T& C! N6 g R
.active_low = 0,5 Y& p' N2 X( @8 k; Z
.gpio = DA850_USER_LED2,
3 E" t+ ~1 d* D' ~) V .name = "user_led2",
7 {5 d- s. \! w y5 |( A9 y* d .default_trigger = "default-on",3 l# g$ Y x" f/ I7 G' @) T
},5 z9 A$ L* U4 ^5 Q
{
3 P( U8 K1 a+ E; Z0 i .active_low = 0, X3 S* V8 m* k9 s4 ?2 E8 p$ l
.gpio = DA850_USER_LED3,, K7 q& Q& H& {6 ?: Q" H
.name = "user_led3",
' N! S3 Q' G) H6 c! c: o .default_trigger = "default-on",! k5 R( d+ p ~/ r- E
},
) V3 X$ G: R. ^/ M) y};
1 t4 l& Q8 ]! g" Z* o% Y7 [( j( ^8 c: p6 Z: e- c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# y9 F# y0 U9 i# g, o r; J: v
.leds = da850_evm_tl_leds,
0 k4 U8 |, e) B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 _ i6 x# ?+ Y6 m};) S: J3 e3 x# c R9 a6 ~8 W6 D
8 N, J! M8 H: C- gstatic void led_dev_release(struct device *dev)
; i$ g0 s) L& k' v{
* ?: _7 ] \5 J3 \};
7 S2 h7 h6 x; ^( `
# X' D# S: H, G8 ]6 s3 x: lstatic struct platform_device da850_evm_tl_leds_device = {
% s2 ?7 B$ l8 o% a .name = "leds-gpio",
5 r( j$ R6 |+ y( T% c0 r! }& [/ f .id = 1,
. s) n" z4 d; m9 N* l .dev = {
% V% A: @8 c6 i( n. e .platform_data = &da850_evm_tl_leds_pdata,
! P3 d$ z( G5 d& i d/ o .release = led_dev_release,
; Y* R7 Q/ `) ?; m) {2 O, l* B }6 y* s$ c4 i, M1 Z3 X$ s, i
};
* @% _ q" @* @3 b
6 Q) `) r% E7 n, U8 o9 \1 s' ?. B# F; j8 kstatic int __init led_platform_init(void)
" U' z" d, Q5 l; P+ L, K( o1 Z5 G{" G" a! g; [( Z
int ret;8 F4 x0 P2 Z% \/ f }2 I9 \
#if 0
* f; I( e! _0 X( P2 o2 V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% k4 `6 V' [0 x; m1 @
if (ret)5 @ s5 L1 n+ R4 {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- O, s6 R' V) w8 c# v2 K- { "%d\n", ret);
% l3 [8 B0 A4 k* S; y @" ^/ ]#endif! L/ D) d H; {! K0 e$ x
ret = platform_device_register(&da850_evm_tl_leds_device);
! r1 a! U5 \7 x& L if (ret)/ R- L+ [* u- y6 h$ H
pr_warning("Could not register som GPIO expander LEDS");: O7 C: i! S f- e ?
else
8 I: x' w8 u f" _0 {7 k4 _' U: G printk(KERN_INFO "LED register sucessful!\n");' \# Q! o) r) l# I
+ C; r& V% ~; I) j& @- `9 `
return ret;
- W7 r4 {# E; D}
! ?$ L" M# M9 s, x# H9 K. N; |! ~0 _, {" m7 r
static void __exit led_platform_exit(void)
5 v' K3 t% l, n. R) y: y( y{7 a9 t+ V; r0 |
platform_device_unregister(&da850_evm_tl_leds_device);
8 y& O4 N" g% Y! J: V' X( H6 N4 U* o1 i8 i
printk(KERN_INFO "LED unregister!\n");$ d( z, M; ]- Z) R! G
}/ j$ `9 |8 \$ Y% K
4 j* k6 w5 X; c' N4 N% j8 E* B6 umodule_init(led_platform_init);
; }$ U' l9 q' X9 r0 v, [module_exit(led_platform_exit);; @! Z C$ c2 _2 ^6 \2 G0 ]; D
+ z! T7 s1 y1 T
MODULE_DESCRIPTION("Led platform driver");
6 Y- K0 r$ m8 [, f9 t- h; YMODULE_AUTHOR("Tronlong");
) U7 `- c+ D; _0 Z7 gMODULE_LICENSE("GPL");- W* f$ `$ \0 L0 x8 K* P0 f) H9 z; ?
2 ?! i: k V( {$ f8 o$ @& k* ` |
|