|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" o" Z' v: b. ^; ]#include <linux/init.h>
- d6 F8 U( h+ s* O* a: C; ~! p#include <linux/module.h>$ r2 v, ~6 U/ ]; p
#include <linux/kernel.h>
6 F! b( E1 T" b#include <linux/types.h>
! H6 m* K0 I7 p#include <linux/gpio.h>, N1 {) J7 C }5 k
#include <linux/leds.h>& g; z" L8 Q7 I! X
#include <linux/platform_device.h>8 o/ F% e; T# L* u- z k3 o
6 ]6 |, Y2 U- D) O$ R! _4 B8 h* |#include <asm/mach-types.h>
7 v2 ~& t5 `( F+ X% [9 _; a3 g1 T* C#include <asm/mach/arch.h>5 r% ^% P2 A4 o
#include <mach/da8xx.h>% S5 i9 [0 Y2 j, a3 f
#include <mach/mux.h>
9 F. t# I7 U8 Y+ O! o' E) H1 U! p5 _: h7 }( _& Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
}2 T7 {1 s) }( ~$ {* O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), U0 H2 @. V4 V" k2 M6 A0 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 r2 z8 J+ }- |9 c9 z1 E8 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 x9 s" I- M" h ]* t
/ N1 N: N" h8 I5 A A% C
/* assign the tl som board LED-GPIOs*/
; X: C0 R7 [7 ~' ^static const short da850_evm_tl_user_led_pins[] = {
# E7 B. n' |' r8 |9 N7 B /* These pins are definition at <mach/mux.h> file */& h9 j' t/ N4 g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 q) f& C! b8 X% u% V9 d3 ^; ~+ }0 ~
-1" P' r; }; N+ ~$ l! w2 X% }- _8 W9 w
};. X2 J0 l: {8 x1 i
% D8 a0 ~3 ~7 g4 G( v# B+ dstatic struct gpio_led da850_evm_tl_leds[] = {
2 V! g) @# J' ]2 X V% D1 k {
0 X u3 y$ }% ~: Y! {* ~ .active_low = 0,; b; q' E" s3 z9 t
.gpio = DA850_USER_LED0,! s: |5 _& q9 |1 ^6 p# l
.name = "user_led0",0 G, c: h3 F2 F d
.default_trigger = "default-on",% c( T, `( k, h% p: X
},8 [" m: c7 d+ i
{
# W. [& E0 l# v c- I8 b- S7 P .active_low = 0,1 o [2 ]4 D; O/ E! f" H) r
.gpio = DA850_USER_LED1,
& B. p8 ^; Y) }" B- X3 T .name = "user_led1",# F- n4 g7 J! {
.default_trigger = "default-on",( ~. t+ c+ g' l7 Z# ~; W! D
},
) h: d+ K5 C6 W4 n- z- i {
& I0 |# f# |5 `( ` .active_low = 0,2 Y* d2 R( q, u
.gpio = DA850_USER_LED2,
9 n/ @5 ~" E7 y. x) C" s .name = "user_led2",
, v) |8 d2 U0 m7 A/ R .default_trigger = "default-on",+ M# ^ i" P- Q+ c$ b# I
},
! l/ k# \) L, R# u) ^. s* l# b {
! ~& d$ |" b+ B1 J- o3 } o- x .active_low = 0,
- {: U6 `. q, W) }' Z .gpio = DA850_USER_LED3,
( i d% N! l7 l) f" U& O" \ .name = "user_led3",
3 X+ g+ @1 [$ s1 U .default_trigger = "default-on",2 T- I; E/ r g- Z" P j0 E0 e
},! ]3 ~( A: ^- q3 W5 D$ {6 G5 }
};. j0 h4 I* Y. q8 K& r
4 D( [* \1 B5 C, n4 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 a& N \ k& ?2 V5 T$ L9 s
.leds = da850_evm_tl_leds,
: A" A4 z5 M& R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 ^8 p8 A. I& [' O6 t# }7 D4 Y5 ]# Q
};
/ u( B0 N7 N v$ n, \2 Y2 C7 [# l* r7 K7 c6 `
static void led_dev_release(struct device *dev)% r1 Z2 n5 x1 L' S! S
{
# [# Q% Z% I, ]; n3 h0 {};$ @4 {, K: v8 S4 ?- V% ~
0 x& h3 e% `% e! B% m) H. ~static struct platform_device da850_evm_tl_leds_device = {9 \0 r3 _. j( B3 J( w( C9 m8 ?8 D! o7 D$ Z
.name = "leds-gpio",
1 F0 G% W+ Z6 z W2 g; N3 s2 g$ U .id = 1,8 u9 `- k( [3 R6 x; A0 d
.dev = {
. F! v8 }1 F' Y- _5 `2 R! d .platform_data = &da850_evm_tl_leds_pdata,1 e$ O9 k5 P/ H0 K' S% K5 h
.release = led_dev_release,2 ~! A6 x2 e, A) @4 {6 _( E2 Z" j- x" M
}
5 e4 Q, ?: m/ ^" \" ~6 {0 i};
1 K) M b; F" I3 K( m+ T, B$ A+ w: z% ]3 [7 Y! j( M2 h
static int __init led_platform_init(void)
" S" b. M0 e/ k) @" J% g{* m! w: E1 X5 j1 h; h
int ret;
$ L; E* \$ f, ~- z: c T4 X* @0 X W#if 0
) Y+ ~1 k. o2 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' S2 U, b' e, G( c
if (ret)
! B5 K8 t, Q0 _8 |' h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" c6 }, \% f8 ^7 ~
"%d\n", ret);
0 L% _' G3 `% O$ A#endif
w: u7 A# R1 Y$ F ret = platform_device_register(&da850_evm_tl_leds_device);- i) q' P) r+ M
if (ret)
/ ?3 o5 S: n; E4 w3 I" Q pr_warning("Could not register som GPIO expander LEDS");) _' W5 }, o! R
else6 w; x; ^3 p5 |- p8 P
printk(KERN_INFO "LED register sucessful!\n");/ P; W2 g% }/ t6 Q8 x8 u
( N; l2 d2 a) o, }3 \! @' U
return ret;
$ b4 Y1 G0 L( q% W/ F}
' ]% z9 Y5 l. x L$ L
! A F7 @# u7 `+ } cstatic void __exit led_platform_exit(void)
$ o$ \, {' Q4 o% \$ L{
" P5 {6 a6 \: k N: F% `6 H9 _ platform_device_unregister(&da850_evm_tl_leds_device);
# l( B9 l1 |" u8 M: m q1 U2 H3 g0 n5 Z+ j7 O
printk(KERN_INFO "LED unregister!\n");+ h& A) P }7 B6 H* v/ \
}
+ X4 `+ J% }4 w1 P9 n$ ^/ ~$ D
" w" ^" u7 Q$ c& k: [module_init(led_platform_init);
# j$ p* o/ I! Z, nmodule_exit(led_platform_exit);" ?8 J) G: \" e+ c+ @
) `& g& z5 m( B8 s; P' ]$ s: S1 iMODULE_DESCRIPTION("Led platform driver");
* v: a, B. [& s" O. YMODULE_AUTHOR("Tronlong");
$ \, ~ u# U4 ?5 g, a x) Y/ tMODULE_LICENSE("GPL");, F0 b) B! h6 n
+ F7 b% ~$ Z4 R
|
|