|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 D+ E# W7 j/ B5 ]6 V
#include <linux/init.h>, D# ^: y. o" D8 C' _. p: y: n& w
#include <linux/module.h>) [( K' n- Y" G7 X# e1 R" h
#include <linux/kernel.h>6 \, e/ n1 V" r' x: k- N
#include <linux/types.h>6 I* y3 v/ e! N# `8 d
#include <linux/gpio.h>2 D! X1 \% J% Z! e4 h0 E
#include <linux/leds.h>
: R$ ?( x5 \ U3 L( W, Q#include <linux/platform_device.h>1 A& I& C# e$ V; h) Y
4 m7 Y8 g% ~7 j, D' t#include <asm/mach-types.h>
* C/ C+ k% ^* h: e- d8 A' H1 t# ^5 c3 I% y#include <asm/mach/arch.h>+ B4 F- E7 P* j4 W7 J
#include <mach/da8xx.h>$ ?; T5 ~+ r; ~) j. K: e1 j1 V
#include <mach/mux.h>
f5 N- l$ C' \5 d7 d2 n7 ~8 u) Q% Y. a) ^% `7 Z( |* |8 P$ q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 J: o- v' Z! `& \6 ?! D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 S6 _' J) ]9 ^* T% ^7 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' C ^1 e3 H) d: h$ c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& h2 E$ _% Z" Q! O* R
7 B [+ e1 Y% c A' y( S3 @
/* assign the tl som board LED-GPIOs*/
' i( ^$ b7 t4 y5 W" W# Ostatic const short da850_evm_tl_user_led_pins[] = {* z0 t/ T+ ^$ x+ V+ J
/* These pins are definition at <mach/mux.h> file */4 ~+ Y3 s& B$ z; T" A/ a# t# \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) ?# Q Q! v# T$ S -1
; s6 }9 m' A' j- w' ~};8 M! K- N8 T# L3 o
/ r, f2 d( g+ X# L6 Gstatic struct gpio_led da850_evm_tl_leds[] = {
4 l5 k) E0 x& m: Q; W& a# C1 S {
; T7 e, n" X9 y! Z3 X) I4 u .active_low = 0,
6 u x: U& f L! s8 @! ^0 ?; ? .gpio = DA850_USER_LED0,
$ b- ?2 i5 `6 g. F) D, q .name = "user_led0",6 P) ?" M' c0 K. h
.default_trigger = "default-on",& Y5 a/ V: n# d3 [! ?* o1 ~
},
& a z1 l0 n" I% A0 ~9 ` {
3 d5 h1 b/ ?: R: k .active_low = 0,# ?+ b6 K6 R! G* }$ {) v, r0 p. F
.gpio = DA850_USER_LED1,
) }% U* N; ]5 i .name = "user_led1",
3 l* \, t( H) y( }2 ] .default_trigger = "default-on",
7 x0 [* g% q+ t; { },1 z, W* v1 w3 V" X7 K" e! ?
{$ N4 m9 ^! A" L }3 j
.active_low = 0,
9 N1 i& U' z0 s/ E# h) W .gpio = DA850_USER_LED2,, P' w5 A6 K2 M
.name = "user_led2",/ i" T6 u3 E1 \( M& x
.default_trigger = "default-on",9 A# F9 H$ R( d& L- b {2 y
},
2 A+ R& E- P! L, _+ d' d {
1 T! U( j( u0 s8 C5 ^& S5 P: d .active_low = 0,
1 l) D7 r0 d0 X! A/ ] .gpio = DA850_USER_LED3,
" f( D! P. W. N) ^$ t. { .name = "user_led3",9 o2 g3 v( @) a ]' e* I
.default_trigger = "default-on",
4 Q) l7 M |3 k* @: [8 I },
0 S9 P6 `6 V2 V) v M};
4 k8 u& ~+ n- {4 C4 \. ?* T% l& W7 Q3 z9 u/ e$ U) i0 n0 C2 j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 p* `9 T+ z1 f! f3 d2 y, v
.leds = da850_evm_tl_leds,
5 T% u) A) j& y* |" I' Z P% r) f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, ?9 p3 `9 W+ l7 x B
};$ i/ E7 i& g2 `# m" D! m
- L U8 K, m" Z' J/ h0 X2 O
static void led_dev_release(struct device *dev)0 K5 t! v+ ?! _! G. U7 m
{
Z0 \# m( V) [& e: r0 N6 L};
; g) F. g$ j3 B* V6 x7 D& @) r8 \: Q: k( G8 N
static struct platform_device da850_evm_tl_leds_device = {4 d5 J R1 E+ x/ `
.name = "leds-gpio",1 a4 q7 z$ a g8 X2 Y8 y/ S# [
.id = 1,8 s. g7 E5 C# j! E
.dev = {
8 @1 W; D! K: `7 ]" S .platform_data = &da850_evm_tl_leds_pdata,' s+ _1 I' N8 A* g
.release = led_dev_release,
. s( Y7 L' O: w }
% F. {2 _% `: C};
" w8 N, k/ p8 W- f# U- Y
0 C- M- E, y9 X% H" d+ r7 ustatic int __init led_platform_init(void)9 a' W6 Z3 P, |" v
{
7 `; S9 @" s9 z" h" }2 S# m int ret;
. s0 p( m C* A2 j) X9 f7 N' z: {. m#if 0
4 x# T8 \6 t/ i$ O4 G$ ^4 q; M n' r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ l) p* F/ H( e C8 |: E- x2 G if (ret)
( g6 f. H8 }. q+ R; ] m) ^& A; Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, N4 P$ q' a# _ "%d\n", ret);
: c: Z0 M) e0 H5 O9 T9 i8 H1 a#endif& e' u! C' L3 T& B: I- b6 j: G# p. R
ret = platform_device_register(&da850_evm_tl_leds_device);
+ b" A5 X" w9 n6 ~, @% z if (ret)
% L: ]1 E- A5 z% l, ] pr_warning("Could not register som GPIO expander LEDS");
* V( c! U8 V2 i7 Z+ s/ v, z else$ i) u" i, t8 I: g' O* X, v
printk(KERN_INFO "LED register sucessful!\n");: O4 m( v/ e/ a7 i
" w3 M$ Y, y7 I2 m. b return ret;
5 Z. K% p& r# ~8 W0 g& Y0 q}
0 ]( v4 Z3 W* ` Y# L8 V; c! o
G1 x: U0 V! s4 M4 lstatic void __exit led_platform_exit(void): r3 r5 U; _1 }/ m( C
{
' G" q* }6 N0 l7 O platform_device_unregister(&da850_evm_tl_leds_device);8 n; l7 `1 t' R1 U6 _ u
6 z' x8 M6 z9 `6 |
printk(KERN_INFO "LED unregister!\n");
* i$ R0 y: l4 U& t/ L8 Q1 F}# K4 V' _# q3 L% |+ V
6 I- V7 {( E% I! w5 x- zmodule_init(led_platform_init);
3 Z. y ^, x, f- _* J; [* vmodule_exit(led_platform_exit);
! C! }* P+ ]% m0 C: b. T! o+ r. o; h; D
MODULE_DESCRIPTION("Led platform driver");
, P$ ?2 \$ c6 GMODULE_AUTHOR("Tronlong");
( G6 l3 @/ j Z9 H" O8 w4 g3 FMODULE_LICENSE("GPL");7 J1 W5 u7 k: D# N) m, P2 R
) i$ \8 E! R9 Y/ K |
|