|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. ^0 H3 e6 P, V. N, ~
#include <linux/init.h>" C% @* A9 l% [- \" u5 G3 o
#include <linux/module.h>
D! i; D. J$ A* D! n# d0 I#include <linux/kernel.h>
" P9 z: V1 t4 H# b9 P; S" o#include <linux/types.h>
# F3 q& J! `4 `+ h3 g( m* j#include <linux/gpio.h>
* x1 E) u! V0 {9 s+ ~( i#include <linux/leds.h>9 n6 [5 i7 n/ F4 P1 H( l5 t
#include <linux/platform_device.h>3 ?3 h: j( \1 o9 a! w9 _
+ h; s& n: o2 v6 j' T+ w6 Q" V#include <asm/mach-types.h>) I" ` V6 L1 S
#include <asm/mach/arch.h> X' t C& c9 D- p* k) y
#include <mach/da8xx.h>
~2 O, |$ } l6 p9 X# l! W#include <mach/mux.h>( F; }% B# ?( y/ n
9 C) e2 L' [( k, f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* y/ d1 a6 G j# P$ i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ ~. n: R8 F& o/ G8 Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 a% c$ w4 r9 d$ c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) k3 w# {* W5 ], t9 @. \6 u
+ t: X0 ]: H$ B4 K
/* assign the tl som board LED-GPIOs*/7 ~2 F/ u& F/ d8 I T% _8 N% s; |
static const short da850_evm_tl_user_led_pins[] = {& ^# M- b9 I% @ O) Y5 a
/* These pins are definition at <mach/mux.h> file */
# a: V: b4 @ D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, Z5 M6 X+ M1 B% @+ K3 f/ Q -1/ C3 ]. i0 Y# ~5 h; O" ?. Q+ ?
};
~& y3 c7 C# @' u: `
! d9 _* x" |. p0 ^static struct gpio_led da850_evm_tl_leds[] = {
4 i, \0 j& {! |- q7 t {
$ T& d$ k1 @; v; P .active_low = 0,
/ D* D6 I/ |9 d6 g; _* c! ] .gpio = DA850_USER_LED0,7 F* _ N9 e( V& ^
.name = "user_led0",
$ c2 k1 O2 H( M2 b, W1 }+ F4 W; Q .default_trigger = "default-on"," H, K9 T! k, Z- ~
},
6 I& F8 S- y% C0 [$ Q( e6 G+ t {
4 ?' T# C4 k2 a& d .active_low = 0,
/ O0 w* f) |% Y .gpio = DA850_USER_LED1,
; R" S" z7 }+ w! {" M& M .name = "user_led1",
; p( a- K1 y! d- G6 p, i, g+ p* C .default_trigger = "default-on",
+ e" Y! Q g6 t1 m+ A5 F },
7 [6 S$ q4 k& A- o5 q* i+ V4 s {
; F$ m- c: a) Y. p! q .active_low = 0,
5 o8 g8 K4 ?9 I* k3 K$ [ .gpio = DA850_USER_LED2,
' K7 k0 h# Y! U9 b .name = "user_led2",$ x$ M( v, q7 c4 ]) \. J) w1 }
.default_trigger = "default-on",- y D; Q' F; v" f
},
8 D' o6 Z. E8 j+ ^* a. \/ \ {7 h+ B5 b2 k5 f8 D/ ?
.active_low = 0,
9 X; {2 g( B# w- Y$ T/ r .gpio = DA850_USER_LED3,
0 q; l0 y& D: [ .name = "user_led3",
: p# O' o) o' F1 M: ` .default_trigger = "default-on",2 D0 w4 I. p i2 l- O* u' I; X B: ]
},
+ y9 A- b j; j- m% H};
; Z7 ]. I! |* ~" Q1 H7 V
$ q' e( y: d ]3 Z6 E# g2 t" rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, X- K8 n/ [! |! k! x; B) ^' \
.leds = da850_evm_tl_leds,
Y/ a/ a0 O6 J+ ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 Q$ Z8 s4 u% Z' c+ [6 h3 W0 W
};( p; f. M8 g) m B' n! H( \
; j9 l; V2 M& B: c4 v3 i
static void led_dev_release(struct device *dev)
0 L1 C: Z' D1 P{; T& o- |1 R, N; g2 w
};
6 p8 Y) |2 H/ {9 y- Q I) ~# [9 L1 \6 o. ]: H" M- b7 u
static struct platform_device da850_evm_tl_leds_device = {
6 |5 d. h) e$ @ .name = "leds-gpio",5 u$ l6 Q' [6 W8 \
.id = 1,! K. J* N( m8 [
.dev = {& i& }( Y- {0 W6 D( y
.platform_data = &da850_evm_tl_leds_pdata,8 J$ a5 b5 g# e5 @+ X% A* B Y
.release = led_dev_release,
; H* u+ H; U2 Z: D$ p }
* V. J0 G+ Z" c};' n% |; @" Y2 E' X2 F
- [- d: V- U7 _- d8 r
static int __init led_platform_init(void)
7 w H8 c. |* g* T; m; m{7 x6 Z" S1 N, J' A1 O' m
int ret;
1 k: O: y3 h% I0 z* P3 O#if 0% U1 V$ d/ e J y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! p1 {& `; I2 b2 y, q if (ret)
$ Y, \# x5 Y' d g0 y9 _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* M0 P# e- J+ k5 ?; @ "%d\n", ret);
' P) T+ G, `8 y, {. ]8 L5 F#endif
" h- D; D) j6 P+ U9 Y! `& B ret = platform_device_register(&da850_evm_tl_leds_device);! A5 {( C2 D2 ?- |( R
if (ret)- N+ U% S. B; r @4 p# a% s8 w
pr_warning("Could not register som GPIO expander LEDS"); W) {1 d: F0 n' Z) y8 i" H1 O+ H
else
/ j; E! G6 \: f printk(KERN_INFO "LED register sucessful!\n");
, D; l$ d6 U5 M) j, z5 X0 W& ~' x+ Z! r* ?9 X! X
return ret;7 m# B4 _6 @- e1 S- j! c
}
, }# ]* I, C$ \
9 G' ~5 L) H3 |( E0 dstatic void __exit led_platform_exit(void)+ h% q0 s, ]: _, z9 `
{# z0 i$ A: z5 n+ ^: v4 i
platform_device_unregister(&da850_evm_tl_leds_device);
K- v+ Q* F2 _& G
\: N4 ^% a8 B- }6 s3 W6 l* N' e printk(KERN_INFO "LED unregister!\n");
9 Z7 l/ }3 Z* f0 l% ]}* B j5 Y' {& T1 G% t( B
* a! R- W: K! c5 {# s+ H3 ~
module_init(led_platform_init);2 ]& m. D& W: ~' H) m5 h9 b, R
module_exit(led_platform_exit);( T, U- k5 l; N# w
2 @: v& l; K5 v- y9 V! V! YMODULE_DESCRIPTION("Led platform driver");
7 ~3 p* m/ X$ j2 \' _ QMODULE_AUTHOR("Tronlong");- f4 L, Y4 C+ x. ]! j; p
MODULE_LICENSE("GPL");
0 c6 G2 A7 b* S) r5 ~* c/ B/ p
4 c9 x/ U4 Z! y5 K' ~4 g |
|