|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, V! T: ]9 W$ T#include <linux/init.h>5 P# U" X7 P+ ?1 ~ n1 f5 D4 Q- z
#include <linux/module.h>
, Q: H5 B) K$ S% ?4 B) f#include <linux/kernel.h>
5 @1 |* w/ U" _7 J3 |# x#include <linux/types.h>
8 P8 W) B1 N Y Z$ Z! X6 c( T a( K#include <linux/gpio.h>
. A) [: i+ @% }# ^. H#include <linux/leds.h>& w2 }" w9 ^: f; T) W& v( _
#include <linux/platform_device.h>
! l. _. P4 [' d- K6 o/ W& r0 w# Z! d: x
#include <asm/mach-types.h>: z9 P' s0 k& a1 L; |7 t6 N
#include <asm/mach/arch.h>: f8 x. S8 l4 D3 a# X. v
#include <mach/da8xx.h>) J7 U* G% R( I$ I, V: r# W
#include <mach/mux.h>
7 m% K6 r. U9 t0 M; I1 U
; ^$ x" |' }% f( ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 o' X I6 ]+ n. l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); E I* b7 p3 b# Y* d1 _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' f* V' x- K3 `+ T. x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 w! V: \+ {; m; I/ H
# [) }2 {7 d& C8 r* D/* assign the tl som board LED-GPIOs*/
& b) \) I, C. X% P/ i, _! z' istatic const short da850_evm_tl_user_led_pins[] = {. {, x3 y1 [6 x4 ]7 V
/* These pins are definition at <mach/mux.h> file */- y: ~! L7 B9 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( _! D0 F7 v) j' L, O -1: j8 G/ y: H; T/ o7 s
};
2 |1 K$ k& \$ C4 d1 O( D% E% i5 L! }, p# H; h: K$ }1 E, p
static struct gpio_led da850_evm_tl_leds[] = {# M6 S" Q' Y1 J! C$ V3 K, P
{
- H# E8 E. {1 c& f3 Y# y+ E6 G# t .active_low = 0,9 y' G0 e P' Y! \# h
.gpio = DA850_USER_LED0,, k4 v0 M4 c# Y. T# X
.name = "user_led0",
' m9 U: V3 ~) d# r0 k* l0 ^ .default_trigger = "default-on",
, n/ O# J& u* u },
7 B* m5 b" g; d5 u {
$ H8 K; O, q6 U* _# j9 G0 X: L .active_low = 0,
9 l2 _" N) L6 f .gpio = DA850_USER_LED1,
6 g. |: p4 G8 W' p/ _* m8 z .name = "user_led1",
7 a1 O. Y% v/ I) V% ?' r3 p5 w( _ .default_trigger = "default-on",, g2 Q# h" n W+ B
},
% r' K. D3 n/ U6 j {. }. ]1 ^! l1 q# B
.active_low = 0,
( s, _5 q8 B6 f+ e .gpio = DA850_USER_LED2,1 G, L, y- T' k1 b0 @% d% {4 ~
.name = "user_led2",1 r& B6 u# J% P$ G" U
.default_trigger = "default-on",, \1 G7 j! p6 v# D1 f3 L
},0 |5 a/ G* g4 B( }, [' u$ x
{
; }6 T3 W1 }& w7 N .active_low = 0,, W2 O3 y& R8 ~
.gpio = DA850_USER_LED3,; c4 A+ I. M$ \
.name = "user_led3", q# _# q6 ~! G8 `5 s& {# ~3 a
.default_trigger = "default-on",
5 j* A E. Z% h9 z$ {* r0 E; a2 K6 [ },: Z. d+ `! ?. {
};
" F1 D' J! |2 Q1 X5 @8 e. m
5 n7 {, h; `* [( O% a& d6 {% `% Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 ?7 y" V. l- U
.leds = da850_evm_tl_leds,
5 H+ e, F% p- q1 S. q' l* |, B; M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# n: E2 ]8 ]0 W- ]' W};
! U" ~& f( s s( t0 x# m4 W$ R- j m7 E% A4 Y5 R
static void led_dev_release(struct device *dev)9 ~4 S! I0 v L# Z( F
{
, R$ z1 {5 C6 L" x; C8 p};
) Y5 r" i. K% O# P1 [4 s/ X! [' J7 R+ @1 S- ~7 }2 H: \
static struct platform_device da850_evm_tl_leds_device = {
( V) b* ~5 }3 n .name = "leds-gpio",
. H# w" ?, ]( \) O( `, K* V L .id = 1,
. |# s6 w# _5 K0 B' P) G .dev = {
! b$ X& s& G( m. a( y .platform_data = &da850_evm_tl_leds_pdata,
# f, ]/ Z; q2 p* ~% t { .release = led_dev_release,
$ a7 b5 `. {7 d$ {) M X* @* {7 z }, Q! }) ]4 W7 e" y% B7 z7 {
};
G9 m5 |3 w b- Q% s
6 L0 ]+ m; U5 sstatic int __init led_platform_init(void)) u: D) ~3 C2 S0 ^3 ?& }. E3 h m
{- m) r9 j, C4 }/ U& |6 O
int ret;. E# ]8 z9 `9 Z
#if 0, e& v- B' T! n- [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# |2 r. W+ i K, h& A4 E; X if (ret)
# m6 D; K# ?2 q7 Q# X* x) { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ P @( k! M' x) L; @& {# T9 F "%d\n", ret);
! [. p+ k9 L* k) v7 L7 s) t#endif% f' a* A- n6 Q' T" t5 M
ret = platform_device_register(&da850_evm_tl_leds_device);
% L" e; X u ?. X7 \# y$ J if (ret)) k3 @. u! s6 s: @- F
pr_warning("Could not register som GPIO expander LEDS");8 l5 X+ |7 i+ n$ w* j5 }7 K% c
else2 ]! M% V, C: a0 D5 Q
printk(KERN_INFO "LED register sucessful!\n");
; X$ m/ E- |) g$ g& Q
6 d: z$ F7 T5 s return ret;
* K; ~3 a: v# J% |# j" G* e}
/ T$ l% l2 R2 {8 |5 L1 @* L" v# E: ?$ {0 p
static void __exit led_platform_exit(void)0 H( U$ l3 S6 T: }3 X, s& P: x
{
- T% B7 f8 @5 c7 y platform_device_unregister(&da850_evm_tl_leds_device);& [7 ?% Y" k A. t8 g8 h
/ Y6 c3 c+ p" C7 ~0 Z4 T
printk(KERN_INFO "LED unregister!\n");
+ G$ d: M& l4 v. Y/ N8 V, V}
0 i6 m/ a9 X. W, w2 \5 h1 z- M
/ |: }1 f$ a g: s9 rmodule_init(led_platform_init);
- {, {$ m5 i3 v9 X% ^module_exit(led_platform_exit);6 \2 ?# K: n( q: c
% I7 _0 D) O# k, XMODULE_DESCRIPTION("Led platform driver");$ C3 q' |* P9 r/ Q2 E/ \( U3 N) Q O9 p
MODULE_AUTHOR("Tronlong");' e; v4 c7 J# M3 K5 S+ G4 \
MODULE_LICENSE("GPL");7 ]1 n( E8 Q, t+ g. I4 J V- V
9 |+ {+ d. V& P2 W |
|