|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, H5 Y8 u# T+ z, q5 g/ ~#include <linux/init.h>% G% J' E4 [' H0 f" ^' p
#include <linux/module.h>
" Y' A2 S3 Z1 U9 ]; s2 z( B" T6 J#include <linux/kernel.h>) r" L& n& E7 {7 c& s+ a
#include <linux/types.h>% M1 N K5 \* H) e5 j
#include <linux/gpio.h>3 t$ M% X; b8 w \
#include <linux/leds.h>9 P9 R! V( a! _, B% D% k3 v
#include <linux/platform_device.h>
- s6 Q! w" m* W+ Z2 G! j- v0 O5 U# S' v1 h9 C
#include <asm/mach-types.h>1 a, P7 Y6 \6 e5 P
#include <asm/mach/arch.h>
6 T% `7 @+ ]6 N/ J6 ~# i# `4 {! Z# _#include <mach/da8xx.h>
+ Y8 j' }/ u0 v; n#include <mach/mux.h>/ D& u( z2 i+ Z* ^& {3 m
! l2 U: _7 W. s2 y1 R7 X# }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 p3 K0 c- w9 t0 l x, n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ E% t1 ?# C! v$ S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 Y- m* w2 L/ k8 ]6 G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& B/ n1 o# j2 l- ~. E `9 ~3 {) j
7 \" @! n& w6 a1 w' z/* assign the tl som board LED-GPIOs*/
1 q5 s9 n9 B7 [5 h% a# pstatic const short da850_evm_tl_user_led_pins[] = {6 p$ u6 J1 h2 D
/* These pins are definition at <mach/mux.h> file */- E( r% S( I/ O; c u7 t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& b( d' Z- P* J -1
! U$ [" c9 |# Y9 A};( f& O: N9 |6 ]1 Y5 F
h% F; ~( |9 i. e0 Ostatic struct gpio_led da850_evm_tl_leds[] = {1 E# z2 J, i; L- I2 @$ |) w+ |
{2 G) K9 q- B! w, V
.active_low = 0,
+ H3 ?" ]# o- e+ R .gpio = DA850_USER_LED0,/ m( @) a. S9 k& l5 n0 \
.name = "user_led0",
. C `- [+ A' k. `! ` .default_trigger = "default-on",
0 F- ]/ W3 @6 D Y1 o3 X },% M/ ?* c5 D" U; C& Q1 Z' E
{$ v+ N3 j( R( C# l" Z/ S
.active_low = 0,
9 t$ L2 z3 ] p6 C .gpio = DA850_USER_LED1,! |* q! ^/ A: B# Y! J
.name = "user_led1",
6 |& X$ D! F7 A; d .default_trigger = "default-on",
4 B; a8 U& }0 q- i& w },
8 ]9 k, \( j" w& H2 M {
5 S+ @4 }# L6 J" i; ] .active_low = 0,
% q3 G p9 R2 Q$ A% J .gpio = DA850_USER_LED2,) z- ?+ D' S s4 s. X1 m
.name = "user_led2", d% z7 B# l- Q; P. B
.default_trigger = "default-on",
1 \2 d% f& ~8 \4 K },
% |/ [9 ^/ n) O2 {2 R { L; C$ q' i4 F4 \+ O$ D8 m
.active_low = 0,
# K* q- c, F4 z7 Y+ \ .gpio = DA850_USER_LED3,( w6 I H6 z1 q$ Y
.name = "user_led3",
, T) W) A5 X( ] .default_trigger = "default-on",
6 y, |2 F. {, Z7 h- g },- ?$ ?) N# D: P9 L4 {" O$ V
};
9 f+ B9 U* u, n0 G, s
+ J: x9 F( c" o) O) O# tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, Y4 k6 x2 F f0 Z! m, C
.leds = da850_evm_tl_leds,* n6 q6 ~1 o. z/ D/ K1 s+ A8 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! X( I4 C# l& i7 l3 l0 K
};0 D( y6 Z8 _ m7 @1 F
; z+ z* N/ u, N5 p2 P+ j. J
static void led_dev_release(struct device *dev)' {7 U# E9 o0 I; D9 f
{
, }% Q2 H' k9 \8 Q; l! p* \};5 U- U0 T! ^1 F; C( k& Z; M
# @8 w( V6 j" E8 }static struct platform_device da850_evm_tl_leds_device = {& R# R5 Y9 R0 z! M) |6 A
.name = "leds-gpio",
+ F5 i6 c. T! S7 {3 a c) ^% N .id = 1,% w3 f# Z: n8 B% S, t
.dev = {
4 r- r1 V/ r9 k7 G. B4 S3 N6 c* u! K8 ` .platform_data = &da850_evm_tl_leds_pdata,
" j4 e2 q6 A; u( s+ j .release = led_dev_release,
/ h8 l! W. m- g. P1 k/ ^, e' Y8 k: H7 @ }
7 c. F- R/ }# M! J7 h l};* @) Z2 j% g t* M
) T6 l5 V0 S9 o9 c
static int __init led_platform_init(void)
" g3 u7 k* L3 L% y6 ?- t{" z5 M% A! y" I! l% D& a
int ret;
6 J3 B; z, [9 g- x# h% q: d8 L#if 0
% a, @/ \- S& ~ L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) O" ~' i8 X4 U- e- r4 ] if (ret)
. S- |7 m. H8 H- W+ j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 Q& Z& ?; u4 E% G/ F+ E
"%d\n", ret);* s# ^* s J a2 g2 g% p4 J
#endif2 F6 ~. j; D4 D/ N A, ?+ Y
ret = platform_device_register(&da850_evm_tl_leds_device);
( Q, Z% ~; g2 i( L if (ret)2 I/ I, Q8 p! k- Z; C) a5 y
pr_warning("Could not register som GPIO expander LEDS");
: ` B+ y R4 [0 V else* u. X8 ?6 F' Q1 `
printk(KERN_INFO "LED register sucessful!\n");
7 M, w# n. v4 E% ?* j/ n; M4 z) E( m& E: t+ e6 F$ E' x0 o
return ret;8 `( I( I" `8 x1 M% e+ ?, R! ~
}- w, U, j5 G+ C1 F4 ~* u
4 W1 t2 R' g* }. V J: U2 k: Tstatic void __exit led_platform_exit(void)+ i/ k. q5 a4 u5 S5 e. a' p9 ]& y7 G
{2 g$ ?5 ` ] S k6 T
platform_device_unregister(&da850_evm_tl_leds_device);
$ F3 t3 x: t; F
9 Y, z) W+ N( V8 r8 u printk(KERN_INFO "LED unregister!\n");1 E6 D' [3 L6 A; e3 }. E0 J
}, S& Y+ R5 U! S! c) N6 t, f
3 E* o) r1 q* |1 z/ f' O* P# q9 |! ]
module_init(led_platform_init);
+ V7 {# v- G- i* u* Qmodule_exit(led_platform_exit);
t1 e2 c4 e$ S5 z6 m' M! `$ y$ Z
- Z% ]# A$ y* y: D0 t+ }4 I' n) PMODULE_DESCRIPTION("Led platform driver");* U& F! T# X$ P: q5 e
MODULE_AUTHOR("Tronlong");
9 I- a4 w4 e4 c* g. R7 rMODULE_LICENSE("GPL");+ s: m! ^- X& S& O6 y( ?. g& Z
0 N+ f0 h- E* u" U1 a; g: W! w; X g |
|