|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 E* ]. ]& r* x+ f. @; D5 H& m
#include <linux/init.h>; u9 ^3 J9 ^. g1 P' }& T- q# U3 k6 F$ l
#include <linux/module.h>9 n9 Z8 {/ j" N; M
#include <linux/kernel.h>
$ p4 k% X c+ l4 E#include <linux/types.h>8 L$ O! f. |* T
#include <linux/gpio.h>
7 h7 a! v2 _# P; {) p$ J! {/ k#include <linux/leds.h>
3 G4 p O0 y- W B! U, p#include <linux/platform_device.h>% ~5 i6 l4 a/ I7 G7 u) `; t
, N4 r Q( U. F. M
#include <asm/mach-types.h>
' K7 ]' f( F: b' c# j#include <asm/mach/arch.h>
/ o8 m( g$ i& T#include <mach/da8xx.h>
; W: S" U+ u2 a0 g#include <mach/mux.h>
, p S, W/ J" I5 T
: Q' e% K! r/ @3 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); V/ b7 W$ e" V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); A" g. O- @, c [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- M, L. x: y) B- S2 }0 A. ^# J4 Y3 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) }9 K1 N0 i8 |+ y |+ R, r
" \, H$ }4 N- U- L @+ v
/* assign the tl som board LED-GPIOs*/: J( \ v1 U8 E" p
static const short da850_evm_tl_user_led_pins[] = {
; {4 o* H( s2 H* I0 B /* These pins are definition at <mach/mux.h> file */
+ f9 e- T$ X; p0 u) H1 w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 k/ } a/ V) v8 d8 b5 c2 Y
-1. E$ l h' V1 X, j$ }% d; ]+ x# ?
};# S+ ?7 E. B/ G0 r
+ B2 ]5 \ E: G3 {0 ~8 l
static struct gpio_led da850_evm_tl_leds[] = {
5 Z% |, |1 X& r [5 k6 D8 V {3 f2 u3 K/ N6 t) X) X% s% `+ n
.active_low = 0,
& |$ `. A0 S$ O6 V$ Z* G/ ]- { .gpio = DA850_USER_LED0,2 [; w4 _6 Z3 B0 r6 S+ Q7 t* ?
.name = "user_led0",/ M4 c& p0 E( ^5 S
.default_trigger = "default-on",
3 s4 B* S+ y3 ]" n },8 F; d: D9 Q' j% F
{
6 L2 ^! \3 A6 N. e# W" C: T j3 _/ b9 G .active_low = 0,( s- E3 @; k" d5 l2 m
.gpio = DA850_USER_LED1,7 X& @1 O, D8 f; Q5 h' z* @: p
.name = "user_led1",
; [1 @( l6 ~4 N, v5 x- {5 y .default_trigger = "default-on",' f! f I6 b8 F" n/ H% |+ X7 ]/ _
},
5 N( f* L9 j% V, L+ {! m, I {
9 }$ U& y" ?$ n' n% k .active_low = 0,
$ V: A$ J4 P+ s6 {. |+ C6 S .gpio = DA850_USER_LED2,0 S) Q1 ~# z) z1 Z( c3 B$ g" Y- S
.name = "user_led2",
# G7 B: q6 f8 B/ d0 V6 _ .default_trigger = "default-on"," x: O9 _0 c+ s" R% W6 G0 X
},
% l! j# }, N. } {. y/ f& b8 O9 g( T5 `2 ^9 c
.active_low = 0,8 S. c2 h$ I* C
.gpio = DA850_USER_LED3,
( `& Y6 L% ?/ ?" l% } .name = "user_led3",
6 F5 b, p6 [! d4 Q K$ Z4 } .default_trigger = "default-on",4 g4 p2 a& G" x
},3 \4 i; |' d6 Z; b
};
4 U8 r/ l/ p+ b. r; e* U
/ M$ g6 h0 y: G5 m6 K1 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" S4 B5 E) L* ^6 d; e .leds = da850_evm_tl_leds,- }+ K# ]: d# u. E# Z# s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' H- _4 y. Z. u4 G: s) y
};% P! @ }' f4 u7 z$ s( @' F% ~
+ [+ J9 l0 l1 a) g: r- G
static void led_dev_release(struct device *dev). }8 \, e. M4 F" z# o1 ~
{" w9 R1 o: ~2 S
};
$ T' I) ]/ V6 Z8 H- Q- ^9 X
7 T5 a. X* i0 Istatic struct platform_device da850_evm_tl_leds_device = {- b$ C, p. \( t3 r- ^/ u: n
.name = "leds-gpio",6 s2 `. D" v" o/ j
.id = 1,
; B' P8 s" g- T5 R3 V, `! g2 J .dev = {
! E) m% P: b I& K# w) d .platform_data = &da850_evm_tl_leds_pdata," D2 {( i: e b
.release = led_dev_release,0 `+ v2 P1 z2 y# g+ B8 M+ B
}$ F* r# j4 M3 O. @
};7 H. R1 ]0 \! i! h* ?; S
- P2 f% q; \3 q" P$ u7 Y/ {static int __init led_platform_init(void)
( h" \, B2 {! v/ m# ]{
j3 J% I2 {3 a/ x int ret;
3 e! R/ d* `- s; c, N& C: W#if 0
9 w5 L: U# t7 g: ]% X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, W8 r( o& N5 h1 f) K& e% ?; u if (ret)) i8 Z' h" q) m. N3 _" C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( u* s+ k: p6 H1 |; R9 t
"%d\n", ret);
0 _" x( J1 H# {3 z) ]#endif" M/ @( |# Z+ I1 {$ ^8 O+ _
ret = platform_device_register(&da850_evm_tl_leds_device);
' W6 T [" ?7 p if (ret)
* @0 X% j) {; ?7 ~; r+ s pr_warning("Could not register som GPIO expander LEDS"); P4 H9 L6 c8 f: } d
else
2 G' U% {7 b8 E5 y+ H6 T9 T printk(KERN_INFO "LED register sucessful!\n");
4 R) ]7 e3 `# _! L3 P' L) v+ x: {5 j% i! Z& }
return ret;( r3 Z- y L8 @" q
}& M1 \* k7 H/ ]$ `+ {; A
6 |8 F9 u r0 N, P" {static void __exit led_platform_exit(void)
4 I' o; o2 V: L4 X{) {5 J. j% W# M! T" T. W; h/ G9 {) W
platform_device_unregister(&da850_evm_tl_leds_device);7 H6 j. G7 j7 O+ P( |, g
. G+ E: z# `' D printk(KERN_INFO "LED unregister!\n");0 q8 a' ^% h5 O) f* s {
}' W G A( p# p& Y3 K& d
$ y9 H. D* t: p
module_init(led_platform_init);, ^) F: w& [4 j# H' I, q$ Z
module_exit(led_platform_exit);
c: `" B2 S a% T: T- {5 S H
# Q8 P2 U: m: \MODULE_DESCRIPTION("Led platform driver");6 s# M+ v) Y2 n) {: z7 C' U
MODULE_AUTHOR("Tronlong");
/ F$ t; T# l6 f D6 rMODULE_LICENSE("GPL");
* L: q8 x5 f: d4 s C ?9 Z- r K" ]$ q( k" R+ I9 }! Q
|
|