|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 m8 D5 D+ a* \( g' N' c& h2 H& S3 [
#include <linux/init.h>( x# P9 P; ~2 ]- t( h6 E5 M
#include <linux/module.h>
0 G1 [# |' r0 a' O, z# G#include <linux/kernel.h>
: f& m1 ~3 |$ Y) @; N, G U#include <linux/types.h>& Y! ]! z; g l* k" c; C2 g+ v
#include <linux/gpio.h>
, O1 C8 m) ~1 q8 n8 X#include <linux/leds.h>
7 R; s# ^9 `+ @" v: b+ Y#include <linux/platform_device.h>- `! C9 e/ ?# [, F( \
. ~5 N R9 h6 k. W" _. I#include <asm/mach-types.h>
4 f* q- W- V( @ W! M#include <asm/mach/arch.h>
- d% g+ d4 m2 d# P/ Q H( e, W. \6 T#include <mach/da8xx.h>
: U" h9 }3 K3 Q+ @* g( n; }3 n#include <mach/mux.h>& y2 i5 m. i- @2 v0 Q4 h
% \3 X2 X, ?, n' D" ^; X, G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 x8 q0 J- Y$ A F+ n8 j Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 u* K& ? }% A5 N4 _0 r/ ~& R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); L& p; q# J+ _5 h H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! h3 P% n% K3 A1 v
3 C/ ]5 s% c) s' H
/* assign the tl som board LED-GPIOs*/
" J% B) Y. s1 d+ u# hstatic const short da850_evm_tl_user_led_pins[] = {
4 `1 q3 }. r2 y1 `" k% y /* These pins are definition at <mach/mux.h> file */: f7 [) W, \5 d1 O' ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
b/ s6 Z$ B; f3 g! L -1. l* J0 `9 |" N) a1 y
};2 ?; S& W$ S2 t3 ~" E# m3 ~( t( G8 s
# i+ k) `1 f2 z9 M* Q5 l7 Pstatic struct gpio_led da850_evm_tl_leds[] = {/ c4 D z; j3 x8 v: N( P
{3 ?# {( g& i* h7 h9 w1 Z
.active_low = 0,
! h4 X1 L1 H9 x8 }1 g .gpio = DA850_USER_LED0,
% j: X" y4 x& D; n7 v! ^' Y .name = "user_led0",
" T/ S1 q/ Y+ s, @9 n .default_trigger = "default-on",
& B1 e& |+ z' z },
" u6 E9 J; o$ c) Q* b6 R8 V {
% K# U- n1 b9 T. ` .active_low = 0,5 y5 W" c; Y! a7 @
.gpio = DA850_USER_LED1,$ J0 K" k& \( M! J5 b* g
.name = "user_led1",
$ R' f3 e0 [. F5 | .default_trigger = "default-on",
; b: g! [' ~; z6 i" | },# z4 Y1 A3 U1 y
{
8 l, x: y E) U* ]+ M .active_low = 0,! O2 ~5 ?, s E
.gpio = DA850_USER_LED2,( B& ]( P. J: ?0 I" L0 x
.name = "user_led2",1 l' ~, B" v7 s
.default_trigger = "default-on",3 M$ U! U; H) R% X% L* D" S
},
& K1 m ]2 ?1 f. Y; O3 n {
- B+ _) s; n O6 C. \- X6 [8 O .active_low = 0,( e2 [! G: t) W* M8 L
.gpio = DA850_USER_LED3,5 l3 U- c$ C3 b: S
.name = "user_led3",
: R. V! N5 n, o4 t, d E, ^ .default_trigger = "default-on",
/ T4 |9 ?# B: \1 P' v2 X/ \7 f },+ s4 Z, ~% o- }! y1 m: c& K* L! I
};# |. \" m2 M4 w7 H4 s8 J4 P
U5 K2 B8 D/ x, q" Z: {7 ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { ~# t! I' q: {' U3 k: Y1 N; K
.leds = da850_evm_tl_leds,& S# O2 {" \% Z4 d7 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* A8 p; w- t6 {- M) j3 Y0 K};
& B2 B- n5 U: X+ @, `/ P# G
4 k3 M3 `2 W) n& A, }static void led_dev_release(struct device *dev)* w r. v# E3 A+ V; @3 J. M$ G$ U0 t
{
4 _0 Z$ |# g5 @2 }6 U, w; d+ N: [, G, ]};
1 l6 n5 g1 b4 E" ^; {
! J4 V4 [- v0 G' c. ?& Xstatic struct platform_device da850_evm_tl_leds_device = {1 r* G: l$ ]. a, X" B2 x
.name = "leds-gpio",' {* g: y' a% _2 O \( K1 W
.id = 1,2 [' I7 q$ w7 O9 m# f
.dev = {
" J8 T2 j4 h6 l9 ? .platform_data = &da850_evm_tl_leds_pdata,. U. {0 X- B H& J- `
.release = led_dev_release,
2 p( p7 C1 p+ _. q }: n' R6 a4 G- N9 B' H/ X) I+ M
};
! U+ E d6 l# K$ [' @7 W
; N1 |: Z3 N3 Z1 e! T1 @2 Qstatic int __init led_platform_init(void)
7 p2 g1 v* v' [% L1 t{, O' k! J; S& l5 g9 R2 x
int ret;" m- t% {0 w' [1 r1 d
#if 0
3 l. A' V0 z2 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- b. ]( u a, W* @ {" ^
if (ret)
! j0 Y) [% F3 T# ~" @* @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* O6 P. A* k F4 c, l "%d\n", ret);( J+ u" L$ Z5 ^$ o. [( u, D q
#endif1 @0 m. Q {/ f z
ret = platform_device_register(&da850_evm_tl_leds_device);0 B, C0 U: F& ^1 D9 V2 Y" z+ M
if (ret)% _1 Z. B3 W1 e) m. N9 K
pr_warning("Could not register som GPIO expander LEDS");
' L) r9 J8 n. r else
/ P9 Z5 G. H) V) o4 Q printk(KERN_INFO "LED register sucessful!\n");
0 R, n' v$ e( H5 [, e' b1 |) c4 G: \6 D5 F* O% T3 V* w$ R5 R
return ret;) ^6 j+ M2 F# V7 ]: \7 b! y+ ?
}
" u) }: a1 |$ D; S( S4 @% {( O3 g' J5 J) ]
static void __exit led_platform_exit(void)
; t5 j- t3 G! Y; l; g6 U{0 n& [' `7 _; T# ?9 u
platform_device_unregister(&da850_evm_tl_leds_device);+ S- N7 d5 F: t9 g% \( m7 |
7 F5 y) p- L( } ]
printk(KERN_INFO "LED unregister!\n");: E, Q8 V& K2 B! \, m* \) e6 i
}5 w6 } s! L. [1 F( D" l3 O
( X( E! F% {9 ^1 Fmodule_init(led_platform_init);, h0 _$ k- }3 G/ b. W1 g
module_exit(led_platform_exit);2 A' j2 Y8 q; l1 F" u; F& |; w0 m1 x8 @
/ M! M: I; F7 Z* G; YMODULE_DESCRIPTION("Led platform driver");5 X3 K* K) a1 S' p* {
MODULE_AUTHOR("Tronlong");
* {& ~' }( R% o/ D. zMODULE_LICENSE("GPL");5 n4 s3 r2 L% X q
, ]( F/ D( L' w' A! n |
|