|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 Z1 X/ B7 k# o" u, A" L' W
#include <linux/init.h>, N: ^5 ~( y6 ^3 a3 r) ?$ ]4 @
#include <linux/module.h>
8 d2 l3 ]" Q+ @2 R; B# ?, ?#include <linux/kernel.h>2 q' ~0 ` |/ O7 ^9 V8 Q2 T
#include <linux/types.h>
/ x2 J$ b' o0 L7 e: z( C3 t2 E#include <linux/gpio.h>
9 P* W, s* k0 f9 I# x#include <linux/leds.h>
# ~6 Y( ?! A8 j9 K; N [ L#include <linux/platform_device.h>
: F; U4 |, h" V, j! M* F2 L6 z2 v( u/ P! l4 [( k
#include <asm/mach-types.h>, A# I2 _$ {. x/ {
#include <asm/mach/arch.h>
6 e% O# ~$ b9 B" Z( \3 I#include <mach/da8xx.h>& H' Z+ ?: z+ j/ j
#include <mach/mux.h>( U( D$ a- F7 W5 t1 p
: m* O& m8 O- s: \5 H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ w* p5 o2 ]" x' [! f7 Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! x3 @7 c! @+ I/ x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& J8 j% H) U. L+ S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ h v+ i/ F' n4 F
9 P& t3 c3 Q! E; {" N5 P
/* assign the tl som board LED-GPIOs*/$ G9 v% `+ Z" g3 w2 e8 O0 H, R
static const short da850_evm_tl_user_led_pins[] = {
{* m2 X7 }& `1 r! o /* These pins are definition at <mach/mux.h> file */
! C `' S2 w6 D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 Z; p. h, ^7 }) A) s
-11 O0 d% z" J) k7 r
};. F3 ]( a& G4 e H+ X% f
# ?4 M+ h' p' ~( C5 L( g5 Vstatic struct gpio_led da850_evm_tl_leds[] = {/ m$ w3 ?* ^' p) Y t
{
: ]8 P6 B7 u5 W+ b: g8 g. K .active_low = 0,5 ~5 o3 U% J! L% i1 ^! Q K5 a
.gpio = DA850_USER_LED0,6 ]3 Z$ k8 b9 \: t
.name = "user_led0",# b' M- R$ O5 j# C% i f
.default_trigger = "default-on",6 O: h1 e, p8 B; i0 c
},8 K4 W F! r' S' B. ^+ }. l# e2 y
{% L6 [) q0 r7 S2 ^& u7 \; Y0 V, Q
.active_low = 0,
; B/ n4 ]/ t3 c4 o/ h% r .gpio = DA850_USER_LED1,
$ |$ w& h P( A5 o/ t .name = "user_led1",& w# `8 I& N& H, x* l( i' s$ W
.default_trigger = "default-on",
* ^3 Z( Q6 a6 s! L* b/ D! j },
9 p3 Y' T% S6 C {
/ l/ T' s6 P& ?' B .active_low = 0,; j1 R8 I* W/ E# r) ]' M
.gpio = DA850_USER_LED2,
; H9 v( z( o" o1 { .name = "user_led2",
$ b0 w: F; H. _# M9 J .default_trigger = "default-on",
4 D, Z" G( C% T! g0 l/ N },% x- p5 C$ W1 R
{: G! q+ c% C0 Y7 L
.active_low = 0,2 f- u1 I$ h# }% ^7 \
.gpio = DA850_USER_LED3,6 O# m; v1 {3 O% G1 c4 b8 a
.name = "user_led3",
. {* [ K$ f( u: ]8 D1 v0 O& Y$ s .default_trigger = "default-on",
" h6 t V/ L. k% M) X: D9 o) u, q4 z; K },) f/ m2 |# O9 o; b
};- E+ k" T6 z# `% E# q: L+ Z
8 Q, D7 ~/ U/ M6 p8 _- E& i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- v+ ^/ p; B# f8 ] j
.leds = da850_evm_tl_leds,
$ O/ N. N) N; z" a: d- { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ G1 Y7 N3 h* W9 Z h+ e
};
! Q% C# x) s; J l
* ]# r2 b/ }8 x( h: s$ V4 ^static void led_dev_release(struct device *dev)
4 ^: U3 x0 R6 m' m{8 u( ]4 D2 J0 Q6 ?2 E: L
};
9 }. ~1 i/ U' S: b1 d; l. V, S9 ~$ n$ X: U0 i( r7 Z, Q
static struct platform_device da850_evm_tl_leds_device = {
5 j. i# w/ S# @ f7 z' H$ Z .name = "leds-gpio",3 C9 Q4 d2 T/ B" K
.id = 1,
; ]# n8 T+ J3 y9 N0 q- P! g+ J9 m .dev = {
9 d/ b# l! W( K .platform_data = &da850_evm_tl_leds_pdata," J$ t% c9 C8 R: m( v$ j2 c y$ K
.release = led_dev_release,
: s, M4 ^; d: n! F# n }" ] i2 D Z- h0 T, e$ n
};
2 F E. a8 H Y4 K. \1 \; t$ I
. M/ V8 X' r3 Astatic int __init led_platform_init(void)) Z6 S- u' |# S. b
{
! c, \& g% X3 ]3 k6 Y6 P int ret;0 @* Q+ M3 G" U/ ]9 N6 O
#if 05 w6 h8 c" c7 H% n/ G) b$ ]2 d0 v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' p/ v$ J- D% o; g; o2 w2 x if (ret)0 C$ [) z q4 k7 H7 E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 t8 z( I% |# Y# B/ K# U0 P: {
"%d\n", ret);4 y* m8 |" f4 b6 }4 ~2 \4 \- u y
#endif
" d- Z9 i& i. [; c; q ret = platform_device_register(&da850_evm_tl_leds_device);
! @5 |" C4 \& I; A! Q if (ret)
+ @: b, ?1 y! ? | pr_warning("Could not register som GPIO expander LEDS");& F E S0 x$ S, N
else9 n$ v6 m( r* K0 F$ u2 U
printk(KERN_INFO "LED register sucessful!\n");
" n; O3 a2 E1 b; k! }2 [0 ] N6 L0 w8 }3 v5 M3 b& S' Q
return ret;
+ u1 `5 I$ |6 t3 Z o- N}0 U/ U, E# }- B6 x1 h# O
- ~# U% _0 N0 i
static void __exit led_platform_exit(void)* }7 h1 m# b t% E
{
, }0 R, _' `* A& z6 @% L6 X. B platform_device_unregister(&da850_evm_tl_leds_device);# ~1 K. o' ]4 y: F( G
% r- g6 L/ p$ m' _3 w( I$ m2 p printk(KERN_INFO "LED unregister!\n");- l" ~7 o5 q9 I1 e+ k' U e" r: |
}
# }: k0 }8 {! Q
- f7 m; Y5 E: g: g/ H0 k% Gmodule_init(led_platform_init);
0 ^6 H* h" V) Bmodule_exit(led_platform_exit);
& l: G/ a0 L, B/ ~: `& a4 Y
9 t: J% h2 G& r( r2 g3 t0 K9 cMODULE_DESCRIPTION("Led platform driver");. {( k$ [* @) U$ t, C0 `
MODULE_AUTHOR("Tronlong");+ Z* a% u" i" V$ F/ a7 w! ]& j
MODULE_LICENSE("GPL");
$ u9 B5 }, b% g9 z* {6 \' k) V0 H, a
|
|