|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# S* }9 i* w) ^5 M
#include <linux/init.h>. l4 f4 g' A0 O: J- B
#include <linux/module.h>
, q" d' D2 l% v6 V#include <linux/kernel.h>
1 W4 L0 n! A8 V#include <linux/types.h>
0 R7 i; `% H. P6 T: K2 x#include <linux/gpio.h>
# R. q+ Z4 J3 Q5 f8 i7 D#include <linux/leds.h>, W& g5 E' j4 I/ g0 T! ~
#include <linux/platform_device.h>
8 ~2 z3 L8 C, D
8 L" i; F2 p4 q) p/ `$ l4 N#include <asm/mach-types.h>2 p: J3 y* o0 c* W9 |
#include <asm/mach/arch.h>; t7 _; E% q; y* Q" |
#include <mach/da8xx.h>8 R G# K5 z2 n1 d1 u
#include <mach/mux.h>
8 M/ ?8 i) ^4 ~$ [! V3 S3 b2 F0 ]4 ~3 K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- w9 s) g: E5 D' m8 X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- H7 N% G) @0 _3 O3 H3 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ u$ T" S3 u: `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ X1 H4 p' M$ l4 {& q+ S6 h9 v
! i/ R. Y+ Y6 y! ^# Q3 r/ C! ^/* assign the tl som board LED-GPIOs*/
, @' K4 O3 s* H' C* ^0 lstatic const short da850_evm_tl_user_led_pins[] = {
8 W8 v% _* Z4 k /* These pins are definition at <mach/mux.h> file */
$ U3 F0 `# G4 M) o4 X# V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# @. _6 E* R" j4 }
-1
0 l0 o) O# n. c};
0 R* N- W+ ]$ C; g6 v- W2 _! ]! y5 r5 |; K
static struct gpio_led da850_evm_tl_leds[] = {
$ J7 g2 }2 r6 y( R$ [) U( g {' | L5 r, K0 X0 Z3 a( K
.active_low = 0,
+ T$ E0 H" e( [3 `& b9 o3 S .gpio = DA850_USER_LED0,/ i2 ~* ?# a) k8 z3 o0 W
.name = "user_led0",
# B8 ]- K9 ]: L: |$ k8 Q .default_trigger = "default-on",3 r$ D% {4 Z+ y4 l2 t
},
* M9 P) g0 A2 ~) H& Z9 Y4 V( F {
8 q7 G5 H3 c- i .active_low = 0,
7 ]& s* D7 C5 S) w2 s .gpio = DA850_USER_LED1,
2 O9 P' B5 m1 P. r .name = "user_led1",' u6 ~- J, a# a% q
.default_trigger = "default-on",4 `- W% o5 W# v. d- Z% x2 I
},5 S3 e3 n Y( O: A$ E' z8 G* n p
{ o1 c* a- E/ J6 g! | V5 R
.active_low = 0,
9 j O ]7 X' T1 u8 L9 _8 p2 l .gpio = DA850_USER_LED2,
0 C# [' K" l& {0 `' l9 x9 I+ m .name = "user_led2",
; X- {& n5 k7 c# P7 h" V: F$ p .default_trigger = "default-on",
n1 C$ F2 G& d& r( v j& m },
; f- C% }) R) W( [* I& j {3 P% A* F% b; E3 Z
.active_low = 0,
1 ]. X" f; v6 W. v# e; M% J: \ .gpio = DA850_USER_LED3,
" U8 M2 I/ F" a0 d4 g4 b0 x: S .name = "user_led3",
/ ^2 M! B3 G) @3 G" D .default_trigger = "default-on",
" |# o( }6 c' d2 a- i },
% y& b: Y ^% r* d};& c+ f2 n6 s6 ~
, y8 e2 S1 J6 o4 O- t5 K6 M( n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" P# k% i4 i# f1 e# f$ q$ x
.leds = da850_evm_tl_leds,- ]' O2 P6 w, h0 m8 x3 X4 X& L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 T; Y6 |6 l3 a9 R6 k3 T};/ [+ \) W {' I. e$ c
$ K2 u8 N! ]5 X6 b% T- }. M% B6 lstatic void led_dev_release(struct device *dev): b- S% `) { A6 k7 d0 u( o
{
- a% M+ _; O( T" m& M& ]};( h e2 a9 K- z" o
$ e& k& k9 h0 u F( C+ p
static struct platform_device da850_evm_tl_leds_device = {1 `% i/ u1 |& ^) P3 M: f4 Z
.name = "leds-gpio",2 U/ y4 k$ N `0 S: O5 K/ C5 [
.id = 1,
& ^- y/ r- ]6 N7 j* x' S .dev = {3 ~$ v! D, |; h" ^
.platform_data = &da850_evm_tl_leds_pdata,
7 }; v7 a! O" m; L .release = led_dev_release,
c. v0 H: ? A" H, F }, V* R5 Y$ d$ O/ A0 V+ o/ f( p2 I
};
2 Q/ g, z* r# \: a: h! W- q6 _0 i& f" R8 ]2 X& _
static int __init led_platform_init(void)
" }" v2 J6 [7 h* K) p" S{
4 Z$ d, Z+ V+ A$ q( [$ [ int ret;* v/ @+ ~: E$ W8 _7 Z2 i! }7 b2 W
#if 08 a+ T1 g3 ~. `* y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 _8 i* R" r2 ?7 e J3 q if (ret)6 a9 {% w! L% h" b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; x& Y8 J. c0 Q7 I4 q- ~4 |9 D2 U
"%d\n", ret);
% N1 P( a% Z: x: A( J#endif
3 M1 _3 @" ]1 ^3 _3 c ret = platform_device_register(&da850_evm_tl_leds_device);
3 H$ K4 p/ d) C' f9 E. C/ [4 y if (ret)
1 f' _$ O) D8 [4 o' _) h4 C pr_warning("Could not register som GPIO expander LEDS");
7 G- n' ^8 o, @6 L& C! m else
% Q& a; @7 M) w/ L printk(KERN_INFO "LED register sucessful!\n");+ ~8 _) A) M7 c9 H9 S" D
1 @0 V) d6 Y, T( r Y return ret;
9 U. F4 C! I6 B0 @, ]' X& T}
. R& t! v8 |( h) V4 }2 ~; U" Y ~# a9 A
static void __exit led_platform_exit(void)
5 P; h2 h. e3 Y% r1 B Y$ f% A{
4 `' n& B5 Q. i platform_device_unregister(&da850_evm_tl_leds_device);. v* {" x. X: }, y) Z: F: v
" a7 ^ m- U. c5 E: @: H
printk(KERN_INFO "LED unregister!\n");( W" f. [. c1 m" ^
}2 i+ v! l5 n- B, Y0 ?8 m. f
4 t& }' Q# G+ Z6 P$ M; j: B
module_init(led_platform_init);' u6 J$ l9 p M M6 m4 o" b1 U
module_exit(led_platform_exit);
. o8 f; |: m- l/ s/ @" J- o; q9 O1 S8 Z& d! d9 w. m' {& h9 C U
MODULE_DESCRIPTION("Led platform driver");
$ Y' Y/ U& ^$ ]; ~% m s$ ~MODULE_AUTHOR("Tronlong");
7 A9 ?( o, S3 B! p! ^MODULE_LICENSE("GPL");$ U0 t3 _9 I; X* O G% K/ Q. O
; P! u! V1 Q `. {
|
|