|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 z9 w& f$ S- s, T6 n3 k) x#include <linux/init.h>0 {% |4 J+ N1 O; o# C/ ~
#include <linux/module.h>" V& h% B% z5 q
#include <linux/kernel.h>
# O( ^) ?8 I. |8 g- p) h. f#include <linux/types.h>( A# h$ i- G/ J
#include <linux/gpio.h>
! e" x L" Z2 B3 d" l" h5 m( z#include <linux/leds.h>: \3 W6 L6 _- J1 @; e; N; H: i
#include <linux/platform_device.h>; R) ?# L7 f* d: k, t& h- g, }- \
) N1 Y# l( P/ w4 W1 n1 |
#include <asm/mach-types.h>
/ d# Y! J4 `: J#include <asm/mach/arch.h>
% [ \0 O) k9 D0 J4 ?& Y2 L#include <mach/da8xx.h>
/ s( c* n/ v$ ]9 w1 w) ?#include <mach/mux.h>
- `! g1 L; P/ x5 Y0 Z: Q9 K5 d. S$ X3 C$ L0 l( R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, z$ D2 p, l+ q5 `$ ?" v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# m% r" h* |8 l, S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: H' p& D7 p: Y1 Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ ~. D( Z% L, y' y; F4 p/ h
2 }' l5 [4 F0 ^# z5 g4 @/* assign the tl som board LED-GPIOs*/
* M% ^! I1 H& Vstatic const short da850_evm_tl_user_led_pins[] = {& y" U: T) Y+ P9 t( }
/* These pins are definition at <mach/mux.h> file */
0 n( k1 X0 m- w% Y1 X. a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 u4 h/ u6 H% [, q' `: W6 B
-1 T; `5 {4 M: S, [, E; w2 G7 D
}; j' g& q5 x3 V6 Y& A$ R# \# m
- t: |' a6 e' Y; A
static struct gpio_led da850_evm_tl_leds[] = {
! a- R* g* s3 W {
$ D: s! Q5 A; D .active_low = 0,* l, W1 ~/ c: t* P
.gpio = DA850_USER_LED0,
, R0 [( v$ x" ^( ?' j9 @4 d .name = "user_led0",8 x0 E3 x2 C5 }! N" Q' a
.default_trigger = "default-on",1 W1 y! [' H `( E X+ z
},2 _+ U/ Y! v9 q% N4 q. [1 W1 J
{# X: |8 }0 J4 X* S# d- X) G
.active_low = 0,$ m5 O6 R" R' V) W: g+ H& Z
.gpio = DA850_USER_LED1," }2 U* r" f! r9 z
.name = "user_led1",+ [3 e2 q* k. m6 v+ k: [- k
.default_trigger = "default-on",6 w4 x7 s" u0 L: f; L3 Y' d" M
},
3 U3 L7 D& e; \% |* f& G {! F) X- e* o) J7 ]5 v
.active_low = 0,; M) u b. E7 \- O6 O" i6 D
.gpio = DA850_USER_LED2,3 k7 W2 d) l6 g0 y3 h5 ^ [
.name = "user_led2",
* R0 w$ y1 E+ w+ w# R .default_trigger = "default-on",
: K( f4 V# H1 x# H. s },
. i6 \9 R( P7 o! g2 B8 ` {1 A6 Q$ P2 J' d2 z! y; L8 y
.active_low = 0,
. v! b7 p8 t6 X+ l .gpio = DA850_USER_LED3,* t0 p7 s6 U1 }- T+ h
.name = "user_led3", g* M; V) P& \7 m& e8 {; D
.default_trigger = "default-on",, e, Q N1 J( C
},
$ q" Z5 d, `- s5 i9 |};$ }9 E( _; N/ e4 M+ L v
" n7 u* \" S2 D7 d* Q. D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; G" J9 |' @2 }% A .leds = da850_evm_tl_leds,
; H+ ^5 H6 z% Y- { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: W6 h! A" j% P3 E9 Q
};
" g! e8 m4 o$ [0 D/ g( P1 R6 a- g" ]) e6 s' e% T" d
static void led_dev_release(struct device *dev)
8 l. ~" w& _, |; ~{
1 c$ y' G/ \9 K) P \};! [. x% a$ ^9 M r' P' D) x4 n% h
) G( S' x/ W5 p9 S" \ Z8 q/ \% |' P
static struct platform_device da850_evm_tl_leds_device = {: r2 S. F. H+ n, @
.name = "leds-gpio", |' c" r/ G$ L6 A
.id = 1,
: P- X( f" v' A .dev = {
6 K& l2 m, C8 ]+ @3 \2 V .platform_data = &da850_evm_tl_leds_pdata,; E1 p2 f1 d0 T
.release = led_dev_release, U8 s0 X& K2 f/ m% }$ r; s
}
) N0 x- z; V2 l: p};( h- U( @2 k! w) m! q0 S6 q K% h; D
9 j* P) X6 v2 z1 `3 B# r0 B7 }2 Nstatic int __init led_platform_init(void)
* y9 u5 k1 b" w! ?! l6 D. r8 T" _/ W{5 @- ]+ V; M8 V; n' |: Q7 A" w
int ret;
9 K8 f2 [4 P( }$ [9 M- K' o#if 0
7 P/ E, ]( V1 x$ A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& l Z. S, R6 v% }' y" M2 N if (ret)
" G5 H. G# \% q8 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: d+ ~7 V% G2 V* b+ ?8 G "%d\n", ret);
; u6 W! i( b5 T+ L#endif
8 F: x& G0 C! Z. [- J+ i' A ret = platform_device_register(&da850_evm_tl_leds_device);" D, d7 v1 c3 M, n
if (ret)3 G( x4 x, l* O
pr_warning("Could not register som GPIO expander LEDS");- @8 {9 y, z C# W' v6 Y) @
else9 H- Q0 l& G; o s
printk(KERN_INFO "LED register sucessful!\n");& D4 X/ Q0 M- T# u" f, U
% S' y. p9 b$ k1 ~! j0 b return ret;9 K, I( ], j; q) L' Z' f" ^# d( {
}
6 n% S* L! [. E- k5 x& k; p: Q! ^1 f3 n9 ^ _
static void __exit led_platform_exit(void)
) p6 E S: I1 l3 U* ^" e3 R{
q% {9 U! G# o; H, y platform_device_unregister(&da850_evm_tl_leds_device);8 W) x% F5 N) K4 o& s
# j2 S% P5 ?2 J8 s4 N2 ^ w printk(KERN_INFO "LED unregister!\n");& |, j D6 i. s
}
. y3 P! g% D& T$ C9 Y) Q# \( i
% l) I6 @/ A5 a' L* xmodule_init(led_platform_init);& A% u8 m# g7 @. K
module_exit(led_platform_exit);
, q- H2 Y! A, L) C% e* E
, l" Y F& U0 S _MODULE_DESCRIPTION("Led platform driver");
. y2 Z. Z9 X* h; t6 L9 {+ z! nMODULE_AUTHOR("Tronlong");
, g" C2 C8 F1 [7 T* e% |- tMODULE_LICENSE("GPL");0 Q/ @) v" T8 p
6 W: ^! X1 y" P' t0 d! q5 Z
|
|