|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 K0 ~( F3 l K5 K3 `#include <linux/init.h>+ I' b6 D V: I
#include <linux/module.h>
# s h, D6 x' m; H8 D/ |#include <linux/kernel.h>
5 j6 H1 N8 f: t% ?#include <linux/types.h>
- m9 {6 [* b" R1 J#include <linux/gpio.h>
9 F: [: W: I! K7 \$ w9 t. C- j#include <linux/leds.h>% K/ p! @, r7 ?" X2 @
#include <linux/platform_device.h>
# j3 s$ b' ~) T
% O/ x7 W4 J4 ^: P5 j#include <asm/mach-types.h>/ ?8 ?9 U, I2 Z6 I) y
#include <asm/mach/arch.h>7 y* s8 f# a: `7 d
#include <mach/da8xx.h>" W/ ?' d E" f5 G. Y
#include <mach/mux.h>
, S! L4 V3 T/ n$ @
. X+ D6 I0 _9 l6 H; }& _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) E% ~$ @8 f1 v: y) }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, d2 ~9 T$ W4 S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. D" R d) l; @% D% c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- M% X3 J$ n! v+ x! a6 p0 ?* X
3 t% D+ d) `- m2 `1 h/* assign the tl som board LED-GPIOs*/
$ [, l5 k# m: @/ Lstatic const short da850_evm_tl_user_led_pins[] = {
5 X) M$ p/ i6 M' W$ d+ K /* These pins are definition at <mach/mux.h> file */7 Y4 h3 \5 ?! M0 u1 b8 H; F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 z+ ]4 O, Y; R5 Q -1' i ?' R7 w, x$ ?8 u( t: n% H
};" j. @9 s# I) F4 P0 K: v8 J
; }* ]. ]* n }1 f X* l! o
static struct gpio_led da850_evm_tl_leds[] = {
2 d/ o0 r- U8 v, f3 T6 l9 e# L {* F+ v9 ]7 w V3 A# ]
.active_low = 0,1 a' q7 \$ O: D- T! M" h+ Q
.gpio = DA850_USER_LED0,
! u8 K( P! { N .name = "user_led0",
1 ? Y# E9 v1 s4 c; t) m' W+ i* m .default_trigger = "default-on",+ e3 {4 a$ ]- P. a# Y, ~/ {/ @
}," m0 b6 d4 i c3 V2 _7 F
{
& F# |5 u# ]0 G% N, c .active_low = 0,6 S V* X6 [: t% d
.gpio = DA850_USER_LED1,
$ }7 t& u% r9 q$ a& }( `2 u) s7 T) O .name = "user_led1",
7 C# }2 c" P* j8 y4 p7 X3 D .default_trigger = "default-on",
; o9 @7 ~) ^9 x },
" ?5 [+ d ?! X4 ]/ a4 d {
$ _( s! `6 A5 W3 ~ .active_low = 0,* ` Z1 b# F/ n6 {5 n6 h) j' J
.gpio = DA850_USER_LED2,4 R& a5 r5 M$ |. p8 Q6 C
.name = "user_led2",
; ^* M) g: ] f. g' |5 o .default_trigger = "default-on",
' K! f+ U" C" A$ ~# i },
5 V+ \3 ~. w# W {* h4 |; J3 e* F5 V2 t
.active_low = 0,
$ J% e- n* D, @1 D4 X .gpio = DA850_USER_LED3,
t+ c. G$ w& p, T .name = "user_led3",
3 R( I7 {2 Z3 R/ F: f .default_trigger = "default-on",
# V* v" G8 D$ p$ [! A },
; }: m3 x& |3 C8 Z3 W};
H+ |. P1 o$ ~& r/ E! `$ v9 L
3 o2 @! u, T9 H; o# {% t% Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& r$ b7 u: p: i4 K- d* U
.leds = da850_evm_tl_leds, l8 X, {$ w5 H2 h% q- ] r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* w, D; z0 V& P: g};. b; [9 y# ^ w' g3 y
0 c2 W* v4 `2 U6 V' d
static void led_dev_release(struct device *dev)" {# {/ r* m# e
{+ ^2 o8 v) q( S9 |) \. D X
};8 W2 g2 x( x4 `" F- O, [, Q
0 E$ _. Z' i" h9 R6 p
static struct platform_device da850_evm_tl_leds_device = {
# b" r% e9 O9 t .name = "leds-gpio",
! p9 F7 K/ t6 ?1 l( l( W# C .id = 1,# _2 @; J" J" Z- S3 y: X1 G
.dev = {2 ~4 j/ H: R" ^5 a6 r+ y
.platform_data = &da850_evm_tl_leds_pdata,& \5 ^3 o, c" B, T1 _: m: L; V, M
.release = led_dev_release,
{) _! M$ P8 X* M! B }
; W' u3 L0 L f2 y% R}; h( A1 ^" z) W7 ?( g& ^
3 j: k: K2 f, c; A" O* H0 a7 Dstatic int __init led_platform_init(void)) D8 A2 {( j, Q
{
1 P$ y" m) c9 i) h" O int ret;. U- J7 j/ Q/ @* j
#if 0; P: P8 }2 f9 B7 f3 D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* [! Y$ A+ g7 a' L1 \, W if (ret)7 P4 L0 V3 n R) R; V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 E# T2 m! [' u: ?/ O5 k
"%d\n", ret);7 t9 \7 C- c. v( ]; L
#endif
! V+ D$ s6 s! a% @2 Y ret = platform_device_register(&da850_evm_tl_leds_device);2 C( o1 K4 _' _% i5 _/ S% y
if (ret)6 x2 `( z% P; c* R
pr_warning("Could not register som GPIO expander LEDS");+ g8 c7 v: H2 l C- C# H
else
3 y* o# |+ y' d printk(KERN_INFO "LED register sucessful!\n"); _* \; N4 P9 a
- m0 N. J; Y3 Y; R. _$ ]
return ret;0 j6 l. Q1 X' h' i' R" S! {
}1 C! J1 `1 w: x2 \0 z3 [) S4 e
3 G# N2 T) ~) P/ i/ u0 p9 Ustatic void __exit led_platform_exit(void)
, o z: J" J+ X{
- h, ~' L. k% m# s ]: J7 [5 p) H platform_device_unregister(&da850_evm_tl_leds_device);
% E j3 F8 b* ~( q* p: O- C
a1 X+ V7 _% g; r/ N; W' H printk(KERN_INFO "LED unregister!\n");" W1 @) P+ r2 O% w- `
}
S5 c% N4 I* M0 Z; o5 G R9 a! M# a8 _( N8 c
module_init(led_platform_init);. r! s8 H2 S4 v6 |& j
module_exit(led_platform_exit);7 o/ X6 n! ?9 F9 A6 l" P
( J: J, I$ }2 k% [, |% @# l8 h
MODULE_DESCRIPTION("Led platform driver");
& ^9 S& ^% w8 iMODULE_AUTHOR("Tronlong");
: f" W9 b& H- A% T; nMODULE_LICENSE("GPL");
0 L. E l0 g" b4 m& J' q7 Y7 \
/ B: s# d3 x4 v/ n" M6 u |
|