|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* `8 Y/ t" Y5 g& M7 M, {
#include <linux/init.h>
. [0 E7 r. |! @: ^#include <linux/module.h>3 ?6 c% A. G: X# |
#include <linux/kernel.h>1 L9 _; c, u5 Q* [1 V; t9 P* G- d
#include <linux/types.h>
: @0 {1 i% J. W' f2 j0 I \#include <linux/gpio.h>$ S) g# H8 l# r0 V# |. ]
#include <linux/leds.h>/ R& g8 w9 r) X3 N
#include <linux/platform_device.h>1 c) s' a6 u8 a3 F0 y, o% s( m
0 D j6 X" [* p+ b F* j
#include <asm/mach-types.h>* Y: Z; b. A7 E% B: I4 r# n5 U
#include <asm/mach/arch.h>3 G/ R6 G: }( X6 P
#include <mach/da8xx.h>
, B- ~# t, f7 ^3 B3 h#include <mach/mux.h>
# C* w4 V! W @9 Z- V9 @
# _( Y; T5 U% d# c) Q) P5 D! k9 ]# Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& `0 P' q3 s- u5 N2 }9 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 J6 H- r# _4 _) X; n# O, Z, n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): k+ N' h5 x* R I2 H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- U O% C& w0 b/ n* L- w
7 ]7 Q5 @0 X! t6 h5 V/* assign the tl som board LED-GPIOs*/0 N8 B$ c" P |, W5 C
static const short da850_evm_tl_user_led_pins[] = {' u2 g7 J9 q$ \2 e: M2 z
/* These pins are definition at <mach/mux.h> file */8 F$ O6 P) z7 H( I# V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" [4 } F1 M( Q& q# k -1
& O; e; N2 `4 o};
4 f( b8 O& n, c. c# s- K
9 l# z% D5 Z1 O! `( r; Dstatic struct gpio_led da850_evm_tl_leds[] = {
$ f b3 E. y2 u* p/ w4 V. I& m" k {( ~; X% y. i6 L" o3 ?
.active_low = 0,
: M, D$ |+ ?/ x! s1 ^ .gpio = DA850_USER_LED0,
7 O; ]2 u& O2 [# S: G* M3 B1 f .name = "user_led0",+ O/ {0 W# W" w) F' s9 ~. Q
.default_trigger = "default-on",7 y8 |' a2 ~' f% L" D$ ?
},+ o( D# y, _3 w5 m0 S+ w3 m
{' S. y4 F8 ^4 H2 N
.active_low = 0,
7 {. k! Y- }8 H: e+ N) m9 K3 t: _9 } .gpio = DA850_USER_LED1,
- C3 p p0 Q( c6 v .name = "user_led1",
N1 `1 I! h' h8 e .default_trigger = "default-on",
& k$ @! {- u% [3 [5 V },0 Q, N4 M/ C" p8 P* V
{; A9 s0 q' p1 T5 [
.active_low = 0,
. D; H( c _8 t .gpio = DA850_USER_LED2,8 I5 |' V$ l. d M0 M: l
.name = "user_led2",
) V, O6 F7 \( e2 ]" p$ s' Z0 C .default_trigger = "default-on",, H; x: p) P; \0 q! R8 G
},$ _, X; m- t) J) p: T6 J
{; @5 u: Z$ u8 Q
.active_low = 0,
# q% t' l+ t; M; D' C .gpio = DA850_USER_LED3,8 M, b6 U3 A y5 b+ @. |
.name = "user_led3",
- R; l! V& ^9 J8 A .default_trigger = "default-on",% f$ Y" p( p f3 x0 y; Y
},! E. k8 k4 Y2 U% b$ z
};% r; S. q" m& ]6 k) J" |
7 E. N4 d* l4 i* u1 E2 b1 M* P+ a8 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' x' V W4 j6 N" O
.leds = da850_evm_tl_leds,; F5 r, V1 z5 {" K J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 ?5 I& ^4 v9 {
};
; Y! D9 n; D/ ]: g7 z2 B7 t! D$ O5 B# `; g, q* L( A
static void led_dev_release(struct device *dev); ^( N9 ~, o# w* v
{* C4 W* D/ D8 h0 m* N3 w
};
5 d8 n6 z( G7 |$ e. v; r1 C b7 V4 }8 n) m r
static struct platform_device da850_evm_tl_leds_device = {7 t* x9 N1 D" `! z+ i8 L
.name = "leds-gpio",
" u! i; A7 l+ v8 Y& O .id = 1,
4 X& _6 }8 A9 i- } .dev = {; B3 w0 A/ z2 u
.platform_data = &da850_evm_tl_leds_pdata,3 T/ ]* {8 u, e, K4 q( A) t A* ^
.release = led_dev_release,+ x3 n `( |; p. y& t! t6 `
}: j0 `/ Z3 e& c) X
};
5 A7 O: S# s$ R0 o3 {+ }
0 p+ h0 S$ ^; p: pstatic int __init led_platform_init(void)9 [$ c8 |; m# x. N
{3 f9 X/ V' G( q& U7 Y
int ret;
8 u2 i, b8 M" X! v6 l' M#if 0
7 i+ V6 c& Y2 k' @# g5 N c' o1 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 T& ^1 Z1 f C if (ret)# s6 w- d$ e% S& C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 g: c$ ?2 h8 z+ R- }' n. q
"%d\n", ret);
) c$ O, s# Y8 ?/ d& \6 @+ m#endif _" ] T7 x0 L; Y0 {4 [; q
ret = platform_device_register(&da850_evm_tl_leds_device);
. P0 j6 k* l9 N5 @6 b% a3 D if (ret)# s$ u Z. q+ M3 Y% G% F8 S
pr_warning("Could not register som GPIO expander LEDS");
: ~# Q! c# b) j1 N else
% V, r$ K: F0 W+ Z( A$ [6 X printk(KERN_INFO "LED register sucessful!\n");
2 e9 e$ \, L. ?+ n9 c$ t& R0 [
1 v5 @" }! X5 E v. ^' | return ret;
- P( [/ c7 C, Z5 B$ `; }}
" A( a; i( X& W2 N/ O6 o/ v4 p M7 p) [' s: H
static void __exit led_platform_exit(void)% |- ~5 c4 r2 G% p' g, M V ]
{
{5 ~; R5 _2 d4 \, T/ K platform_device_unregister(&da850_evm_tl_leds_device);
$ e w1 j- @1 `& ^
2 T+ H" L4 b; ? printk(KERN_INFO "LED unregister!\n");: o7 B- l5 ]8 \+ z1 {& G: S' e
}9 j$ M$ i+ S) @4 V$ b( @( p' N, L n
- R- n* q2 |; `# a6 [
module_init(led_platform_init);9 i: o8 R3 m# {0 f) P2 v
module_exit(led_platform_exit);- Y K2 F6 v: @7 L# {& G
! o" b, _5 j" [, AMODULE_DESCRIPTION("Led platform driver");
* |! x) v! S O* rMODULE_AUTHOR("Tronlong");6 h, x2 n+ Q" [+ a
MODULE_LICENSE("GPL");
; i; C" l. T+ f* S! }
5 x$ k7 Z* B0 t7 ]/ z" K2 H |
|