|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! ^: j) C" q6 p- g* x/ a
#include <linux/init.h>. e" g- n2 G0 P1 [
#include <linux/module.h>4 F2 L: F/ @4 A: L7 V
#include <linux/kernel.h>) K+ c( K. V( a; [( x' M' K
#include <linux/types.h>/ N! m2 b( P5 x9 i
#include <linux/gpio.h>; M- s) O; b4 {- K4 D4 E
#include <linux/leds.h>9 H* J9 p, |6 c
#include <linux/platform_device.h>
x( x) ]; S6 `7 u3 V0 |- m* S& a u5 h7 [
#include <asm/mach-types.h>
' g. J; E) p& i& V#include <asm/mach/arch.h>+ d N% e, _& q& i( M5 |% i7 g
#include <mach/da8xx.h>
# e5 O: g9 \! o# t3 S#include <mach/mux.h>* c/ h! _; o" @1 p8 Q
, |' ~& r. J9 Z }4 ~9 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, g! O) T: F1 h/ `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( N' w* c/ A& j' ^' h: J5 x5 p8 u l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ I3 b0 O7 }4 H; l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); B5 T' o3 u6 U8 a1 U8 N" p
8 X$ Y9 r, i5 s. p" y
/* assign the tl som board LED-GPIOs*/
, y1 O4 ]4 T/ ]& A. U- Zstatic const short da850_evm_tl_user_led_pins[] = {
4 G& r- w8 N3 m% a /* These pins are definition at <mach/mux.h> file */% s$ _1 c, k. Y) u: V! a- y; V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" N* y7 a S `6 V1 ^4 d: P -1
# I* _3 J8 r, A4 n5 F7 y7 ~ |};- i9 \" W# X. @5 R+ a- P3 u
) X& T5 t0 z* p- d0 sstatic struct gpio_led da850_evm_tl_leds[] = {
: H, }' ~+ |7 i {# k3 H3 r' x p& I
.active_low = 0,
0 w% \5 s# A, A" x4 T+ ` .gpio = DA850_USER_LED0,
+ w( j& e. e$ p% T, j; K .name = "user_led0",0 j6 [' |$ g6 {
.default_trigger = "default-on",
, e1 i/ |# e: B },
R: w( I/ X9 [; ~5 h# | {
, M6 T3 o8 @2 m$ F .active_low = 0,8 o3 e5 J6 T3 y: _+ d
.gpio = DA850_USER_LED1,
) o4 z, y- I# m8 D o0 v .name = "user_led1",4 i, o6 T9 L0 O0 o& Q1 r4 Z* i
.default_trigger = "default-on",
- y; r& k3 L3 A },
M Z4 Y" G2 j( @5 `0 W: L4 D$ |7 j {
9 ~ d7 w* Z9 b1 S" { .active_low = 0, M4 M" ?: [3 `- A
.gpio = DA850_USER_LED2,
3 ]! t9 j( H7 |! C9 D/ l8 J+ R$ N( @ .name = "user_led2",$ _4 P+ w6 V% [# ^% p
.default_trigger = "default-on",1 C- t Q' }! r0 W# H
},+ ]+ P1 w1 e# `$ ]. T
{: c A4 |; e2 n4 M$ z
.active_low = 0,
' M4 O$ c$ R4 L3 Q1 s .gpio = DA850_USER_LED3,% e5 Q/ o, y0 f h+ b5 |" l! y/ j% H
.name = "user_led3",
& g6 _" i) X" K .default_trigger = "default-on",4 D, _/ n- h% R5 ]& B& c4 p
},6 E$ a3 V3 n5 M, T) R
};
( r2 n D0 E; z5 }' k- X1 v U' z/ M+ Z- T& D8 s3 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 F. R" O1 U8 |4 p& h! l0 v
.leds = da850_evm_tl_leds,* p5 h ]& E# G9 O, u! r, h: ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: |4 r8 d0 Q8 G
};0 ^: u3 G2 c6 k3 J' ?- e i
" t$ L3 [: V7 ?8 l' u1 ^static void led_dev_release(struct device *dev)( U. m0 \9 o) K1 x4 R& b
{# n1 \" A% I6 S; ?9 E
};
2 ?4 ~: z7 D1 t+ d0 p1 n w$ U( V7 V* z, o( Q7 W
static struct platform_device da850_evm_tl_leds_device = {
0 c1 U- C9 H" E9 I6 t5 e" u .name = "leds-gpio",
' _+ O& W. K) W- K: I! h4 S .id = 1,0 v! }" _, h+ O2 F9 V' G L' I" D J
.dev = {) Z) ~# [4 G9 R- O
.platform_data = &da850_evm_tl_leds_pdata,6 D4 R7 a8 N2 ]0 V t% k# Q
.release = led_dev_release,, S# O+ w( a. W+ I, u: Y
}; G" C& K# p: p3 U* P+ L
};0 C/ w4 C% _, n7 s* ?; p1 T
5 J4 Z8 z9 n2 i7 Ystatic int __init led_platform_init(void)
3 t' V3 h+ |1 ~/ |{* k& ^! y, f. G
int ret;* I E: i, v+ C" z( D3 T6 A& p
#if 0, X2 i, j& {& S. \- T$ p; I+ q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; g, c$ g0 C( ~+ S$ U
if (ret)
8 X; z3 X E" E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; j" \2 D. j9 K5 ]: P "%d\n", ret);4 e5 G. [* r/ ]
#endif
$ T+ ^+ b9 C" n8 ?, C- ]+ p ret = platform_device_register(&da850_evm_tl_leds_device);7 [' m" w V. k0 E3 Z+ m# \
if (ret)
% W5 @9 n7 K/ \7 t1 s) P; } pr_warning("Could not register som GPIO expander LEDS");
. d- U5 E; m5 V1 T9 f1 H* O9 X4 r else
* X% D& S7 X5 S1 ?, ] printk(KERN_INFO "LED register sucessful!\n");
0 |4 a Y# F; C' v& y5 \4 A3 y- i4 S k' q W
return ret;
4 V) T. A" S, f5 @, L) e% i}
/ D4 r1 w, i3 A2 g
* T$ {, J2 i9 N9 {, Pstatic void __exit led_platform_exit(void)9 @) Z C, O, L& P' e6 d
{
6 R3 j1 k2 F: q1 E! l) G c platform_device_unregister(&da850_evm_tl_leds_device);9 T/ A5 C+ ]/ O2 i* Z$ o
7 S& B: P2 C8 X* `
printk(KERN_INFO "LED unregister!\n");+ r) B+ ?: V! t* p8 e, I! J3 J
}9 _; o, }$ {! {) A1 |& [/ C% K
2 Y7 Y' f- S& F( e
module_init(led_platform_init);
1 V* u$ G* u8 N. z1 Hmodule_exit(led_platform_exit);
2 B$ y) K- ]/ `
' o* I4 q) X H2 Y% fMODULE_DESCRIPTION("Led platform driver");* V) j) K+ X" j: U- v
MODULE_AUTHOR("Tronlong");
2 s5 @' m5 x# N" W" `+ gMODULE_LICENSE("GPL");. y9 R7 l7 M( _1 _- F( ^
9 {3 K; X* n, s% L4 E* i$ p |
|