|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 a1 L5 J: f0 K" @. s0 Z- E+ H#include <linux/init.h>, n8 O& e1 ^: ^( H4 L/ d
#include <linux/module.h>& p# {' i1 s o2 R0 m9 T
#include <linux/kernel.h>
, b2 Z: S. W/ Y! W; N. z( s#include <linux/types.h>
4 x1 H( ^- G8 [- c#include <linux/gpio.h>
5 v9 h$ y8 e, J! L4 b" V$ \' _#include <linux/leds.h>7 O! K: Q. ?8 c' [4 E
#include <linux/platform_device.h>. A8 } W8 l3 d7 p
' ^2 s: b Z3 ]% ~$ k4 D
#include <asm/mach-types.h>( Q3 z2 H7 K8 ^( {
#include <asm/mach/arch.h>7 `: H( D5 Q1 Y" z% q' ^
#include <mach/da8xx.h>
; y. W# u* Z$ s9 d8 T9 O" U; g#include <mach/mux.h>" g4 S- k% x3 w; A, Z4 F p8 l
4 h6 c7 O9 ?; D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 p; l! _# w1 ? y: D* F( v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' A+ h2 E! B( H0 w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 `/ F! v1 T( g. C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 J7 m. w2 T( D I
. e- P) b$ V5 q6 @0 M/* assign the tl som board LED-GPIOs*/
- C& v# I4 { U/ rstatic const short da850_evm_tl_user_led_pins[] = {
; M. k' {. D9 }' f3 T- C! o /* These pins are definition at <mach/mux.h> file */
; H7 S' h7 v8 G+ `- E' A2 X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 [6 {; {6 h P8 y; q
-1
" C" \/ |9 ?# y. @( q, I};
# ~" c0 S6 \. V
+ x6 B# i k5 f# L3 v/ cstatic struct gpio_led da850_evm_tl_leds[] = {
A! [. J6 s! ? {
& L m, w# N4 ? .active_low = 0,
3 ~. S/ o# ~0 w2 U& | .gpio = DA850_USER_LED0,
5 B9 m8 `, o/ g+ L' y$ K/ K- w4 G .name = "user_led0",4 r. S" c' ?) o, t: \! s) R3 B% D
.default_trigger = "default-on",
" s, F' c; C2 ?/ M+ L7 U7 [/ _# N8 w },$ N2 z4 g5 |& q8 a& o+ L: |1 S
{
. x4 c0 I* ~: ^1 ? .active_low = 0,
+ u$ W7 K) ]! @: g$ a+ v8 c .gpio = DA850_USER_LED1,5 W; }: @) E" g3 F( i: Y8 O4 M9 ]
.name = "user_led1",* n6 f/ m; j- b$ u) z/ r1 L
.default_trigger = "default-on",
# [$ A% V6 P1 {; H( q3 @ S },# N! e# V& J2 L! @* a: p( D$ x+ p. A
{7 }% I4 @" [" [+ H' V
.active_low = 0,' ]9 G( {! z" ?3 [3 g" C* F4 M
.gpio = DA850_USER_LED2,
. w1 ^2 @% f6 y& H8 l .name = "user_led2",1 |$ \7 K ^- t5 F- S3 f
.default_trigger = "default-on",
! G# C5 j9 R% q },4 {0 H; Z' _& H& ]/ m" V
{
% t% v1 v: n& Y: r* N4 C) `& E .active_low = 0,
. I- ^; i- M! t .gpio = DA850_USER_LED3,
# I0 Q% T9 F6 ?! L8 O+ D8 Q7 _. R .name = "user_led3"," \6 B! h, K$ t, {; L
.default_trigger = "default-on",
9 @3 E3 {2 b0 O; P/ _% W) H$ Q },
, f. V' I* m' o3 }7 q0 `; f8 z};! b0 X4 }$ l! a$ w) m% |, L
: c& n5 R6 E: }3 t+ q( Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: z8 e: X& E; Y .leds = da850_evm_tl_leds,4 E8 F+ S$ a' D
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ H( \: A2 e- [5 N# Q1 N8 y
};
. o# i( D+ u* Q/ B" M/ h0 R1 O0 C" }7 P9 h
static void led_dev_release(struct device *dev): M; A) J% [4 H' s2 l* @
{- h! W1 r5 D, q& C" o2 J
};
$ L, K2 Y; H8 L
! ^/ v" Y; O/ m7 Z8 v; istatic struct platform_device da850_evm_tl_leds_device = {# K1 }5 A9 X' b, f5 Q* o
.name = "leds-gpio",
9 T5 o7 h" {! Z7 Z: q8 B .id = 1,* v2 D& w/ V+ o( W
.dev = {2 A4 q# Z3 R7 b* h( Z, ~* t6 m
.platform_data = &da850_evm_tl_leds_pdata,
$ \/ a- A! n: J& y .release = led_dev_release,* U+ y0 D8 K; s' X' i3 q/ \
}
) J* v- h8 X& u6 q8 @9 J* C};( t1 t3 A$ r$ x% b7 d! @0 p
8 y4 v3 f+ |6 H& s2 {0 b8 t4 ~* F# y
static int __init led_platform_init(void)! b0 f0 w1 b' _
{
( a. A/ v# j' |5 b6 s int ret;8 r% H5 h) \9 r& C a0 g7 {
#if 0
, z; ^0 T( F$ G0 a1 m4 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 ?& g, l/ Z; c# M
if (ret)3 c, q" l3 o# f
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! _/ ]& L$ G" O% i7 S1 _8 b "%d\n", ret);
! t4 G5 `, B$ m, N& F# b#endif6 G9 I( o9 G% \9 c+ s( a
ret = platform_device_register(&da850_evm_tl_leds_device);
: A/ x0 ?- K* W- d( r if (ret)+ R& [8 Z) f4 G3 P9 [
pr_warning("Could not register som GPIO expander LEDS");6 R7 F5 e- m) m5 b% s! j. I
else7 X1 P$ w( B8 a+ ~& `2 i0 L
printk(KERN_INFO "LED register sucessful!\n");
# J5 }* y: m8 O+ x
8 d4 t0 d0 H1 j. Z% r4 f5 j( _ return ret;4 O/ O8 y# m3 y& Y' s
}
/ y1 R. a6 Y2 G! f, O* u, V/ g& X7 `7 M
% w3 R! K) j$ Z1 _" i: lstatic void __exit led_platform_exit(void)
( L% o6 T6 i0 E' ?0 l% P v{0 s# O( G, D( N% Q! a1 |
platform_device_unregister(&da850_evm_tl_leds_device);
% ^: ]! G/ y* A6 F8 J7 j
2 x0 h) X7 C" S1 G' S/ e6 V% B printk(KERN_INFO "LED unregister!\n");
. `. o2 H4 ?, Z I. ~* J. [! k4 ?8 _}# w: u- c9 e# T6 t+ ^+ m- D3 F
( p- P' m& g* o% c* D
module_init(led_platform_init);; l: W0 a/ B6 A5 ?9 T
module_exit(led_platform_exit);1 S. |; Q0 I- }+ s5 ]$ L
2 z6 R* }: ?8 E; g& KMODULE_DESCRIPTION("Led platform driver");
* K2 m- c* L/ ^4 A! \0 ]; O6 p. z7 RMODULE_AUTHOR("Tronlong");
c9 G1 c- H5 y ]# r; ^8 ?7 h2 R% @* mMODULE_LICENSE("GPL");
5 ]! F* b6 l! t f; k1 H6 A" B0 r
7 J: @, [% Y9 o$ \4 c |
|