|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 z! n1 A) I; a& \
#include <linux/init.h>
0 L) {4 G( q/ L: H- _. R#include <linux/module.h>
/ ^) W3 w3 `1 ^: L5 \) M; p' W#include <linux/kernel.h>
a3 a" A3 N% ~* e) M5 c9 X) [3 C" D3 w#include <linux/types.h>7 A4 L' w8 Y4 ]* ~/ s8 o
#include <linux/gpio.h>
' ~4 J3 ^4 J3 _% p9 M$ X#include <linux/leds.h>
$ r6 s/ Q1 G4 R#include <linux/platform_device.h>7 p: z1 ^: Z+ L& R7 s. X. S
' [4 W2 J1 f; g/ U/ o% J% G* N
#include <asm/mach-types.h>( t, J1 t8 x5 L2 j" [" [
#include <asm/mach/arch.h>1 o* _/ Y# N4 V" X/ B1 n. a) y. M( y
#include <mach/da8xx.h>
' x$ h% D$ k- x9 B#include <mach/mux.h>! t' S0 Y1 p9 g9 q' ^% m
9 B7 }) h4 H6 |- H# x1 K5 I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 @. |8 s2 \& p) o; ]! o8 i, Y( y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ I0 ?0 T; N4 D4 g; c3 {- {* y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 N1 U: X8 q! v4 ~% j1 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' l5 S5 d' q0 H8 A! d# }0 q/ x
3 v5 M& l8 X% }, y# C, g6 o9 f/* assign the tl som board LED-GPIOs*/0 p1 j" u' ~) r( P
static const short da850_evm_tl_user_led_pins[] = {
4 D9 g1 \) @+ r7 a$ \4 r /* These pins are definition at <mach/mux.h> file */
% r3 x. f3 S3 H, B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! v1 A: l, e4 b9 M: R$ ? -1
6 c' c4 J$ V: h, S6 h9 v};! X. W m) b! i+ e: r. G5 Z I
$ Q, u% _( C# K8 ]$ i: D h) x
static struct gpio_led da850_evm_tl_leds[] = {& o d [/ I( D5 ]
{
# c" ?- {$ u/ u: R+ o3 B .active_low = 0,
5 _0 y( v; n; d3 E$ T P# ~0 j+ G3 S .gpio = DA850_USER_LED0,
) ?. w) R% u/ s .name = "user_led0",! l& ~1 y j5 g
.default_trigger = "default-on",
( t# s [, O1 G3 T. X9 q },
: `0 A0 }; l' z6 N( f+ V) g) b& I {
2 [ p, i! g0 i, {! C .active_low = 0,
# m9 t4 B2 c) }+ M5 W1 W .gpio = DA850_USER_LED1,
6 ]5 \5 ? D0 e' B$ H .name = "user_led1",6 o1 P$ x. V% ]
.default_trigger = "default-on",
( U) Q# s+ M9 Y8 |) v },7 Y+ J# g' s* t8 {; z
{
; {3 t1 b& u- q @! f .active_low = 0,4 Q3 X, ?$ Y! f5 O
.gpio = DA850_USER_LED2," S! p; b5 Z# H0 V9 ~! U
.name = "user_led2",
2 R) S; ^5 a4 _7 r a' z .default_trigger = "default-on",
% o& c- v* A# r3 [5 P/ ] },
, R5 y1 t4 Q2 f: V3 L3 ^& P {
- n8 ~4 t7 N" W+ {/ @# x .active_low = 0,
$ b) }0 _1 J, q) C .gpio = DA850_USER_LED3,
* I# ~; {9 \5 K& n! k9 v .name = "user_led3",1 X7 Y. o1 N3 B' e+ ]! o
.default_trigger = "default-on",7 H' Z8 f6 C; ?4 O3 h# L( _
},
1 P- u [' o1 H" i, }4 D};
% x% d& o0 F0 g' D# j; ]5 W7 t; ~, _/ v+ y! {; I* ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& {) p; n0 k% n5 u
.leds = da850_evm_tl_leds,2 ~* o" z- y% l) K: |% i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ q' p. |( U" f};# X8 Z2 E! x. l2 ^) n) d1 a
& r$ D# l' Z1 E- X: y9 h- z
static void led_dev_release(struct device *dev); ]2 S* l3 L$ a2 J
{
* D, z( f8 L, j X- W, e# g9 n7 n};
6 w3 ]' b5 n. Z- U3 n* j9 K+ v. Y2 v/ t
. `: e- W* a" R, _3 I. i' I" Hstatic struct platform_device da850_evm_tl_leds_device = {' v/ C6 N- v; @+ R( c3 o8 R8 v
.name = "leds-gpio",
4 u7 T: Z6 E1 K: g& ?- Q* m2 a .id = 1,$ Z5 j. p, z9 A8 E$ s
.dev = {! N& k3 C0 F/ R3 Z$ U3 \2 w* O$ ~
.platform_data = &da850_evm_tl_leds_pdata,1 j2 `5 V* y) L2 C
.release = led_dev_release,
+ d: b6 x" n" J( v }
' @/ R; i/ a. S5 j V};" V1 J3 i! N5 n
1 ` R9 Y- h' x f! g ystatic int __init led_platform_init(void)& v: U' ?$ ^9 R9 W' C
{# [( @9 B) S8 F8 o2 @0 T- }* F
int ret;
! t. G/ f. }3 {+ K! y#if 0( ^- M% G& I$ h+ J( I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- n: P+ D v+ Z7 i, ]' `& d! J if (ret), P! ?/ v/ Z# i4 P* g$ x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 h2 w3 S, u! d6 b2 @* C8 |
"%d\n", ret);
$ }* Q4 t! ?% f" D4 Y5 i5 {' _, u#endif
; v# H2 P6 N2 U9 @ z ret = platform_device_register(&da850_evm_tl_leds_device);% M. c& z& M6 Z" Q- d' t5 M
if (ret)
" f4 y3 _8 }8 A) @2 n9 b1 H pr_warning("Could not register som GPIO expander LEDS");. d% j$ d! z1 P% ^% ]/ `3 \
else* j: n& J7 H: q* k- b
printk(KERN_INFO "LED register sucessful!\n");3 k0 X% w- ~9 ^' |+ P: k1 U
; [( K+ z6 h( }% @: {, _! j return ret;: Z' @/ w A ]6 g4 R& X
}
( G7 F. e' e2 l- R/ G* e2 r/ q3 q4 c( F) {! F6 Z: S5 ]
static void __exit led_platform_exit(void). d+ s" k$ W) |' L8 h+ Z1 q
{
0 ]) |* t' ]( b! V platform_device_unregister(&da850_evm_tl_leds_device);
! N* x4 J( V. |4 Y/ p: O M) A' t; g! y
printk(KERN_INFO "LED unregister!\n");. ^3 h3 g, x8 s
}0 l2 o8 i3 U$ w5 Z
# q6 g, |+ L- I% z5 x) H( `0 [module_init(led_platform_init);
; w5 u* ]5 X8 f/ ?module_exit(led_platform_exit);
( n6 C! M8 C* @9 E4 x3 j2 Z0 c, \4 K8 }9 X
MODULE_DESCRIPTION("Led platform driver");) j% q$ D2 p6 Z2 U1 z! L/ }. e; N
MODULE_AUTHOR("Tronlong");
9 c( c% l# ?2 {( U% nMODULE_LICENSE("GPL");0 ?6 d) d( S4 h; i
# O. v j( ?0 w- @ _1 z( x |
|