|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' K" F- N6 B6 V! b# g+ v2 ^) x#include <linux/init.h>
8 [1 @2 U/ T; @/ p' W0 b& d#include <linux/module.h>
5 x5 Q3 S. S/ p1 `2 z& t5 _#include <linux/kernel.h>. i1 V% i1 m y# S/ @7 T- ^
#include <linux/types.h>
) q! D, C: B& b0 _#include <linux/gpio.h>. w5 ~# g$ b* f0 U4 G
#include <linux/leds.h>
T' G. E( o: R# J; |#include <linux/platform_device.h>* F* [- O1 Y. x+ Q0 q8 f
' A0 O! H7 W( p" v2 [#include <asm/mach-types.h>& Y& l% n1 f% E# a" F- G3 X' `6 n
#include <asm/mach/arch.h>
- l h. ]) \, t#include <mach/da8xx.h>
. C; t& ^" g. u" D. D#include <mach/mux.h>6 g* P2 R6 S+ ?+ r9 H5 v
2 Z$ q6 \% g- F$ b0 A4 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); L$ d2 J6 ]( U; K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) P! w) Z" l! V4 h' _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! w# b j) E) G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; M: |+ l' T4 V2 d
- U* }6 u: h" X8 H" q/ a- w) U& L# O/* assign the tl som board LED-GPIOs*/
+ e: _/ Z# m/ t5 ~) o( ostatic const short da850_evm_tl_user_led_pins[] = {
' j. u( z* ~4 x" L/ f! z* V) v6 q /* These pins are definition at <mach/mux.h> file */: R3 S* T* @' }9 _* Z! U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& Q* q0 U( r0 a$ a3 L ]0 m9 J -12 ]8 ~* R. G+ K3 R& D' R+ ?, P
};! n. p/ H) O3 t8 c: A
" C2 C Y8 f( X A7 |; z
static struct gpio_led da850_evm_tl_leds[] = {
0 U2 E, S" R# K, J5 P3 ` {; {1 L" p% G& ]% i
.active_low = 0,
0 B7 c/ s. l$ O- s" M1 n .gpio = DA850_USER_LED0,& N, q$ d |" [1 b5 K4 Q
.name = "user_led0",2 \9 T5 m1 N, Q
.default_trigger = "default-on",; E l A7 h0 a1 I# T
},
% p, l9 F( \2 c+ m' ^" X {
8 @' n( `( C- S) y" Z- ^ .active_low = 0,
- j X* ~- R: F3 p% f .gpio = DA850_USER_LED1,
; J3 _4 ~8 f' r4 a% a. u .name = "user_led1",
$ K$ ~$ n f5 M# p! o9 [1 r .default_trigger = "default-on",$ S1 N$ w7 V6 s5 B) A* W z* ^
},0 u$ d( I, ?) {0 I
{
# d) Q C. {+ l9 w6 R5 Z u r. f .active_low = 0,9 m% D9 l, C& B& @4 i* u1 _# _
.gpio = DA850_USER_LED2,
( |3 \2 p) {- v5 H2 b, X V! U- R8 ` .name = "user_led2",0 o% ^; ]; b8 Z0 F7 Q5 @
.default_trigger = "default-on",
. Y" e: w% ~7 _# y* u K) L },
$ w$ f4 M; X; ]- K3 U2 C; U {
/ y. c+ d& ~, j) p% V! k .active_low = 0,
2 }" ^7 u( D# n4 V n0 ] .gpio = DA850_USER_LED3,
/ a4 D# S$ O }4 d# f8 B0 [( d+ D* ^9 f .name = "user_led3",
! C; j" {$ {9 p2 r0 a8 B0 c .default_trigger = "default-on",
# K; ^( o* Q# u. i$ {4 o( ~; W2 N },
- B' i4 T; g/ e+ I7 F* L4 D};; h/ ` M9 n8 z2 x4 z
! ~4 N! y f# [; O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: v, G. X( j9 m! g" v .leds = da850_evm_tl_leds,
5 N8 F5 D0 `- ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. X5 H- [+ g; N3 W7 g
};: I9 K' j' m) z9 i0 f
9 v! g- w" y. L; F4 q1 o a
static void led_dev_release(struct device *dev)
2 w6 ^5 Y3 S+ F$ n{
+ T$ ^! m" @: R; l' k};; H- R. t3 \. }8 o
9 c6 `0 s& R5 l
static struct platform_device da850_evm_tl_leds_device = {
1 M; G. I2 s0 E. a8 p .name = "leds-gpio",
: k: N7 J+ `! ?. w .id = 1,8 i6 ]; n8 G9 v* L& ^: F
.dev = {
# y, S. K) ^) q) g. ]' ~6 w3 a .platform_data = &da850_evm_tl_leds_pdata,& i$ ^* R5 f& ]' ]% e* r8 z
.release = led_dev_release,
& a: x' B6 ?! u) c* r0 o1 l }
) G1 F5 X& Q( v- w};
2 e6 ~& r2 O( s3 D: Y
, {. ?5 b- m9 E8 {5 astatic int __init led_platform_init(void)
4 B3 E, C% }; F' V" J{
; Q: U9 E/ h4 ^: x- q% e7 N int ret;. G) h' M/ q( j/ _6 r
#if 05 x3 k" o9 }' X. e3 U$ R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( I. v0 G; u: J9 {( l if (ret)) i; _! ~' g) f8 k9 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 z9 J! ?) s$ h# o
"%d\n", ret);7 |% c0 z9 }9 ]% t% [. ]: \: C' ~2 h
#endif7 X( m" G; A2 b4 Q* y
ret = platform_device_register(&da850_evm_tl_leds_device);" p1 h) I) x7 L l, R, m/ B6 r3 r
if (ret)
; L, s; T0 ?8 Y2 q( m' e9 y pr_warning("Could not register som GPIO expander LEDS");/ b6 O L' q& w! b+ s7 ]
else( l/ A+ ^* T2 l5 _5 K! @. I! i
printk(KERN_INFO "LED register sucessful!\n");% M( y$ O0 x+ e+ w; O% n4 y1 m
4 g2 D7 h) P7 V+ T& a* Z
return ret;+ P X' F" d) h0 M: {7 V$ U
}
+ g: F* u( {: v% v" W+ ^0 i) L& y7 W8 l
static void __exit led_platform_exit(void)
3 q" ?7 U% a2 u# B! x{
( B" @/ w0 R! L$ _: g/ p3 o, { platform_device_unregister(&da850_evm_tl_leds_device);' r- @3 [. b2 G' u& _1 H
2 L) d7 K p k' L
printk(KERN_INFO "LED unregister!\n");2 Q) E- P6 [$ M8 {& H5 z
}
$ \1 @. d0 |) N5 B) k: `
% r$ f& s8 P8 `4 F' {module_init(led_platform_init);
5 L; F C- M- T: N( {$ Pmodule_exit(led_platform_exit);
3 }& U6 B( E; @
; K" S/ B) _1 [1 WMODULE_DESCRIPTION("Led platform driver");
0 F( x; h; T, S1 oMODULE_AUTHOR("Tronlong");
1 P9 e5 X1 {7 v& Z' D1 P) lMODULE_LICENSE("GPL");
; f/ o* j# D; R# @" Z
?3 y; s5 A( M8 c |
|