|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 A8 b( y1 ?: a! F* Q
#include <linux/init.h>
% ?, }" w% S2 w, X#include <linux/module.h>5 a4 D( \) Z: I: G& a
#include <linux/kernel.h>
# W- U+ c) t6 H( S8 ]6 g8 `% Y8 I) ~#include <linux/types.h>
& h. @+ X8 k! s#include <linux/gpio.h>1 q+ D# i7 D% \0 G5 A- ?9 a
#include <linux/leds.h>
$ K! M4 y6 k* v% f4 H#include <linux/platform_device.h>8 k" X* \5 N. a8 A, R
* k6 W/ E% H- t) x. M6 h; |9 j#include <asm/mach-types.h>
' u1 `$ J) G5 R8 a+ x#include <asm/mach/arch.h>
7 A: O- z+ }8 ~$ T$ V$ @3 @#include <mach/da8xx.h>
' g) P# k7 w# D7 A#include <mach/mux.h>
5 w/ U6 ?* |! u2 r4 X, u
# J7 z! X& U9 E% M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& |: U/ i* C3 \* b9 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 r# t- Y% e% \0 c) g! o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% U1 l2 ]8 c) f6 E N* Y" ~+ D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). ]9 L7 Q+ V! z M% h% L+ F! F
0 B6 X, H/ S( _3 i4 J5 S
/* assign the tl som board LED-GPIOs*/: \( c0 t# w( s; l, q( e! p
static const short da850_evm_tl_user_led_pins[] = {
7 P7 y0 {& w6 [9 V /* These pins are definition at <mach/mux.h> file */
+ D6 c1 \) ^. L/ ^( Q& z1 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 [" I# ` u0 `; D! l/ t
-1 Q0 ^1 y! P/ R6 |! f0 F; _ M
};8 b+ v+ V z: A; ~1 {2 ]: [. U- ?9 j3 Q9 q
. v* B7 O1 l4 y
static struct gpio_led da850_evm_tl_leds[] = {
0 _0 l. A6 v0 u% X6 ^' v {- @2 z9 d4 x2 m, Y2 d! }$ i2 c+ J
.active_low = 0,
+ }- l& C1 t' o" m0 i+ Y .gpio = DA850_USER_LED0,7 r! `: L) s6 B: R' R: ^
.name = "user_led0",
% L( J" i/ E8 L- U! F" p- S/ m .default_trigger = "default-on",
) P/ l7 i/ O6 u7 J },
0 r' x, L% k; N! P" u: H+ h/ k) x5 q { E: ]3 J0 E6 H j! N% K
.active_low = 0,3 ^3 O& @9 Y! H" x
.gpio = DA850_USER_LED1,
% {& u" @4 ~# _' N- T4 e9 r; S# M .name = "user_led1",
! N; }: u( u6 n ` .default_trigger = "default-on",
5 w' w' Q7 x3 W D },7 Y' `# T9 S0 A8 k6 E
{, n$ }/ `4 \' ^( J! r2 q
.active_low = 0,4 }/ a# K) _4 n$ G
.gpio = DA850_USER_LED2,
7 }8 g* N. A5 z$ T2 ~& Y& q .name = "user_led2",) \' f* j; l! Z, Q' i
.default_trigger = "default-on",' T6 }4 }7 Y) K o: P- P
},) ~# ]5 w6 i) C: z, `
{
n8 R u* e" Q/ ]( j .active_low = 0,
, D, Q; U5 H$ C: ^" G. J+ W .gpio = DA850_USER_LED3,
- s& h9 [$ }" `: G- H5 {. @, v .name = "user_led3",4 u; O2 O" A. h% p: }# C: f
.default_trigger = "default-on",
) H4 P2 ?( [: v8 v1 j& ? },$ n; @7 L8 E; t. R+ a+ D
};
+ F# y8 J% q1 ~5 i* f: ^
2 K6 V' `" ~3 L& V1 m2 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' U: E, F8 [' e5 j
.leds = da850_evm_tl_leds,& D" |* ~$ i( _5 H: b6 T6 `7 J9 ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; ?( Z4 d. M- K+ G z" ]. y
};
, v( V' @$ s' e R( C/ R$ k. ~) X4 c% H' T9 ?
static void led_dev_release(struct device *dev)
- ]5 A& q4 R8 O& ?8 s8 [' f{
6 j0 N) `) p) | B};8 _: c Q* u, \6 k! _/ E
. m# W/ Y4 s9 G Fstatic struct platform_device da850_evm_tl_leds_device = {
, n5 \# r. \4 \) x; b) }* h .name = "leds-gpio",
1 y$ j0 p" E8 _! S( U: s" Z7 ~ .id = 1,6 `- L) ~. e4 G6 R) V1 z$ I
.dev = {
, i p$ X0 Q8 K' W. j0 r i; o .platform_data = &da850_evm_tl_leds_pdata,
: Y' {( |- L2 j0 I- s8 Q+ \! Z .release = led_dev_release,3 Y" E* K; R. E+ q" T) \
}
0 s1 p7 h: m0 W; b}; X" D L% [) k; a
6 k2 n" s& s* t5 z* zstatic int __init led_platform_init(void)
E: C' Q2 Q M{4 J/ B8 n+ t3 z& ]7 |/ d
int ret;1 J8 h( H5 N# E2 }* ^! T/ O, n
#if 0' z3 R( r* n$ U! D; P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 D6 Z* o9 L; U9 Q/ S if (ret)
' J) }1 g1 _7 `) O; h0 e, \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( @, l! V: m4 {3 D1 o, _( p, A "%d\n", ret);) E7 U' C) k8 [, W6 _
#endif+ V, k7 e# J0 m- ~$ h
ret = platform_device_register(&da850_evm_tl_leds_device);
- |7 Z0 K" Y4 ~9 E0 ? if (ret)4 T3 w* d. V% H I4 n
pr_warning("Could not register som GPIO expander LEDS");
+ H. o1 d G/ A! T else
% o, C1 g; C0 ]6 a3 c printk(KERN_INFO "LED register sucessful!\n");# ]5 U" }' N: ^ k# o$ h
+ s# ~- A. w2 E return ret;
2 d: G9 Y9 c5 R& T) O}! l5 i8 ^, _# e! C
$ I8 u% H( Z" N+ t! O
static void __exit led_platform_exit(void)7 c1 F$ _0 G9 P6 a/ D% T: R
{' ~. j& O) m0 S: G, k
platform_device_unregister(&da850_evm_tl_leds_device);2 A0 _! O; B; @
, n4 d6 F7 Y+ S0 _; f/ p printk(KERN_INFO "LED unregister!\n");
$ [# p% G: P1 @. t}
" G& |) ]6 m% v4 d: D' _# ]# Y1 n9 f; ~
module_init(led_platform_init);1 n9 g+ N, e* J' p
module_exit(led_platform_exit);
7 {1 F: i. E- R+ d. d- k7 s: X {& j, Y5 d6 R" J1 a8 L! `9 p" B
MODULE_DESCRIPTION("Led platform driver");
( T- {; N8 x% W# Z3 d% Q2 ^! |MODULE_AUTHOR("Tronlong");: I* o! G, ~; H8 |5 I( h0 z
MODULE_LICENSE("GPL");9 n0 a% p, i+ O3 o! r8 w9 P7 r
3 Y, u9 u; m; y
|
|