|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 s* v7 s# S A- V1 h/ E3 l0 k3 d#include <linux/init.h>8 q, M) n( j& j* c
#include <linux/module.h>
3 v, J- R9 h \+ H8 K8 T1 z6 g) B#include <linux/kernel.h>4 u. y m4 U v: U0 a6 j
#include <linux/types.h>( K3 [3 B3 n5 Q& I* \
#include <linux/gpio.h> L9 N2 P# C! b6 J4 d1 h
#include <linux/leds.h>
: Y: }8 f! M# H3 z) o- f#include <linux/platform_device.h>
" W/ |/ {* Y! q& _* \7 G" g
- d) Y: W7 K" r9 {#include <asm/mach-types.h>+ B: h- k9 y7 P* g/ O- i
#include <asm/mach/arch.h>
3 q4 ^9 W7 v5 }0 q# X#include <mach/da8xx.h>6 |; }, R+ h; X; F+ f7 z5 n, h" r
#include <mach/mux.h>
3 Q# W( M9 q4 Q4 {( C: k# s! x4 E0 F! z$ i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- S' ~2 [% Q5 X" ~! k- U" L( c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& |1 n* j5 d+ u9 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ w( ?% m2 ~7 A F! q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 V, y& I8 M, z; m: ]% J6 A
' Z( S9 K5 u! C/* assign the tl som board LED-GPIOs*/
) {; ^" }' s- X8 P# `static const short da850_evm_tl_user_led_pins[] = {
* x7 ^. j- v( N /* These pins are definition at <mach/mux.h> file */0 h& b% s( r, X# z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% w4 ~) p! V/ T& |9 ~+ {) t5 x3 r' ?
-1
6 y6 Y( W& I% L, E3 N6 O: f};
5 u/ \, v/ y/ C% M+ E0 m. s8 X# p) o. e7 x+ |
static struct gpio_led da850_evm_tl_leds[] = {
8 r( H1 k1 Z) \" r7 ] {+ x* g( k% Q9 x5 |2 V. i
.active_low = 0,7 [+ k& D' n- W0 `/ \
.gpio = DA850_USER_LED0,3 P8 e$ I5 \3 g* ]! n
.name = "user_led0",
- Z5 @/ H! D* L; O% w .default_trigger = "default-on",
! f6 h/ w/ s' t3 l },
# n2 E# q! g4 g1 {) c& i! c {
' P t1 M5 T: X1 _ r1 n" Y" a) { .active_low = 0,
7 J( e" B: }& x5 W .gpio = DA850_USER_LED1,
3 E& Y9 k" h% @8 e! a3 ] .name = "user_led1",( n# z, F. Z# u7 X- C' g! D t
.default_trigger = "default-on",! {; S1 n7 v& H/ @1 F, W) M
}," v) @4 ]0 ~: C& a7 S' |
{9 S" I p. a2 G. c
.active_low = 0,( A0 f) v6 e4 ]: C; I
.gpio = DA850_USER_LED2,
" l1 T) w @4 B( ? .name = "user_led2",
; ?! ^/ X: }2 P3 N .default_trigger = "default-on",
: _% k7 S' O6 Y: a& T- D! J9 z },
U3 \* u- Q/ }* F5 } {2 J) t2 P5 N: v0 c; o. H5 B$ q
.active_low = 0,
& e: d. I" o$ N8 x .gpio = DA850_USER_LED3,
: `5 v/ Y' S+ A1 n8 ^8 Z .name = "user_led3",
) Q9 J5 L7 x0 R$ j3 |$ o# Q) T4 H .default_trigger = "default-on",3 I9 s$ L5 d9 n& x
},( T8 q' {% W7 `: ]9 t) W+ N
};
7 v: @; D6 ?5 V- h. v6 [
$ q& Y, K+ M# O- Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# v. G4 C% D/ q, H W7 q' d
.leds = da850_evm_tl_leds,
9 ]0 L3 Y% V: U! Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 m; u; W9 D- B$ V2 K};5 y5 v, T8 i0 i2 s# @1 U
6 v* J% `; K0 F6 u9 _* w. m$ i& Q hstatic void led_dev_release(struct device *dev)* n, g: K: Y! J$ W; O: z
{
8 g% Z1 U1 y4 ~ }};
6 w8 O( {# s/ A" b* K' Y" _# Q# L M: H/ E+ j
static struct platform_device da850_evm_tl_leds_device = {4 C- R+ a" q; v/ J
.name = "leds-gpio",- T: s% C0 s9 g. y7 t4 G
.id = 1,5 K, c4 w4 Q/ l! W" o
.dev = {. m. h6 m# [1 j! Y% O0 Y: E1 M* E& n
.platform_data = &da850_evm_tl_leds_pdata,
7 V! ]/ m& c7 I# C9 p$ C4 [ .release = led_dev_release,
: _# [: g+ G- E } I2 m* S9 ]) N6 G
};
H' i5 ]6 X8 {( G* [5 F0 Q$ h
. r+ |1 d& o; i% {: X# K& c( |static int __init led_platform_init(void)
! S+ @2 V+ t' x. w9 O{
2 K2 e6 [5 s; M% L" N0 L" w% F" L- S. I8 X int ret;
2 L* a- }3 N' ?2 Q" H/ T#if 07 I' M; q6 X( Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* g, Q. ~% @% t1 [ if (ret)
& ?1 E; B) t0 V8 \3 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, R5 v) v/ c8 Z6 K) W, p3 s "%d\n", ret);
( [7 }6 W: x% T- I- T#endif* R/ x1 A, g0 M( v c
ret = platform_device_register(&da850_evm_tl_leds_device);* N7 p# a2 j1 g
if (ret)
5 g S, F5 m0 t8 o% P pr_warning("Could not register som GPIO expander LEDS");1 }8 W8 _7 e2 @' e/ y; H
else
3 G" | H: t( \) I8 V7 U. \ printk(KERN_INFO "LED register sucessful!\n");, j/ R' y) G- n. j- {
6 T: T; D2 X" n5 c* H
return ret;
! o$ o0 w/ S0 h, {4 h9 A& _5 t9 W}1 h! {- D2 m/ E3 U$ x1 e6 Y% a
+ V1 h# z u) _7 |4 Ostatic void __exit led_platform_exit(void)
% r8 g1 E; z% l- `: S{8 F9 g, J6 f3 @* k: F
platform_device_unregister(&da850_evm_tl_leds_device);
4 ?6 f: O4 z& o. c% ?8 T
6 \2 f" T3 V& H# u printk(KERN_INFO "LED unregister!\n");) U2 \6 r8 s" B: @+ i
}
+ {9 y5 e) p4 ?
% E4 h. ]: V! v$ j. m b1 P5 G/ pmodule_init(led_platform_init);
4 O; N' e+ r7 t0 P7 y) t- y$ Q, vmodule_exit(led_platform_exit);; R2 K D( Q( Q" j9 m" H% J# s
) [7 t r: d2 b e8 u/ f0 i
MODULE_DESCRIPTION("Led platform driver");
4 G" k3 I) @% ^& ]) _MODULE_AUTHOR("Tronlong");+ k) a; K, \* m1 A; X; T( h$ r
MODULE_LICENSE("GPL");" e$ Q* N4 ^6 P% i4 R0 D' ^9 C
# w% {) i; A- B2 N2 W/ X$ e) d
|
|