|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- k8 V3 h* D g- a( I#include <linux/init.h>7 t0 R" u/ R9 M/ ?( x- ^4 {6 A3 v
#include <linux/module.h>8 V& q( R4 q1 {3 u) @5 F
#include <linux/kernel.h>
2 T$ y( ], T* v$ w3 B#include <linux/types.h> G3 R6 j" ]8 X& B! D" r& R: P
#include <linux/gpio.h>" K P( l0 j1 i; e
#include <linux/leds.h>2 \$ T3 d( l! z' V0 z
#include <linux/platform_device.h>
; c$ W9 @, s* D: H$ D$ F9 G- |2 n" h1 k3 e& T! _+ T& A
#include <asm/mach-types.h>
: R9 x( k' U, o#include <asm/mach/arch.h>- R- f, {8 }. F! M. ?% r: V
#include <mach/da8xx.h>
! g% V9 ^% C( e% `; T+ y3 x#include <mach/mux.h>
2 s X2 ^! W c5 e X: R3 O+ Z# U2 h3 | b' e% ~/ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" \. B8 Q! c8 I, O9 T7 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 m4 O/ I9 a1 T/ U( C8 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" D4 R o0 s9 P. |2 y( i6 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 w9 N( m- U0 o! c' C
Y) d. B4 ~1 d7 T* X5 S) {/* assign the tl som board LED-GPIOs*/
& N: d: Y; m, z; g: }0 e7 r. p2 D3 ^static const short da850_evm_tl_user_led_pins[] = {
3 f0 Q. o% i; H7 T4 i2 B9 C/ C /* These pins are definition at <mach/mux.h> file */4 ]( F, C2 t# z( G& x3 `( M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. H; b d5 h+ ?# z
-1! |# k$ \ \1 N5 R3 L
};
+ w M0 m' p% t/ ?/ e C, A- ?
; T7 c" }6 V4 _" w6 }static struct gpio_led da850_evm_tl_leds[] = {
( [7 Q& q5 C: V. {0 C1 e {7 s1 w0 b8 _# [* O2 z$ O! W) U
.active_low = 0,1 v! n! f& f3 O- L- E& x7 V" O
.gpio = DA850_USER_LED0,
, ?" O* v$ G6 Z) h- G .name = "user_led0",
) m( u8 m8 N7 V6 r4 z2 y+ I .default_trigger = "default-on",
! s+ o6 A5 x n1 s( d6 I },
1 L4 ^# s" K8 ^ D7 f3 I4 E {
, p* g) \ u4 R+ P# x/ O u, n! z .active_low = 0,+ \& S @9 L y1 H: a" k. P
.gpio = DA850_USER_LED1,
9 m& H2 _* d* u N, j+ Z .name = "user_led1",
5 N; w- c& t; N1 Z* @. _2 A D .default_trigger = "default-on",
6 V1 h- Z% G$ p/ }% l },) b$ c" ~5 M4 @1 O
{) W1 {* p5 a7 L. ?9 X' p
.active_low = 0,0 S, ^4 L6 n7 D! k7 A! g' t: K
.gpio = DA850_USER_LED2,
# C5 x) N q- u6 T* F; @: x .name = "user_led2",
) w/ n3 b/ i( a7 L- I! d .default_trigger = "default-on",
& p T# w8 W, Q },
+ }2 T- X' g5 i* h {1 b+ S: \8 ?$ A0 a: g* o9 w, \8 F
.active_low = 0,
7 P' Y% v$ @# F- n; V Y .gpio = DA850_USER_LED3,5 O1 n A+ V* Z" g: v+ {% O b
.name = "user_led3",& N5 Z4 T: y' o, X7 c& z) Z+ `1 G
.default_trigger = "default-on",
, b2 {! W; Q" P1 k6 @3 e },
$ o3 M( v3 q: `, f* j3 y};, N9 h( w' k2 `* U& a
" b, ?3 Z* @. v' ^' U; Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ I; T* _2 N8 y; ^
.leds = da850_evm_tl_leds,
* a: a1 D/ {8 T2 o* x( @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ u3 R6 D, L& |# ]1 Y+ V
};
7 X) v J: G* T: Y, A) K5 m+ h+ T
/ e: S6 B: c1 q f1 _static void led_dev_release(struct device *dev)
2 J2 e' T8 F) u& p' K7 t{' X F% `8 R( ^& y' r& y) i4 N
};
; N4 r: [7 l. @4 Z* U0 c
; J9 k/ ^" v; D1 ostatic struct platform_device da850_evm_tl_leds_device = {# @1 d" h. e8 M2 K
.name = "leds-gpio",& U+ x4 ]3 a$ y; j1 y
.id = 1,5 [: R8 b, Y, h9 z+ ^' A3 O+ Z
.dev = {
# J# C- r1 |7 N0 u! Y' l H .platform_data = &da850_evm_tl_leds_pdata,7 |; l0 c& @8 a/ a$ N
.release = led_dev_release,
: h4 E* J+ u8 `6 C3 M. x _ }+ a6 l' G6 q2 M6 A5 o
};' b& u4 ?3 E' y- R9 u+ p2 K
7 d/ c) ~& f" E5 S$ `: Bstatic int __init led_platform_init(void)
$ R8 w: A2 \( q `4 C, F{
: B& C' T, }- {. E7 J int ret;$ G* C) d$ `! d" W
#if 0; l8 m4 g" O; j' {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 T$ m3 U( U! p5 |$ z- L$ X" b1 T if (ret); |" R. I( e+ t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& V1 m* z# e3 {5 d# ^ "%d\n", ret);
7 d3 l2 ^4 _! z#endif# b& v: |$ F! y4 |; L' x
ret = platform_device_register(&da850_evm_tl_leds_device);; e+ ?; g% a4 ~7 Y v1 F% `& S' l
if (ret)( J# F4 O/ @8 t3 S
pr_warning("Could not register som GPIO expander LEDS");$ }3 S& W: @" u
else
' G9 c2 r% n# m' X. x/ r( q. r7 ^ printk(KERN_INFO "LED register sucessful!\n");
, O; [: d5 k9 p/ D) e8 m
l+ y1 T! q& Q( M return ret;
2 L) ^$ t, h/ F- w6 l2 ~8 {}* u& ~6 O" p9 d6 K0 V) N
+ s, _ Z& y1 W: i6 mstatic void __exit led_platform_exit(void)+ O7 n$ R( y# }: _/ F. t6 \
{0 s3 ~8 C( ~9 z" [5 P9 A
platform_device_unregister(&da850_evm_tl_leds_device);/ W1 ~0 C. P& Y. r5 y7 s* q
1 x; c7 F7 u3 w {
printk(KERN_INFO "LED unregister!\n");. M9 ]' M; ]7 o- `
}
! W; J% O+ G' d' L0 _7 ~7 h3 a* Q) _2 {
module_init(led_platform_init);
( f# x9 O' } l. C' _module_exit(led_platform_exit); }1 x u1 T: n* f" M
4 F6 W" h) R% j2 R0 f8 V& |0 g
MODULE_DESCRIPTION("Led platform driver");0 X0 v) f. }2 {, C7 _& G
MODULE_AUTHOR("Tronlong");
2 [5 d3 d& V o; W% e2 I0 {: A( `MODULE_LICENSE("GPL");
- O$ H5 T: [8 j/ \4 N8 e9 L
6 P2 y3 l7 N+ A5 { |
|