|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 B; b0 ]0 |7 n. I; d#include <linux/init.h>" @3 `' ~1 C5 W4 o3 ]) m( A
#include <linux/module.h>
" F' h% n x1 o# R7 k#include <linux/kernel.h>6 I: K5 L6 ~1 x3 u
#include <linux/types.h>; d4 l' D# ~7 b
#include <linux/gpio.h>/ C! D- d, l/ z
#include <linux/leds.h>
' c& W" a0 m! y, |6 z. r% d4 t#include <linux/platform_device.h>
0 b) |4 l7 c" G4 a: n( N0 G2 e, R4 _8 B
#include <asm/mach-types.h>
3 ~/ u3 c7 \ m2 c4 s; h* Q* f#include <asm/mach/arch.h>
6 z2 y# b8 C) ]# W#include <mach/da8xx.h>
& `* m5 J% ]! C @( t. `, s/ o#include <mach/mux.h>
* j- ]" ]0 T4 N) B* ~. W/ h G+ C+ f2 t8 u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ a' y' [" n; b3 V4 O- S' {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 ^, E, H" }. b* k% X' m5 O) w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# _# P7 K4 A: M/ d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* _ u% {# Z- g
+ U& o( _ V5 f8 X* E: p/ U2 ^) ]
/* assign the tl som board LED-GPIOs*/- s5 P2 R" R; B$ b' d
static const short da850_evm_tl_user_led_pins[] = {; S8 u7 {4 P' P( _- j, b
/* These pins are definition at <mach/mux.h> file */
6 D3 H! m' F+ p- k- C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& X8 ?$ o4 o5 O. F$ p& o! @# j* B, l5 t -12 ]/ y/ p8 [, C: s3 C( Z9 V
};
" a7 e1 m3 `3 c( Y4 `- X; g
+ Y& R$ B+ W; m5 Z2 @4 I4 Istatic struct gpio_led da850_evm_tl_leds[] = {9 }9 ]" V8 m }- g& Y2 n
{# M8 ~- w/ D- r3 m7 v4 q; H' g% ]
.active_low = 0,
% ~9 A9 T0 h$ \2 H! N5 @) i .gpio = DA850_USER_LED0,8 f. O+ w: w9 z" f2 ?/ ^
.name = "user_led0"," w( u, \2 e% v( `! ^( E6 T# {
.default_trigger = "default-on",4 N U/ O( |/ w0 u" @
},2 A+ A5 V% k( ~1 p; r2 G
{
/ b% ?# @" x4 Z7 C: u( `) S& M0 j .active_low = 0,
3 [1 V/ [% q- j, i, i; b# h! b .gpio = DA850_USER_LED1,
7 z* B- O9 ?- p$ E. i( g) M0 w9 N .name = "user_led1",0 `8 p1 {8 r, g, d& @( s( ]
.default_trigger = "default-on",
1 k, n* T! `* g" Y) R: d V },
6 V5 l1 K* S7 l s+ Z1 G/ Z {
9 E3 H$ e/ v# \ .active_low = 0,- u! W5 ~# L2 ]6 A( u1 Q
.gpio = DA850_USER_LED2,
: B: R ^6 v0 ~9 K .name = "user_led2"," M: C( M' P0 }- {2 Q# Y: E. o
.default_trigger = "default-on",: p& q) }7 T" u
},
& h! S- i5 V) `- f {3 R6 F9 c {& H" x0 P
.active_low = 0,- d( [' ?: {" D" ~: O
.gpio = DA850_USER_LED3,: [+ L, g' h7 X; p4 l6 P5 Z' [& V; `
.name = "user_led3",4 H( H5 x& h/ H7 u
.default_trigger = "default-on",9 [! |1 j6 m1 b: j9 d$ S( j
},
& v- M% f ^9 P! w};
9 ^7 H9 T9 X, B5 ^
5 r# b/ i e/ n k' j, _$ Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- k! `4 l2 o: r# C& {. ?* M
.leds = da850_evm_tl_leds,
3 s; W) ^% ^! g7 V5 M5 `& K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) o1 ?% e# b" f8 j3 y }
};7 L1 h# ~( t/ G4 T1 f: w+ ]
( h) X) N6 R' Rstatic void led_dev_release(struct device *dev) x1 V% o1 q2 B, M7 B8 c' b
{
. E# }4 K# `% h7 v};
2 w/ Y) c0 A: R+ @' s! G0 a7 N, U: _! @2 |+ E
static struct platform_device da850_evm_tl_leds_device = {$ N; S8 ^: R0 l, _3 {# O( B3 U1 i
.name = "leds-gpio",% B! j# a% M0 k% I N( k
.id = 1,
- A) W) V/ d2 E# r: _. h5 | .dev = {0 ]1 p. n/ N, R
.platform_data = &da850_evm_tl_leds_pdata,
- ^- w$ c6 G, {9 l .release = led_dev_release,
9 x$ n8 T! r/ j }
- T6 q4 f; F% ^3 e. p: y. J};
; L7 M6 {% A5 M
9 {; `9 {# u8 ^6 V& Jstatic int __init led_platform_init(void)
* V- ]& Y; w" H& ^1 p! b{, P( [* q% ?. k6 r' ]* a* a$ D
int ret;
! y M, x# E8 f) m#if 0
- G; h, l2 B) o. o$ H: T8 N# B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" d G; ]9 |8 r# c+ A
if (ret)5 m e. d. e6 j) I% N+ I8 x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 u. u: s' t" C: x/ x, B "%d\n", ret);
6 F9 \2 I# ^$ I& Y" N#endif$ j% q6 \; O/ D
ret = platform_device_register(&da850_evm_tl_leds_device);% C: w+ l6 x' ?
if (ret)
5 \: M9 T* T& \! I& n$ R pr_warning("Could not register som GPIO expander LEDS");
* G/ X1 h/ B! G) L& s$ {$ z; i else
* u+ `4 T0 k8 ] printk(KERN_INFO "LED register sucessful!\n");
$ v# T! b& Q2 R. ?1 ^! e7 a4 B+ F% R9 q! z8 \( y) ^, K& i
return ret;# ?; i1 X+ p, i5 Q7 a
}$ D( v2 h" U. r/ U% [) p2 m
5 T6 i0 @* S! A5 f2 ]& Z" A: r7 Mstatic void __exit led_platform_exit(void)
) W1 K! g6 L0 O6 o9 e6 D! O{: A/ H0 P: ^3 }" Z
platform_device_unregister(&da850_evm_tl_leds_device);
K9 v! U% H' y5 p$ ~7 b& S+ b# @; G2 d* x$ F: g
printk(KERN_INFO "LED unregister!\n");
7 ]5 A. {* F+ [}% y, ]& K6 J2 n
: w9 l! {) r) R: z$ f
module_init(led_platform_init);
- R- Q& y6 }# _1 \7 P9 [/ O6 `module_exit(led_platform_exit);
3 `( k5 h+ P) L: x" ~) N1 x0 m1 F$ h: s2 H8 `/ c
MODULE_DESCRIPTION("Led platform driver");; X1 x( M" T0 T6 s+ z
MODULE_AUTHOR("Tronlong");
1 b/ J: m2 y" ~9 j7 yMODULE_LICENSE("GPL");3 @: _8 A/ ~8 T3 E7 N" B7 N7 s
3 \. \5 O# W. \
|
|