|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ z% U' l. t% e" W' |- Y3 P& P
#include <linux/init.h>5 j& o& g$ n. C2 U7 s
#include <linux/module.h>
6 o! y) c4 O- d#include <linux/kernel.h>" G7 k2 q$ ]( N! f4 A" e' I
#include <linux/types.h>% B; ~ H" q2 ]+ g2 T
#include <linux/gpio.h>9 O4 ?* l! C/ O! |, E& S
#include <linux/leds.h>5 ~: p+ Z8 A4 v& F, D
#include <linux/platform_device.h>
% Y, x' z* t* U2 y1 s* Z$ n- R% U, ~# h- q3 L+ [
#include <asm/mach-types.h>
: k! f% a( U# G$ L#include <asm/mach/arch.h>
5 y. }7 V; l- Y9 a6 k5 P- j#include <mach/da8xx.h>$ o# S( N* u. R7 j. h1 Y# i7 E
#include <mach/mux.h>
! t( U2 K- B0 }6 h9 @4 V) G& Y3 ^! f$ A; H3 c; k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 \* R/ ]2 P/ C) g! K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): ~! W- f7 N" h4 s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 z! I% P, {* e1 Y! |1 S( U" k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 m1 Y7 {. Z% H$ Y
2 [2 V$ K* i- g/* assign the tl som board LED-GPIOs*/
4 T/ F) O/ R! `% Dstatic const short da850_evm_tl_user_led_pins[] = {
/ \: w% T/ H4 J8 n" O /* These pins are definition at <mach/mux.h> file */
0 d( N; X4 ]6 d9 K! Q6 H9 S7 | { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* g6 e) ^7 I6 W7 ?+ C# q3 p5 E6 [ -1
6 w. Z/ ]# b( R& Q3 Y};
; p2 F. d* k! N' u; ?4 d m5 {. T/ M% \* L0 H
static struct gpio_led da850_evm_tl_leds[] = {
( O* V4 @( X, \4 D: n q- C" U {
. G5 b) t/ r) Q4 m .active_low = 0,
) L" E( n, W! o$ ?; R# B+ u .gpio = DA850_USER_LED0,
: j0 \5 R6 |: d3 P8 R- N .name = "user_led0",
/ a. H( A% s% {; k* G3 B .default_trigger = "default-on",
' m1 O% L! f# s$ b },3 x3 L; k3 j0 ?0 x5 ^
{4 m5 w' T) j) C$ k
.active_low = 0,
- L% p3 x5 h3 w1 z* ~9 N' {3 e .gpio = DA850_USER_LED1,
0 Q2 L ]+ y* K .name = "user_led1",# K! \" M) C7 T4 R6 f4 p @
.default_trigger = "default-on",
5 [( Z# l: Y, R6 i9 v. ? },
8 N% @5 u# n! v3 V2 E {
' _2 g0 V2 S3 T% G .active_low = 0,; A9 {8 z, @9 Y3 U& a& u! d
.gpio = DA850_USER_LED2,
r4 C8 h5 D$ ]$ n0 b .name = "user_led2",6 Z9 i# T* O9 ^
.default_trigger = "default-on",
# n# c: b1 |2 a1 c },
, F `. p& u6 d4 ?8 b {
( A4 c4 T, ~8 q% J. V$ s; F .active_low = 0,
" U l' H" G2 ?8 R, _ .gpio = DA850_USER_LED3,1 }1 d6 T+ A. A7 @
.name = "user_led3",
. ]5 Z' }+ c/ S .default_trigger = "default-on",1 E! L5 B: A# e* T' h: x8 ?
}, g9 t3 ?& A: A) G) ^
};
+ F2 M8 b( W9 s. \( {: y! c5 }1 P9 g+ }$ [4 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% W" a6 k( x V .leds = da850_evm_tl_leds,
& o- V& Y. ~+ s( X. B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; J/ a: V+ D3 n1 [8 o};& G Q% ?$ ] f. N
9 t% U- u& l) G* A* Bstatic void led_dev_release(struct device *dev)
$ _$ q# K( c. ^ x( @4 ^! g9 ~/ i{
$ I+ D: D y1 [- h) q# a};$ g* d4 X: b, I2 g% L( X9 k* g2 ^$ Q
1 E4 Z* ~1 m; |/ T
static struct platform_device da850_evm_tl_leds_device = {
3 w5 F% P2 G6 x" v( j' q% |! T8 a# d .name = "leds-gpio",
8 d( |& Y# G- W, j .id = 1,
+ F# \) w6 w* V3 A2 N; ] .dev = {
}9 p4 n) L# T4 Z/ `/ u .platform_data = &da850_evm_tl_leds_pdata,
: _ K/ v. h3 @ j" f .release = led_dev_release,
) r# {6 y5 [. H% d6 Z1 |$ h! | }
$ S' e9 Y0 K5 I4 K6 ^3 g};8 M) w4 |% b4 t4 l, l) m, R; Z
* V# x! `# _( ~' p
static int __init led_platform_init(void)
' W, N- @% ~: \ S{
) U$ P1 w" {3 \! `; T" f int ret;4 @ q# X9 d& e. j4 N. u
#if 0* Z3 d$ N, I1 U) w: g* z) {: N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 o! h# J O. N6 k
if (ret)
5 B$ `- i9 r0 T, V& C: V' }. k pr_warning("da850_evm_tl_leds_init : User LED mux failed :" a% Z2 L, s4 D$ k
"%d\n", ret);
5 T/ [4 x$ Z. g#endif
( a: g8 o: N& e+ Z" S ret = platform_device_register(&da850_evm_tl_leds_device);
5 ?# }$ D3 j3 W, W! v# P if (ret)
3 r6 }4 N8 s3 I# m4 I pr_warning("Could not register som GPIO expander LEDS");! A6 J/ q, o8 e7 G& L4 `
else3 P; q' j e; S3 y8 C% j3 d! K% M
printk(KERN_INFO "LED register sucessful!\n");# `- @ U, Y7 n f O# }
7 j9 ]1 h9 X4 l return ret;! S6 x2 Z" {/ E3 }/ o, @; h
}
7 M, C7 o' ?4 F8 X/ h
+ ?# i+ ~/ m$ b/ qstatic void __exit led_platform_exit(void)" v/ d& x3 A+ W/ B9 [2 U# T
{
7 @, o- y. I# T: i, O: E, X- K platform_device_unregister(&da850_evm_tl_leds_device);
' x+ L6 u# D! A& O r. n9 L5 c! s- @
printk(KERN_INFO "LED unregister!\n");6 U- O) O# a9 x4 \
}
" \3 I. z3 |+ Q5 Q! I/ F# u8 Y# e8 h* X$ L
module_init(led_platform_init);7 |0 {& |: n8 O( U' I- ]
module_exit(led_platform_exit);
+ S$ ^. K# b! H$ |2 V0 Q R' g& _6 G9 ~
MODULE_DESCRIPTION("Led platform driver");
5 D" @ f( o4 c" _" YMODULE_AUTHOR("Tronlong");$ g5 P" l5 Z7 d1 x* r" e
MODULE_LICENSE("GPL");
5 R3 g# y$ b, T0 u
% |3 S! e6 ?$ j' a2 g |
|