|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# z3 |0 _9 f }( k' S o2 u' B
#include <linux/init.h>' V' Q- @% L8 v+ |) _& B7 U
#include <linux/module.h>
8 u% _1 ]# h) \2 i5 ]$ c( s# q#include <linux/kernel.h>
0 P2 y- J" }7 b# E! x9 s#include <linux/types.h>% `3 W# J( O3 m5 w( ]3 p0 N) }
#include <linux/gpio.h>
1 ~+ y; _ ~. D2 V#include <linux/leds.h>1 W- h/ l. c! T% b" H1 g f
#include <linux/platform_device.h>4 a# L% ~" \, E. s0 X% Y5 Z; N0 W8 o
4 R) ~" d! P1 x" K4 P9 r. c#include <asm/mach-types.h>/ }; e7 Z+ _* c) S, g" a
#include <asm/mach/arch.h>: `; O6 m3 B6 b* g& E. {$ L0 H9 `6 r
#include <mach/da8xx.h>, u1 m5 F8 I8 P/ a
#include <mach/mux.h>4 C' `% |& Z5 w F
. w% o: ]) n- H: ~$ T; @9 e1 h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 ?3 u: V- T' S% t% z) |) l. w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( I' x7 E1 ~" G7 _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ g+ F8 ]* r" G. _: @/ T8 U c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ Z( T3 z( A1 v! {3 }8 o( s0 X! Y# Q; m9 l7 J
/* assign the tl som board LED-GPIOs*/8 J- z5 x; u1 ? G+ `
static const short da850_evm_tl_user_led_pins[] = {3 J& b( X- l/ R5 s1 y
/* These pins are definition at <mach/mux.h> file */
; a$ x. A/ h* P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 O8 Y9 q5 U* e -1
; |/ s" \/ s( y. e: t* P! p};
+ f6 u6 i2 q/ d* Q% ]
' \( y: U4 W5 K5 r& V2 ?1 Ystatic struct gpio_led da850_evm_tl_leds[] = {: R7 ] V9 n9 Q* @4 U
{
+ k6 U5 l9 m, Y" c- R' { .active_low = 0,+ N' p6 C; M1 B0 g
.gpio = DA850_USER_LED0,# J ?4 O: Z* n$ t. L- i
.name = "user_led0", U9 s: L# e& j1 k/ H$ G
.default_trigger = "default-on",- C, q7 y5 J' g6 J# R
},; y* g- ~* e9 \1 T6 S1 _# d' w
{
% K% T* f g! ?* ~: ^5 W' Y: I .active_low = 0,
! j; N- a, U3 ?8 E3 p, a/ n8 ] .gpio = DA850_USER_LED1,
V$ H* F+ D9 H) ~# Q. M .name = "user_led1"," u2 w/ G' Z/ B" }0 s! v
.default_trigger = "default-on",* x% [4 t9 E5 w3 S, |0 r- @( } z
},1 J! h: T6 W' G% c7 {( h7 \
{
9 Q" A X! g% H: l5 ^% p2 m .active_low = 0,, p( [# J7 }+ a5 I( b& E1 n4 d6 m
.gpio = DA850_USER_LED2,
; W# u6 c% b" W* E6 z .name = "user_led2",/ k% }" K8 \ {
.default_trigger = "default-on",$ x# P) _- U9 K: e9 b+ B
}," k; b N q2 T
{& |: J! C5 q! v9 v* o
.active_low = 0,
$ s$ @7 I' D; L5 m .gpio = DA850_USER_LED3,
5 q6 \9 k/ C* B8 o B5 W .name = "user_led3",
% l5 [3 n' N3 W0 I .default_trigger = "default-on",
6 _8 |- H A2 c },
# x8 Y% T# r7 r8 S/ [. x/ I/ a};5 g. q& c$ z' C# a
: q: c. C4 x1 _! J. {- _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& F1 u9 [0 i# A .leds = da850_evm_tl_leds,; q# T; _: F' d2 c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 k: S: }9 ^- K, P( |; E" V0 o( }8 ~$ E};
. f: C9 h0 ^/ {1 X6 V
* j3 |" l2 b! u& r4 G4 jstatic void led_dev_release(struct device *dev)
) O# R' Z1 {2 Q+ Q# |% E{
6 G z! G) Y$ z @9 [2 H};" v' [ U+ I* o2 Z3 c& ~2 [
+ D- v- p* G# } J/ W) R8 [
static struct platform_device da850_evm_tl_leds_device = {: v- P0 L: R+ C+ l! J; O) f. L
.name = "leds-gpio",
0 _) t8 f/ m/ g' c .id = 1,, ]4 }% b7 F3 m2 r& N3 d
.dev = {1 y5 L) g& j9 N
.platform_data = &da850_evm_tl_leds_pdata,
; \ O' k+ s( v& h5 ^ .release = led_dev_release,$ | g/ R1 M/ V9 R( q* {; {) r/ K
}
" k# Y: K/ R/ P8 ~' w1 u2 C1 f# g" c( l};) T, Z$ K9 G1 b4 n+ t `" i
3 o- x. |. ^/ T- p( C( H5 T$ C" i
static int __init led_platform_init(void)1 S9 J+ Y" @. m& R% I- o5 x6 j. m
{" [3 n; y B- k: c9 ~3 U3 ~
int ret;. t! j3 o3 k. Z: z2 W5 Z; C( B! i
#if 06 _9 h2 n/ Q+ S9 f" Y7 P! c$ ]; Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 g1 C2 h3 {8 u0 e5 Y0 z( r! e if (ret)
" T1 o. b' }- O+ ^5 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ T P8 K% ~0 P9 S; K "%d\n", ret);
3 M2 b% ~: \6 _7 j f% u#endif3 f- f7 ~* q! p8 f$ z
ret = platform_device_register(&da850_evm_tl_leds_device);$ h/ |# M7 P) Q. N% t
if (ret)2 L+ T/ U) R7 P( b/ m0 D- }
pr_warning("Could not register som GPIO expander LEDS");
+ t- I* [( `4 ^) W$ K# H# D8 n else
7 F# `6 |. u- k, `- I' H4 @ printk(KERN_INFO "LED register sucessful!\n");
0 w& e( X; _( [% `" R7 w3 _: J( G+ z. w5 n& r8 H2 o6 n
return ret;; d0 o$ A* p9 s! N0 D& ?
}
1 q* O0 [% J) I% H- s6 O* ^' M8 G' Q+ P: w; _7 w
static void __exit led_platform_exit(void)
3 i |$ J2 j) M) ?2 C9 I{+ ~3 |) v. I7 t
platform_device_unregister(&da850_evm_tl_leds_device);/ z2 @' \$ _. z) t: f i
. W e0 w4 D/ U
printk(KERN_INFO "LED unregister!\n");
9 s) g/ a4 @7 R1 ^}
- o- Q6 h, s8 p% t" @7 E% M& b: o
9 y, U! \3 I% |5 C( ]" M3 kmodule_init(led_platform_init);7 q' t: l; ]3 C8 I1 P3 V- D4 ]7 y
module_exit(led_platform_exit);( k& y( h5 `0 \& \( @
" K1 i/ c! Y! D+ i C
MODULE_DESCRIPTION("Led platform driver");
5 j4 O. `% ?) @1 V1 J$ AMODULE_AUTHOR("Tronlong");5 M/ G# Z" o: j8 c
MODULE_LICENSE("GPL");) `9 L/ B; j6 |& D
+ t+ S3 G$ @8 p0 K) j( y, v
|
|