|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" H, i; b' n; c A; n z. B6 R8 m#include <linux/init.h>
) p0 \5 {1 q; E g3 i* ?#include <linux/module.h>9 `6 h9 }/ q5 N
#include <linux/kernel.h>
! a; O0 X0 ~( _8 d8 F#include <linux/types.h>
: H3 Y2 ]* G5 o/ I8 v#include <linux/gpio.h>; P# u2 q% z: Q% [0 R$ p1 }: |
#include <linux/leds.h>
6 r1 _; C3 U7 o+ K Z#include <linux/platform_device.h>1 D, E5 x/ ?, ]
2 X- b, J9 m: e1 i: F
#include <asm/mach-types.h>
9 c5 y3 i1 X( |6 L9 S#include <asm/mach/arch.h>
; z! T7 q- v2 ]9 l9 |: v: W+ z) [( r#include <mach/da8xx.h>
( J; b& p5 H* _4 i' s4 M#include <mach/mux.h>
' o" O9 a8 }8 L4 p4 m) U% d% S
R. c, `# v! o. p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( |7 A1 j2 {: C/ M( c e! s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# T/ L1 ?6 O: q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% W# A+ X- x J# K# {8 |1 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ l }7 p/ r3 s# R& D: s% Q, L2 G3 s
0 O) K7 h/ m6 S/* assign the tl som board LED-GPIOs*/, z7 R2 p' `- Z6 x0 L# _0 |
static const short da850_evm_tl_user_led_pins[] = {2 { t( W9 `# ]0 x: U4 J2 y7 f& c
/* These pins are definition at <mach/mux.h> file */
# X% V4 o# q4 F1 {2 H1 n" U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% ~( |" h3 {- }. L$ S2 p+ ~ -1
2 w* I, J0 u5 `- }# N0 F) N$ U};% F* r( P; O$ \" V
1 t" l7 g% e1 O. p8 s- fstatic struct gpio_led da850_evm_tl_leds[] = {
) D# N( x* O' q% I {
) I+ a0 w3 C. ~- J" E0 E, { .active_low = 0," M0 H( s! n o/ f& w
.gpio = DA850_USER_LED0,4 w7 T0 l9 n. a) }1 {4 h
.name = "user_led0",8 r9 @! ?& D% ?5 g8 j7 y: O% k( K
.default_trigger = "default-on",
9 {; e- g, \! Y },
% h0 B! ^5 f# D9 e8 I( h+ h6 w+ [ {3 `& C1 ^2 E+ l$ w
.active_low = 0,
6 J5 w! @7 D; R- z0 n .gpio = DA850_USER_LED1,
2 k: O0 v+ O7 P9 F/ L% b% U. F .name = "user_led1",
6 ^1 w% c4 W) c( i/ d .default_trigger = "default-on",
G% ] a5 Q8 i) O0 e3 r* G },
; s$ j( j2 M7 k0 v- D8 Q4 _: d {9 \/ S( ~5 z1 l9 C
.active_low = 0,
+ f7 J1 i( b4 H! y" e. @ .gpio = DA850_USER_LED2,
; m' r! T/ V/ _! T; D/ J$ e .name = "user_led2",' |# J+ l2 d$ T" ?! C4 k, h9 i6 u
.default_trigger = "default-on",% M$ G9 n$ Q' F) _
},0 g r, B# h4 Q4 J; F+ |' `
{
9 }9 s- I7 K1 }! \4 a* o8 m .active_low = 0,6 t. r; ]/ s: {: X' u; v' x
.gpio = DA850_USER_LED3,
8 F, k: X. z3 a( X6 a .name = "user_led3",2 F, h/ g8 `: F2 G7 D3 l% @
.default_trigger = "default-on",
$ r4 a: n3 a- U" [! H+ X+ ~. X1 Z },
. p5 b7 w. M/ S7 t};
9 S0 M& \" S3 N/ m2 z) f4 I0 n1 p& D1 ^- _! W2 p `; T! ^. U3 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- x! V q* M, D .leds = da850_evm_tl_leds,
/ p: G @2 k1 J. } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ H, G/ v& n i};. ^ }7 Y# G$ Z
. Q( N; C5 g* |! w' |+ L0 ]# Istatic void led_dev_release(struct device *dev)1 [) b, G. n: z
{* o# @% o9 ^& m& n
};: p8 b. L/ m8 Z8 Q- D. I2 _6 {& g
+ r5 f2 V% P7 t/ s8 k1 U
static struct platform_device da850_evm_tl_leds_device = {
& c+ w: g% i- c! t g2 |7 a7 O, ?$ v .name = "leds-gpio",3 _0 G& B* `6 |& B) o2 c
.id = 1,
3 B! `( Y! t3 u6 M Y .dev = {; S* Y0 c- H, r+ T% a
.platform_data = &da850_evm_tl_leds_pdata,# |% Q7 Z! D: w+ c% b
.release = led_dev_release,
- b3 i1 |, D( o3 R }
. h0 ]1 ]6 f5 W: d, A% a; C};, V( L5 S% z, ?* _- L
; ~2 V$ Q" X' W# d: ~" C% e1 W
static int __init led_platform_init(void)
2 j0 o7 R+ y' W{. @ Z0 T! D- f7 Q4 H6 B# @
int ret;
7 q }, `3 A( S# C#if 0
5 ]+ R- w: F9 Z* p% W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 V9 t. c, p- U6 e if (ret)
, X0 R4 g: Q( v- `' Q. }% a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; k' D6 ]; E9 `8 ?# o. ^ "%d\n", ret);
8 d- @" V# c) ~1 A: V, l#endif
" r" Z1 e- y3 J, s! \9 T ret = platform_device_register(&da850_evm_tl_leds_device);, J9 [7 N7 n6 h7 w& U) X
if (ret)
- F0 `& Q: G6 O2 {3 x, F pr_warning("Could not register som GPIO expander LEDS");5 R# G y; i9 c' [- L8 m
else
. [. D3 Q: ~5 y# X6 y printk(KERN_INFO "LED register sucessful!\n");
( U/ V: n% X6 W
. U, {, e; L% q. H5 {) }4 S0 w# ? return ret;
( Y! Z* g- m7 Y8 R}+ M* N n. v, ]2 S" d! {
8 m+ P- ^+ D' `# x, k( qstatic void __exit led_platform_exit(void)
, W+ `5 G8 f& S' e6 ?! x{; m# ?( S; w/ h: F+ n) m, T, Q, a" Z
platform_device_unregister(&da850_evm_tl_leds_device);6 H$ i* R3 D0 {! p+ Q0 O ]
/ y. ]' K: U: ?; G7 L3 n" ?
printk(KERN_INFO "LED unregister!\n");
/ w* r0 G6 k. M}
* a8 f( w# Y7 b
9 M W3 A+ I5 r$ N* }module_init(led_platform_init);3 d, H: k: p: {
module_exit(led_platform_exit);
G$ Q8 \% ]1 }* e) S
0 y: n; B2 _7 V. e7 H! e- BMODULE_DESCRIPTION("Led platform driver");- U" s; _2 `1 a% }, M
MODULE_AUTHOR("Tronlong");
! b% c4 o8 b' X% D/ `MODULE_LICENSE("GPL");9 ]/ o A3 `. @# D/ W
; }+ ` G; V, ~" Q' q
|
|