|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" J/ E" T0 Q4 h# D8 V& C' s
#include <linux/init.h>
) j: e g* N5 }7 y% I0 X#include <linux/module.h>8 z4 r* d* \' X L2 o! y, K
#include <linux/kernel.h>2 K4 y( e4 \2 B& ~0 a, c# ]
#include <linux/types.h>" A2 t9 q, t# J4 E+ S. J+ M2 K n
#include <linux/gpio.h>
/ o; t! R" v2 a$ Y4 T: \#include <linux/leds.h>! ]% P1 K% q6 Z
#include <linux/platform_device.h>" d7 A) y- ?* F+ b9 W7 B( g
9 v$ i2 l. ~7 d2 Q$ ~3 e3 k#include <asm/mach-types.h>
; [' L. Z7 `* x3 D N#include <asm/mach/arch.h>) n9 F9 W9 `$ ?% G, Y9 P' P
#include <mach/da8xx.h>: t* b1 C& V: n7 V" C# F
#include <mach/mux.h>. [# h# X+ {+ E3 a, N6 X0 d
& D* u5 m# ~+ g: y. }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b5 V- g: @' T, t5 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, [0 F- [( }8 T e#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ X" C2 S3 g" r' H$ E. G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 I1 Z9 }) J( m/ l" ? ^
2 W+ p& T: c) F/ g2 P! \% m" d/* assign the tl som board LED-GPIOs*/8 I3 m9 F" u/ f- ]
static const short da850_evm_tl_user_led_pins[] = {
K4 ^7 S0 S0 o7 X /* These pins are definition at <mach/mux.h> file */
: x/ ?- F+ o! @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 M, @7 c2 X% I; g( w& j3 k' |6 h -1+ G. K |7 J. h w. j4 W
};, f- ~ q8 m. b
: |4 d3 c( u, j5 z5 Rstatic struct gpio_led da850_evm_tl_leds[] = {" k# t+ s+ f2 X7 U6 O" _
{
% d4 ~7 L# h( _ .active_low = 0,
" _2 _0 X3 d2 ]$ u' l) [* s .gpio = DA850_USER_LED0,
8 J+ j( m8 V1 a D1 K+ `) t .name = "user_led0",/ [4 S1 m- J9 g
.default_trigger = "default-on",
! f2 I/ W/ e% ]/ X) y },3 L6 I P7 ~( W9 Z+ O# u
{) ^# l' T* E" k9 v& _9 i
.active_low = 0,# }' s5 j+ w& _) Y3 _( s6 Y- O
.gpio = DA850_USER_LED1,0 b: R4 |- V8 E; A- h9 T
.name = "user_led1",
& `% a8 H) m9 q5 W! O% z .default_trigger = "default-on",
) P0 p) N4 Y g. D/ n4 i },0 z" ^/ ]! ~# @9 ~/ z) J5 V3 L
{# S8 G/ C" E2 A# x
.active_low = 0,. v: u N+ |8 E' ~) s$ D5 y9 c
.gpio = DA850_USER_LED2,- v+ W: y; i4 x/ V) ^& ~6 e
.name = "user_led2",% m: T+ }6 f9 x- P
.default_trigger = "default-on",* d& i2 f( z) N. ]+ }% j8 Y
},/ n# K* G4 G: M# V N( P- u; Q" l7 l- ?
{
. h. p) h, P' A1 i) B; [" [ .active_low = 0,( _+ J% M+ e. p. D' n1 A. o
.gpio = DA850_USER_LED3,/ E$ _+ K6 I. v) P7 {& C
.name = "user_led3",0 t/ k. a5 s2 o; C3 Q% h! t, c
.default_trigger = "default-on",
) m ^0 x1 ^2 ~3 e },
: Q4 p8 _( L5 }9 p};
1 B8 p* t0 |" ~# g# g
5 R5 X a- D2 f+ x6 \. ~0 wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ m" ]/ l7 M: D
.leds = da850_evm_tl_leds,, m% K. i& K+ s+ M; L U3 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. _# c9 N1 S& K" [: m C, ]
};
. h" n- L8 f' A! O1 M- Q i" q; k0 L' V0 W3 [- w2 f' N
static void led_dev_release(struct device *dev)- m4 M" _/ y7 Q% g
{
( ^/ H/ w/ o- E; Y1 }};
# c* J @5 f5 F4 t0 A9 T4 E9 k8 n
& e6 ?. P4 W0 \5 ]static struct platform_device da850_evm_tl_leds_device = {1 \, [) M: Z: j1 U
.name = "leds-gpio",* ?: k. T# o N$ k1 n- m
.id = 1,/ T E% x. d3 E2 ^
.dev = {
! f) t! j7 ?8 v T2 d2 E y# M .platform_data = &da850_evm_tl_leds_pdata,: A1 h0 E1 v) b. r
.release = led_dev_release,8 n2 a5 X" {) ^" F4 X
}
5 t: s# ~4 b2 S. Y# l};+ s- s( T) P% B
2 Z+ F: ~) b& w) Gstatic int __init led_platform_init(void)
- [7 j/ \5 ]4 z$ A{* A" b) R4 N8 F$ f
int ret;+ h( K5 S) q: h+ D
#if 0) G6 d. w# [5 h) _( K! H: Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 ]: ~* H8 ^5 Q0 m$ E
if (ret)
6 Z% j1 ^/ T) T+ i! ~( u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( M. s) S! A7 X- p8 {
"%d\n", ret);* Q- P. L2 [; }( L* e4 |
#endif
# T0 t; U- {" r% j# c: B ret = platform_device_register(&da850_evm_tl_leds_device);5 \5 m$ ^9 a9 ^! `2 z; W
if (ret)
$ |, }; [; p* Q: G6 y pr_warning("Could not register som GPIO expander LEDS");5 S) w( L* S' p8 {
else2 ^! U$ Y) [9 [0 G( ` |
printk(KERN_INFO "LED register sucessful!\n");
( G; B0 J5 W4 A/ O$ i" y/ f
# k1 w( d& i5 f0 K return ret;
/ d9 y1 ^; \: G}
2 N. H! R: V; h/ m5 D( V4 w
5 w! Q$ _1 Z% Q* Fstatic void __exit led_platform_exit(void)$ ?8 Q% \0 Y; l d5 I
{
: O6 m7 _6 j" Y( x4 K platform_device_unregister(&da850_evm_tl_leds_device);2 e% S/ c6 J+ G
" x* H$ |- K. W" C/ m& J printk(KERN_INFO "LED unregister!\n");
$ B, X4 c7 q \8 U- d) |}
9 p3 J. w. L$ R7 d, v* F
0 K* x7 {6 j" H0 Zmodule_init(led_platform_init);! A) C5 b L6 t5 V% h ~7 k
module_exit(led_platform_exit);
0 _& c) f! N% @8 ]
# Y* C' R Z+ KMODULE_DESCRIPTION("Led platform driver");
1 h/ Z5 }, h1 fMODULE_AUTHOR("Tronlong");
; L- V" H: N' v1 o. B. {MODULE_LICENSE("GPL");9 P) ]9 z0 l# ~! e. f4 ?7 V8 V! I# E
# N+ v$ g3 N& F7 M0 n7 P9 s |
|