|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 {7 s! N- S% a; W+ l
#include <linux/init.h>
4 k- ?2 i9 x8 k#include <linux/module.h>
! e7 ]5 w3 @5 p6 d#include <linux/kernel.h>% x2 S: m2 R7 B4 l3 E! z
#include <linux/types.h>: R' T( i. U- k$ Y% J2 H' T( a' {
#include <linux/gpio.h>9 {, B o5 o/ O$ ^
#include <linux/leds.h>
, ^; \. w/ m5 Z' _' C#include <linux/platform_device.h>
4 C0 F) A" @: L# a; r" Q
6 U4 ~7 G- |' M" f) j4 F#include <asm/mach-types.h>9 ^8 A d1 m# @
#include <asm/mach/arch.h>
$ V. S) O) ^! I* h1 g) ^, Z& p#include <mach/da8xx.h>+ i$ J6 Y2 o3 g7 R* b8 I
#include <mach/mux.h>/ F9 W& o9 G6 l* o3 [ h4 b
3 n; I ^. S, r4 \6 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 H$ W6 e9 ?& l( n/ k: q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( v- K# [) B' v! t+ o" q2 ~5 r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 A: X0 T& \, u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 f3 k3 ]' R2 |! j6 Q: G
5 L# J: U0 R/ o, l/* assign the tl som board LED-GPIOs*/7 Y1 ?; ]3 h% q2 V6 C+ }; x) ]
static const short da850_evm_tl_user_led_pins[] = { Z' \4 w5 b/ D/ A; q3 c6 j6 D
/* These pins are definition at <mach/mux.h> file */
% M8 a/ a. {# X, U0 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
T& C0 v" ~0 a% z7 Q -1
7 R. k" s; i% g3 J7 j5 Y};$ }/ [3 Y0 c. U, E& t a8 O
# X3 c! P/ d9 F7 A
static struct gpio_led da850_evm_tl_leds[] = {
" F8 Z6 j: Z# n+ u$ u {, T. Z; m) K! e2 d, `/ [
.active_low = 0,
5 M+ J; C* u& }* `( F- U: z6 s6 Q* | .gpio = DA850_USER_LED0,
0 b1 N- _$ }# c$ U .name = "user_led0",( p& H+ f8 e' b i" I: M9 C
.default_trigger = "default-on",
' q5 }) @: Q! {) y" ]& f' @ },) w) d6 {1 C: W, S* ?: v Z
{
2 y7 ?' X: w' b' z- C2 ] .active_low = 0,
8 s9 S, s2 f8 E4 T+ r2 T .gpio = DA850_USER_LED1,
: m. o- T+ U6 V5 H' m. s .name = "user_led1",4 A" r" A+ [! ]6 ~' z9 I
.default_trigger = "default-on",! _7 P$ J0 Z' V# w
},
1 B U+ u- m a2 U: j5 k( i) a8 e {8 L; E$ H$ X( Z6 v/ G2 K
.active_low = 0,
& V' J1 E( X9 Q4 k+ V .gpio = DA850_USER_LED2,
9 a8 K* K5 }+ V/ K .name = "user_led2",
0 }4 ?0 q3 Y# |# C .default_trigger = "default-on",
- {# h$ v3 B- Z. O$ ?% D },
1 n0 V1 Z" D7 k0 p4 N: ] B) ~/ R {
F, ]! Y2 k( V .active_low = 0,' {7 U9 u+ f0 p( E+ D
.gpio = DA850_USER_LED3,
9 m% @% k1 ^( O6 ?5 M7 v .name = "user_led3",3 y- y; t# P/ {
.default_trigger = "default-on",/ v! o& `3 v5 ?1 T# ` Z
},1 h. y; p* J% m$ G
};1 k0 N* z# R6 Q% I% ?+ w. P
. R J! s1 f# a9 T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
q- K W+ ]9 o+ M/ ? .leds = da850_evm_tl_leds,
( u8 i2 l4 M3 h' B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 u. e; ?) W1 a2 i5 K& W/ w' ^' S
};9 w: J3 R6 {$ w% i& _; z9 J0 ?2 U
; F( K& j5 @1 }0 h8 E! _! Cstatic void led_dev_release(struct device *dev)$ N9 k1 B# s! ^; P
{
$ b+ y1 P1 }$ s& o. @}; F5 d& L8 W' A( S
/ Q) d3 @1 b1 G4 K9 p% mstatic struct platform_device da850_evm_tl_leds_device = {5 k# `4 V6 G* k. V* L0 e8 e* F* ^
.name = "leds-gpio",
6 Z" o( c5 C+ V/ S4 O3 g .id = 1,4 N! N+ ~2 T1 B1 @: }* O: Y
.dev = { h5 c1 X* T5 l2 s# g+ ~7 p' Q
.platform_data = &da850_evm_tl_leds_pdata,
) ^, H& d1 b( @# X+ t" ]4 r .release = led_dev_release,
; k% k( s1 a1 ]0 @0 R# {% y N4 a& ] }4 h3 Q0 F. n7 S V. x# t$ k: B
};! V. ^# r6 U% z3 L' A9 q
0 l3 y+ {- ^* p. ^' Tstatic int __init led_platform_init(void)6 {* G8 r2 W: P( U% g0 b' `, I# G
{
" d6 G$ Q- D5 K& O) h' W int ret;
1 A5 s- j8 L; |$ T' y2 q7 {# z#if 0
( r$ S2 x$ C9 m5 u* ?7 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: K2 y. N3 P ^* v7 z if (ret)/ x; j2 j* h3 C J q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. l+ i0 m p+ m3 i6 f4 K "%d\n", ret);
. O* q& k+ {. a2 w/ z#endif ?, {9 q' ^4 P
ret = platform_device_register(&da850_evm_tl_leds_device);' S( ]" w' ?, c) y" @
if (ret)
( i9 ~6 G( z$ L9 F3 }& r" q; d pr_warning("Could not register som GPIO expander LEDS");
, c" a% r& O# b; y! y else
, }6 @! I! t$ w6 e6 S/ z printk(KERN_INFO "LED register sucessful!\n");
; o6 E9 C% ?% L" h0 }* S7 t+ `# I3 \
return ret;" v6 A( _! @. p. p5 H1 R! S
}) i9 O8 {3 M* p3 o6 x" ^) p# A# ], ^
9 c* z, r- n% {8 fstatic void __exit led_platform_exit(void)8 V4 o5 j" y ]. `% f1 q
{
# r$ {9 E0 G' c2 S; }" H! y platform_device_unregister(&da850_evm_tl_leds_device);( Z/ A9 Z- }: u" n! U$ E4 o
' }5 `+ U6 T5 G7 U6 Z printk(KERN_INFO "LED unregister!\n");
8 h8 Q- D) H: {2 q& _' {, K9 `$ x; V}$ Q1 S/ W9 N; r, M$ @
& ~) e& W9 w ]. O0 Amodule_init(led_platform_init);
0 z, \9 k7 X7 Y A3 Ymodule_exit(led_platform_exit);
7 e$ B9 x2 q* d( t# B3 l) x- v& J6 M% X D1 f- A0 Y B/ ~' y9 h
MODULE_DESCRIPTION("Led platform driver");
4 y/ e& B* w y& ^7 tMODULE_AUTHOR("Tronlong");* g7 G+ c5 m: m7 [. @; f5 X
MODULE_LICENSE("GPL");
! s9 m" y+ G: p# |1 {1 S/ @% {& l1 g, q& A+ V
|
|