|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
p: X+ X2 j4 C% ]$ U* s#include <linux/init.h>/ k6 e5 N/ n4 j& H+ Y- K
#include <linux/module.h>
# V* S r. C7 f& M% t#include <linux/kernel.h>
* ]6 {& V1 A; n; L- ^( K#include <linux/types.h>
. T9 q/ Y5 c" X3 e, Q! q4 M- B#include <linux/gpio.h>
* E1 ?* z0 t/ ]#include <linux/leds.h>% d7 R8 [; s/ F0 W1 @
#include <linux/platform_device.h>% U- c4 u2 E! @7 T+ C8 T
* \8 N0 G+ m8 z* G3 ?" x3 k#include <asm/mach-types.h>
( v6 o+ n/ v( f7 i#include <asm/mach/arch.h>
0 c; l! K" h8 Z#include <mach/da8xx.h>
' F7 O9 M* X0 y& K3 p6 V#include <mach/mux.h>3 m# y. W9 U' ~) l; H
9 h! e- b8 x! l: W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 m0 F4 Z# d' l' P, x0 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 r7 c! i3 j0 o% k. E* z2 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! e4 t8 Q6 K# b7 X) O, t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- I ~2 Y/ _6 G) d: Z* j
9 a A: W6 b) j6 _! e4 [8 H# E) z/* assign the tl som board LED-GPIOs*/: L7 Q. }* _. a9 [8 g9 @0 _9 _
static const short da850_evm_tl_user_led_pins[] = {
! W) `: x' D, Q& X/ M, C4 ], f0 ^ /* These pins are definition at <mach/mux.h> file */ n2 W& L' d9 h: P; l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: o0 l- n: m) \0 n -1) ?5 r% j; s+ l1 s1 [' M
};
4 |9 W7 p( t. e+ Q, B
/ u9 M9 A; Y5 Z2 L( xstatic struct gpio_led da850_evm_tl_leds[] = {! G+ C- P8 O6 V, M
{
! f' y( K* J0 \9 I .active_low = 0,/ R$ i% Y1 q3 ~7 x/ q( u7 a5 L
.gpio = DA850_USER_LED0,
' u5 Q! t# _, M; a5 M" L2 i- @ .name = "user_led0", u! I0 M9 v# u+ q7 Y1 M* `5 a# e
.default_trigger = "default-on",
5 i* e0 v9 C7 L },$ K- A) a+ }# F! N# K
{' [" n! G `* N" J4 k2 C4 M0 z
.active_low = 0, q6 w: J& [( a1 ^
.gpio = DA850_USER_LED1,. b- E2 |! Z7 V8 a
.name = "user_led1",: b5 W; G" N% B5 M3 M& e
.default_trigger = "default-on",
6 \0 V" ~, G& L' _2 [ },
2 R) G. l! j/ E7 a- E {
# E. ^1 u& j) x .active_low = 0,
0 o& s5 E$ c" G; X .gpio = DA850_USER_LED2,. B. i. W! }+ C9 a
.name = "user_led2",- W# ^' n/ ? ~
.default_trigger = "default-on",
4 e! h( K* S8 F0 n6 B9 l },# n6 W- S1 m* v: {% m9 Q/ W$ J
{
2 H# [% z" |2 D, N .active_low = 0,
/ e* [; S2 |4 \ q/ x/ H .gpio = DA850_USER_LED3,+ a! T! h2 T3 {0 M( k
.name = "user_led3",
' e, {. s8 r# D1 i8 u0 | .default_trigger = "default-on",
1 v3 ?( I9 d4 ]4 t( ]' ^' e },
; I* z _; r3 [6 }$ B3 y, n$ x" W( @};6 [! {7 i* E7 u9 W: r3 g$ |' e
' y# a& q: X! j9 q3 c9 } n2 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ I3 l0 a: \1 t; o2 W# M7 F: o' a- n
.leds = da850_evm_tl_leds,* @ {2 `8 [( F' n$ l0 V! m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% M* y& J$ A: M5 W7 p$ ^
};
, L% C, I$ K/ @3 R) v& O7 M( n2 c! F F3 Z9 S- O
static void led_dev_release(struct device *dev): b" h, W7 J! K& A- N+ s* u
{
) [) y+ ^) i- t+ M% V& y# g};. y$ Q4 q/ c2 \9 L5 P8 @8 w; {: D
5 S' E: [! n) _9 g) Z
static struct platform_device da850_evm_tl_leds_device = {& `2 [/ `: A+ c. A: ?: b* f
.name = "leds-gpio",
2 K0 h. M N0 @ .id = 1,+ l% q. Y/ `; {- d- j7 g. y
.dev = {* R9 \9 R4 Q- D9 c0 }+ s$ }
.platform_data = &da850_evm_tl_leds_pdata,3 |! o- ?1 d5 p4 @" g
.release = led_dev_release,. e& V% F" N( A9 R& _- b/ P
}& e# g1 t* w4 ?* c: l
};9 Y O1 _* C4 D8 e$ e8 u
( h& K5 t4 G6 X( Y
static int __init led_platform_init(void)8 \, ~( a& P# n! i" g5 b% n1 f' e4 E
{# l1 a$ S) f, V! `+ u
int ret;
/ u5 V! n; U% A( ?) c$ N#if 0
: y- e7 N. P( p3 R" c$ d8 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 v: S7 N' b/ @( a/ Y8 k. ? if (ret)
0 m s! N) v! ^; q+ f0 L6 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, N" c2 c1 t0 T: ?* E "%d\n", ret);% f7 r2 I: I- f9 e+ v( \, j
#endif
2 P5 E1 J( n, W: L ret = platform_device_register(&da850_evm_tl_leds_device);
! v' t5 L% o& P if (ret)
, L2 b2 B% [% E! r5 m9 K9 e pr_warning("Could not register som GPIO expander LEDS");
' ?: y2 o; R$ C7 A) h$ k& g+ y else. Q4 D1 g C) a% h& {( w
printk(KERN_INFO "LED register sucessful!\n");) ]0 F; t5 z9 i! u$ i) ]- h( w
- {- e- b* |+ a
return ret;
" R+ ? X7 p1 ~8 j: D; y3 L' [}* `0 C& x0 s t
5 |+ O, ~1 B9 G( k% u
static void __exit led_platform_exit(void)9 D$ u# n, k! e, _) Q
{
3 @4 k$ Q1 E9 B7 \ platform_device_unregister(&da850_evm_tl_leds_device);
$ J9 v/ n2 c ]& C: |+ R" H4 c; ]$ w
printk(KERN_INFO "LED unregister!\n");
' Y, a- ?1 F! ^1 W}" y9 n( O' |" `# P' ?6 X1 ~
7 I) D: X; U: h% _module_init(led_platform_init);# t. b n; ~, P6 o$ n" \
module_exit(led_platform_exit);+ O5 ?. y$ a9 r2 C8 D
4 a( g$ R7 ~* T# I$ k
MODULE_DESCRIPTION("Led platform driver");
) G& K8 ~6 E, rMODULE_AUTHOR("Tronlong");/ L g: E _. B e' P, J' p
MODULE_LICENSE("GPL");
% U/ p( b0 s2 m. l
+ D t/ M, c4 b {- \- U$ }) I7 r |
|