|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 I0 G4 f1 v& T3 T( s/ c" V5 ?
#include <linux/init.h>
0 i5 k/ m$ S* j4 m4 r6 s! ^#include <linux/module.h>
5 [, I% T! q: |$ s& w#include <linux/kernel.h># x! b4 G# W6 }1 i
#include <linux/types.h>
' w0 G* u# H) f5 K8 z# K#include <linux/gpio.h>( R* ?, O* j( T# Y0 P/ ]2 _8 f" P$ P
#include <linux/leds.h>% N. y4 I: v( r \9 V1 i
#include <linux/platform_device.h>% A7 g$ y! }! t
6 n9 d, X# c8 t9 h#include <asm/mach-types.h>
x( u9 ] u8 w2 ^#include <asm/mach/arch.h>& v6 h4 G% z$ @& l* e3 y
#include <mach/da8xx.h>3 [$ b# l$ `7 g2 s% t7 e
#include <mach/mux.h>
* B8 \4 O3 p) [: |) Q& l7 e0 h. X4 P5 b1 e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" a% t* r; T" V5 v4 e9 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( E3 a& k1 [$ e: t$ ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( V" h9 x. E; s* F- c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' o- u' {' H% J9 J9 ^
5 v5 |' f% a: {: ?' H8 u/* assign the tl som board LED-GPIOs*/6 p1 g7 p; m0 Z" }- g4 ^
static const short da850_evm_tl_user_led_pins[] = {% B1 Y+ Y- A' j* M1 ~3 W: @
/* These pins are definition at <mach/mux.h> file */) t; v0 V" \3 c/ M5 v/ q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ y( s3 o. [& i( g: M- G4 Z -1
+ M9 ~- [, ~! c( M5 Z$ v};
6 Z* i1 {+ ]( n- I; V' }6 h! l/ Y1 Z" E; R6 X( L* J7 x- c' R8 x1 P
static struct gpio_led da850_evm_tl_leds[] = {
0 s7 U7 @3 q: ^- a9 Y n4 ]7 W {
# Y/ F N2 ^7 z .active_low = 0,5 R1 n ^# S" M2 m* A
.gpio = DA850_USER_LED0,
: `% D! M- h3 n1 e/ M9 k5 l .name = "user_led0",
' y8 ^3 j) O! r( n5 o' A .default_trigger = "default-on",
& z& {9 x7 z# L$ z },1 }1 s6 m9 s7 x
{- Q7 ~* u, W9 C6 W! O/ a6 n/ _! R. \
.active_low = 0,( K" E; R f2 h; G6 {7 Y: ]
.gpio = DA850_USER_LED1,. }# [ d' v# d
.name = "user_led1",) V& w3 M. w" |$ q& y* {; E! W4 w
.default_trigger = "default-on",
' Q- a ?3 \6 m, h3 B' O },3 A$ y" d$ ~5 d: M
{* X. Y9 g5 C' M/ d) G j
.active_low = 0,
2 Y& i( N* W' N& D7 u .gpio = DA850_USER_LED2,
# [! }' [5 }$ h3 D3 i* T" N' U9 E, f .name = "user_led2",# ~4 _ k' @/ R. V5 U9 U- y$ ]
.default_trigger = "default-on",
`, w- K% Y# T4 r; o }," \0 T5 z" y* |1 p6 X
{
* [1 S& z1 z7 l) `3 ^" C .active_low = 0,* N! r B O- p3 m, m: F
.gpio = DA850_USER_LED3,
+ A: r3 y) T' J$ D1 L7 B( p2 \ .name = "user_led3",
) ]. G: V$ b( d6 {) j .default_trigger = "default-on",
) [' y% n4 R/ C+ N$ f },6 _# u6 L% E2 K$ |& l, k6 I
};
/ K) }- w* N! e7 H$ a" Q# e8 ?# [
. J0 `/ i7 Z& ` t4 d( O3 _" {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 w$ U Z2 L2 J) J! q .leds = da850_evm_tl_leds,
, V5 x3 V7 m4 W9 h0 N Y9 P, G1 N) ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( q: q7 [ F# ^, n) R& _
};
( A- c6 x$ o4 ^
7 |. R8 o: u* x1 Istatic void led_dev_release(struct device *dev)
6 |! v0 L. e0 @! n1 O3 f) x{1 U: \7 l4 K+ W2 K0 _6 x$ B0 ^
};
+ N3 d: d7 T1 x- Z& u/ X
# r. @- r: g5 m0 d$ z0 ystatic struct platform_device da850_evm_tl_leds_device = {( y1 V" B% Y% f! ]
.name = "leds-gpio",
! |& V& f1 [/ P/ F1 \# y .id = 1,
, ~: s3 m4 g) s- i$ K7 W/ X .dev = {
; F; {) _% x/ H: i n .platform_data = &da850_evm_tl_leds_pdata,
, ~$ O5 f9 K. u6 P .release = led_dev_release,. I, B1 a7 x$ \- e' j7 e+ e+ R
}
) S* X; t/ b, y) @0 U" ^6 _) k};
2 }9 g K4 G4 M4 v1 e7 W n* d
8 D U* J1 h. @3 ^static int __init led_platform_init(void): A/ O, Q- D" H) X- c( C- M
{
4 u# N+ o. Q5 i/ q1 Q int ret;* h, C, n$ P3 M- U. m
#if 0
2 M+ E% C+ _7 {0 C; ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! v) ?. m7 |- G$ V
if (ret)
# m* Z6 E: ^8 ~/ v% ?0 q& m! S+ Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 Y+ F0 c2 _' k1 c1 H3 Z "%d\n", ret);: x8 U, q0 G' a& e# E" I$ G
#endif1 K9 C4 _6 }: U7 J
ret = platform_device_register(&da850_evm_tl_leds_device);
3 H, t! g; B5 a7 s2 C% { if (ret)' K- F5 D+ ~% f5 o* ]7 f4 u
pr_warning("Could not register som GPIO expander LEDS");3 v* i! L; S- E
else
5 h- @; I: ?; m+ h1 ?0 z printk(KERN_INFO "LED register sucessful!\n");
7 [5 R$ t+ R" [7 y7 H) P* h$ K+ }4 _$ s2 I- f! I2 n2 R4 q0 }9 F
return ret;
' N; P2 t8 {. a# t9 H7 ?. X9 w}
- ?0 \% M/ p; Z1 x5 k: A' V0 w: O* C% U5 [, {
static void __exit led_platform_exit(void)
' H8 R% x8 `% j{* T+ `! U/ z3 `% q1 D8 F8 t
platform_device_unregister(&da850_evm_tl_leds_device);
( X n( d2 j! U2 T1 |
k; o# D( ]" \ printk(KERN_INFO "LED unregister!\n");
+ _& G, H3 w7 k: I}
! F$ p; M& e" P, O" J1 c! e, ^' R
/ `4 {4 N: Z% z. ^! L4 U+ Wmodule_init(led_platform_init);
8 W; w6 d) t" J1 g. k! Dmodule_exit(led_platform_exit);! U( `9 f" J" X& B* @& c ?
1 M V7 k5 |2 t# M/ `, J" o9 C* AMODULE_DESCRIPTION("Led platform driver");" f7 v# j' B! I$ Y
MODULE_AUTHOR("Tronlong");* N- }- I5 {" w0 L$ b) z. H% y
MODULE_LICENSE("GPL");! n6 @+ K- `! M' q
4 `3 I+ X4 g, l j; W) u$ r
|
|