|
求大神给下面的程序做注解,请稍详细些,谢谢。
& o( y) T0 s V' y5 I#include <linux/init.h>
2 D6 h2 k" S4 S#include <linux/module.h>, ^1 |5 B8 M" y$ s% J( Q* W
#include <linux/kernel.h>" T6 z2 p5 H0 L7 j2 t
#include <linux/types.h>
3 f9 S0 i. a, J S/ o#include <linux/gpio.h>$ p: z* C4 c) G x `- p$ d* R
#include <linux/leds.h>
8 A6 e; E3 ~) P, c! K#include <linux/platform_device.h>
3 g! G S1 y0 t
, [! q4 p) u, z8 a3 d. b* ^: a#include <asm/mach-types.h>
( t9 `% O. E8 G4 O& d#include <asm/mach/arch.h>0 x- C: X2 n0 k* H+ p) r7 a) N P( A
#include <mach/da8xx.h>1 ?+ ~7 {* }) w5 x7 x
#include <mach/mux.h>8 i3 G% U; e8 e1 }& K
0 ?7 O8 X" Z, ]( m3 I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) j) Y$ _4 Q$ _# n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 g, M# v) B+ N! @6 Y+ F5 T6 n5 f: I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* x5 h. X) X7 t; k; }: m+ K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, j& e; B2 C* j) U9 ?
& W& l2 I0 ~% `' i4 r2 ^! F" H/* assign the tl som board LED-GPIOs*/
6 |+ i+ t; M' _static const short da850_evm_tl_user_led_pins[] = {
2 i) l* i4 n: j( D+ t0 P0 d /* These pins are definition at <mach/mux.h> file */
4 u" ?6 M3 a r5 O' f6 Y0 ~! K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 l9 Y4 A' B7 [1 l/ b -1' j8 j5 ]( V) Q
};
0 m/ R) i' x- U- x0 f
( F" G1 ~- W* W3 ~( v: n% ^static struct gpio_led da850_evm_tl_leds[] = {
# Z2 @8 r2 d k3 Y {
, }6 k% N5 S, M9 A1 z: r- ^ .active_low = 0, x h! `4 T7 Y, X) q9 V
.gpio = DA850_USER_LED0,( c c2 b* l- D& g
.name = "user_led0",
( S5 w$ e# c. `" q .default_trigger = "default-on",8 `! n. T7 H! n# Z( y9 e
},
( v' h; h, f6 A% `( K {$ G$ B0 B S" O, H! M
.active_low = 0,3 X/ r+ g( K- \7 p! L5 H/ P
.gpio = DA850_USER_LED1,& i8 l p, B0 p4 a" k$ Y7 [* {+ C
.name = "user_led1",3 P6 E4 ?7 ]2 m+ H- U" R( r
.default_trigger = "default-on",
! E+ G$ @$ h" C2 y; @+ b6 l7 ^, B9 p },+ e& U/ y E% }
{6 W$ H# X7 g, J3 G; ?6 c
.active_low = 0,
* b$ U$ l$ O! H7 B# p% i$ U% k .gpio = DA850_USER_LED2,
% W2 a! z1 k3 D1 B' } .name = "user_led2",
5 q& c$ o+ `: x8 n8 m .default_trigger = "default-on",$ o J: M, U9 D# F
}, n% B, x: o$ o5 K: \# H8 F
{7 J @& t3 R* s$ W V
.active_low = 0,
l6 ~: O3 k( n, Y! x .gpio = DA850_USER_LED3,- o2 W4 ^2 i! a: {5 K6 @
.name = "user_led3",
2 O; F; j( _, u6 ]" z8 S1 [* V .default_trigger = "default-on",
0 E2 o0 T( ?* _0 w r) p' y& s },4 x9 ~( a4 `; U! C
};* r% ]9 h! [4 a. v7 q
1 b. b0 F0 m# g. _. x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 ?! `, ], s# y _, u
.leds = da850_evm_tl_leds,) z! C/ d5 |4 ]* C G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: H2 i( T; O- V$ r% s5 e
};, ?' Q# Z3 h2 F6 e/ w
' c; o/ i! g& A* N
static void led_dev_release(struct device *dev)
, y- N6 R1 h B" A- [* y) K* k{
; V) g; _4 e% e; ~, ? ^! f P};
" a% \3 ?8 \, y6 Z$ i+ u4 @
. Y7 Q( o4 L# J5 `' J6 mstatic struct platform_device da850_evm_tl_leds_device = {! b2 I* [0 H9 e h
.name = "leds-gpio",
1 S- L+ l7 ]% U6 o$ b6 y5 N. j! ^4 d .id = 1,- o5 `7 I2 Z, H4 ]1 ]+ g& V
.dev = {
; S. B# H$ q' e3 C, ] D .platform_data = &da850_evm_tl_leds_pdata,
, j U- M) t: X) [ .release = led_dev_release,
/ n; F9 r5 s; q' j- N" \ }3 t" i& R7 A3 G$ |$ P9 k# d
};
0 M" ]4 z, T( \! U4 W& F6 t. C8 n1 B7 C) x5 w5 y* U5 d
static int __init led_platform_init(void)( _; _! @2 n, N- u3 ^! o l& @1 H' f
{
/ K* T! g6 W/ k( |5 m int ret;( E5 k* T. Q2 H5 |: u
#if 0 Y! ^; j3 S+ I! t* o" w5 R9 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- a" o; y7 R* @7 v2 ~& A/ l! a- C
if (ret)* _5 j4 T3 Z+ u" Z7 [0 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 t7 E y: s# V* a" i
"%d\n", ret);' U C3 @! M/ D5 P% W
#endif& a% E7 k$ X& ]3 O, d9 b
ret = platform_device_register(&da850_evm_tl_leds_device);3 K: l. S( F; u( I0 c( d- s
if (ret)
# s. z8 f: v# N! l% e# s/ m pr_warning("Could not register som GPIO expander LEDS");# \1 }% R& l% d! E. V2 Y; Q2 u- W
else; H# c3 b# g+ Z
printk(KERN_INFO "LED register sucessful!\n");
' E+ y+ F' f6 {; `% O* D( ?% j" p5 ?
return ret;
p, A. ]7 R& X}
" d0 G0 I7 v8 {: V' H
" e% H8 `! E5 f+ Sstatic void __exit led_platform_exit(void)
# l1 \& x1 @5 q$ ^& p9 ~{# |, N& b% P9 p7 o1 q0 E+ l9 V
platform_device_unregister(&da850_evm_tl_leds_device);* @% S+ V; ]& t( W
5 k; Q1 I6 p# w$ C. K printk(KERN_INFO "LED unregister!\n");' o3 c/ }& Y- F
}
! t4 v5 v$ ]( S' z! K- l
1 j: y. L1 m- r" e$ e) Mmodule_init(led_platform_init);% F, U5 y! j, I
module_exit(led_platform_exit);
& _) h) X. V5 q5 Z* G$ S5 K* d% F# U) j
MODULE_DESCRIPTION("Led platform driver");6 s; h" @! t; _& E- C0 ~
MODULE_AUTHOR("Tronlong");, M3 x$ [4 ]9 i0 D" L
MODULE_LICENSE("GPL");
y) ^- V& C& u9 c5 J$ P- q- X' [2 F$ N/ q5 o- w K
|
|