|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ S$ q5 p" I4 ~8 k; G+ h
#include <linux/init.h>- o7 b8 C* [( b# l) y
#include <linux/module.h>
2 ]2 c, Z' ^9 L# D#include <linux/kernel.h>
: d" s# A* g8 S+ e3 k+ i5 p#include <linux/types.h>
- Q w! Y! S7 i& I5 W6 c#include <linux/gpio.h>9 y; B) z2 W% }2 @. Y* H1 L
#include <linux/leds.h>
" G' n9 c( M% x+ P- @#include <linux/platform_device.h>' }) l7 W' C! n. F0 [, c* t
/ b2 Q2 ]9 c' I, ^0 H
#include <asm/mach-types.h>
" K) S: ]4 z$ K#include <asm/mach/arch.h>
$ T" T* e& l; a#include <mach/da8xx.h>
! y* U! C1 B- {3 g#include <mach/mux.h>
8 y: P$ z# q4 a; _
% s* V, s' L& E' g. D+ I3 c- j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* j1 m& ]5 c5 Y2 ^; W
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 u. O* ?5 i! ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- w$ s% o1 c# A6 e9 M5 d1 e0 O$ E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. `6 @2 c0 [- P% a5 Y# o
3 @& ^$ x6 W3 ^; D# h8 f1 O7 b/* assign the tl som board LED-GPIOs*/
- ]* ?4 S1 W2 Sstatic const short da850_evm_tl_user_led_pins[] = {0 T- [* }# @* p5 k0 g" Q2 x; f
/* These pins are definition at <mach/mux.h> file */
) w/ w4 u6 q5 Z" x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* x' _( L9 y/ T$ _2 f* v$ y& U
-1
: H2 V' {& w( d! z* n5 U};" `/ x, E2 g: y
8 J* w( V7 h& e- {' \' ?+ Cstatic struct gpio_led da850_evm_tl_leds[] = {
! C$ }$ t9 o) o1 Q' ] {
: Y) H/ b* a6 X1 T .active_low = 0,$ [6 ?( b( K+ T G
.gpio = DA850_USER_LED0,
! @1 T. m: i& t8 s5 P .name = "user_led0",
/ _4 [- A% Z# ^8 U7 G4 a- ]% l .default_trigger = "default-on",
' Y+ P7 L5 ^' j' E5 t: b& h },
/ P6 D8 a0 c$ A1 M- Q; [1 U* ~ {1 M# ]# n6 Q' L* j* P7 s9 |& G) z
.active_low = 0,# X- R% Z4 g( T$ [; u
.gpio = DA850_USER_LED1,+ ~9 S5 [5 _. J" N) h) D: j! o- R& @5 v
.name = "user_led1",
1 a) }. a6 B: g- A, C' F! a! E# U .default_trigger = "default-on",
7 W; w+ r9 |, o, S* h },
- z% U7 w+ n: Y9 p {5 ~. ?" b& g& Y+ B: H" }" S
.active_low = 0,
* r- C/ J5 k6 K7 P5 K .gpio = DA850_USER_LED2,$ ~* r. j' c _6 o6 B0 z2 _6 x0 l
.name = "user_led2",$ M! G2 [7 m$ H5 P4 P
.default_trigger = "default-on",
, p/ x% z6 G6 b },
- ]8 p" j( h: H. b {
6 ~$ V6 P; w6 Y V3 R' U) @+ @ .active_low = 0,
2 L j" p5 {- w3 }6 C1 o .gpio = DA850_USER_LED3,
6 ~8 T: m! ?3 z( h) V .name = "user_led3",/ ?1 u! B* d- {1 A! {" g8 m$ y; d
.default_trigger = "default-on",
+ w' { i3 p" w) r3 A },/ G8 [3 H n2 F; ~
};/ f" \; H5 l3 G/ |: h# d1 k) M
+ q) E" L$ z9 `! L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 \' ]7 a M9 c7 l- X
.leds = da850_evm_tl_leds,4 K5 _3 z1 o$ Y. M7 `7 W8 d. Y7 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: R$ f/ n e, S3 o! ?" p};/ j8 p. J+ M( e! r
+ L' ~1 h& h6 I" n# Z/ Estatic void led_dev_release(struct device *dev)
( i/ {. h9 }2 m* u5 _{
" ~/ z& b. X! D% n. T+ M- Z: X t8 E# |( U};
( q9 n8 T( F: c2 F* }) D$ J: n( Y' j* a
static struct platform_device da850_evm_tl_leds_device = {5 {7 z' G, j% w% @! i) i
.name = "leds-gpio",
! }" P' l4 X. l) ]+ D6 @% w .id = 1,
) A$ W) D7 @3 m( j$ H .dev = {6 a o, a5 I/ X/ v% F, R
.platform_data = &da850_evm_tl_leds_pdata,
# y4 i/ W( k. h' e+ D$ u5 v7 r9 P .release = led_dev_release,3 \0 R! G P& ]$ o( ~
}4 k. p6 P3 T8 B o
};8 L4 A! f8 d3 c) ]1 H3 I6 f* R
; T+ {+ I5 n: D" c% q5 S
static int __init led_platform_init(void)& R' {7 @: k4 H X; @) u
{
/ [; }# o7 { M1 q) I! M5 {6 F, Z int ret;
n; w' x5 `# |( A& q: N#if 0
/ I# b2 }6 q/ O% H9 L$ B5 N, t3 j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 K2 _! N H" H; ] if (ret), h" l. x) ]7 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. A2 J. S6 N$ p/ O! S4 E "%d\n", ret);9 _/ ]) l% F, P" w
#endif
, ? ^+ I. T: g4 P2 S) u+ |3 \ ret = platform_device_register(&da850_evm_tl_leds_device);# f4 y! n D( Q, B, _( B
if (ret)
& B5 A8 X& J' U pr_warning("Could not register som GPIO expander LEDS");/ S# o+ i* l1 L) Q6 E( w4 t
else
/ N" W- t$ P" _- [/ F printk(KERN_INFO "LED register sucessful!\n");
: m4 C$ T$ ]3 S
0 P0 T5 w8 I4 P- y! g return ret;, u: B/ n( d5 E( b' S
}
& h9 h8 |& U! U- s0 D7 i+ U1 b7 h5 Q5 q" c e1 W' z& x' _% v5 d
static void __exit led_platform_exit(void)
x/ W8 l% i& l. l# Y# Q{* i3 R7 n% G D0 w
platform_device_unregister(&da850_evm_tl_leds_device); N1 K' N( \0 S0 q0 P
. ^. L6 [- r( C- ~
printk(KERN_INFO "LED unregister!\n");% z$ l* ?' `$ |2 c* ?
}
/ _5 f4 F, V+ w* E6 i3 J5 {, b4 P" \* x/ H4 C/ j
module_init(led_platform_init);! Q: g+ c" n ~
module_exit(led_platform_exit);* S2 F O, F" ]1 |* {% o5 v
# k* F3 g! @4 X. Z+ OMODULE_DESCRIPTION("Led platform driver");( l' w# Y r0 Q1 D- K( z
MODULE_AUTHOR("Tronlong");: f8 \* x I' }/ d" Z$ S
MODULE_LICENSE("GPL");
! A* `9 t# P% d. l$ I! h& J8 e1 u* t4 z' D2 P, n
|
|