|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& u& }( k$ V4 C2 t#include <linux/init.h> w9 k4 K" s7 V0 C- E4 Y
#include <linux/module.h>
4 V1 l. k% h: \( c8 R' x#include <linux/kernel.h>
2 Z) I7 [2 I. v* T) a: Y#include <linux/types.h>) V; t1 \, z$ i
#include <linux/gpio.h>
# p7 Y" |# w) ]6 Z' f5 T#include <linux/leds.h>9 k5 p+ a2 _; l1 s9 r3 e9 w
#include <linux/platform_device.h>
. @+ p9 A% b- Y3 b5 W0 _7 ]2 A' R/ ?- i% D2 p
#include <asm/mach-types.h>
E2 S' p5 l2 ?7 _( M$ k, ]#include <asm/mach/arch.h>
$ K$ p7 `$ ~1 W* L; Z" K- z#include <mach/da8xx.h>: F. F9 T- q& [7 q$ B! N
#include <mach/mux.h>
" Y3 L4 x1 P6 g# d" e/ E1 H. q$ n% {0 H; |# D; _' T8 s+ Q: C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 q% u: J. {# m$ {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' h3 I" q8 s/ |) ^4 f R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; V9 o2 x# R; q7 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 x3 Z. W0 Y+ y8 O9 V: f9 p
2 a P5 @- u3 f* \* N& @1 a
/* assign the tl som board LED-GPIOs*/) Q% z+ A4 v+ `' n2 E- i; [
static const short da850_evm_tl_user_led_pins[] = {
, A( W$ F; |9 t /* These pins are definition at <mach/mux.h> file */
* G9 r/ t' S4 T I" ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" \& v3 D8 F# C7 [ -1* o6 V% M% K* C
};7 y3 a# S& j1 s% ~. y( m
9 f! g5 B; k# B3 [" j* s& y* d
static struct gpio_led da850_evm_tl_leds[] = {2 R1 ^$ |% ^/ [# @3 {: k: }
{' |, m! ?0 L- x2 `2 x0 N
.active_low = 0,, H+ t* h2 Q% s& V' p$ v
.gpio = DA850_USER_LED0,* K% r% h3 e; J$ s/ U7 P
.name = "user_led0",0 ~/ f! r5 x$ R1 f2 C4 x" D
.default_trigger = "default-on",/ G/ l% W9 M" z2 x) B& Z, R
},
* o1 e6 y4 b2 e+ i! N& y* m: P {8 v- ]. W* {8 X" o& S% l
.active_low = 0,5 _8 m# E$ p) ]6 }( I! ^1 y
.gpio = DA850_USER_LED1,+ h3 R1 ` f* F& t" M5 Q, M2 }. ?
.name = "user_led1",! o( u+ D- ^( _
.default_trigger = "default-on",
. t2 J. N k: \8 b( o },
- F F$ E7 |2 t' Z% U" O {
2 U. o( ?6 y. \: A .active_low = 0,
+ Z7 L3 o P, O% o! d .gpio = DA850_USER_LED2,
& y/ U+ r9 t9 M; K* g- ] .name = "user_led2",
0 u* g4 ^4 o6 s6 n" D7 s .default_trigger = "default-on",3 M! e( ^, ~) w% j9 H; M
},6 X" k* x( j+ R3 u! y0 E
{5 |2 g2 ~" o7 q0 B! A& v' f
.active_low = 0,* q0 i3 S/ J% [5 t: ?0 H+ {
.gpio = DA850_USER_LED3,
$ k5 |' Q- B& Z6 S .name = "user_led3",( e0 d# l/ N1 k( H
.default_trigger = "default-on",
, X" R0 \" t& N! `0 c) q1 e/ u( Y },' y: Y# w2 d: ?, c
};
6 F1 p0 @2 H" a/ i$ ?# b, E2 s! D0 j" c' D+ b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 X5 [$ J2 c7 G2 E6 `
.leds = da850_evm_tl_leds,
3 x$ E' F! B9 V T; B( i+ y .num_leds = ARRAY_SIZE(da850_evm_tl_leds), O/ A$ u& g- ^
};3 x, T/ s/ [+ V8 S& L' {& d2 r
" w6 n3 H1 P7 ^- b0 G4 B$ G2 T9 qstatic void led_dev_release(struct device *dev). E8 ]; S+ K6 u) {
{
( q7 m# o' o4 k2 s; m& g};
% G' k k/ J0 ~$ `, z+ ~! ^4 Q5 _7 D
static struct platform_device da850_evm_tl_leds_device = {
6 F1 q& Z Y" l .name = "leds-gpio",( j& F" C; K+ P, N
.id = 1,
, H- ?3 q& O/ s0 W; t5 } .dev = {/ J- e8 D" o/ h7 C7 h* V: d1 L
.platform_data = &da850_evm_tl_leds_pdata,0 `7 U% B1 K6 y( A2 C
.release = led_dev_release,
! Y" y' L- U. m( n6 i; z1 K }' p1 y+ p% U1 a* y
};
, x6 C9 G( V* Q" ~/ K; ^0 B* U; X- @$ ^$ o8 x8 g. Y) Y0 ?
static int __init led_platform_init(void)& R1 j4 |! y5 h% C# d
{0 t: v7 R) p ~; g
int ret;
' ]* [; s* F8 P#if 0' p" f- U& K+ |" q3 [: Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( `8 f; d1 s# M: o& k6 [- U
if (ret)
c' g3 V, y7 u7 A( m5 C3 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# {8 U, W" y5 Z3 r "%d\n", ret);
. n: L3 P3 T1 T+ N#endif
! [ f( u$ F! \; B8 A. U; U$ C$ l ret = platform_device_register(&da850_evm_tl_leds_device);
6 Z; N& Z( @5 I! A/ y- S if (ret)% @0 x7 d/ }7 k& P3 M$ p# k* n9 G
pr_warning("Could not register som GPIO expander LEDS");6 K; [8 P) p' y, Z' k% ]( d9 `( k
else
, R, ]1 J5 B& M% x+ f$ f printk(KERN_INFO "LED register sucessful!\n");
# R4 r- I$ @. D: v" u$ t# s# M. i$ V2 i- [( r
return ret;8 y i7 e# e$ W8 }
}; h' D4 s m4 D) @
$ B y( y( b, a8 d5 ?) J# H Lstatic void __exit led_platform_exit(void)
+ X0 ?3 _, ^- O3 R* D, J! ]{$ w& x# V9 K8 k( E$ X2 `
platform_device_unregister(&da850_evm_tl_leds_device);' p K6 i. i- Y \9 ^6 L; j
5 c( d S" @; B& T; a$ Z- L printk(KERN_INFO "LED unregister!\n"); {% l; Z/ M; V- t" G; x, r6 m! x
}5 o6 C* N/ h2 F+ S
: x) J3 L* E$ y, v8 i2 _module_init(led_platform_init);; G% M5 Q% `/ m
module_exit(led_platform_exit);5 h$ @. Q$ n; w1 M8 h( G! q8 p, |
* s/ H/ G8 [5 R7 qMODULE_DESCRIPTION("Led platform driver");
2 ~* c! Q0 X1 \/ p7 M) ^ oMODULE_AUTHOR("Tronlong");
& [( r( P% l# B2 t6 q% x! hMODULE_LICENSE("GPL");# W6 L& }% f! |# t8 @6 |
& ]( C% y' U- P) R |
|