|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* [' `$ ]5 I7 E8 }
#include <linux/init.h>
r: G& r$ M3 q5 `+ [#include <linux/module.h>
! {/ w) ]& {2 D- s6 l2 |3 O! F) i#include <linux/kernel.h>
" I$ m, \3 b4 @, W+ Y- h7 _#include <linux/types.h>
! h; X1 m. b( f: e#include <linux/gpio.h>; A+ a% {* r' ^% H7 c: ]' n
#include <linux/leds.h>( Q. }# p$ J z/ Y
#include <linux/platform_device.h>7 n: k5 C. _$ \+ P# D% D3 o6 g
+ L0 ^# C( D5 N; u, J#include <asm/mach-types.h>6 K( l$ Q; t2 @( h2 L/ |" v4 `
#include <asm/mach/arch.h>
, _: k; e( b: u/ m) U- D#include <mach/da8xx.h>
; w# D# |1 O9 a#include <mach/mux.h>! c6 Z2 G) s* o9 {. k# K6 e& k: `
p8 N2 j; z v% M4 H' \" \. @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 S9 l8 w/ y; S5 B0 J! S; A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 L+ K6 B& i/ z* d5 j2 J3 C1 ~- J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! h- R% H6 Y/ X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 @, |+ H: _) y8 @4 g# B
8 _. p7 x$ A2 Z/ u$ G/* assign the tl som board LED-GPIOs*/; k& q' J* T; t# n
static const short da850_evm_tl_user_led_pins[] = {
, E0 d8 q9 o5 l6 [ /* These pins are definition at <mach/mux.h> file */
( N4 L( c |* t4 c/ j$ ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 b+ }: p' D6 }, f0 s -1
5 y+ T9 o- g0 ]" \' G) B};
5 L/ j7 S2 ?& r' }/ ], w' H4 L
v" l# S! t ?* W2 N* p& Y% Astatic struct gpio_led da850_evm_tl_leds[] = {
2 Q0 }. ?5 @4 |, p! I {3 I% q( q+ R* O. P* d& m
.active_low = 0,5 U0 A; c4 s; A- E
.gpio = DA850_USER_LED0,
: @8 T/ o- e" l3 }. \7 } .name = "user_led0",
$ m+ q( b* \5 p: d .default_trigger = "default-on",9 C; C! l. c) L, n' \6 K
},
2 q1 I# C- B- R) H& i; v S {7 T4 t' G2 I' J8 K/ x( @% f
.active_low = 0,
2 B7 D+ _1 c$ U# V+ l- r% d .gpio = DA850_USER_LED1,
6 h2 F. H O* _0 ]2 c: X .name = "user_led1",
6 ]: I3 S6 T# j! D0 K .default_trigger = "default-on",; ^* `- I* ^, @% h
},
) t& O4 a0 B3 L7 |: A {7 I6 s5 R- d: ]/ N$ N
.active_low = 0,' L" S2 X1 M6 ]6 A
.gpio = DA850_USER_LED2," ^: @" H( h4 ~! y
.name = "user_led2",2 Z2 M" `' G7 P* I
.default_trigger = "default-on",/ m7 U0 f, v5 z4 S2 K ^
},7 c' o3 l' K3 I& l( e$ F
{. F' T/ f+ l1 j% a
.active_low = 0,
, D5 x- S# E g4 {" V6 V: ~/ j7 P% s .gpio = DA850_USER_LED3,
9 W1 `4 n2 g1 Z .name = "user_led3",5 C- m1 L$ W3 j6 @
.default_trigger = "default-on",
& `; K4 R8 w, K _2 H4 ^% I },
# c- g4 f r' B% r- E, i; S};
1 ~* C8 s; E6 M$ |% K2 X5 W
3 Y$ t( w& e3 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: {" K+ P- I4 w6 t; x1 M .leds = da850_evm_tl_leds,9 s k0 K+ ]$ z, I/ N' `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& H3 z. ^5 c, @8 E F- }
};
/ T, Y5 f4 z. R+ f9 ?; N$ X0 ~7 S) D( `1 \0 l/ j5 S! a
static void led_dev_release(struct device *dev)
$ _( V) p. R2 r! Q* z9 p{
' k( D0 i2 H% ^" m};
8 Q) W5 `% s0 J" d) q7 g, e
: Q6 p! b5 |% t' k% b+ ^static struct platform_device da850_evm_tl_leds_device = {
5 m- J% }, K- o M$ P) A .name = "leds-gpio",
- n3 X2 K. \$ A0 G. Z" C3 N .id = 1,$ {/ |$ @ b8 e* U* [# [- t+ t
.dev = {
( t3 q5 c+ x' h$ F4 m .platform_data = &da850_evm_tl_leds_pdata,; U6 A1 {* E# U* a& _& B$ p, S
.release = led_dev_release,
, } B, c1 v- q5 Z' ^ }! ?. G( k D+ s
};
J: R' J% O3 e
# b, X& A8 e# g1 a" n9 A5 T) sstatic int __init led_platform_init(void): [" r4 R* G5 G+ g! x8 z/ `
{
, _" y9 ^- V# _/ ~4 I2 s# | int ret;
" c0 }$ k5 d3 q, M6 e) B#if 0
2 H) U' Z( C' u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% y0 ~/ A0 ` D
if (ret)
; `) k- m/ k k" Z" X: v1 Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 y W: }) Q7 @
"%d\n", ret);
" p* k) s t& j% f8 Y' {8 P/ y#endif n( j3 x/ u) L
ret = platform_device_register(&da850_evm_tl_leds_device);
) k7 w* t: }* z/ B6 t if (ret)1 c$ Z5 S; [) [
pr_warning("Could not register som GPIO expander LEDS");; y" V, t" U' l0 P: ^
else. W. T( ^! J4 g. u
printk(KERN_INFO "LED register sucessful!\n");
# U! ]1 U. G; i( e `1 z3 M2 s
) D* r) ~6 E; n" l7 f4 v$ } L. @ return ret;5 I6 z$ [$ p ^ s
}6 C5 G( C' q! s- L% W/ r
1 R5 c( p8 }' o6 K' l, r5 f
static void __exit led_platform_exit(void)
; e5 H) |, G1 u5 e0 b{* j5 }2 _( [5 B7 I3 ^4 m% E6 ?
platform_device_unregister(&da850_evm_tl_leds_device);
# b6 H d6 z; N+ I( R: k: b) l. H8 Y9 l, I
printk(KERN_INFO "LED unregister!\n");/ w! ]* @9 ^' i5 U ^0 n& w
}' ]6 c E2 s& G. I+ _5 U
: i$ G4 `: \5 \4 r
module_init(led_platform_init);
u u! n0 A, y! Y" ~$ _module_exit(led_platform_exit);
2 q) r3 ^7 Q9 n x6 K
" |3 E) c$ j. V; T$ B9 zMODULE_DESCRIPTION("Led platform driver");
# Y9 H0 t" T+ P; @( kMODULE_AUTHOR("Tronlong");
r+ Y8 W: I3 h) Q8 B, tMODULE_LICENSE("GPL");
+ n/ y1 Y/ l; }0 E* v
. W% T+ z* i1 K# J( A |
|