|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
u2 q. g% }& y/ S6 l$ D; w7 y#include <linux/init.h>
1 M# X+ ]' u! S9 z/ W0 m# h _: |/ x#include <linux/module.h>
: J+ T! b9 @+ B8 M# r" t; v#include <linux/kernel.h>
4 G; c8 i7 B" M& }$ j0 y+ a#include <linux/types.h>
% K ]- ]6 J. w* u0 C+ x- C5 q#include <linux/gpio.h>4 w. \0 t( ]% ^2 X* Q- K2 w
#include <linux/leds.h>
& o: q( K- g2 p# ^; _#include <linux/platform_device.h>
* L+ Q) _. v$ z7 C1 O5 z' _; u: S0 @9 J2 R0 Y+ F1 I
#include <asm/mach-types.h>& V ^9 e" j% R
#include <asm/mach/arch.h>0 t1 U- X5 S. K
#include <mach/da8xx.h>
, w5 u$ Y( ?2 V# e5 L2 y#include <mach/mux.h>
: V: [/ C# `7 @2 x' n' |; u |6 f7 _& a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) {: ?" j( v& N- j! ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! d4 f. }: b7 w& u$ M+ C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& @) g5 \+ e7 Z( b" ^/ S8 k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 j! ]5 Y9 e/ |
3 k8 P6 [" o9 F" \& X
/* assign the tl som board LED-GPIOs*/0 k" {9 N C) \4 O/ y+ k
static const short da850_evm_tl_user_led_pins[] = {8 Z4 W9 b7 M8 F# n+ F
/* These pins are definition at <mach/mux.h> file */
' ^8 T, g/ o: \/ ?% V D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( Q- d# Y' i, P' V3 e9 p
-1
- i Z m# W! {$ C3 s; T, a};
' m3 d8 S! F# _. L1 G3 @6 \/ B; `0 k
$ O' _+ W: E, K! E" M1 r8 K6 t$ s6 istatic struct gpio_led da850_evm_tl_leds[] = {% t; o/ W" g e% E) g
{- r8 [( h! K! k' D# ?, I
.active_low = 0,; Z6 I) i4 `* G a3 {0 n2 A
.gpio = DA850_USER_LED0,# h1 l1 w9 Z+ ?' m) f) T
.name = "user_led0",) @- K* n' D$ y% F: g
.default_trigger = "default-on",
) Q( A. i/ {9 X% [, L) d' p },0 j1 k! r7 f: C# _3 M$ V) P4 m
{
) \! x4 i2 Q% L% @0 M .active_low = 0,
9 u$ j; B. Q: ?. L: b, ? .gpio = DA850_USER_LED1,
) C4 P* Z" n( C$ H/ J .name = "user_led1",
2 R- W' m* J' {7 h# f+ r1 `$ S! @ .default_trigger = "default-on",
& g5 N/ U' V; N9 p% z9 n0 p* a" N: ] },
) r `2 [3 ^" v8 G: h2 _% | {4 K4 w, {6 A) ]. l1 u% c) b
.active_low = 0,
8 y3 n+ @3 A" O" E7 {6 G: V .gpio = DA850_USER_LED2,
- _' m& g; C' J; Q .name = "user_led2",
; M4 Q' S+ K( G% Z( B: d* W .default_trigger = "default-on",
9 N' a7 N. g" O& m },
2 @: f* M0 G& I7 D* G {
) {8 Z5 Y: O" V( H3 _ .active_low = 0,1 Y& i6 V& W& x+ e2 p& L
.gpio = DA850_USER_LED3,! g3 D+ i0 {' U( X7 X! h
.name = "user_led3",9 M3 s% H+ D7 }
.default_trigger = "default-on",+ @- o# Q* w9 |1 V1 f7 e
},% W" N9 @: e3 m c
};2 q! K6 n# k" z* h1 f2 P- r, C
# X; T1 G' E0 h! k+ Y cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' E. z% A6 _; l: l" u1 W" f0 }4 U
.leds = da850_evm_tl_leds,$ e' b2 A: U w( j6 J9 B1 G$ Z1 G/ s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" [' z; M R8 `};0 ~/ v4 }$ i0 e' C
. g n# |( E9 h: l3 ]
static void led_dev_release(struct device *dev)
) N/ N" {+ ~1 L{7 W/ V& J g- f; R9 ^7 E+ T
};4 y. s# |" R! B, [8 Y
) g5 g( G& P0 X6 |3 ]$ k- F
static struct platform_device da850_evm_tl_leds_device = {
# s# Z( D, l. m1 P$ M( ?& Z% H$ J .name = "leds-gpio",
* E7 B- b5 t- K% _/ j4 C .id = 1,
+ C4 D1 I# i- b' @ .dev = {! {: F: R4 L+ m; r
.platform_data = &da850_evm_tl_leds_pdata,' {5 H/ b; i& i4 U
.release = led_dev_release,
: O" g' E0 F h) j3 |9 Y }( ^$ e! c9 k4 ^9 z6 L: k r" L+ |
};! n( @0 u2 \4 Q6 v2 [
5 J) [% ]+ ~* s, e2 B, ?9 L7 z* istatic int __init led_platform_init(void)
# ~/ z, U, M) ^. n2 R{
6 o! `6 H& T% ]( T8 V! J int ret;
2 u! Y6 f& l3 f: |( v#if 0
- L M( I1 s! ^' M4 A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: K/ e: |6 H0 Y- `5 j( ?! o B if (ret)
% A( q5 H7 X% B6 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. \+ j: ], [& L+ R "%d\n", ret);3 q1 E% {5 m3 |* I
#endif2 D! Q8 ]2 R Z3 E7 D `- ~
ret = platform_device_register(&da850_evm_tl_leds_device);- m8 t/ C$ L7 k& ^1 W
if (ret)8 d0 _4 W' [2 S% m6 J) T- C
pr_warning("Could not register som GPIO expander LEDS");' R4 F8 V* y; P& n( b5 S
else
3 ~: ~- u. @5 r printk(KERN_INFO "LED register sucessful!\n");
& u9 Y. X3 |) ]2 u- v' P
: T" \- f: f7 n: c6 | return ret;
$ ]. m+ z( d" w' Q0 J}9 }+ j- u; m; Y% O- `0 @/ S
5 F3 p" E4 \4 E/ c- x
static void __exit led_platform_exit(void)
0 ^5 R3 o" P% ?% f{
0 Q2 s* m0 [; Y* q4 @" [- y4 h o* b# b platform_device_unregister(&da850_evm_tl_leds_device);
! a1 a; }% P/ g& R7 o+ v
4 h4 p. {* p; q# g' z; E4 V printk(KERN_INFO "LED unregister!\n");
/ t' H- O, y/ J3 l}$ \- F7 s2 v# q: Z. u
& e& L- e6 F+ L. W
module_init(led_platform_init);2 y" S2 t, \( Z! l% I$ I+ ~3 z$ c5 ~! W+ \
module_exit(led_platform_exit);% o3 I6 D' ?9 c3 m! u1 [% l! `
, U. W1 l+ j! \6 A# }6 p* g8 b
MODULE_DESCRIPTION("Led platform driver");+ e- L. t9 ^2 ~0 K
MODULE_AUTHOR("Tronlong");7 e/ u9 H+ I9 M) u1 F* n; M7 H
MODULE_LICENSE("GPL");
, ]6 O' R$ M3 t0 V( \7 b+ f! P8 n) B# O
|
|