|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 \( ^* [9 G$ t' |& e3 x#include <linux/init.h>
. \# I: }/ m& p' [0 J#include <linux/module.h>
3 g% t! b2 n$ M, @8 U4 h#include <linux/kernel.h>/ `( V9 F( @$ ^" } B, v
#include <linux/types.h>3 x8 P8 T7 H D( P- ?( n. P" c
#include <linux/gpio.h>, _# _' ?, L. f/ d$ E
#include <linux/leds.h>$ ?, c' d, e8 A1 i1 u( r, G/ B% u
#include <linux/platform_device.h>
. }0 r7 ~+ @$ l& q
9 B- D. M& }, C#include <asm/mach-types.h>
: \1 `0 S1 F2 Q#include <asm/mach/arch.h>" k2 d: I: `* B$ l' I$ i
#include <mach/da8xx.h>% h( O; W. a& R y
#include <mach/mux.h>; K2 L# t! ]3 M5 r, c. S/ L7 r
- b0 V C) c0 L* X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ e$ \4 S# o+ m9 a' F, l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" g- O- F+ e6 }. Q% z& `* T: d8 N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& m4 g, {" y4 ~; ?8 N2 A& |- v( w* s#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 d7 ~5 P/ _. A% X2 p }
" d- o# Y: o/ h- ? T$ y/* assign the tl som board LED-GPIOs*/( h) V6 S9 M$ v* l+ e* C) @
static const short da850_evm_tl_user_led_pins[] = {
4 H5 B+ M" C% M" Y- r5 r: n /* These pins are definition at <mach/mux.h> file */# i1 {" k6 }+ ?! d& B0 S- n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
R- m( U2 v; j7 l, D2 o -12 L( w, h0 V; W8 Y! G: K% K3 P) q
};
$ _( `$ O8 U( `, m+ w) Y; n& y( g$ d' p$ L6 S3 i# |9 c( u
static struct gpio_led da850_evm_tl_leds[] = {$ x2 ]" E: r/ E3 _! i
{
& G$ j- ~$ ]3 g; ^8 w4 E4 |2 A( j3 f3 y .active_low = 0,4 `6 E# P; H- Q
.gpio = DA850_USER_LED0, R N/ n$ _8 {& w0 v% d
.name = "user_led0",# |: d t% P8 o: i' Z! J
.default_trigger = "default-on",
- y# N# V/ f2 {( E* @8 J6 ~ },
k8 [$ T1 ~& ?; |9 Q {
5 ^& f1 C& o! B* A ^% m .active_low = 0,: u3 ~7 g; y; m* n8 J, d5 r: r
.gpio = DA850_USER_LED1,2 Q# [8 q1 y& r4 o/ v; g
.name = "user_led1",! Z/ b+ `5 q9 P. \6 e8 y
.default_trigger = "default-on",/ K: Z# f0 z8 {2 j2 v+ |
},
6 G* M9 ~7 o5 o. Q {2 s0 x; x5 t/ M' _
.active_low = 0,
, v1 @8 k: I' @! t, S. \ .gpio = DA850_USER_LED2,
+ V! q0 l) R$ m. x6 P/ ?3 S6 w .name = "user_led2",
: L# E t' i; e! d. E3 J' H' q, { .default_trigger = "default-on",
9 i* d% g1 ]" g+ C. e- K0 z8 F },5 E% K! F4 H' q8 G1 X
{4 v# @5 g, x8 u& [4 C- r5 Y
.active_low = 0," O" V8 e8 L# W: y/ D K
.gpio = DA850_USER_LED3,7 v' n r: U. `. }. |2 I- t
.name = "user_led3",7 h) ]+ i, G7 A0 M. p
.default_trigger = "default-on",
( c. ?0 `5 P- _. W9 x( b) x9 Z },
+ R) l8 o8 ` e/ c};' h9 R0 a/ A4 G
$ M m* ` L% p$ c0 v# E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 T0 E+ M# \9 J( P* J% S
.leds = da850_evm_tl_leds,/ b x' h4 J/ p* m& s4 Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( N/ {5 e) j7 D* g
};
0 w0 r9 G) @! q6 T4 [1 `: Z! r- N! v) y% J4 a
static void led_dev_release(struct device *dev)+ D+ c/ A* v* ^+ g1 i
{
7 }( j! N" H5 J. b# {- R+ Z! M};
6 `6 ^5 B- Q$ d4 ]2 a1 n1 P% [0 l. _. O- P8 g0 b) I
static struct platform_device da850_evm_tl_leds_device = {+ m, c% s3 k: k2 ~
.name = "leds-gpio",
) S, l& j4 |& J, }+ l9 w3 @ .id = 1,$ k8 u; c% S/ `/ F1 f& a. m' {
.dev = {
{4 n# g1 L6 V; @3 r( f4 S .platform_data = &da850_evm_tl_leds_pdata,4 p1 h/ Z: v( q5 O
.release = led_dev_release,9 ]8 I p% ?- _. F1 Y- i5 A
}
# N/ M6 m4 z2 j% \" e4 V8 K};& _6 {+ c( {3 e# N1 D
: f, z8 `# S$ Q% q$ @) l! istatic int __init led_platform_init(void)
5 k0 i m$ t9 S0 R- W5 E{4 C3 ] G l2 h h5 G: r; w1 b9 h
int ret;
; m5 q7 k9 r" U- J! x) `#if 0% l2 R- d5 I3 \1 W# _7 o9 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 y+ \) @6 C$ I if (ret)9 k6 o+ m/ ~) C5 U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- P' ~. h( r" E- l5 m7 b+ c* d "%d\n", ret);% _! D# ^3 V5 y& }
#endif+ `# s( i5 N: y
ret = platform_device_register(&da850_evm_tl_leds_device);9 }" |% Q, C$ O
if (ret)
) ~# O% K7 `; d+ G- O+ d pr_warning("Could not register som GPIO expander LEDS");+ Y M% ?5 o) k! A# ~; y
else) @ W, v- |$ z$ i z
printk(KERN_INFO "LED register sucessful!\n");
`8 S& n; d7 I$ G0 P
6 V# t V6 g2 o% v# |9 \2 T/ l" d% D return ret;
7 M7 }2 P* Q* B: m8 L5 y8 Y# E}
$ a y4 p3 R* j- P1 G0 y
# U: k# s7 d g9 _static void __exit led_platform_exit(void)1 F/ S/ |1 ^( E2 D
{
! v, i) C1 R- w' p8 K platform_device_unregister(&da850_evm_tl_leds_device);7 O5 [0 { q! s0 e* N& ~+ I
! ]: @' } j2 t: H* p% \# s
printk(KERN_INFO "LED unregister!\n");& N* y% _5 U9 L
}
! O- }& c3 m. n) J, A# @: i
1 c2 [% Y0 X8 C" S# v1 xmodule_init(led_platform_init);
6 l4 s9 G; P7 A8 A8 n7 c zmodule_exit(led_platform_exit);
1 t- N3 i# }2 o' v4 a7 D- H/ d
! P2 t, a/ t4 @. l, QMODULE_DESCRIPTION("Led platform driver");
& L, v" d0 J" C I$ wMODULE_AUTHOR("Tronlong");
* I( c n; O8 X4 P w6 C1 O w. h- kMODULE_LICENSE("GPL");3 r4 T; c: A l+ Z& I$ A4 j# c
+ A5 b" r6 y( f" p' e
|
|