|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 s! |# ?8 s- T+ I#include <linux/init.h>6 ?2 {$ B5 P _" O6 g$ V' R1 R' f: T
#include <linux/module.h>
( O% r$ l& k2 M$ O: _7 x8 \% m#include <linux/kernel.h>
" l& A; N, p: R: Z#include <linux/types.h>, Q% G* Q3 L% L: r% ]' X! Q
#include <linux/gpio.h>
! G6 Z# \3 i/ ^#include <linux/leds.h>
- b4 c: W* G" D- G#include <linux/platform_device.h>6 z* ] D. |6 k, o
; [9 z. n. f' f5 P+ a! I& q0 x6 H
#include <asm/mach-types.h>
5 A+ v) E% y Z6 _, v& t: H#include <asm/mach/arch.h>
3 q+ g. [) B3 l- o#include <mach/da8xx.h>' \% x2 Y/ ?; @/ y, Y
#include <mach/mux.h>
' ~9 L1 @. ^2 }- P4 m/ p
* V' L" K0 q8 L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: P4 c: h& F. i6 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 O9 o$ v& b3 [- {- P5 d. s5 I. H! f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); l* e- b$ z9 e T3 m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! v3 u$ x C6 |. _, w" a
7 t/ g+ f% p* R/* assign the tl som board LED-GPIOs*/
0 ?# C' k+ o; w* S" Wstatic const short da850_evm_tl_user_led_pins[] = {
) Y( m- n/ |" c; W: q* [ /* These pins are definition at <mach/mux.h> file */4 v+ ^ ^: o9 x; a0 @6 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
_$ _4 U0 L1 |+ f% L* n; @ -11 ~5 d3 j6 p$ y
};0 C& E, j8 a6 F: T5 j
/ j; t% B5 u6 q8 R8 s$ Astatic struct gpio_led da850_evm_tl_leds[] = {, r/ h+ T4 }* j4 L+ x
{, b. M! [$ ?: }) w5 X4 p! s. h
.active_low = 0,
0 q' k5 i! x. q4 y. ` .gpio = DA850_USER_LED0,+ K6 I/ G6 H" _/ v' }
.name = "user_led0",+ c a1 u' \% D+ Q
.default_trigger = "default-on",
7 |5 }: @* E! [' }& [ },4 o( E4 i2 ` W1 y. U
{0 } a8 U; Y8 }& l9 P+ @
.active_low = 0,% o5 [% K/ Y# k% N' Y6 n. N
.gpio = DA850_USER_LED1,
1 N7 m' o7 Z% W; w/ }- ^" ] .name = "user_led1",
! Q" {" A9 `3 L' z7 u/ J8 i .default_trigger = "default-on",
9 l/ L) f: G& q2 E' `9 V },. x5 d/ f. |; B8 Y
{/ ?' ]+ O( Q* d8 @' j' o
.active_low = 0,
' S, K) e7 V7 E# L1 ^, Z' \: m .gpio = DA850_USER_LED2,/ y$ I) l2 c6 k
.name = "user_led2",+ D3 }9 h# K) {# R4 e7 g6 `/ a$ r
.default_trigger = "default-on",% `5 Q/ q- B( p- q7 h4 w7 h
},! V' r, M' ]1 Y. p3 n
{
p0 g( o5 Z" z/ W' N: }* D( { .active_low = 0,
0 Z3 c/ d$ }! P3 l .gpio = DA850_USER_LED3,
2 f3 s6 P& { n .name = "user_led3",
% ^1 K! S E0 Y. j) n+ T .default_trigger = "default-on",/ W8 z I. ?; N; q3 D1 p0 C
},2 V1 j' F" z% c6 K0 e- R" l8 ~
};
, l" P2 {. ^7 P7 }
+ B) `% B8 Y* c- h' }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
6 ]7 o% I* L! g6 X+ G+ r1 {) N .leds = da850_evm_tl_leds,
5 V! G- G @: r3 _- x) l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% W m% H% {' p: W8 h0 V' a};
- V( X: U' B' }# _
& R6 a* }& }5 H% @* estatic void led_dev_release(struct device *dev)
) l- N. d1 U5 ?2 R. q* ~0 H{
/ t! G/ W& b9 [6 C- S" e. l4 Y% V};
/ w; O7 w$ M# D% c# f" I* g
0 \9 L7 x; Z9 A, ?$ U& Estatic struct platform_device da850_evm_tl_leds_device = {( H; k3 b1 e' h: O& f
.name = "leds-gpio",7 l5 I2 r9 I" M3 _2 W
.id = 1," U+ @: P/ o. M8 h% E2 P
.dev = {
* n G+ f; p2 \% ?. C) F+ U# N .platform_data = &da850_evm_tl_leds_pdata,9 Q* e1 a& N" y2 Q0 p g( b
.release = led_dev_release,6 @9 V4 M0 r9 o D2 w: n U& S6 c7 C2 _
}$ R9 I4 K& e0 }! E. G8 K& F
};! v8 }) G9 a' a9 E5 O
! _ l- G0 R4 a4 h$ M6 {) ~
static int __init led_platform_init(void)
( b; G5 [6 H. Q8 S C{# M1 p/ X9 G0 ^& |5 y
int ret;6 d5 C& Y6 W& D/ }$ J: F1 |6 d
#if 00 Y3 l1 |; a. b3 q+ G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( u; e4 P" M; }3 O3 p if (ret)$ o- o8 e( ^% h2 E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", b; a( ^. {$ ^+ ~3 v# W
"%d\n", ret);% X# s% ^# f+ H/ r
#endif
5 w8 x7 w2 A, \7 z ret = platform_device_register(&da850_evm_tl_leds_device);1 c2 Y7 u6 Z& R8 [) Z. i4 f
if (ret)6 e0 E8 H6 W; w; V
pr_warning("Could not register som GPIO expander LEDS");6 G" C, `4 r9 t5 ^
else3 \: T! d2 e5 Q+ d7 c- r( S$ a
printk(KERN_INFO "LED register sucessful!\n");& D( c0 K& r; s0 V+ w/ A
, p0 H$ n$ `7 k0 A4 y' A; N, r6 n* M return ret;! l [5 I2 t: y& c
}
# m9 f! Y, P1 H' F
, E. k* N) }! [9 g) C: l( X `static void __exit led_platform_exit(void)
. U- D: M1 \ T+ m# c{
; D- [/ e; z/ w! r$ H% B+ z9 l platform_device_unregister(&da850_evm_tl_leds_device);- w9 v( H9 |# J$ j, e2 d- H$ Y, e
+ N' a7 M% Q; d4 C- A: A printk(KERN_INFO "LED unregister!\n");
& M" [& C4 l9 ]9 E}
{, N/ m5 i. }+ W
# b' A2 [6 |( Q+ Wmodule_init(led_platform_init);) r* f5 d, X& X) G5 V! z
module_exit(led_platform_exit);
- P1 ]- ~) B9 n7 r& P9 O$ { G3 l' @, @( b0 j8 K& W
MODULE_DESCRIPTION("Led platform driver");" t0 ]* x( u4 y! p! |" M/ g$ e
MODULE_AUTHOR("Tronlong");
8 ~5 q6 y) Q' M, d+ g' F) H& [- JMODULE_LICENSE("GPL");4 o8 a: w1 [ G2 R1 f9 U
( t) b+ m" B+ s. t! c, \$ l/ u1 {
|
|