|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' j. a! ^) L0 A3 v4 \#include <linux/init.h>
) U6 Q, ]: c4 Y8 z/ z6 O' M7 }" s#include <linux/module.h>
4 {4 q. m. w) j; l# f#include <linux/kernel.h>7 T# L% K" o' F6 l4 e
#include <linux/types.h>
P- ]9 S0 Y6 V- o! |#include <linux/gpio.h>/ g) z* S1 j. G# s* x6 N+ [
#include <linux/leds.h>8 @$ m/ r! I' p# C
#include <linux/platform_device.h>5 m" ]$ B7 l) Z/ j: q- S2 |
# |4 M z& U, X! l# L Y8 k#include <asm/mach-types.h>; Y8 v; ~. X9 z* d1 W' j3 @% r
#include <asm/mach/arch.h>1 o; Y" A! X7 ]. K2 r4 M
#include <mach/da8xx.h>
; O: }: i5 N% o5 y4 X# o( W+ ^#include <mach/mux.h>
4 j! S/ w9 c0 r" m! q8 V3 e' u% S3 |0 J/ l6 T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
Z U* n# n% ]" W& V. q. v g7 n) u8 b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 B3 s3 }$ U% h9 \! ]7 J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( u* ^* x7 v) `, h$ B1 F: ~: C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- A! F0 {5 U/ K" Z# q1 Q" D
3 N) H9 Y O& {/* assign the tl som board LED-GPIOs*/
# g7 c* x! t- h8 h# Dstatic const short da850_evm_tl_user_led_pins[] = { C) W @# p' I- n
/* These pins are definition at <mach/mux.h> file */3 q5 ]; D# m- d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 w4 H3 D) K U: a -1
6 |( P/ z9 x4 W1 V) {};
0 J2 G( g5 Y2 {
* x: ~2 P& x& mstatic struct gpio_led da850_evm_tl_leds[] = {
( f+ ~9 v u$ x& M& P5 _( x) p# V {
" x; D5 U5 q) ]4 C .active_low = 0,
) P y& \6 P, R. C. [7 b .gpio = DA850_USER_LED0,
0 h; K) `2 k# {4 M- k, b .name = "user_led0",- C$ A: |. y6 F; f% A
.default_trigger = "default-on",7 }, ?7 y7 j J) [# w
},
# M& V1 z. n# M2 q! _' z2 n {
# |* ?3 O" J9 ^0 t' U .active_low = 0,
1 E; c. s f+ @ .gpio = DA850_USER_LED1,+ B: B* W4 d& F5 f: O
.name = "user_led1", ]8 K- }5 O T" w/ P
.default_trigger = "default-on",6 T+ `7 O7 N4 A$ ]- S" N1 k
},$ w5 v* D9 J& W/ n; g5 ]
{4 Z, E5 T9 {5 E, S
.active_low = 0,) n3 H* _) v o, h3 x
.gpio = DA850_USER_LED2,
+ ^4 w* P1 m! E .name = "user_led2",( ]% `. S# s- f c6 j
.default_trigger = "default-on",
( Z3 T) @7 @( B },
0 B4 E8 j7 c8 Y& i) ` {
( H, a. B1 v4 ?) K# h .active_low = 0,
) B7 F+ {9 V2 h1 y( |; S$ k% w .gpio = DA850_USER_LED3,
& _) o# F4 }/ B) r4 F" s .name = "user_led3",, ?7 a( m% V3 K% r/ x! {
.default_trigger = "default-on",' x) k+ I' L2 ]2 S; {) [- p7 s
},
d$ g$ {/ E( @/ `5 {: W$ O/ J* n};
% V6 B3 N) p" N9 _, k* q( u3 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& T0 d; ^ I% R9 r5 C! P7 T7 k .leds = da850_evm_tl_leds,
! v: y- b$ i7 M6 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. c( f' ]* _! s) W" q: I5 S) y- k};7 E- [! R/ h) }- r/ ]1 @7 o- v
* V3 w* ]& q7 Q' Z# o5 wstatic void led_dev_release(struct device *dev)- _( r( E! E& @5 s) ~& X" V) j
{
# u6 h: s! ^3 B};
; I; m6 J3 K) r8 F4 u( f. v, e+ x) N, u- U
static struct platform_device da850_evm_tl_leds_device = {
1 Q. R2 L$ m7 u7 }2 W; m2 H .name = "leds-gpio",& n6 p- N ^' K& x5 S% h0 X3 g: T
.id = 1," k/ _' ~/ N. t4 Y9 D2 y% }8 R
.dev = {: T* h- E# y- m: m* n: G1 R0 Y1 ]% j
.platform_data = &da850_evm_tl_leds_pdata,
" k; j/ [$ p' N% V9 X0 g4 N5 u .release = led_dev_release,# S% l- y3 ]# s, W9 ~
}
5 \" y9 ?7 G; B9 G7 Z/ b% l- _};
5 d2 K" v" H& k* t7 ~8 e
: z+ ^3 _$ X3 s" }& y4 ustatic int __init led_platform_init(void)! a+ R! U/ n$ [/ a
{
$ X: X$ o% m7 h( Q# H, K, w int ret;2 B" J4 W' n+ P; a8 ?( A
#if 0
7 K7 Z2 n# A* E& x/ } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 I; S" E; E* {; W: C
if (ret) r# c- O1 L$ ?" }6 d( n/ F+ w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! Y' }! l) v D
"%d\n", ret);
# h# S* h% P5 D7 o' K+ `4 K#endif V$ G$ x- k' |: l
ret = platform_device_register(&da850_evm_tl_leds_device);% u+ p2 h ]# R) ?% [ W& [5 o
if (ret)
/ G. {! R* S _* H/ V pr_warning("Could not register som GPIO expander LEDS");
0 T4 V5 h" _! L0 o3 N0 t else
& ^# g8 e, i2 u8 ~" d" s printk(KERN_INFO "LED register sucessful!\n");
/ z; q6 {! y7 @& X- W
/ C! K% c& n2 D# }5 v' ? return ret;9 j0 }: i* s+ O+ Z# X
}
" b) R. l. B( X2 w) O" c
0 t9 F6 ?% |4 ?* Ostatic void __exit led_platform_exit(void)
. b" J4 h" @5 k7 M U{# a( z9 A% E5 B9 _( }% C6 m: R
platform_device_unregister(&da850_evm_tl_leds_device);
# p/ ]: S( [; H! Z7 x1 e" e
' Z2 {! t% S( n7 l4 p4 X3 Y printk(KERN_INFO "LED unregister!\n");+ ^5 n7 B! v+ K0 U3 k$ l; o% n4 ~* N
}0 B5 G9 e3 Y! H1 a" {/ y% g2 d
# K: g7 U; u5 A) gmodule_init(led_platform_init);9 L+ I R V: A% f- f9 B
module_exit(led_platform_exit);/ n* d% k( i7 x
& P6 \+ g# l% s5 PMODULE_DESCRIPTION("Led platform driver");( T* ]. l$ q, X/ j; O
MODULE_AUTHOR("Tronlong");
, F8 G0 B/ D' s6 O7 @MODULE_LICENSE("GPL");4 Y2 i* R4 E+ q5 S9 D3 W
) f* z0 ^+ w* ^1 \& V |
|