|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 H* A$ a. V$ \
#include <linux/init.h>, I4 d Z' X' \
#include <linux/module.h>6 y, G2 i5 {* N, a9 y$ h) Q
#include <linux/kernel.h>) n: R# t3 ^7 R0 G. o9 s w; q
#include <linux/types.h>8 a& H3 H* Z0 d$ Y6 f& K
#include <linux/gpio.h>
6 \8 H$ R% ^3 a#include <linux/leds.h>9 b% E2 t5 _! @0 ?8 G c% r" j7 h3 L
#include <linux/platform_device.h>
/ r5 W+ `, v& M* T. T, }3 w, `0 V! |! O+ P+ U; o
#include <asm/mach-types.h>
; T* U' H+ R3 k2 {2 ]0 p#include <asm/mach/arch.h>
- ]# h( E+ A* f5 S#include <mach/da8xx.h>1 L1 q# t. ^0 P( }" r$ s" Y
#include <mach/mux.h>
& D9 S& d6 S1 O6 a( G3 \
" N {3 n( B/ n* y" p- F7 S. z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b6 Z/ [, k. X* [1 W5 Q8 R% M2 ]' a
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 y" f( x" N! W; V) i7 L9 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* q% a# i- f% K) e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, l( w0 {, N/ Z4 w& l% z' ~$ [" x ~- k9 U
/* assign the tl som board LED-GPIOs*/
; D& U9 F+ l$ E% nstatic const short da850_evm_tl_user_led_pins[] = {
7 L1 e! Y8 A9 u /* These pins are definition at <mach/mux.h> file */) g; n+ n3 r% X l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, g% G) y6 E1 Z+ x( F
-1
4 r. u, e4 o6 _+ x% z. s};5 q) X! v$ G* n- ^; r: f
- z6 p" j" t" X* l" ~& C$ Rstatic struct gpio_led da850_evm_tl_leds[] = {) ^7 w) m2 o8 h8 Y) q0 Q
{
- M2 L2 t9 J+ C: `7 \- B2 p6 x: i .active_low = 0,: e% B6 }3 }- M; B; o" E/ U5 J
.gpio = DA850_USER_LED0,
, |' Y* ]8 X9 Z/ j! Y- f .name = "user_led0",
5 ]- L% |6 U, \ N, T5 e, i .default_trigger = "default-on",
- L' a4 N1 Q& l1 Z5 X },
0 X( A9 L" Z$ [6 a/ H- } {
9 O- s, }: a, a0 y$ Y: O; P .active_low = 0,
- C L d' |3 {1 z# ] .gpio = DA850_USER_LED1,! v6 Y! C( F0 r9 x. X+ Y. B
.name = "user_led1",' S2 } d3 l9 r' A. N6 _4 ~- @5 m
.default_trigger = "default-on",
/ H2 W& U" i+ \0 c; E },4 A: u( \% S, q; K; l, O5 q
{; P, l6 P& e! k p* d
.active_low = 0,( Q L9 B; a3 i, i
.gpio = DA850_USER_LED2,
' H7 T; L+ W# v6 L& K1 M/ x .name = "user_led2",
# J8 D+ ]7 V6 {& j- ` .default_trigger = "default-on",0 Z5 e3 P2 J) f) x9 |$ X
},
- H/ `2 T$ ]/ g {$ c0 C7 \! S* t- T3 |. F- S2 V9 B
.active_low = 0,
- i8 O6 L$ R9 X' h' k/ x .gpio = DA850_USER_LED3,
, b( H) }9 f. _ ]; H! x9 M .name = "user_led3",
' @3 T+ T* ~0 {1 g .default_trigger = "default-on",% k( l: i' @- ]# [ ]3 ]% z1 Y, P. D
},3 l$ _# @5 Q& ], W, A% E/ w
};
9 q5 k4 Q' |" P M5 o$ ]8 X# z* `" i# Z2 [- {$ j# r# @5 P" ?" C" h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ f3 ]$ g' l4 ]5 k2 _ .leds = da850_evm_tl_leds,
" U: A" W4 [0 G) v3 r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& S( ?% r" Y/ u8 I0 ]};
- w! e2 U: o6 T7 j7 }0 l# f* t9 O; D
static void led_dev_release(struct device *dev)0 _0 o/ @3 r |. d* X1 G9 N8 n! v
{
T' t6 v- D$ r# m};
% M# H" ?! C5 `* `+ j
: \3 T, g& M+ s) r6 W5 H$ fstatic struct platform_device da850_evm_tl_leds_device = {% I' s2 x/ m6 _% _3 b3 {. b
.name = "leds-gpio",
/ ~9 C/ X# R( n9 D4 p# {# _, g .id = 1,5 \+ l0 S d5 \% y
.dev = {( i. u' K3 s" s: c) K% S
.platform_data = &da850_evm_tl_leds_pdata,
# W4 ?; f! z6 `8 \3 R .release = led_dev_release,5 {* h: s; s3 x0 M1 T( x: p0 D3 p2 ?
}
! f8 z( V4 P( t1 y};
: Q1 O/ c5 T2 |. s- Q- q8 q" q6 j% _' l, ^0 t6 T/ k
static int __init led_platform_init(void)1 e9 s5 N+ U0 t; i
{
) o, u4 p* L& t; y: L int ret;+ B6 @- t& _4 h( Y% v* c
#if 0+ t0 B# {1 l! I& r4 O1 p7 V% c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 |6 m+ u9 b1 g2 b% \ if (ret)
B0 m m' ]7 t8 g4 ^: C6 M3 z( R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- @+ h& x! L' p
"%d\n", ret);. n J1 ?; Q: @- m( ` l2 e- {
#endif
" W3 y5 F- S$ ~ ret = platform_device_register(&da850_evm_tl_leds_device);1 W$ w1 B' @8 M2 w, s% N
if (ret) \3 i+ O2 g1 L8 f( M$ l: M5 D/ O
pr_warning("Could not register som GPIO expander LEDS");3 v4 ~5 w# g5 H& j
else
3 b8 {. B; T2 \, c) o1 ^ printk(KERN_INFO "LED register sucessful!\n");
& M8 [1 b; p1 w" Q9 o2 | K4 X; A$ e8 Q7 Q: A" y& K
return ret; X, A1 N$ N" d6 B, n9 V
}- k9 t: Z( \& V2 ]; w+ G' R% O
" e8 u+ u& x( l istatic void __exit led_platform_exit(void)3 F) u2 G" U# e- w0 P
{7 f- r% r, }% O& V P3 U' K6 y
platform_device_unregister(&da850_evm_tl_leds_device);. G% Q- ~+ ^0 k9 o
' w2 H! s- S, l% v S
printk(KERN_INFO "LED unregister!\n");
0 J2 H9 b% o i! P}0 g2 y5 a) q% g2 X% ^
% V4 O/ A0 b; N/ w+ N/ k
module_init(led_platform_init);
- w5 m4 G) i+ d, ?! m5 [7 bmodule_exit(led_platform_exit);
7 ]8 q1 g3 C# e% O; J/ B
2 e% H4 p J$ k, \MODULE_DESCRIPTION("Led platform driver");, G4 z4 z# I$ l* ?
MODULE_AUTHOR("Tronlong");
! b: u! c" q' x$ L+ CMODULE_LICENSE("GPL");
7 \; Q9 o1 S1 J+ Y! R
) ]& r& k( D2 P2 i- I |
|