|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ G7 p) r! ?7 ~$ p! }$ s
#include <linux/init.h>
0 |2 B- y n# a4 i. ^#include <linux/module.h>( ~* s- @3 }" p
#include <linux/kernel.h>
) H! S. h' f' T5 S# T0 T8 M- F#include <linux/types.h>
( R+ z/ |( U2 h# m( |#include <linux/gpio.h>
$ t- R1 f' p' E% b#include <linux/leds.h>3 H2 v5 a! z9 Z7 E+ S* E
#include <linux/platform_device.h>
( R9 |7 g! H, A+ Y) c/ ?: E: S& ] L1 y S8 }. P. U/ F
#include <asm/mach-types.h>
7 A( J1 @2 g! s! P#include <asm/mach/arch.h>. Y* K0 K4 }2 v. l! o0 P9 W
#include <mach/da8xx.h>
% m+ N( d2 e9 W" U9 O#include <mach/mux.h>
( K7 s% L% a9 D; Y
* L4 J4 A* K W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). `2 L' ~+ R8 |; E* z3 H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 ?5 H+ d- r/ ]* |, a$ j, M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 p# T4 z( I$ e4 i7 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 N' b' n( Q4 Y3 j0 R* b
) k, X- L X l& b/* assign the tl som board LED-GPIOs*/2 d d+ b2 Z+ J2 k
static const short da850_evm_tl_user_led_pins[] = {6 z- _2 g( U( z
/* These pins are definition at <mach/mux.h> file */
! Z, T) P; t7 N1 ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 W: Z) Z9 A3 X4 B% A* R/ R% n A -1
- q! q1 M8 i0 W' C8 h. B0 L5 Z};
% B6 m% g1 J2 _* I. w; E7 l
! A5 Z+ l" K K- g C2 @5 sstatic struct gpio_led da850_evm_tl_leds[] = {
9 L% Y& r V6 N$ D3 ~ {; s" _) Q) m u, i
.active_low = 0,5 \, t: j+ k* s! @2 S$ `3 \
.gpio = DA850_USER_LED0,
$ R- P# X7 _" w" u5 {( t .name = "user_led0",2 T; J( H8 M9 \9 B# Q* r
.default_trigger = "default-on",
* S6 I% H' Y- e8 W6 m, _ },; B; E7 \: F8 C( b) }+ Z
{5 F: T* w+ ?4 Y2 |
.active_low = 0,% Y" V& M7 C) A" j
.gpio = DA850_USER_LED1,
5 {+ c, L. T A$ Y" K .name = "user_led1",3 f T, U0 a3 ~9 F" j3 w
.default_trigger = "default-on",; O' K4 I' k7 U) [) `0 g
},
0 y: v9 K9 z- g6 n0 N. P0 O- | {
! ~$ X! `! F1 r) c" a .active_low = 0,8 Y$ C" u% x8 f5 F3 ?
.gpio = DA850_USER_LED2,& z% k# `4 e, L, Z# ~- K( U- G
.name = "user_led2",5 t9 `' Z5 r1 m+ e/ _
.default_trigger = "default-on",
8 ]" g4 j4 s) H0 A },0 z9 P. D+ t9 o( H5 D% ]% ^" s
{
( x. i2 A! @7 _7 _& G- ^+ ^& d" u .active_low = 0,
3 x3 e' r/ c9 M .gpio = DA850_USER_LED3,
( e+ ]+ }" F2 m+ q+ h .name = "user_led3",
& R. X' q% G) s .default_trigger = "default-on",( [* o& m$ t! j* D
},8 } t$ j4 I, g! ~! Z" u
};
6 c% {; t7 s6 U0 n) J5 |+ K
' s) q4 g" a: p6 i' }( gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 s$ b$ ?. a- _: I .leds = da850_evm_tl_leds,
9 R4 N3 G4 F ^! W+ X6 u. @" S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& K# e; x5 i6 X f+ S3 ~- ]};6 X' L! {( |( V& J8 S
% A: C3 r! J; Y. D! r hstatic void led_dev_release(struct device *dev) f. } w; J( Y+ t
{8 `7 b) I3 K- b s5 p
};/ {1 ~3 m9 q5 ^* C- X; w3 Q
- I3 a' T* ^6 q2 N9 Z' ^
static struct platform_device da850_evm_tl_leds_device = {4 a; I1 u5 [' [1 k
.name = "leds-gpio",% h( U+ q( U% b- C& f- _# j4 y
.id = 1,3 s5 R4 e) z1 e3 q
.dev = {
7 n- l; e5 |: M- o9 h: _; a% X, A .platform_data = &da850_evm_tl_leds_pdata,
# m+ F) c# o( P' _( D .release = led_dev_release,. m" n8 k2 V7 s7 |( L6 D
}) \) m8 a6 S x: D' A" g" \
};
, o( [9 ?9 U! w# x3 p9 x0 W$ l' c- w: X c9 c9 q) j3 s
static int __init led_platform_init(void)
) E4 h& P6 l/ ^8 a. h6 L{
" a$ [+ Y3 W) Z& P3 k7 _8 _ int ret;& j5 _* L: L% C j( P1 w4 p
#if 01 j* J$ g' {2 O: `& Q5 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 Y1 ]! @: s0 w* j if (ret)
% N d8 g N. L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
V" P0 l) v; o: i' d "%d\n", ret);
9 s% ^2 r' B0 A+ f/ }( F0 f#endif5 E' y* @( T+ K; W) y
ret = platform_device_register(&da850_evm_tl_leds_device);; ` c% E8 ~( F, B
if (ret)9 v d0 X; h: l7 N7 [+ w
pr_warning("Could not register som GPIO expander LEDS");! N! C+ Z R0 R7 {/ j4 G
else
% z& N0 D6 @' L. ?5 u printk(KERN_INFO "LED register sucessful!\n");
7 _( F% N7 S; j; T+ L3 p7 A7 e8 e" L; @1 x) ~) z
return ret;
) R7 m2 `( x7 b) i# Z3 i1 z}+ r( s8 A- l+ g8 f& ^# c, h# J. U
; S! g0 H6 `) M4 x# T
static void __exit led_platform_exit(void)
5 [; c. U9 C+ O{! y1 T+ I8 {2 V2 Y8 O
platform_device_unregister(&da850_evm_tl_leds_device);. {2 ^' y f4 ~0 S' e8 y7 d! o) e
! t9 J6 ~" K" @1 I U# w; r printk(KERN_INFO "LED unregister!\n");
& X2 q J- I2 j1 x1 s) }}$ P- H+ e7 Q! V3 D& d2 s" b
% J$ N; h" S3 X2 f2 r% h/ h( i4 G/ u p2 qmodule_init(led_platform_init);
1 K' V# ]0 Q* I pmodule_exit(led_platform_exit);" H0 ?& Y B1 q0 W' e
( R3 ~7 p S( ]5 s% AMODULE_DESCRIPTION("Led platform driver");# ~2 e1 ~/ u8 g1 ]4 c: m' O* g
MODULE_AUTHOR("Tronlong");4 I4 Y7 X; y; P1 [9 k" L. }
MODULE_LICENSE("GPL");
- B2 j0 x. M" Z$ k' I9 y1 T: t, C; q
|
|