|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 }- g1 h. G: p8 L2 R
#include <linux/init.h>5 _; p: K5 X3 K; |) Y
#include <linux/module.h>, e" ^) ` d2 b1 u5 S
#include <linux/kernel.h>
8 j; L) @) _- J }- {0 p+ n8 R#include <linux/types.h>: T* d7 F$ a) v" j' _# U, v
#include <linux/gpio.h>, n# m4 c9 n2 T3 u r- p
#include <linux/leds.h>7 A' N* E; \) K, u) k- z: T& i
#include <linux/platform_device.h>. n) G0 K4 @- R2 g: V% m# |
" h+ M0 Y& |7 {0 W4 @+ c8 Y% ?
#include <asm/mach-types.h>" P4 o, ]/ G+ J" d
#include <asm/mach/arch.h>
$ A7 E0 w8 _' l. p4 l( {2 P( g#include <mach/da8xx.h>
7 x; l: `% z0 Z; k#include <mach/mux.h>
~+ f- Z; M- ~+ ~( {) \ z, |; H5 N
% r+ z: L) F: c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% ?9 f% W4 ^0 m g. q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& Q o2 ?: B: v* q9 A4 M" z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 L4 P' I6 w, ]2 H( N# A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 K/ K- d' b8 U! B. I: Z
4 K' S+ p9 e9 n" K
/* assign the tl som board LED-GPIOs*/
. U x- R) D8 A+ L1 s. Istatic const short da850_evm_tl_user_led_pins[] = {
" W) V$ _' s5 K /* These pins are definition at <mach/mux.h> file */
F6 P! U F: I5 h9 g1 ~4 l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: g! a( U' P t: u2 m* g
-1% p! Y* ^5 `* C% i
};
9 y; R* c& e9 }( n y1 Q1 h- w8 {* Z
static struct gpio_led da850_evm_tl_leds[] = {: V h, u# b O$ H9 D
{8 N$ k/ w: e6 l% f6 d
.active_low = 0,
9 V! o" y; e6 v5 G3 U& g; M W .gpio = DA850_USER_LED0,
+ f! _0 `" l! N# H: G. x .name = "user_led0",0 A3 R! r# E9 R
.default_trigger = "default-on",
/ ?! m5 \7 a* R& t2 h; n },
4 D& ~- M/ a0 G* z2 R* C {5 e; } p* s9 b1 `& x
.active_low = 0,
~7 S% i" m% G% t8 P .gpio = DA850_USER_LED1,
; d4 |8 r- n- ~/ V0 R3 Q1 p .name = "user_led1",
0 E9 p) J' ^5 h8 C% e9 @! A' k8 M3 ? .default_trigger = "default-on",
9 u7 _' a- N; [- J7 h/ c9 c },
0 L+ y1 n: R2 i: p3 `! [ {8 W, V. u' E( B( v, }6 l
.active_low = 0,
; e8 h, Y! l2 B( i. d( e$ W .gpio = DA850_USER_LED2,
6 D8 g& s7 N8 a( E- N+ y .name = "user_led2",
& p+ @; r/ T2 B- [5 o .default_trigger = "default-on",; W3 V: E0 @- P' A0 X
},9 F/ l: x4 S9 a
{
* M$ H( x$ J3 Z# b8 E% X" N .active_low = 0,
$ C5 B ~' y( g& E .gpio = DA850_USER_LED3,
5 T' @; @$ n+ y8 K0 h7 J1 g U .name = "user_led3",
; O9 u4 Y. Y0 b2 Z" t .default_trigger = "default-on",
3 C1 ?5 q+ w2 @) U9 E- N2 q },
6 e- y) h# A+ T/ `};
$ h( v2 y7 G" J$ H* \" s9 [; D8 t. ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 J7 \( v% `; ?( |: P X .leds = da850_evm_tl_leds,9 h- \& ?3 P* M( q" C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ O- K- e4 H5 O. w/ s+ j' \};+ b! S v6 z0 k! }* S$ Y+ i
3 u1 ^0 \3 f1 A; ?7 d* kstatic void led_dev_release(struct device *dev)
$ f+ F" I2 `, u% N& b{
2 m. O0 C! g7 A! h- t/ y+ M. |7 ~) O};0 n- m9 n p! B" S
7 x d2 |8 X* W; v& Nstatic struct platform_device da850_evm_tl_leds_device = {
+ m. T u! V- ]; }( r+ g% m: D .name = "leds-gpio",0 l% w9 f" g$ T& d8 L; H
.id = 1,. w# H f% ~1 N o: g2 g) @) W5 c o( F
.dev = {
4 R l( m: h7 o* H( D3 p( p9 ?6 S .platform_data = &da850_evm_tl_leds_pdata,
5 g' K3 J/ p' @. u. u+ o .release = led_dev_release,) m L' c# g J# e
}
+ x/ M6 I; N9 i9 f* O};$ L x9 u$ X) u) E
2 {" R8 U1 G$ O6 I; G& T, H5 o* H
static int __init led_platform_init(void)1 g/ D( v, } G& j2 ]+ q
{
$ V4 h9 h( P: |5 i7 f* q/ v- P int ret;" [8 q, [$ D; [
#if 0
. ~; [8 {& ]5 `+ M& H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: h3 L% X4 k- Z9 S8 E
if (ret)$ x1 v i4 f! z# \/ i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- w1 z$ @' |* E: `1 T3 n8 @
"%d\n", ret);
5 I$ ?: [( a. K6 S& m, W#endif
+ W5 i6 n0 f$ x' P ret = platform_device_register(&da850_evm_tl_leds_device);; i4 m* U+ y) [8 Q8 a n; l* B6 N
if (ret)* b" T8 L4 O$ o# x) p! @
pr_warning("Could not register som GPIO expander LEDS");
0 b8 _1 L2 }) ?3 {1 l) m else
9 [+ C/ I7 F V5 n printk(KERN_INFO "LED register sucessful!\n");* O) G/ j3 \' }( H7 x2 @ i
! N; w) p- m1 ^5 w$ G! n3 b' z- h5 ` return ret;+ ?# X. k1 k* C9 I/ p% f
}
! E& f! U/ {+ z+ B7 K6 p
5 W+ ]5 I2 x0 Q( bstatic void __exit led_platform_exit(void); D( Z7 b$ b: g/ {' S0 U, e4 c) h
{
1 z" N6 e3 r" [& `# S! k9 X+ J2 } platform_device_unregister(&da850_evm_tl_leds_device);
) A( G0 _/ I+ x4 Y+ s( ^: \' N9 M H9 b q
printk(KERN_INFO "LED unregister!\n");
% j# Z7 T* l" l$ N: a5 i2 R}$ \' p( O8 C% P/ _
1 P- K" P3 u& S( {/ r& p2 s) O4 S. Umodule_init(led_platform_init);
# w0 e* k/ ?+ ^2 s2 `module_exit(led_platform_exit);
' |: q. A& i) |, B2 N- Q7 K" _! M; w6 o3 L2 x5 l' K
MODULE_DESCRIPTION("Led platform driver");2 ?: f" T3 p7 T) l
MODULE_AUTHOR("Tronlong");
/ z: \- R) F3 p3 c3 F2 Q& y+ r+ CMODULE_LICENSE("GPL");' m% k6 S: i! t8 N5 Y
1 c& O9 g# z8 y( a0 k& \& s
|
|