|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 j- g0 s( ]' _8 K" R+ O
#include <linux/init.h>7 l0 d* }1 |% o* A' N
#include <linux/module.h>
# [! A9 N/ x; V3 ]$ L, s#include <linux/kernel.h>4 M4 B$ \! X# G/ T [
#include <linux/types.h>/ B6 U5 \/ ^0 v- X4 e4 {
#include <linux/gpio.h>
/ ~ K0 l6 O K( {& N7 [#include <linux/leds.h>
& d- M- ]' r6 ?3 T#include <linux/platform_device.h>
' ]$ c; {2 _+ ?: T" g. I0 W7 i4 ]1 m" i6 B# X! |) ~
#include <asm/mach-types.h>
$ I" z- G) L& U1 T2 J" ]0 p#include <asm/mach/arch.h>& Q! c2 d3 v+ t0 {4 g1 j
#include <mach/da8xx.h>: H, ~- B: [9 G" g8 \3 ~
#include <mach/mux.h>; \3 C' e: s) I" I
" H/ s* [4 \' m; W1 j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" D. R8 ?$ r% s& }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ [& u( s* M0 H0 y, g# p$ g+ b* P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% l; \/ }7 w% x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ ~' G7 \# S% c' r- M! K
$ W- F: j p/ ]8 }/* assign the tl som board LED-GPIOs*/
! F/ o* q: [ [2 w% ?( nstatic const short da850_evm_tl_user_led_pins[] = {, Z R2 M: u1 ~) j" w/ m b& {
/* These pins are definition at <mach/mux.h> file */
! {8 A; l( O! B, Y1 ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; H" w" U8 R) ~8 [- s
-12 W4 n" `/ ~4 O+ k% L
};2 D* g0 e7 N: V+ w w$ d8 d
5 O1 u8 F' ~3 B" l' a6 c! S
static struct gpio_led da850_evm_tl_leds[] = {8 G0 l8 I; h/ |. x) v( L5 R# Z
{
! e0 G/ Z# G+ w$ I6 P; t .active_low = 0,- G- s+ o9 f; t- X5 d7 `
.gpio = DA850_USER_LED0,* F( u! }7 @$ Y( x
.name = "user_led0",2 ~, a+ n- o% X- d# @, |& d
.default_trigger = "default-on",: _8 ^ o/ X8 R$ a0 Q3 L/ z2 b5 t8 E1 c- [
},
) ^! t8 H( |8 i9 |. z2 m {+ x6 D" ^' n# U4 p% n
.active_low = 0,
/ s2 D% \! I; n( q2 \" ` .gpio = DA850_USER_LED1,5 ~! ?3 n# D& `
.name = "user_led1",# o* T) Q) j& P5 l& b7 n# ^+ ]- t
.default_trigger = "default-on"," ^/ b6 o, z; z9 k2 q- [) q9 E
},1 Y9 m7 k }/ U0 U. h
{
: D$ c* J% h% b" { .active_low = 0,! [! ]% q8 M( c& s
.gpio = DA850_USER_LED2,4 w* x- _% U' B) z( y( H
.name = "user_led2",
& q( t& L) C" P8 b- p .default_trigger = "default-on",; Y/ w. r& @* @3 ~+ G' B
},+ |6 _* f; S- K9 Q
{( `9 w; M* |) E, [
.active_low = 0,( t& Z( H2 Y2 l3 m' ?
.gpio = DA850_USER_LED3,
9 {! `5 g; G$ p# o/ b .name = "user_led3",
2 W/ P) u* `) R- u ~ .default_trigger = "default-on",9 ]4 m5 B$ F \) G( i; `
},% d [; l& ^( T4 N. N9 U
};( _ _" |/ |- }% P
( w& F, r/ C# W7 O A) Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 I! A/ A+ e+ [' L( c( A .leds = da850_evm_tl_leds,
) e7 F5 [$ H9 V6 ~ A" E& w( { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 \* z, ]7 i& X* A};
( }* f% J1 M9 r( h7 I+ h! \: `" U, A' i8 u8 @
static void led_dev_release(struct device *dev)
% v- M% c& l z9 w{# \: `$ |* H0 T Z6 A5 x- }
};; z; a+ j1 v+ b8 f+ w
, i# \' {/ z) s9 q/ [static struct platform_device da850_evm_tl_leds_device = {
3 F9 J5 ^; j; X0 I% z- ]# Z) f .name = "leds-gpio",
1 W" L3 _! x2 i1 n .id = 1,
! W* S' e& o" i7 M+ t .dev = {7 v8 _. t" h% }. Z# R% C' P
.platform_data = &da850_evm_tl_leds_pdata,
1 ?. n( e2 G# s( s5 ~. n5 ?) d' T .release = led_dev_release,
\0 l& \- @0 S E" U }% o7 a* Y6 l- d0 f! x v8 r V
};! d2 O$ P: I6 M
7 [: K: o0 X5 l; b4 J
static int __init led_platform_init(void)
3 M C1 `4 q* J3 l5 b{% D! x3 N1 s' Y1 g+ w
int ret;
' Z2 ~ l3 j L4 P& x+ \0 k8 a#if 0, Y2 k$ O& p% V' O' W+ R( ?. f% _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ G' p; A I. t3 s" {' K if (ret)( K9 ~- I* Q+ {( i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# X3 e4 d! A4 m. [ "%d\n", ret);
' |4 ~2 i4 d7 @% p7 H! x#endif
* b/ N; Q0 M) R `9 y ret = platform_device_register(&da850_evm_tl_leds_device);6 N& D$ s" M8 b
if (ret)
" t g4 U# w# T5 N; i pr_warning("Could not register som GPIO expander LEDS");
. K I0 p' F( j! @ else( _4 f G# _2 y
printk(KERN_INFO "LED register sucessful!\n");, N! ?0 L9 E i, ]
- {! C* ]8 u) V. y' v
return ret;+ i: \0 i8 c- C( E
}
0 n. c. Y: C3 {3 I/ y W. [8 d& b6 q& P/ B
static void __exit led_platform_exit(void)
- k* p) A: F. a) M{
& V% y5 y- u8 \) c; D4 l4 O* ] platform_device_unregister(&da850_evm_tl_leds_device);3 e4 f$ {! o. ]0 y" F/ r" E0 ^+ y
4 X- S* Y8 }: {; m, a0 S6 x
printk(KERN_INFO "LED unregister!\n");
3 L1 c$ P, g5 i# ^7 r& R, {}, l( L" l: l1 E4 j0 _/ O; ?
6 w5 f+ K4 g$ W7 ]
module_init(led_platform_init);5 G1 F" x4 x0 q. a
module_exit(led_platform_exit);8 H/ J" O* `* |: q, T- O% e6 B9 Q" ~
8 U# r- `8 M# J% D. e
MODULE_DESCRIPTION("Led platform driver");
7 V. x1 A! z( |% V! u- PMODULE_AUTHOR("Tronlong"); n2 u. i: T: w( u8 @$ M9 s
MODULE_LICENSE("GPL");
( ]6 q6 D" n& C# N0 f6 N; m$ L0 b" [ \
|
|