|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, y- v$ |$ z7 X; w$ y
#include <linux/init.h>
A6 f' \& x+ c3 ?2 A3 K$ {, a9 U#include <linux/module.h>- L6 R. t1 t/ c# }
#include <linux/kernel.h>
$ C/ P. ~' U4 K! F& B M( n9 Z#include <linux/types.h>' k/ X) m( k6 D( K) @+ @3 J
#include <linux/gpio.h>3 O/ S U8 ? ^
#include <linux/leds.h>0 M6 V; j% ~7 O$ N i
#include <linux/platform_device.h>! R( a6 a5 F( h; E8 K
4 V: n- y* Y2 I4 k9 c' d
#include <asm/mach-types.h>
7 l( \9 O* N8 M' ~. e6 ?#include <asm/mach/arch.h>% y( E2 x2 t ?: Q6 [
#include <mach/da8xx.h>9 C& b6 b+ P/ G. O& K5 o0 \2 W! y R2 a$ L
#include <mach/mux.h>4 m0 S9 o* ~/ y
+ q4 G' \: l% _% U) h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) f, m0 c1 x- I+ W4 k+ s% I" p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& Q+ V0 }& Q8 k, g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! m( T. [* I8 e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' h# V# F/ ` S$ t9 c! d- M. j
9 ^! a0 R9 U3 x0 `0 Q/* assign the tl som board LED-GPIOs*/
# Y' b; K. R1 @) t/ Ustatic const short da850_evm_tl_user_led_pins[] = {
4 B8 b4 X! Q/ r: `) Y /* These pins are definition at <mach/mux.h> file */+ t. V9 |8 Z5 v) F, B! |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 q5 S) m% w, s& U% j
-1
! N. _$ I; x9 R( |2 O};* t. h. Q" B+ i' V8 Y" Z
( l) v8 |) d( u# p! q! D" Jstatic struct gpio_led da850_evm_tl_leds[] = {
, K. ]" C! y* K7 c) F/ V" S x8 l+ j& { {# J7 M5 a5 X" f9 Y1 [% x: i
.active_low = 0,# R" d3 ]% Z/ X6 q" e: \0 w* V
.gpio = DA850_USER_LED0,
& L3 A% M: O) _( V .name = "user_led0",
1 D& n! O" G/ @ .default_trigger = "default-on",9 n, a, S6 C- x. Y+ n
},* `2 W, I0 \: {9 T5 |
{
: a) M8 T7 O. K5 I$ A7 c- q3 E .active_low = 0,
. G6 ]/ s6 t& i8 U4 E# Y .gpio = DA850_USER_LED1,
" t. q0 N6 H/ L& ?6 ^! c) _ .name = "user_led1",8 D% o# l; Q, }5 j
.default_trigger = "default-on",& P- H/ x; E& W
},
+ L& u( K- m( o2 Z- e' f6 I9 S {
4 p7 B! M5 T" J4 P. a .active_low = 0,) E, A: p* q) e
.gpio = DA850_USER_LED2,1 v: }1 a+ H" q
.name = "user_led2",2 r9 @2 |/ M6 z9 Y0 s
.default_trigger = "default-on",( `6 N8 |" X# m) y# b
},4 Z2 y R4 n0 f
{
: T" S) G# `4 I: u* N E' H .active_low = 0,
; y5 F6 n& k. r .gpio = DA850_USER_LED3,% C& m; |# c% a& V
.name = "user_led3",
. z; \% j! _. e( K2 L7 V .default_trigger = "default-on",- A6 t* y% q' c0 O3 J# ^
},+ f! H; p* B2 a" H2 O% Z( r
};. B( I9 t) |' B' R" Z& r
; h: p% F$ W Q; Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 X2 G- B) |. T8 N$ P
.leds = da850_evm_tl_leds,
+ M* Q: `9 E% C .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," U+ w! Z$ H. \1 Z
};
: f% V; `" Z3 i
+ d# a( U/ _4 ?& d% ^9 z0 bstatic void led_dev_release(struct device *dev)
k- j2 @- C W) F( c, X{
4 W) z4 e6 W3 {( i};
$ G3 ~2 h& C- U! E' [ ?1 n% j g& I' T% _' V% [# {0 Y$ x
static struct platform_device da850_evm_tl_leds_device = {4 y) h# D' O- }# ]3 ^
.name = "leds-gpio",
9 s# ]% E! y; u3 f" L0 }5 @ .id = 1,3 L, e& |" f0 [- K" n; i
.dev = {
" V! \: n1 U0 Z+ s& | .platform_data = &da850_evm_tl_leds_pdata,* b. H- M5 Y2 H7 z
.release = led_dev_release,6 j2 i( @6 W/ I. k$ t' \1 ], a
}. {8 _7 {+ }1 e
};( ?4 s7 ?+ i; {/ e( X; V \
# o7 z2 E* _8 _; ] S2 ^static int __init led_platform_init(void)
+ o+ r3 e3 z2 y: ~# E{- x1 N7 P$ [1 k, K f9 s
int ret;, }- |% q7 k) p8 Q; w& M
#if 0
$ J6 s W$ ~1 b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: Q5 `& ?: K2 Q3 z p
if (ret)
$ u- I0 ]4 k: I: ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ F- T; n; F4 p% a' X* m
"%d\n", ret);
( a# ~0 w1 t5 X: s+ R2 {#endif
) d6 W8 x% j# j% @( n9 J* E ret = platform_device_register(&da850_evm_tl_leds_device);
. q' \6 ?! ^, G/ |9 F if (ret)
: ?+ S5 Y h: q' _ pr_warning("Could not register som GPIO expander LEDS");* w+ Y+ r/ d2 {
else
) e! p" _: x4 l9 H* B% s( G) n. F5 \ printk(KERN_INFO "LED register sucessful!\n");& z! |$ G+ Q* L
S u- }2 C6 R# E( Z( Q
return ret;
( E0 R0 c, r) V) g- S}
. F D" q& r# ~# J/ ^# w3 N* {! r4 c
static void __exit led_platform_exit(void)
# H7 K6 c% h8 V5 ?7 I1 S& T{
0 ]4 v5 h: U& r: Q platform_device_unregister(&da850_evm_tl_leds_device);3 H3 e# u# c6 V- w- {
, j3 V' V Z0 c' ~1 { printk(KERN_INFO "LED unregister!\n");
& l/ [. ? a+ k}4 p" y) ~- M; |! M' t
' X; }2 Q& i& h. f" ^) o5 R& S" c
module_init(led_platform_init);
3 T; F. z% t u6 o9 \6 i. umodule_exit(led_platform_exit);9 B/ e! L5 n4 o4 _* M
3 ?0 R% {! B4 i# P% x% A+ B1 b
MODULE_DESCRIPTION("Led platform driver");
2 l& B! v1 w7 z4 d3 n( CMODULE_AUTHOR("Tronlong");; t2 g+ V" K0 N
MODULE_LICENSE("GPL");
' T1 j, h. d; E3 c# b) Y3 P# K1 m$ N9 Z& s
|
|