|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 N" ]1 f' ~: h, R#include <linux/init.h>, X" q+ l+ a" B7 T
#include <linux/module.h>
$ A# s; r I; x' `! q; X/ t#include <linux/kernel.h>
' X, T1 o2 _$ N/ o#include <linux/types.h>
2 H8 c" r+ }, T" \/ m% ~% `& T#include <linux/gpio.h>
) y* n5 f% _* P& `. f#include <linux/leds.h>' D* E6 J! p' \; E0 L+ V/ m
#include <linux/platform_device.h>/ i3 s" j' N8 ~8 j0 k* I0 h8 _. z
0 M0 p4 H5 e8 k, s
#include <asm/mach-types.h>
. K: E& W: I$ t& D3 g#include <asm/mach/arch.h>: \4 Y" w: p3 J" J1 M) m C; l3 A3 A
#include <mach/da8xx.h>
( d$ ^2 E$ D- j) s5 b" F#include <mach/mux.h>
3 _2 F! v" |, l9 @8 f1 W
3 B8 ^% u1 m1 |6 \( x, q1 _5 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- T" g1 T+ W6 }$ O6 B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 R$ H$ F9 G6 `" s6 g/ R0 ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. v4 D ~! ~; f Z- K6 y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ W6 Y5 b+ z5 d' i. {' |) c; t% p) T& l( ?0 S6 @5 T
/* assign the tl som board LED-GPIOs*/% ]; S7 y* q* O
static const short da850_evm_tl_user_led_pins[] = {
+ U- D2 E4 s i' b /* These pins are definition at <mach/mux.h> file */) V* e$ }, Z5 e# l8 m, Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ B J: T: B: U/ o, R" I5 g0 |
-1
4 h! G2 i* X+ Y5 s: Z};' ~3 t& |9 B M
# P; r+ i( l' C: i S8 a
static struct gpio_led da850_evm_tl_leds[] = {
0 t7 @: N, w- a9 N. J9 _4 T {8 h( ~4 r+ O. p$ u1 j2 l3 h2 k
.active_low = 0," X' R; m0 m* `- N. U9 x! f, }
.gpio = DA850_USER_LED0,
! R9 w0 o3 ^' j& h .name = "user_led0",' @% S% `9 C% o# ^0 E) `
.default_trigger = "default-on",0 ~ i) c. G& t& {+ _9 T7 U
},
# b$ I. |- x+ F2 @2 A {$ P+ {, ?% _9 B9 D1 w
.active_low = 0,) ]8 V3 t/ M F8 w% b# ^$ i6 i) k
.gpio = DA850_USER_LED1,+ g0 x' c8 `" L: j0 u; U
.name = "user_led1",
6 A1 w8 C' H# p* q. Z! }) t .default_trigger = "default-on",: z4 |* g4 E! [/ }- u0 p3 r. D- Q
},/ `$ s/ U# w9 K% p3 x, F
{! P$ k! b# P/ [) m0 c
.active_low = 0,, `; ?$ d; `5 |6 `( Y% J1 A- G
.gpio = DA850_USER_LED2,
+ r; F5 e9 l7 ], x# @ .name = "user_led2",
( C! S, T) P& G+ T .default_trigger = "default-on",
# g F: I5 F2 w6 _# c },
, p& M' u- M8 Y8 E {7 d2 s, o2 Q/ b3 M1 @& ~) ^
.active_low = 0,1 n I2 c/ [7 J
.gpio = DA850_USER_LED3,6 o5 w- C5 Q* S- w( i
.name = "user_led3",
4 u; u6 Q# V6 K0 C .default_trigger = "default-on",& g9 l2 W; F5 I% B8 T+ F5 \2 p
},
2 k0 g3 A$ H# T# A8 E2 _};& M. M9 O8 F+ K) m0 U
; j, \* s: ] W/ z4 o2 }% {; istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* _4 Z# V ^% W2 j3 _ .leds = da850_evm_tl_leds,% n1 D5 z% E; S6 ~9 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% K' @, K# D4 _* f};
) A# ?$ y0 ?, {& e) e# A
# A+ \9 S' M6 Z* ^static void led_dev_release(struct device *dev)
/ j8 g( L1 v5 v+ B{2 T& _ [; H) Z! S2 L# n( ~
};5 ?5 n' a% w/ W
( E$ A! I9 x* n, _0 r: M# Nstatic struct platform_device da850_evm_tl_leds_device = {! h* F3 o: J# t) L
.name = "leds-gpio",, \3 P: K$ b$ ]0 H, }) }
.id = 1,
8 C' B- q+ N, ]4 h .dev = {
% a# H( [& T) s4 C! O0 y7 H1 w .platform_data = &da850_evm_tl_leds_pdata,& [8 D6 g! {; j$ M, ]& z* V
.release = led_dev_release,8 Y: x) n4 F2 P- }* x2 p/ M' v
}
$ k* u5 i& X6 A};; G l4 |6 C5 E
' f" u) n& p; h- L$ V0 G j. M
static int __init led_platform_init(void)
. z1 Y3 p( c* A$ d9 F! ?8 n- r% E{
* F- ]/ @- V+ l* v. G. w* K9 l( F' B int ret;+ w2 p8 ~9 w! z. C
#if 0
+ Q: M1 K2 N) w9 M5 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 S4 |& s( _! H `# G if (ret)
3 h! U5 ^. v+ w, C) q1 r6 l5 J }- | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- ~0 ~+ C7 x' C0 f- J- s
"%d\n", ret);
2 T0 Y8 x+ Q2 H#endif
1 b- c3 [3 y, v0 J. x4 t. Q' I4 [ ret = platform_device_register(&da850_evm_tl_leds_device);: c; x( y; N K! q9 I
if (ret)5 \) G/ X6 i6 B4 |% Q0 ?# m
pr_warning("Could not register som GPIO expander LEDS");
( U0 E4 z6 m. j; D) r. Q( _ else$ H s: {- i# G. W% L' b
printk(KERN_INFO "LED register sucessful!\n");. Q; _$ f6 `6 @) u7 k
' ?! L+ O0 P- r! W return ret;; K3 k3 w$ R3 T" A4 v
}
2 i8 M0 ^9 X( P5 A2 a
. g& g+ O$ J1 a1 `& d* P5 b8 Hstatic void __exit led_platform_exit(void)
" Z0 |' k& w- J% I{# X) l! b+ T3 o" r+ Q* q* B; N
platform_device_unregister(&da850_evm_tl_leds_device);0 |& T7 i0 R6 q; \, _; e* ? o5 T0 g
6 l. L4 p2 [2 i0 j* e- z8 n: w printk(KERN_INFO "LED unregister!\n");
# O: o) n, f, Z8 @}6 K0 J) f$ g4 N d6 |+ M/ R
4 R- X7 J5 z) i( F8 L& ?module_init(led_platform_init);
: c+ R' L& {9 _* K1 ?5 Umodule_exit(led_platform_exit);
6 m! k# u" Y+ P9 h/ n
( C4 U* l, m x3 ^, LMODULE_DESCRIPTION("Led platform driver");$ U# B0 L% x9 z3 q9 W
MODULE_AUTHOR("Tronlong");
) M7 d V- i8 R6 v% p" xMODULE_LICENSE("GPL");
( p) [4 Q$ \7 i+ A& m& B8 {' G0 |/ ?( p, S! |3 Y- N
|
|