|
求大神给下面的程序做注解,请稍详细些,谢谢。- Q/ y$ j8 A/ ?' W
#include <linux/init.h>
8 Y2 P/ ]5 s6 J+ D7 n& `1 y#include <linux/module.h>
; D& ]8 z7 X% J( a C9 m#include <linux/kernel.h>
- J: J/ ]% b$ K& p; e#include <linux/types.h>
; X) P+ D' f0 H& [1 m' c& k' A#include <linux/gpio.h>
m& U: N: d) X8 r#include <linux/leds.h>
' K/ S" r6 }7 E) ^; K; Z. N( [#include <linux/platform_device.h>
. |: Y( C6 R: ?5 A1 g: W2 Q& l _6 }: X9 m* i, v+ _. H6 ^
#include <asm/mach-types.h>3 G: A+ D U" x3 @5 s- G5 ^
#include <asm/mach/arch.h>: P5 R( v) z F9 E1 ` f
#include <mach/da8xx.h> j/ b1 z! w8 |. J2 G) w6 N
#include <mach/mux.h>7 u5 O8 z% Y2 b4 M# F/ U* _
. C: Y0 s+ l4 E- q: A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 P! X0 @3 p2 j- s6 L0 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 Y" ~0 Y) t) \" S( k2 d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 c& Y9 A2 a! k) a" A* }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, c, K2 n) @% L- K' t/ `: y: M3 S2 i2 s R! Z( y
/* assign the tl som board LED-GPIOs*/
( b1 q8 G0 Q$ i: I8 A- d3 ^+ Ustatic const short da850_evm_tl_user_led_pins[] = {
! {9 }% w8 T; u' z+ W /* These pins are definition at <mach/mux.h> file */# s) _# _& ~7 }7 m7 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: N& ^2 H2 F0 b1 I9 k- H2 F -1+ _( n9 z% |2 N7 q
};
) F+ a! k8 |0 K" ^, x/ G
! i5 N/ e$ r( s3 R; nstatic struct gpio_led da850_evm_tl_leds[] = {/ ^, V, b% |- c. M3 S
{
( E8 ~% p' f' l, @! J6 x .active_low = 0,$ \9 O1 O' p$ Q7 X4 P& h8 X
.gpio = DA850_USER_LED0,
; B" f% r# b# v I3 M- z .name = "user_led0",
6 D% H( i+ Q, l+ Q .default_trigger = "default-on",# n5 _* R# f( b5 x3 \
},( Y3 w5 B0 P& }7 |
{3 ^0 @ b4 W9 H3 Y
.active_low = 0,, g* X H3 q) S, o
.gpio = DA850_USER_LED1,$ ?# [# Q3 ]0 K* ?) n# I" L- @+ l
.name = "user_led1", y, S) @) c. _8 R: G. o
.default_trigger = "default-on",
# e1 T# \5 z) d# h$ g. m },1 T4 ^8 q3 h+ n) a: n. \; {6 i) n
{
' f& |( h* O. ]1 j4 V% r7 a .active_low = 0,
; K/ k. y- l5 o+ T1 m: m .gpio = DA850_USER_LED2,1 I% i, H! a0 v4 w1 x; P
.name = "user_led2"," p& q: k" K3 O q# S
.default_trigger = "default-on",+ j# ^# B, m- y. J# w! |8 B1 j
},
' G- V: w; I3 T {$ i( ~0 e1 e6 l* A
.active_low = 0,; t( f" R6 R; h4 j% P
.gpio = DA850_USER_LED3,
8 g2 g1 B0 Y8 S .name = "user_led3",2 U: Y3 w. p6 I, F& a/ i
.default_trigger = "default-on",, w! Z8 v* b4 h+ w4 S4 U9 L
},
5 V# E5 X$ W5 Z2 ?2 K4 m& z};
& c4 k; i/ c$ e* x" s0 W f5 Q; _& J3 i5 E# D( q) w X0 m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 p' @$ G" U( D) f
.leds = da850_evm_tl_leds,
; |) I' g2 v4 P% ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 ?# ?# `# G6 g* p' O};
9 E0 q g. P$ e9 e& D
' h# O: D' i. e1 b1 J, }static void led_dev_release(struct device *dev)3 |% T. _+ T* Y& y
{
/ w! D; y8 F2 ~4 j6 ^# K( S- _};
, L7 K: S- y2 N0 F( U7 t" y4 ^ n V
static struct platform_device da850_evm_tl_leds_device = {2 G& s. a9 O/ h% v% B8 C: U
.name = "leds-gpio",
/ ~8 e4 E0 f! V$ I$ A- ` .id = 1, S3 Q; r9 f; j1 d
.dev = {
0 Z- d7 ` @; Q0 c4 U .platform_data = &da850_evm_tl_leds_pdata,
- p: f; P, }+ q7 T) p, M .release = led_dev_release,
6 Z6 L5 N) ^1 B9 B9 k }
( }* n _( t/ H5 k/ g; t1 ~};
7 n2 h, Z% C# `, N) s' R
' d9 A2 i; U. p; i' Xstatic int __init led_platform_init(void)
2 ]. e6 K* c6 G( W1 v5 S! I7 L{
( V- R$ D7 g% Y0 \$ Y* M8 x, P int ret;0 S. u1 Z$ u' [2 ^4 C
#if 0) {! z9 }$ J0 A5 K8 m) L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 U5 Y% _" t6 }* D* P
if (ret)
; L/ ~9 J* z2 M, O2 J9 g- t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ U" Z$ ]! }2 X, [; q0 `8 P
"%d\n", ret);3 Q) u& Y6 S) }
#endif; N. c, `% d& C, G& D6 c" R
ret = platform_device_register(&da850_evm_tl_leds_device);
5 S n- B6 J6 | if (ret)+ |! Z( r; F% p6 D. _6 z( z# y! m
pr_warning("Could not register som GPIO expander LEDS");
: ~% w, H2 Z) ^ else, f. m |/ S% k
printk(KERN_INFO "LED register sucessful!\n");9 f, H+ {5 l; o2 D. C) R
. x" D: K7 x- _ t1 V F! [
return ret;& U+ Y+ U J- J: t6 H
}
& |! u6 r$ A2 w& ?5 U) `/ _0 [/ p% ]8 j+ q9 y$ G# E9 H
static void __exit led_platform_exit(void)8 K4 Q) x) W5 u! @$ G
{! K6 w* E/ c$ S
platform_device_unregister(&da850_evm_tl_leds_device);
- i2 ^. x ?2 J7 q r
: D. ^* u9 q# Q( k printk(KERN_INFO "LED unregister!\n");
% v: \& [( ?( k8 N+ l2 @}$ V+ e7 Z" d9 H* b2 } a; }
9 z: |) @! U# p6 o; U, E* dmodule_init(led_platform_init);
; P9 _, n/ P- E6 k& zmodule_exit(led_platform_exit);
4 @ O( _1 I, ?7 n# Q* ]" N9 Q0 S( s j& x
MODULE_DESCRIPTION("Led platform driver");
2 f$ s1 \" n" u6 e, r, T" Q/ RMODULE_AUTHOR("Tronlong");
, l, p$ z H X4 b2 g+ tMODULE_LICENSE("GPL");* y8 u, ^! [- I& l* C
( s- N/ D9 {+ l6 c( k% b' U4 K |
|